Skip to content

Commit 96e4648

Browse files
ja-y-sonJayson Chen
andauthored
Update upgrade criteria test (#56283)
* Use scoped registry instead of global * Align test content with the test title as iframe document should provide a global registry * Address comments --------- Co-authored-by: Jayson Chen <[email protected]>
1 parent 5f87182 commit 96e4648

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

custom-elements/registries/scoped-registry-append-does-not-upgrade.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,22 @@
9292
const [doc2, win2] = makeIframe(test);
9393
win2.customElements.define('a-b', class ABElement extends win2.HTMLElement { });
9494
const elementFromDoc1 = doc1.createElement('a-b');
95-
assert_equals(elementFromDoc1.customElementRegistry, null);
95+
assert_equals(elementFromDoc1.customElementRegistry, win1.customElements);
9696
doc2.body.appendChild(elementFromDoc1);
9797
assert_equals(elementFromDoc1.customElementRegistry, win2.customElements);
9898
assert_true(elementFromDoc1 instanceof ABElement);
99-
}, 'Inserting a node from another document results in the custom element registry to be set and upgraded.');
99+
}, 'Inserting a node from another document with global registry results in the custom element registry to be set and upgraded.');
100+
101+
test((test) => {
102+
const contentDocument = document.implementation.createHTMLDocument();
103+
class ABElement extends HTMLElement { }
104+
customElements.define('a-b', ABElement);
105+
const elementFromContentDoc = contentDocument.createElement('a-b');
106+
assert_equals(elementFromContentDoc.customElementRegistry, null);
107+
document.body.appendChild(elementFromContentDoc);
108+
assert_equals(elementFromContentDoc.customElementRegistry, customElements);
109+
assert_true(elementFromContentDoc instanceof ABElement);
110+
}, 'Inserting a node from another document with null registry results in the custom element registry to be set and upgraded.');
100111

101112
</script>
102113
</body>

custom-elements/registries/scoped-registry-define-upgrade-criteria.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@
129129
shadow.appendChild(node);
130130

131131
class TestElement extends HTMLElement {};
132-
customElements.define(name, TestElement);
132+
registry.define(name, TestElement);
133133

134134
assert_true(node instanceof TestElement);
135-
}, 'Adding definition to global registry should upgrade nodes even after the node is moved into a separate shadow tree.');
135+
}, 'Adding definition to scoped registry should upgrade nodes even after the node is moved into a separate shadow tree.');
136136

137137
test(t => {
138138
const name = nextCustomElementName();

0 commit comments

Comments
 (0)