summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_bug338679.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/base/test/test_bug338679.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/test_bug338679.html')
-rw-r--r--dom/base/test/test_bug338679.html82
1 files changed, 82 insertions, 0 deletions
diff --git a/dom/base/test/test_bug338679.html b/dom/base/test/test_bug338679.html
new file mode 100644
index 0000000000..bcc214f349
--- /dev/null
+++ b/dom/base/test/test_bug338679.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=338679
+-->
+<head>
+<title>Bug 338679: correct reporting of newValue/prevValue in
+ DOMAttrModified events</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank"
+ href="https://bugzilla.mozilla.org/show_bug.cgi?id=338679">Bug
+ 338679: correct reporting of newValue/prevValue in
+ DOMAttrModified events</a>
+
+<div id="test" style="width:20em"></div>
+
+<script>
+var testDiv = document.getElementById("test");
+var e_new, e_prev = testDiv.getAttribute("style");
+var phase, recursive = false;
+
+/* driver */
+var tests = [ test_1, test_2, test_3 ];
+var i = 0;
+function nextTest() {
+ if (i < tests.length) {
+ phase = tests[i];
+ i++;
+ phase();
+ } else {
+ SimpleTest.finish();
+ }
+}
+
+if (SpecialPowers.getBoolPref("dom.mutation-events.cssom.disabled")) {
+ ok(true, "DOMAttrModified event from CSSOM change is disabled");
+} else {
+ SimpleTest.waitForExplicitFinish();
+ testDiv.addEventListener("DOMAttrModified", attr_modified);
+ nextTest();
+}
+
+/* event handler */
+function attr_modified(ev) {
+ is(ev.newValue, e_new,
+ phase.name + (recursive ? " recursive" : "") + ": newValue");
+ is(ev.prevValue, e_prev,
+ phase.name + (recursive ? " recursive" : "") + ": prevValue");
+
+ e_prev = e_new;
+ if (!recursive) {
+ recursive = true;
+ e_new = "width: 0px;";
+ testDiv.style.width = "0";
+ } else {
+ recursive = false;
+ setTimeout(nextTest, 0);
+ }
+}
+
+/* tests */
+function test_1() {
+ e_new = "width: auto;";
+ testDiv.style.width = "auto";
+}
+
+function test_2() {
+ e_new = "width: 15%;";
+ testDiv.style.width = "15%";
+}
+
+function test_3() {
+ window.getComputedStyle(testDiv).width; // force style resolution
+ e_new = "width: inherit;";
+ testDiv.style.width = "inherit";
+}
+</script>
+</body>
+</html>