blob: 1b7272b031ca5e18beefa820b22494d2e4c52ed3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
<!DOCTYPE html>
<html>
<script src="../../../resources/js-test.js"></script>
<head>
<link id="staticImportLink" rel="import" href="resources/hello.html">
</head>
<body>
<script>
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.");
window.jsTestIsAsync = true;
function testStaticImport()
{
// element-removed flag is not set at start
staticImport = window.staticImportLink;
shouldBeNonNull("staticImport.import");
// element-removed flag is set when the element removed.
staticImport.remove();
shouldBeNull("staticImport.import");
// And comes back even after re-insertion.
document.head.appendChild(staticImport);
shouldBeNonNull("staticImport.import");
}
function testDynamicImport()
{
function check()
{
shouldBeNonNull("dynamicImport.import");
dynamicImport.remove();
shouldBeNull("dynamicImport.import");
document.head.appendChild(dynamicImport);
shouldBeNonNull("dynamicImport.import");
testDynamicImportRemovingEagerly();
};
dynamicImport = document.createElement("link");
dynamicImport.setAttribute("rel", "import");
dynamicImport.setAttribute("href", "resources/bye.html");
dynamicImport.addEventListener("load", check);
document.head.appendChild(dynamicImport);
}
function testDynamicImportRemovingEagerly()
{
dynamicImportEager = document.createElement("link");
dynamicImportEager.setAttribute("rel", "import");
dynamicImportEager.setAttribute("href", "resources/setting-greet-var.html");
document.head.appendChild(dynamicImportEager);
// Reoving <link> just after appending it.
// This should start import loading, but shouldn't make .import visible.
dynamicImportEager.remove();
function check()
{
if (window.greet != "Hello") {
window.setTimeout(check, 0);
return;
}
shouldBeNull("dynamicImportEager.import");
document.head.appendChild(dynamicImportEager);
shouldBeNonNull("dynamicImportEager.import");
window.requestAnimationFrame(function() { finishJSTest(); }, 0);
}
setTimeout(check, 0);
}
testStaticImport();
testDynamicImport();
</script>
</body>
</html>
|