3 <script src="../../js/resources/js-test-pre.js"></script>
5 <link id="staticImportLink" rel="import" href="resources/hello.html">
9 description("This tests 'element removed flag' behavior defined in https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/imports/index.html#dfn-element-removed-flag.");
10 window.jsTestIsAsync = true;
12 function testStaticImport()
14 // element-removed flag is not set at start
15 staticImport = window.staticImportLink;
16 shouldBeNonNull("staticImport.import");
18 // element-removed flag is set when the element removed.
19 staticImport.remove();
20 shouldBeNull("staticImport.import");
22 // And never comes back even after re-insertion.
23 document.head.appendChild(staticImport);
24 shouldBeNull("staticImport.import");
27 function testDynamicImport()
31 shouldBeNonNull("dynamicImport.import");
32 dynamicImport.remove();
33 shouldBeNull("dynamicImport.import");
34 document.head.appendChild(dynamicImport);
35 shouldBeNull("dynamicImport.import");
37 testDynamicImportRemovingEagerly();
40 dynamicImport = document.createElement("link");
41 dynamicImport.setAttribute("rel", "import");
42 dynamicImport.setAttribute("href", "resources/bye.html");
43 dynamicImport.addEventListener("load", check);
44 document.head.appendChild(dynamicImport);
47 function testDynamicImportRemovingEagerly()
49 dynamicImportEager = document.createElement("link");
50 dynamicImportEager.setAttribute("rel", "import");
51 dynamicImportEager.setAttribute("href", "resources/setting-greet-var.html");
52 dynamicImportEager.addEventListener("load", check);
53 document.head.appendChild(dynamicImportEager);
55 // Reoving <link> just after appending it.
56 // This should start import loading, but shouldn't make .import visible.
57 dynamicImportEager.remove();
61 if (window.greet != "Hello") {
62 window.setTimeout(check, 0);
66 shouldBeNull("dynamicImportEager.import");
67 document.head.appendChild(dynamicImportEager);
68 shouldBeNull("dynamicImportEager.import");
73 window.setTimeout(check, 0);