Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / defaultView-on-detached-document.html
blobb5095d2d88625b93ecceacb3f528a750baa59396
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <script>
4 var jsTestIsAsync = true;
6 description("Tests that document.defaultView on a detached document doesn't crash.");
8 var cachedWindow;
9 var cachedDocument;
10 var testFrameUnloaded = false;
12 // DRT dumps out the number of unload handlers associated with a document once it loads.
13 // Unfortunately, load order is not guaranteed, so wait until the first frame has finished loading
14 // before setting up the rest of the test.
15 function setupTest()
17 var frame2 = document.createElement('iframe');
18 frame2.srcdoc = '<script>window.onunload=function() { window.top.finishTest(); };</scr' + 'ipt>';
19 frame2.onload = runTest;
20 document.getElementById('frames').appendChild(frame2);
23 function runTest()
25 var i = document.getElementById("testFrame");
26 // Make sure DOMWindow doesn't get GCed and clear Document's pointer back to it.
27 cachedWindow = i.contentWindow;
28 cachedDocument = i.contentDocument;
29 // This test is structured to catch a document.defaultView crash when all of the following are true:
30 // 1. Document's pointer back to DOMWindow has not yet been cleared by DOMWindow destruction.
31 // 2. DOMWindow's pointer back to its Frame has not yet been cleared by Frame destruction.
32 // 3. The frame is already detached.
33 // One way to satisfy this condition is to test the value of document.defaultView when removing
34 // a DOM node that contains multiple subframes, since ChildFrameDisconnector keeps a ref to the
35 // affected HTMLFrameOwnerElements (and consequently the Frame) on the stack.
36 var frameContainer = document.getElementById("frames");
37 frameContainer.parentNode.removeChild(frameContainer);
40 function finishTest()
42 shouldBeTrue("testFrameUnloaded");
43 shouldBeUndefined("cachedDocument.defaultView");
44 finishJSTest();
46 </script>
47 <body onload="setupTest()">
48 <div id="frames">
49 <iframe id="testFrame" srcdoc="<script>window.onunload=function() { window.top.testFrameUnloaded = true; };</script>"></iframe>
50 </div>
51 </body>