1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/docshell/test/chrome/test_bug453650.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,115 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?> 1.6 +<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?> 1.7 +<!-- 1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=453650 1.9 +--> 1.10 +<window title="Mozilla Bug 453650" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 + 1.13 + <script type="application/javascript" 1.14 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.15 + 1.16 + <!-- test code goes here --> 1.17 + <script type="application/javascript"> 1.18 + <![CDATA[ 1.19 + 1.20 + /** Test for Bug 453650 **/ 1.21 + SimpleTest.waitForExplicitFinish(); 1.22 + 1.23 + var Ci = Components.interfaces; 1.24 + var Cr = Components.results; 1.25 + 1.26 + var iter = runTests(); 1.27 + nextTest(); 1.28 + 1.29 + function runTests() { 1.30 + var iframe = document.createElement("iframe"); 1.31 + iframe.style.width = "300px"; 1.32 + iframe.style.height = "300px"; 1.33 + iframe.setAttribute("src", "data:text/html,<h1 id='h'>hello</h1>"); 1.34 + 1.35 + document.documentElement.appendChild(iframe); 1.36 + yield whenLoaded(iframe); 1.37 + info("iframe loaded"); 1.38 + 1.39 + var h1 = iframe.contentDocument.getElementById("h"); 1.40 + h1.style.width = "400px"; 1.41 + yield waitForInterruptibleReflow(iframe.docShell); 1.42 + 1.43 + h1.style.width = "300px"; 1.44 + waitForReflow(iframe.docShell); 1.45 + yield is(300, h1.offsetWidth, "h1 has correct width"); 1.46 + } 1.47 + 1.48 + function waitForInterruptibleReflow(docShell) { 1.49 + waitForReflow(docShell, true); 1.50 + } 1.51 + 1.52 + function waitForReflow(docShell, interruptible = false) { 1.53 + function done() { 1.54 + docShell.removeWeakReflowObserver(observer); 1.55 + SimpleTest.executeSoon(nextTest); 1.56 + } 1.57 + 1.58 + var observer = { 1.59 + reflow: function (start, end) { 1.60 + if (interruptible) { 1.61 + ok(false, "expected interruptible reflow"); 1.62 + } else { 1.63 + ok(true, "observed uninterruptible reflow"); 1.64 + } 1.65 + 1.66 + info("times: " + start + ", " + end); 1.67 + ok(start < end, "reflow start time lower than end time"); 1.68 + done(); 1.69 + }, 1.70 + 1.71 + reflowInterruptible: function (start, end) { 1.72 + if (!interruptible) { 1.73 + ok(false, "expected uninterruptible reflow"); 1.74 + } else { 1.75 + ok(true, "observed interruptible reflow"); 1.76 + } 1.77 + 1.78 + info("times: " + start + ", " + end); 1.79 + ok(start < end, "reflow start time lower than end time"); 1.80 + done(); 1.81 + }, 1.82 + 1.83 + QueryInterface: function (iid) { 1.84 + if (Ci.nsIReflowObserver.equals(iid) || 1.85 + Ci.nsISupportsWeakReference.equals(iid) || 1.86 + Ci.nsISupports.equals(iid)) 1.87 + return this; 1.88 + throw Cr.NS_ERROR_NO_INTERFACE; 1.89 + }, 1.90 + }; 1.91 + 1.92 + docShell.addWeakReflowObserver(observer); 1.93 + } 1.94 + 1.95 + function whenLoaded(iframe) { 1.96 + iframe.addEventListener("load", function onLoad() { 1.97 + iframe.removeEventListener("load", onLoad); 1.98 + SimpleTest.executeSoon(nextTest); 1.99 + }); 1.100 + } 1.101 + 1.102 + function nextTest() { 1.103 + try { 1.104 + iter.next(); 1.105 + } catch (e if e instanceof StopIteration) { 1.106 + SimpleTest.finish(); 1.107 + } 1.108 + } 1.109 + 1.110 + ]]> 1.111 + </script> 1.112 + 1.113 + <!-- test results are displayed in the html:body --> 1.114 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.115 + <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=453650" 1.116 + target="_blank">Mozilla Bug 453650</a> 1.117 + </body> 1.118 +</window>