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

Commit

Permalink
update test, spec does not support data uri's
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Aug 5, 2014
1 parent 57616cf commit ad5cfb2
Showing 1 changed file with 19 additions and 30 deletions.
49 changes: 19 additions & 30 deletions test/html/HTMLImports.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,34 @@
<script src="../../../tools/test/chai/chai.js"></script>
<script src="../../html-imports.js"></script>
<link rel="import" href="imports/import-1.html">

<!-- the data URI is an html file containing only one import that itself
is a data URI of an HTML file containing only a comment. -->
<link rel="import" href="data:text/html;charset=utf-8,%3Clink%20rel%3D%22import%22%20href%3D%22data%3Atext%2Fhtml%3Bcharset%3Dutf-8%2C%253C%2521--%2520empty%2520import%2520--%253E%22%3E">
<!-- same content as above, but using base64 encoding -->
<link rel="import" href="data:text/plain;charset=utf-8;base64,PGxpbmsgcmVsPSJpbXBvcnQiIGhyZWY9ImRhdGE6dGV4dC9wbGFpbjtjaGFyc2V0PXV0Zi04O2Jhc2U2NCxQQ0V0TFNCcWRYTjBJR0VnWTI5dGJXVnVkQ0F0TFQ0PSIgLz4=">

</head>
<body>
<script>
var timeout = setTimeout(function() {
chai.assert.fail(null, null, 'timed out');
}, 1000);

// polyfill only test
if (HTMLImports.useNative) {
clearTimeout(timeout);
done();
}
} else {
addEventListener('HTMLImportsLoaded', function() {
chai.assert.equal(5, Object.keys(HTMLImports.importLoader.cache).length,
'must cache exactly nine resources');
chai.assert.equal(5, Object.keys(HTMLImports.importer.documents).length,
'must cache exactly nine documents');

addEventListener('HTMLImportsLoaded', function() {
clearTimeout(timeout);
chai.assert.equal(9, Object.keys(HTMLImports.importLoader.cache).length,
'must cache exactly nine resources');
chai.assert.equal(9, Object.keys(HTMLImports.importer.documents).length,
'must cache exactly nine documents');

Object.keys(HTMLImports.importer.documents).forEach(function(key) {
var doc = HTMLImports.importer.documents[key];
var links = doc.querySelectorAll('link[rel=import]');
Array.prototype.forEach.call(links, function(link) {
var href = link.getAttribute('href');
if (href.indexOf('404') <= 0) {
chai.assert.isDefined(link.import, 'import should have an import property');
}
Object.keys(HTMLImports.importer.documents).forEach(function(key) {
var doc = HTMLImports.importer.documents[key];
var links = doc.querySelectorAll('link[rel=import]');
Array.prototype.forEach.call(links, function(link) {
var href = link.getAttribute('href');
if (href.indexOf('404') <= 0) {
chai.assert.isDefined(link.import, 'import should have an import property');
}
});
});

done();
});

done();
});
}
</script>
</body>
</html>

0 comments on commit ad5cfb2

Please sign in to comment.