summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/shadow-dom/slotchange-customelements.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/shadow-dom/slotchange-customelements.html
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/shadow-dom/slotchange-customelements.html')
-rw-r--r--testing/web-platform/tests/shadow-dom/slotchange-customelements.html55
1 files changed, 55 insertions, 0 deletions
diff --git a/testing/web-platform/tests/shadow-dom/slotchange-customelements.html b/testing/web-platform/tests/shadow-dom/slotchange-customelements.html
new file mode 100644
index 0000000000..b0cf93277d
--- /dev/null
+++ b/testing/web-platform/tests/shadow-dom/slotchange-customelements.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Shadow DOM: slotchange customelements</title>
+<meta name="author" title="Surma" href="mailto:surma@google.com">
+<link rel="help" href="https://dom.spec.whatwg.org/#signaling-slot-change">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<slots-in-constructor id="constructor-upgrade"><div></div></slots-in-constructor>
+<slots-in-callback id="callback-upgrade"><div></div></slots-in-callback>
+<script>
+var calls = [];
+class SlotsInConstructor extends HTMLElement {
+ constructor() {
+ super();
+ this.attachShadow({mode: 'open'});
+ this.shadowRoot.innerHTML = '<slot></slot>';
+ var slot = this.shadowRoot.children[0];
+ slot.addEventListener('slotchange', function() {
+ calls.push(this.id);
+ }.bind(this));
+ }
+}
+customElements.define('slots-in-constructor', SlotsInConstructor);
+class SlotsInCallback extends HTMLElement {
+ constructor() {
+ super();
+ }
+
+ connectedCallback() {
+ this.attachShadow({mode: 'open'});
+ this.shadowRoot.innerHTML = '<slot></slot>';
+ var slot = this.shadowRoot.children[0];
+ slot.addEventListener('slotchange', function() {
+ calls.push(this.id);
+ }.bind(this));
+ }
+}
+customElements.define('slots-in-callback', SlotsInCallback);
+</script>
+<slots-in-constructor id="constructor-parser"><div></div></slots-in-constructor>
+<slots-in-callback id="callback-parser"><div></div></slots-in-callback>
+<script>
+test(function () {
+ assert_true(calls.includes("constructor-parser"));
+ assert_true(calls.includes("callback-parser"));
+ assert_true(calls.includes("constructor-upgrade"));
+ assert_true(calls.includes("callback-upgrade"));
+}, 'slotchange must fire on initialization of custom elements with slotted children');
+done();
+</script>
+</body>
+</html>