Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / HTMLScriptElement / script-element-moved-to-detached-document-crash.html
blob5f2397d0f5c7d7175f4e1df85719362eea5a367b
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 <script>
6 description("Moving pending scripts between detached and non-detached documents should not crash.");
8 window.jsTestIsAsync = true;
10 if (window.testRunner) {
11 testRunner.dumpAsText()
12 testRunner.waitUntilDone();
15 var iframe;
17 function start() {
18 iframe = document.createElement('iframe');
19 iframe.src = 'resources/script-element-moved-to-detached-document-crash-frames.html';
20 iframe.onload = runTest;
21 document.getElementById('store_div').appendChild(iframe);
24 function runTest() {
25 var iframeDocument = iframe.contentWindow.document;
26 var option = document.createElement('option');
27 var element2 = iframeDocument.getElementById('element2');
28 var element3 = iframeDocument.getElementById('element3');
29 var emptyScript = document.createElement('script');
30 emptyScript.src = null;
31 document.documentElement.appendChild(emptyScript);
32 element3.ownerDocument.adoptNode(option);
33 var element2Document = element2.contentWindow.document;
34 element2.parentNode.removeChild(element2);
36 // Move the script element to various documents:
38 // Add it to the document.
39 option.appendChild(emptyScript);
40 // Add it to element2 inside the iframe, which is a detached frame element.
41 element2Document.lastChild.appendChild(emptyScript);
42 // Move back to document again.
43 document.body.appendChild(emptyScript);
44 // Pass if no asserts triggered by the above script element document transfers.
45 finishJSTest();
47 window.onload = start;
48 </script>
49 </head>
50 <body>
51 <div id="store_div"></div>
52 </body>
53 </html>