- add third_party src.
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / html / imports / import-element-removed-flag.html
1 <!DOCTYPE html>
2 <html>
3 <script src="../../js/resources/js-test-pre.js"></script>
4 <head>
5 <link id="staticImportLink" rel="import" href="resources/hello.html">
6 </head>
7 <body>
8 <script>
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;
11
12 function testStaticImport()
13 {
14     // element-removed flag is not set at start
15     staticImport = window.staticImportLink;
16     shouldBeNonNull("staticImport.import");
17
18     // element-removed flag is set when the element removed.
19     staticImport.remove();
20     shouldBeNull("staticImport.import");
21
22     // And never comes back even after re-insertion.
23     document.head.appendChild(staticImport);
24     shouldBeNull("staticImport.import");
25 }
26
27 function testDynamicImport()
28 {
29     function check()
30     {
31         shouldBeNonNull("dynamicImport.import");
32         dynamicImport.remove();
33         shouldBeNull("dynamicImport.import");
34         document.head.appendChild(dynamicImport);
35         shouldBeNull("dynamicImport.import");
36
37         testDynamicImportRemovingEagerly();
38     };
39
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);
45 }
46
47 function testDynamicImportRemovingEagerly()
48 {
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);
54
55     // Reoving <link> just after appending it.
56     // This should start import loading, but shouldn't make .import visible.
57     dynamicImportEager.remove();
58     
59     function check()
60     {
61         if (window.greet != "Hello") {
62             window.setTimeout(check, 0);
63             return;
64         }
65
66         shouldBeNull("dynamicImportEager.import");
67         document.head.appendChild(dynamicImportEager);
68         shouldBeNull("dynamicImportEager.import");
69
70         finishJSTest();
71     }
72
73     window.setTimeout(check, 0);
74 }
75
76 testStaticImport();
77 testDynamicImport();
78
79 </script>
80 </body>
81 </html>