2007-02-06 03:20:25 +03:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=338679
|
|
|
|
-->
|
|
|
|
<head>
|
2010-08-03 02:40:35 +04:00
|
|
|
<title>Bug 338679: correct reporting of newValue/prevValue in
|
|
|
|
DOMAttrModified events</title>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
2007-02-06 03:20:25 +03:00
|
|
|
</head>
|
|
|
|
<body>
|
2010-08-03 02:40:35 +04:00
|
|
|
<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>
|
|
|
|
|
2007-02-06 03:20:25 +03:00
|
|
|
<script>
|
2010-08-03 02:40:35 +04:00
|
|
|
var testDiv = document.getElementById("test");
|
|
|
|
var e_new, e_prev = testDiv.getAttribute("style");
|
|
|
|
var phase, recursive = false;
|
2007-02-06 03:20:25 +03:00
|
|
|
|
2010-08-03 02:40:35 +04:00
|
|
|
/* 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();
|
|
|
|
}
|
2007-02-06 03:20:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2017-01-17 13:50:25 +03:00
|
|
|
testDiv.addEventListener("DOMAttrModified", attr_modified);
|
2010-08-03 02:40:35 +04:00
|
|
|
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");
|
2007-02-06 03:20:25 +03:00
|
|
|
|
2010-08-03 02:40:35 +04:00
|
|
|
e_prev = e_new;
|
|
|
|
if (!recursive) {
|
|
|
|
recursive = true;
|
2012-02-14 19:54:08 +04:00
|
|
|
e_new = "width: 0px;";
|
2010-08-03 02:40:35 +04:00
|
|
|
testDiv.style.width = "0";
|
|
|
|
} else {
|
|
|
|
recursive = false;
|
|
|
|
setTimeout(nextTest, 0);
|
|
|
|
}
|
|
|
|
}
|
2007-02-06 03:20:25 +03:00
|
|
|
|
2010-08-03 02:40:35 +04:00
|
|
|
/* tests */
|
|
|
|
function test_1() {
|
|
|
|
e_new = "width: auto;";
|
|
|
|
testDiv.style.width = "auto";
|
|
|
|
}
|
2007-02-06 03:20:25 +03:00
|
|
|
|
2010-08-03 02:40:35 +04:00
|
|
|
function test_2() {
|
|
|
|
e_new = "width: 15%;";
|
|
|
|
testDiv.style.width = "15%";
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_3() {
|
2017-01-27 12:51:02 +03:00
|
|
|
window.getComputedStyle(testDiv).width; // force style resolution
|
2010-08-03 02:40:35 +04:00
|
|
|
e_new = "width: inherit;";
|
|
|
|
testDiv.style.width = "inherit";
|
|
|
|
}
|
2007-02-06 03:20:25 +03:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|