2007-03-22 10:30:00 -07:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=338679
|
|
|
|
-->
|
|
|
|
<head>
|
2010-08-02 15:40:35 -07: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-03-22 10:30:00 -07:00
|
|
|
</head>
|
|
|
|
<body>
|
2010-08-02 15:40:35 -07: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-03-22 10:30:00 -07:00
|
|
|
<script>
|
2010-08-02 15:40:35 -07:00
|
|
|
var testDiv = document.getElementById("test");
|
|
|
|
var e_new, e_prev = testDiv.getAttribute("style");
|
|
|
|
var phase, recursive = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-02 15:40:35 -07: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-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2010-08-02 15:40:35 -07:00
|
|
|
testDiv.addEventListener("DOMAttrModified", attr_modified, false);
|
|
|
|
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-03-22 10:30:00 -07:00
|
|
|
|
2010-08-02 15:40:35 -07:00
|
|
|
e_prev = e_new;
|
|
|
|
if (!recursive) {
|
|
|
|
recursive = true;
|
|
|
|
e_new = "width: 0pt;";
|
|
|
|
testDiv.style.width = "0";
|
|
|
|
} else {
|
|
|
|
recursive = false;
|
|
|
|
setTimeout(nextTest, 0);
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-02 15:40:35 -07:00
|
|
|
/* tests */
|
|
|
|
function test_1() {
|
|
|
|
e_new = "width: auto;";
|
|
|
|
testDiv.style.width = "auto";
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-02 15:40:35 -07:00
|
|
|
function test_2() {
|
|
|
|
e_new = "width: 15%;";
|
|
|
|
testDiv.style.width = "15%";
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_3() {
|
|
|
|
window.getComputedStyle(testDiv, null).width; // force style resolution
|
|
|
|
e_new = "width: inherit;";
|
|
|
|
testDiv.style.width = "inherit";
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|