diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/css/css-toggle/toggle-trigger-multiple.tentative.html | |
parent | Initial commit. (diff) | |
download | firefox-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-trigger-multiple.tentative.html')
-rw-r--r-- | testing/web-platform/tests/css/css-toggle/toggle-trigger-multiple.tentative.html | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-toggle/toggle-trigger-multiple.tentative.html b/testing/web-platform/tests/css/css-toggle/toggle-trigger-multiple.tentative.html new file mode 100644 index 0000000000..bc972bd729 --- /dev/null +++ b/testing/web-platform/tests/css/css-toggle/toggle-trigger-multiple.tentative.html @@ -0,0 +1,92 @@ +<!DOCTYPE HTML> +<meta charset="UTF-8"> +<title>CSS Toggles: triggering multiple toggles with a style change</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-trigger-property"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/toggle-helpers.js"></script> + +<div id="test"></div> + +<script> + +let container = document.getElementById("test"); + +promise_test(async test => { + container.innerHTML = ` + <style> + #t { + toggle-root: t1, t2, t3, t4; + toggle-trigger: t1, t2, t3; + } + </style> + <div id="t"></div> + `; + let t = document.getElementById("t"); + await wait_for_toggle_creation(t); + assert_equals(t.toggles.size, 4, "t.toggles.size after creation"); + assert_equals(t.toggles.get("t1").value, 0, "t1 after creation"); + assert_equals(t.toggles.get("t2").value, 0, "t2 after creation"); + assert_equals(t.toggles.get("t3").value, 0, "t3 after creation"); + assert_equals(t.toggles.get("t4").value, 0, "t4 after creation"); + + let event_count = 0; + t.addEventListener("togglechange", event => { + switch (++event_count) { + case 1: + assert_equals(event.toggleName, "t1", "name of first event"); + assert_equals(t.toggles.get("t1"), event.toggle); + assert_equals(t.toggles.get("t1").value, 1, "t1 after first event"); + assert_equals(t.toggles.get("t2").value, 0, "t2 after first event"); + assert_equals(t.toggles.get("t3").value, 0, "t3 after first event"); + assert_equals(t.toggles.get("t4").value, 0, "t4 after first event"); + break; + case 2: + assert_equals(event.toggleName, "t2", "name of second event"); + assert_equals(t.toggles.get("t2"), event.toggle); + assert_equals(t.toggles.get("t1").value, 1, "t1 after second event"); + assert_equals(t.toggles.get("t2").value, 1, "t2 after second event"); + assert_equals(t.toggles.get("t3").value, 0, "t3 after second event"); + assert_equals(t.toggles.get("t4").value, 0, "t4 after second event"); + // This changes the value of 'toggle-trigger' in the middle of + // firing the toggle. We want to test that toggles continue firing + // as expected. + // + // It's constructed this way to avoid the old style being cached + // in Chromium's MatchedPropertiesCache, which allows this testcase + // to trigger a crash before the fix that introduced it. + t.previousElementSibling.sheet.cssRules[0].style.toggleTrigger = "t4"; + // This assertion is mainly to force the style to be recomputed: + assert_equals(getComputedStyle(t).toggleTrigger, "t4"); + break; + case 3: + assert_equals(event.toggleName, "t3", "name of third event"); + assert_equals(t.toggles.get("t3"), event.toggle); + assert_equals(t.toggles.get("t1").value, 1, "t1 after third event"); + assert_equals(t.toggles.get("t2").value, 1, "t2 after third event"); + assert_equals(t.toggles.get("t3").value, 1, "t3 after third event"); + assert_equals(t.toggles.get("t4").value, 0, "t4 after third event"); + break; + case 4: + assert_equals(event.toggleName, "t4", "name of fourth event"); + assert_equals(t.toggles.get("t4"), event.toggle); + assert_equals(t.toggles.get("t1").value, 1, "t1 after fourth event"); + assert_equals(t.toggles.get("t2").value, 1, "t2 after fourth event"); + assert_equals(t.toggles.get("t3").value, 1, "t3 after fourth event"); + assert_equals(t.toggles.get("t4").value, 1, "t4 after fourth event"); + break; + default: + assert_unreached("should get four events"); + break; + } + }); + + t.click(); + assert_equals(event_count, 3); + t.click(); + assert_equals(event_count, 4); +}, "triggering of multiple toggles with a change to toggle-trigger in the middle"); + +</script> |