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

Commit 4adcc86

Browse files
committed
Add integration test of dynamic HTMLImport with CustomElement upgrade.
1 parent 1ccc2a4 commit 4adcc86

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

test/html/ce-import.html

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<!--
3+
Copyright 2013 The Polymer Authors. All rights reserved.
4+
Use of this source code is governed by a BSD-style
5+
license that can be found in the LICENSE file.
6+
-->
7+
<html>
8+
<head>
9+
<title></title>
10+
<meta charset="UTF-8">
11+
<script src="../../../tools/test/htmltest.js"></script>
12+
<script src="../../../tools/test/chai/chai.js"></script>
13+
<script src="../../platform.js" debug></script>
14+
</head>
15+
<body>
16+
<x-foo></x-foo>
17+
<script>
18+
window.addEventListener('WebComponentsReady', function() {
19+
var xfoo = document.querySelector('x-foo');
20+
chai.assert.isUndefined(xfoo.isCreated);
21+
var link = document.createElement('link');
22+
link.rel = 'import';
23+
link.href = 'element-import.html';
24+
document.head.appendChild(link);
25+
HTMLImports.whenImportsReady(function() {
26+
chai.assert.isTrue(xfoo.isCreated, 'element in main document, registered in dynamic import is upgraded');
27+
var ix = link.import.querySelector('x-foo');
28+
chai.assert.isTrue(ix.isCreated, 'element in import, registered in dynamic import is upgraded');
29+
done();
30+
});
31+
});
32+
</script>
33+
</body>
34+
</html>

test/html/element-import.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<x-foo></x-foo>
2+
<script>
3+
(function() {
4+
var prototype = Object.create(HTMLElement.prototype);
5+
6+
prototype.createdCallback = function() {
7+
this.isCreated = true;
8+
}
9+
10+
document.registerElement('x-foo', {prototype: prototype});
11+
})();
12+
</script>

test/js/tests.js

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ htmlSuite('integration', function() {
1717
htmlTest('html/smoke.html?shadow&register');
1818
htmlTest('html/mdv-shadow.html');
1919
htmlTest('html/template-repeat-wrappers.html');
20+
htmlTest('html/ce-import.html');
21+
htmlTest('html/ce-import.html?shadow');
2022
});
2123

2224
htmlSuite('styling', function() {

0 commit comments

Comments
 (0)