b=540910 use timeouts in plugin_clipping_helper2 so that the X server processes Xlib requests from the parent before testing requests from the OOP plugin
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 22 Jan 2010 23:41:07 +1300
changeset 37493 8b68dd282dd256246e614d8501c63786acff2166
parent 37492 d08b6ddf04b68870657270809e57c42c6c605608
child 37494 bee5caea0941c7f3958c30a90abdae07935cc230
push idunknown
push userunknown
push dateunknown
bugs540910
milestone1.9.3a1pre
b=540910 use timeouts in plugin_clipping_helper2 so that the X server processes Xlib requests from the parent before testing requests from the OOP plugin
layout/generic/test/plugin_clipping_helper.xhtml
layout/generic/test/plugin_clipping_helper2.xhtml
layout/generic/test/plugin_clipping_helper_table.xhtml
layout/generic/test/plugin_clipping_helper_transformed.xhtml
layout/generic/test/plugin_clipping_lib.js
--- a/layout/generic/test/plugin_clipping_helper.xhtml
+++ b/layout/generic/test/plugin_clipping_helper.xhtml
@@ -1,14 +1,12 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
 <html xmlns="http://www.w3.org/1999/xhtml" title="Test Plugin Clipping">
 <head>
-  <script type="application/javascript" src="/MochiKit/packed.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <style>
   embed { width:200px; height:200px; display:block; }
   iframe { border:none; }
   </style>
 </head>
 <body>
 
 <!-- Use a XUL element here so we can get its boxObject.screenX/Y -->
@@ -45,14 +43,17 @@
 <![CDATA[
 
 function runTests() {
   checkClipRegion("p1", [[0, 0, 200, 200]]);
   checkClipRegion("p2", [[100, 100, 200, 200]]);
   checkClipRegion("p3", [[100, 100, 200, 200]]);
   checkClipRegion("p4", [[100, 100, 200, 200]]);
   checkClipRegionForFrame("f1", "p5", [[100, 100, 200, 200]]);
+
+  window.opener.SimpleTest.finish();
+  window.close();
 }
 ]]>
 </script>
 
 </body>
 </html>
