summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_bug338679.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-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>