summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-toggle/toggle-creation.tentative.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/css/css-toggle/toggle-creation.tentative.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/css/css-toggle/toggle-creation.tentative.html')
-rw-r--r--testing/web-platform/tests/css/css-toggle/toggle-creation.tentative.html73
1 files changed, 73 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-toggle/toggle-creation.tentative.html b/testing/web-platform/tests/css/css-toggle/toggle-creation.tentative.html
new file mode 100644
index 0000000000..583e1631d3
--- /dev/null
+++ b/testing/web-platform/tests/css/css-toggle/toggle-creation.tentative.html
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML>
+<meta charset="UTF-8">
+<title>CSS Toggles: creation of toggles</title>
+<link rel="author" title="L. David Baron" href="https://dbaron.org/">
+<link rel="author" title="Google" href="http://www.google.com/">
+<link rel="help" href="https://tabatkins.github.io/css-toggle/#toggle-root-property">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="support/toggle-helpers.js"></script>
+
+<body>
+
+<div id="container"></div>
+<script>
+
+let container = document.getElementById("container");
+
+promise_test(async () => {
+ container.innerHTML = '<div id="t" style="toggle: mytoggle"></div>';
+ let t = document.getElementById("t");
+ await wait_for_toggle_creation(t);
+ assert_false(t.matches(':toggle(mytoggle)'));
+ assert_true(t.matches(':toggle(mytoggle 0)'));
+ assert_false(t.matches(':toggle(mytoggle 1)'));
+ t.click();
+ assert_true(t.matches(':toggle(mytoggle)'));
+ assert_false(t.matches(':toggle(mytoggle 0)'));
+ assert_true(t.matches(':toggle(mytoggle 1)'));
+ t.click();
+ assert_true(t.matches(':toggle(mytoggle 0)'));
+ assert_false(t.matches(':toggle(mytoggle 1)'));
+}, "basic toggle creation");
+
+promise_test(async () => {
+ // Test that changing the toggle-root property to add 'self' doesn't change
+ // the toggle's scope from wide to narrow.
+ container.innerHTML = `
+ <div id="a" style="toggle-root: changing-scope 3 at 2">
+ <div id="b" style="toggle-trigger: changing-scope"></div>
+ </div>
+ <div id="c"></div>
+ `;
+ let a = document.getElementById("a");
+ let b = document.getElementById("b");
+ let c = document.getElementById("c");
+ await wait_for_toggle_creation(a);
+ assert_true(b.matches(':toggle(changing-scope 2)'));
+ assert_true(c.matches(':toggle(changing-scope 2)'));
+ a.style.toggleRoot = "changing-scope 3 at 2 self";
+ await wait_for_toggle_creation(a);
+ assert_true(b.matches(':toggle(changing-scope 2)'));
+ assert_true(c.matches(':toggle(changing-scope 2)'));
+
+ // The reverse -- removing 'self'.
+ container.innerHTML = `
+ <div id="a" style="toggle-root: changing-scope 3 at 2 self">
+ <div id="b" style="toggle-trigger: changing-scope"></div>
+ </div>
+ <div id="c"></div>
+ `;
+ a = document.getElementById("a");
+ b = document.getElementById("b");
+ c = document.getElementById("c");
+ await wait_for_toggle_creation(a);
+ assert_true(b.matches(':toggle(changing-scope 2)'));
+ assert_false(c.matches(':toggle(changing-scope 2)'));
+ a.style.toggleRoot = "changing-scope 3 at 2";
+ await wait_for_toggle_creation(a);
+ assert_true(b.matches(':toggle(changing-scope 2)'));
+ assert_false(c.matches(':toggle(changing-scope 2)'));
+}, "changing toggle-root doesn't change toggle");
+
+</script>