mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 08:51:22 +00:00
- Passes detail to HTMLImportsLoaded event - Adds tests to check allImports, loadedImports and errorImports are reported correctly during HTMLImportsLoaded event
51 lines
1.9 KiB
HTML
51 lines
1.9 KiB
HTML
<!doctype html>
|
|
<!--
|
|
@license
|
|
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
Code distributed by Google as part of the polymer project is also
|
|
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
-->
|
|
<html>
|
|
<head>
|
|
<title>HTML Imports Dynamic</title>
|
|
<script src="../../tools/htmltest.js"></script>
|
|
<script src="../../tools/chai/chai.js"></script>
|
|
<script src="../../../src/HTMLImports/HTMLImports.js"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// some time later
|
|
setTimeout(function() {
|
|
var div = document.createElement('div');
|
|
div.innerHTML = '<link rel="import" href="imports/load-1.html">' +
|
|
'<link rel="import" href="imports/load-does-not-exist.html">';
|
|
document.body.appendChild(div);
|
|
var ports = document.querySelectorAll('link[rel=import]');
|
|
var loads = 0;
|
|
for (var i=0, l=ports.length, n; (i<l) && (n=ports[i]); i++) {
|
|
n.addEventListener('load', function(e) {
|
|
loads++;
|
|
chai.assert.ok(e.target.import);
|
|
});
|
|
}
|
|
HTMLImports.whenReady(function(detail) {
|
|
chai.assert.equal(detail.allImports.length, 2);
|
|
chai.assert.equal(detail.errorImports.length, 1);
|
|
chai.assert.equal(detail.loadedImports.length, 1);
|
|
|
|
var errorImport = detail.errorImports[0];
|
|
chai.expect(errorImport.href).to.contain('imports/load-does-not-exist.html');
|
|
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|