Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Nov 15, 2013
1 parent e4676b1 commit f3c3ab7
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/html/HTMLImports.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Array.prototype.forEach.call(links, function(link) {
var href = link.getAttribute('href');
if (href.indexOf('404') <= 0) {
chai.assert.isDefined(link.import.content, 'import should have content');
chai.assert.isDefined(link.import, 'import should have an import property');
}
});
})
Expand Down
19 changes: 19 additions & 0 deletions test/html/currentScript.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<title>_currentScript Test</title>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<script src="../../html-imports.js"></script>
<link rel="import" href="imports/script-1.html">
<script>
addEventListener('HTMLImportsLoaded', function() {
chai.assert.equal(document._currentScript, document.currentScript, '_currentScript reflects currentScript');
done();
});
</script>
</head>
<body>

</body>
</html>
3 changes: 3 additions & 0 deletions test/html/imports/load-1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
load1 = true;
</script>
3 changes: 3 additions & 0 deletions test/html/imports/load-2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
load2 = true;
</script>
5 changes: 5 additions & 0 deletions test/html/imports/script-1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>me</div>
<script>
var d = document._currentScript.ownerDocument.querySelector('div');
chai.assert.equal(d.innerText, 'me', '_currentScript can locate element in import')
</script>
6 changes: 6 additions & 0 deletions test/html/imports/script-2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div>me2</div>
<script>
var d = document._currentScript.ownerDocument.querySelector('div');
chai.assert.equal(d.innerText, 'me2', '_currentScript can locate element in import')
</script>
<link rel="import" href="imports/script-2.html">
28 changes: 28 additions & 0 deletions test/html/load.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
<title>load event Test</title>
<script>
(function() {
var loadEvents = 0;
function importLoaded(event) {
loadEvents++;
var s = event.target.import.querySelector('script');
chai.assert.ok(s, 'load event target can be used to find element in import');
if (loadEvents == 2) {
done();
}
}
window.importLoaded = importLoaded;
})();
</script>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<script src="../../html-imports.js"></script>
<link rel="import" href="imports/load-1.html" onload="importLoaded(event)">
<link rel="import" href="imports/load-2.html" onload="importLoaded(event)">
</head>
<body>

</body>
</html>
2 changes: 1 addition & 1 deletion test/html/path.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
chai.assert.equal(path.compressUrl(url), url, 'compressUrl handles url\'s starting with / as abs');
document.addEventListener('HTMLImportsLoaded', function() {
var i = document.querySelector('[rel=import]');
var importDoc = i.import.content;
var importDoc = i.import;
var parts = window.location.href.split('/');
parts.pop();
parts.pop();
Expand Down
2 changes: 1 addition & 1 deletion test/html/template-script.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<script>
addEventListener('HTMLImportsLoaded', function() {
var link = document.querySelector('link');
var template = link.import.content.querySelector('template');
var template = link.import.querySelector('template');
chai.assert.ok(template, 'found import template');
var content = template.content || template;
document.body.appendChild(content.cloneNode(true));
Expand Down
2 changes: 2 additions & 0 deletions test/js/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ htmlSuite('HTMLImports', function() {
htmlTest('html/parser.html');
htmlTest('html/style-links.html');
htmlTest('html/path.html');
htmlTest('html/load.html');
htmlTest('html/currentScript.html');
});

0 comments on commit f3c3ab7

Please sign in to comment.