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 Dec 22, 2013
1 parent 2bd2e13 commit 9859d3a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
6 changes: 5 additions & 1 deletion test/html/imports/load-1.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<script>
load1 = true;
</script>
</script>
<style onload="console.log('inline load!');">
@import 'sheet1.css';
</style>
<link rel="stylesheet" href="sheet2.css">
2 changes: 2 additions & 0 deletions test/html/imports/url-import.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<img src="../../foo.png">
<x-script src="foo/bar/baz/foo.js"></x-script>
<x-a href="/foo.html"></x-a>
<x-form action="../actions/action.html"></x-form>

<style>
@import '../stuff/sheet.css';
@import 'sheet1.css';

.foo {
background: url(../../foo.png);
Expand Down
25 changes: 18 additions & 7 deletions test/html/load.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
<head>
<title>load event Test</title>
<script>
window.loadEvents = 0;
(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.loadEvents++;
if (event.target.import) {
var s = event.target.import.querySelector('script');
chai.assert.ok(s, 'load event target can be used to find element in import');
}
}
window.importLoaded = importLoaded;
Expand All @@ -21,8 +20,20 @@
<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)">
<link rel="import" href="imports/404.html" onerror="importLoaded(event)">
</head>
<body>

<div id="test1" class="red">Test</div>
<div id="test2" class="blue">Test</div>
<script>
document.addEventListener('HTMLImportsLoaded', function() {
chai.assert.equal(loadEvents, 3, 'expected # of load events');
var test1 = getComputedStyle(document.querySelector('#test1')).backgroundColor;
chai.assert.equal(test1, 'rgb(255, 0, 0)');
var test2 = getComputedStyle(document.querySelector('#test2')).backgroundColor;
chai.assert.equal(test2, 'rgb(0, 0, 255)');
done();
});
</script>
</body>
</html>
17 changes: 15 additions & 2 deletions test/html/urls.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,21 @@

document.addEventListener('HTMLImportsLoaded', function() {
var i = document.querySelector('[rel=import]');
var importDoc = i.import;
console.log(i.import);
var doc = i.import;
chai.assert.equal(doc.querySelector('img').getAttribute('src'),
'../foo.png', 'src path adjusted');
chai.assert.equal(doc.querySelector('x-script').getAttribute('src'),
'imports/foo/bar/baz/foo.js', 'src path adjusted');
chai.assert.equal(doc.querySelector('x-a').getAttribute('href'),
'/foo.html', 'href abs path not adjusted');
chai.assert.equal(doc.querySelector('x-form').getAttribute('action'),
'actions/action.html', 'action path adjusted');
var style = document.querySelector('style');
chai.assert.ok(style.sheet, 'style has sheet');
chai.assert.ok(style.textContent.match(/@import 'stuff\/sheet\.css';/));
chai.assert.ok(style.textContent.match(/@import 'imports\/sheet1.css';/));
chai.assert.ok(style.textContent.match(/url\('\.\.\/foo\.png'\)/));
chai.assert.ok(style.textContent.match(/url\('http\:\/\/www\.google\.com'\)/));
done();
});
</script>
Expand Down
1 change: 1 addition & 0 deletions test/js/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ htmlSuite('HTMLImports', function() {
htmlTest('html/parser.html');
htmlTest('html/style-links.html');
htmlTest('html/path.html');
htmlTest('html/urls.html');
htmlTest('html/load.html');
htmlTest('html/currentScript.html');
htmlTest('html/dedupe.html');
Expand Down

0 comments on commit 9859d3a

Please sign in to comment.