forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink-import-null.html
53 lines (48 loc) · 1.92 KB
/
link-import-null.html
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
<!DOCTYPE html>
<html>
<head>
<title>HTML Imports</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="author" title="Hajime Morrita" href="mailto:morrita@google.com">
<link rel="help" href="https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/imports/index.html#loading-imports">
<link id="linkNotImport" rel="style" href="resources/fake.css">
<link id="linkNotFound" rel="import" href="resources/no-such-file.html">
<link id="linkToBeRemoved" rel="import" href="resources/hello.html">
</head>
<body>
<div id="log">Running test...</div>
<script>
test(function() {
var linkNotImport = document.getElementById("linkNotImport");
assert_equals(linkNotImport.import, null);
},
"Check on style link. It should be null if the resource refers style thus doesn't represent any import."
);
test(function() {
var linkNotFound = document.getElementById("linkNotFound");
assert_equals(linkNotFound.import, null);
},
"Check on non existing resource. It should be null if the resource isn't found thus doesn't represent any import."
);
// FIXME: should have "the resource is CORS-cross-origin" case.
test(function() {
var linkOutOfTree = document.createElement("link");
linkOutOfTree.setAttribute("rel", "import");
linkOutOfTree.setAttribute("href", "resources/hello.html");
assert_equals(linkOutOfTree.import, null);
// FIXME: test if the import is available after tree insertion.
},
"Check on out of document element. It should be null when the element is out of document"
);
test(function() {
var linkToBeRemoved = document.getElementById("linkToBeRemoved");
// FIXME: test if the import is available before removal.
linkToBeRemoved.parentNode.removeChild(linkToBeRemoved);
assert_equals(linkToBeRemoved.import, null);
},
"Check on removed element. It should be null when it is removed from the document and becomes out of document."
);
</script>
</body>
</html>