blob: bcc214f349683eec26bdea4afec9fb8134ffbdd1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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>
|