--- a/layout/generic/test/plugin_clipping_helper2.xhtml
+++ b/layout/generic/test/plugin_clipping_helper2.xhtml
@@ -28,56 +28,70 @@
   <div id="sbox"
        style="margin-top:350px; margin-left:50px; margin-bottom:1000px; width:100px; height:100px; background:blue;"></div>
 </div>
 
 <script src="plugin_clipping_lib.js"></script>
 <script class="testbody" type="application/javascript">
 <![CDATA[
 var scroll = document.getElementById("scroll");
+var zbox = document.getElementById("zbox");
+var sbox = document.getElementById("sbox");
+var p1 = document.getElementById("p1");
+var d2 = document.getElementById("d2");
 
 function runTests() {
-  var zbox = document.getElementById("zbox");
-  var sbox = document.getElementById("sbox");
-  var p1 = document.getElementById("p1");
-  var d2 = document.getElementById("d2");
 
   checkClipRegion("p1", [[0, 0, 200, 100]]);
   checkClipRegion("p2", [[0, 0, 200, 50], [0, 50, 50, 150], [150, 50, 200, 150], [0, 150, 200, 200]]);
 
   scroll.scrollTop = 150;
   checkClipRegion("p2", [[0, 0, 200, 50], [0, 50, 50, 200], [150, 50, 200, 200]]);
 
   zbox.style.zIndex = -1;
-  flush();
+
+  // A non-zero timeout is needed on X11 (unless an XSync could be performed)
+  // to delay an OOP plugin's X requests enough so that the X server processes
+  // them after the parent processes requests (for the changes above).
+  setTimeout(part2, 1000);
+}
+
+function part2() {
   checkClipRegion("p2", [[0, 0, 200, 100], [0, 100, 50, 200], [150, 100, 200, 200]]);
 
   sbox.style.background = "";
-  flush();
+
+  setTimeout(part3, 1000);
+}
+
+function part3() {
   checkClipRegion("p2", [[0, 0, 200, 200]]);
   
   p1.style.zIndex = 1;
-  flush();
+
+  setTimeout(part4, 1000);
+}
+
+function part4() {
   checkClipRegion("p1", [[0, 0, 200, 200]]);
   checkClipRegion("p2", [[0, 100, 200, 200]]);
 
   // Test subpixel stuff
   p1.style.zIndex = -1;
   zbox.style.zIndex = 1;
   zbox.style.top = "50.3px;"
   d2.style.top = "100.3px";
-  flush();
-  checkClipRegionNoBounds("p2", [[0, 0, 200, 50], [0, 50, 50, 150], [150, 50, 200, 150], [0, 150, 200, 200]]);
+
+  setTimeout(done, 1000);
 }
 
-function flush() {
-  // This function is for X11 to flush the Xlib request queue.  It takes
-  // advantage of the current scrolling implementation, which will do this for
-  // us.  Beware though, it does not wait for the X server to process the
-  // events.
-  ++scroll.scrollTop;
-  --scroll.scrollTop;
+function done() {
+  checkClipRegionNoBounds("p2", [[0, 0, 200, 50], [0, 50, 50, 150], [150, 50, 200, 150], [0, 150, 200, 200]]);
+
+  window.opener.SimpleTest.finish();
+  window.close();
 }
+
 ]]>
 </script>
 
 </body>
 </html>
--- a/layout/generic/test/plugin_clipping_helper_table.xhtml
+++ b/layout/generic/test/plugin_clipping_helper_table.xhtml
@@ -1,14 +1,12 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
 <html xmlns="http://www.w3.org/1999/xhtml" title="Test Plugin Clipping: Plugins and Tables">
 <head>
-  <script type="application/javascript" src="/MochiKit/packed.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <style>
   embed { width:300px; height:200px; display:block; }
   </style>
 </head>
 <body>
 
 <!-- Use a XUL element here so we can get its boxObject.screenX/Y -->
 <hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1"
@@ -29,15 +27,18 @@
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 function runTests() {
   // p1 is partially covered by a table with an opaque background
   checkClipRegion("p1", [[0, 0, 300, 100]]);
   // p2 is partially covered by a table with an opaque background
   checkClipRegion("p2", [[0, 0, 300, 100]]);
+
+  window.opener.SimpleTest.finish();
+  window.close();
 }
 
 ]]>
 </script>
 
 </body>
 </html>
--- a/layout/generic/test/plugin_clipping_helper_transformed.xhtml
+++ b/layout/generic/test/plugin_clipping_helper_transformed.xhtml
@@ -1,14 +1,12 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
 <html xmlns="http://www.w3.org/1999/xhtml" title="Test Plugin Clipping: Plugins in Transforms">
 <head>
-  <script type="application/javascript" src="/MochiKit/packed.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <style>
   embed { width:300px; height:200px; display:block; }
   </style>
 </head>
 <body>
 
 <!-- Use a XUL element here so we can get its boxObject.screenX/Y -->
 <hbox style="height:10px; position:absolute; left:0; top:0; z-index:-100;" id="h1"
@@ -28,15 +26,18 @@
 <script src="plugin_clipping_lib.js"></script>
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 function runTests() {
   // p1 and p2 are both in a transformed context so they should be hidden.
   checkClipRegionNoBounds("p1", []);
   checkClipRegionNoBounds("p2", []);
+
+  window.opener.SimpleTest.finish();
+  window.close();
 }
 
 ]]>
 </script>
 
 </body>
 </html>
--- a/layout/generic/test/plugin_clipping_lib.js
+++ b/layout/generic/test/plugin_clipping_lib.js
@@ -148,19 +148,16 @@ function loaded() {
   }
 
   var bounds = h1.getBoundingClientRect();
   windowFrameX = h1.boxObject.screenX - bounds.left - window.screenX;
   windowFrameY = h1.boxObject.screenY - bounds.top - window.screenY;
 
   // Run actual test code
   runTests();
-
-  finish();
-  window.close();
 }
 
 // Need to run 'loaded' after painting is unsuppressed, or we'll set clip
 // regions to empty.  The timeout must be non-zero on X11 so that
 // gtk_container_idle_sizer runs after the GtkSocket gets the plug_window.
 window.addEventListener("load",
                         function () { setTimeout(loaded, 1000); }, false);
 })();