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

Commit

Permalink
some test fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Jan 14, 2014
1 parent 7cfe225 commit c13e8ea
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
15 changes: 10 additions & 5 deletions test/html/currentScript.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
<script src="../../../tools/test/chai/chai.js"></script>
<script src="../../html-imports.js"></script>
<link rel="import" href="imports/script-1.html">
</head>
<body>
<script>
addEventListener('HTMLImportsLoaded', function() {
function test() {
chai.assert.equal(document._currentScript, document.currentScript, '_currentScript reflects currentScript');
done();
});
}

if (HTMLImports.ready) {
test();
} else {
addEventListener('HTMLImportsLoaded', test);
}
</script>
</head>
<body>

</body>
</html>
14 changes: 10 additions & 4 deletions test/html/imports/url-import.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<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>
<template>
<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>
</template>

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

.red {
background: red;
}

.foo {
background: url(../../foo.png);
}
Expand Down
15 changes: 11 additions & 4 deletions test/html/urls.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@
document.addEventListener('HTMLImportsLoaded', function() {
var i = document.querySelector('[rel=import]');
var doc = i.import;
chai.assert.equal(doc.querySelector('img').getAttribute('src'),
var template = doc.querySelector('template');
chai.assert.ok(template, 'template found');
HTMLImports.path.resolvePathsInHTML(template.content,
template.ownerDocument.baseURI);
document.body.appendChild(template.content.cloneNode(true));

var testRoot = template.content;
chai.assert.equal(testRoot.querySelector('img').getAttribute('src'),
'../foo.png', 'src path adjusted');
chai.assert.equal(doc.querySelector('x-script').getAttribute('src'),
chai.assert.equal(testRoot.querySelector('x-script').getAttribute('src'),
'imports/foo/bar/baz/foo.js', 'src path adjusted');
chai.assert.equal(doc.querySelector('x-a').getAttribute('href'),
chai.assert.equal(testRoot.querySelector('x-a').getAttribute('href'),
'/foo.html', 'href abs path not adjusted');
chai.assert.equal(doc.querySelector('x-form').getAttribute('action'),
chai.assert.equal(testRoot.querySelector('x-form').getAttribute('action'),
'actions/action.html', 'action path adjusted');
var style = document.querySelector('style');
chai.assert.ok(style.sheet, 'style has sheet');
Expand Down

0 comments on commit c13e8ea

Please sign in to comment.