Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: LayoutTests/fast/dom/defaultView-on-detached-document.html

Issue 854453003: Revert of Revert of Reland factor out window proxy management portions of ScriptController. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase and deflake test Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <script>
4 var jsTestIsAsync = true;
5
6 description("Tests that document.defaultView on a detached document doesn't cras h.");
7
8 var cachedWindow;
9 var cachedDocument;
10 var testFrameUnloaded = false;
11
12 // DRT dumps out the number of unload handlers associated with a document once i t loads.
13 // Unfortunately, load order is not guaranteed, so wait until the first frame ha s finished loading
14 // before setting up the rest of the test.
15 function setupTest()
16 {
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);
21 }
22
23 function runTest()
24 {
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 DOMWi ndow destruction.
31 // 2. DOMWindow's pointer back to its Frame has not yet been cleared by Fram e destruction.
32 // 3. The frame is already detached.
33 // One way to satisfy this condition is to test the value of document.defaul tView 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);
38 }
39
40 function finishTest()
41 {
42 shouldBeTrue("testFrameUnloaded");
43 shouldBeUndefined("cachedDocument.defaultView");
44 finishJSTest();
45 }
46 </script>
47 <body onload="setupTest()">
48 <div id="frames">
49 <iframe id="testFrame" srcdoc="<script>window.onunload=function() { window.t op.testFrameUnloaded = true; };</script>"></iframe>
50 </div>
51 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698