Don't load imports from templates in the main doc.

This commit is contained in:
Chris Joel
2015-10-29 16:18:52 -07:00
parent 6bae14a4e7
commit c4ec5cf15b
6 changed files with 88 additions and 4 deletions

View File

@@ -77,7 +77,7 @@ if (typeof HTMLTemplateElement === 'undefined') {
};
// auto-bootstrapping for main document
window.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function() {
HTMLTemplateElement.bootstrap(document);
});

View File

@@ -3,9 +3,9 @@
"../URL/URL.js",
"../WeakMap/WeakMap.js",
"../MutationObserver/MutationObserver.js",
"../Template/Template.js",
"../HTMLImports/build.json",
"../CustomElements/build.json",
"../Template/Template.js",
"dom.js",
"unresolved.js"
]

View File

@@ -0,0 +1,61 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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>Template with HTMLImports Test</title>
<script src="../../src/Template/Template.js"></script>
<script src="../../src/HTMLImports/HTMLImports.js"></script>
<script src="../../../web-component-tester/browser.js"></script>
</head>
<body>
<template id="one">
<link rel="import" href="../HTMLImports/html/imports/script-1.html">
</template>
<template id="two">
<link rel="import" href="../HTMLImports/html/imports/csp-import-1.html">
</template>
<script>
suite('Template', function() {
var templateOne;
var templateTwo;
suiteSetup(function() {
templateOne = document.querySelector('template#one');
templateTwo = document.querySelector('template#two');
});
teardown(function() {
window.remoteCurrentScriptExecuted = undefined;
window.externalScriptParsed1 = undefined;
});
test('links are not imported before stamping', function() {
assert.equal(window.remoteCurrentScriptExecuted, undefined);
assert.equal(window.externalScriptParsed1, undefined);
});
test('links are imported when stmped', function(done) {
var imp;
document.body.appendChild(document.importNode(templateTwo.content, true));
imp = document.querySelector('[href="../HTMLImports/html/imports/csp-import-1.html"]');
imp.addEventListener('load', function() {
assert.ok(window.externalScriptParsed1);
done();
});
});
});
</script>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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
-->
<title>Template Tests</title>
<meta charset="utf-8">
<script src="../../../web-component-tester/browser.js"></script>
<!-- Templates -->
<script>
var suites = [
'tests.html',
'imports.html'
];
WCT.loadSuites(suites);
</script>

View File

@@ -19,7 +19,7 @@
'WeakMap/tests.html',
'MutationObserver/tests.html',
'HTMLImports/runner.html',
'Template/tests.html',
'Template/runner.html',
'CustomElements/runner.html',
'ShadowDOM/runner.html',
'ShadowCSS/runner.html',

View File

@@ -53,9 +53,9 @@
'URL/URL.js',
'WeakMap/WeakMap.js',
'MutationObserver/MutationObserver.js',
'Template/Template.js',
'HTMLImports/HTMLImports.js',
'CustomElements/CustomElements.js',
'Template/Template.js',
// these scripts are loaded here due to polyfill timing issues
'WebComponents/dom.js',
'WebComponents/unresolved.js'