content/base/test/test_bug338679.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:bbf8411ebbf0
1 <!DOCTYPE html>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=338679
5 -->
6 <head>
7 <title>Bug 338679: correct reporting of newValue/prevValue in
8 DOMAttrModified events</title>
9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
11 </head>
12 <body>
13 <a target="_blank"
14 href="https://bugzilla.mozilla.org/show_bug.cgi?id=338679">Bug
15 338679: correct reporting of newValue/prevValue in
16 DOMAttrModified events</a>
17
18 <div id="test" style="width:20em"></div>
19
20 <script>
21 var testDiv = document.getElementById("test");
22 var e_new, e_prev = testDiv.getAttribute("style");
23 var phase, recursive = false;
24
25 /* driver */
26 var tests = [ test_1, test_2, test_3 ];
27 var i = 0;
28 function nextTest() {
29 if (i < tests.length) {
30 phase = tests[i];
31 i++;
32 phase();
33 } else {
34 SimpleTest.finish();
35 }
36 }
37
38 SimpleTest.waitForExplicitFinish();
39 testDiv.addEventListener("DOMAttrModified", attr_modified, false);
40 nextTest();
41
42 /* event handler */
43 function attr_modified(ev) {
44 is(ev.newValue, e_new,
45 phase.name + (recursive ? " recursive" : "") + ": newValue");
46 is(ev.prevValue, e_prev,
47 phase.name + (recursive ? " recursive" : "") + ": prevValue");
48
49 e_prev = e_new;
50 if (!recursive) {
51 recursive = true;
52 e_new = "width: 0px;";
53 testDiv.style.width = "0";
54 } else {
55 recursive = false;
56 setTimeout(nextTest, 0);
57 }
58 }
59
60 /* tests */
61 function test_1() {
62 e_new = "width: auto;";
63 testDiv.style.width = "auto";
64 }
65
66 function test_2() {
67 e_new = "width: 15%;";
68 testDiv.style.width = "15%";
69 }
70
71 function test_3() {
72 window.getComputedStyle(testDiv, null).width; // force style resolution
73 e_new = "width: inherit;";
74 testDiv.style.width = "inherit";
75 }
76 </script>
77 </body>
78 </html>

mercurial