Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 <?xml version="1.0"?>
2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
3 <?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
4 <!--
5 https://bugzilla.mozilla.org/show_bug.cgi?id=453650
6 -->
7 <window title="Mozilla Bug 453650"
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
10 <script type="application/javascript"
11 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
13 <!-- test code goes here -->
14 <script type="application/javascript">
15 <![CDATA[
17 /** Test for Bug 453650 **/
18 SimpleTest.waitForExplicitFinish();
20 var Ci = Components.interfaces;
21 var Cr = Components.results;
23 var iter = runTests();
24 nextTest();
26 function runTests() {
27 var iframe = document.createElement("iframe");
28 iframe.style.width = "300px";
29 iframe.style.height = "300px";
30 iframe.setAttribute("src", "data:text/html,<h1 id='h'>hello</h1>");
32 document.documentElement.appendChild(iframe);
33 yield whenLoaded(iframe);
34 info("iframe loaded");
36 var h1 = iframe.contentDocument.getElementById("h");
37 h1.style.width = "400px";
38 yield waitForInterruptibleReflow(iframe.docShell);
40 h1.style.width = "300px";
41 waitForReflow(iframe.docShell);
42 yield is(300, h1.offsetWidth, "h1 has correct width");
43 }
45 function waitForInterruptibleReflow(docShell) {
46 waitForReflow(docShell, true);
47 }
49 function waitForReflow(docShell, interruptible = false) {
50 function done() {
51 docShell.removeWeakReflowObserver(observer);
52 SimpleTest.executeSoon(nextTest);
53 }
55 var observer = {
56 reflow: function (start, end) {
57 if (interruptible) {
58 ok(false, "expected interruptible reflow");
59 } else {
60 ok(true, "observed uninterruptible reflow");
61 }
63 info("times: " + start + ", " + end);
64 ok(start < end, "reflow start time lower than end time");
65 done();
66 },
68 reflowInterruptible: function (start, end) {
69 if (!interruptible) {
70 ok(false, "expected uninterruptible reflow");
71 } else {
72 ok(true, "observed interruptible reflow");
73 }
75 info("times: " + start + ", " + end);
76 ok(start < end, "reflow start time lower than end time");
77 done();
78 },
80 QueryInterface: function (iid) {
81 if (Ci.nsIReflowObserver.equals(iid) ||
82 Ci.nsISupportsWeakReference.equals(iid) ||
83 Ci.nsISupports.equals(iid))
84 return this;
85 throw Cr.NS_ERROR_NO_INTERFACE;
86 },
87 };
89 docShell.addWeakReflowObserver(observer);
90 }
92 function whenLoaded(iframe) {
93 iframe.addEventListener("load", function onLoad() {
94 iframe.removeEventListener("load", onLoad);
95 SimpleTest.executeSoon(nextTest);
96 });
97 }
99 function nextTest() {
100 try {
101 iter.next();
102 } catch (e if e instanceof StopIteration) {
103 SimpleTest.finish();
104 }
105 }
107 ]]>
108 </script>
110 <!-- test results are displayed in the html:body -->
111 <body xmlns="http://www.w3.org/1999/xhtml">
112 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=453650"
113 target="_blank">Mozilla Bug 453650</a>
114 </body>
115 </window>