docshell/test/chrome/test_bug453650.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial