https://github.com/web-platform-tests/wpt
Raw File
Tip revision: aedcac217946872aa218bfb3b450a88aaf576493 authored by James Graham on 31 March 2014, 15:15:54 UTC
fixup! Update resources directory
Tip revision: aedcac2
link-import-null.html
<!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>
back to top