Bug 805330 - Ensure plugin widget visibility via paint flushes. r=josh,roc,robcee
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Wed, 05 Dec 2012 14:39:26 +0100
changeset 115893 903c331107c2dcca8400368cce112792db3bd221
parent 115892 34840088cc10a7fb9cd94ea56ff07f449bbf1568
child 115894 22807dd4c16c35784e32d1c533e7c82c9c99a7a6
push id24028
push useremorley@mozilla.com
push dateThu, 13 Dec 2012 15:56:02 +0000
treeherderautoland@9db79b97abbb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh, roc, robcee
bugs805330
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 805330 - Ensure plugin widget visibility via paint flushes. r=josh,roc,robcee
dom/plugins/test/mochitest/test_bug751809.html
layout/base/tests/chrome/Makefile.in
layout/base/tests/chrome/no_clip_iframe_window.xul
layout/base/tests/chrome/paint_listener.js
layout/base/tests/chrome/test_fixed_bg_scrolling_repaints.html
layout/base/tests/chrome/test_prerendered_transforms.html
layout/base/tests/chrome/test_scrolling_repaints.html
layout/base/tests/chrome/test_transformed_scrolling_repaints.html
layout/base/tests/chrome/test_transformed_scrolling_repaints_2.html
layout/base/tests/chrome/transformed_scrolling_repaints_3_window.html
testing/mochitest/jar.mn
testing/mochitest/tests/SimpleTest/Makefile.in
testing/mochitest/tests/SimpleTest/paint_listener.js
--- a/dom/plugins/test/mochitest/test_bug751809.html
+++ b/dom/plugins/test/mochitest/test_bug751809.html
@@ -1,13 +1,14 @@
 <html>
 <head>
   <title>Bug 751809</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
   <script type="application/javascript">
   SpecialPowers.setBoolPref("plugins.click_to_play", true);
   </script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 
 <body onload="go();">
   <embed id="plugin" type="application/x-test" width="400" height="400" drawmode="solid" color="FF00FFFF"></embed>
@@ -41,27 +42,36 @@
     var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
     ok(!objLoadingContent.activated, "plugin should not be activated");
     
     SimpleTest.waitForFocus(afterWindowFocus);
   }
 
   function afterWindowFocus() {
     var plugin = document.getElementById('plugin');
-    var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
 
     synthesizeMouseAtCenter(plugin, {});
-    var condition = function() objLoadingContent.activated;
+    var condition = function() plugin.setColor !== undefined;
     waitForCondition(condition, afterPluginActivation, "Waited too long for plugin to activate");
   }
     
   function afterPluginActivation() {
     var plugin = document.getElementById('plugin');
     var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
     ok(objLoadingContent.activated, "plugin should be activated now");
+
+    // Triggering a paint and waiting for it to be flushed makes sure
+    // that both plugin and platform see the plugin element as visible.
+    // See bug 805330 for details.
+    plugin.setColor("FF000088");
+    waitForAllPaintsFlushed(afterPaintsFlushed);
+  }
+
+  function afterPaintsFlushed() {
+    var plugin = document.getElementById('plugin');
     try {
       is(plugin.getMouseUpEventCount(), 0, "Plugin should not have received mouse events yet.");
     } catch(e) {
       ok(false, "plugin.getMouseUpEventCount() shouldn't throw");
     }
 
     synthesizeMouseAtCenter(plugin, {});
     var condition = function() plugin.getMouseUpEventCount() > 0;
--- a/layout/base/tests/chrome/Makefile.in
+++ b/layout/base/tests/chrome/Makefile.in
@@ -6,17 +6,16 @@ DEPTH     = @DEPTH@
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 relativesrcdir  = layout/base/test/chrome
 
 include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_CHROME_FILES = \
-	paint_listener.js \
 	test_bug370436.html \
 	test_bug396367-1.html \
 	test_bug396367-2.html \
 	test_bug420499.xul \
 	test_bug495648.xul \
 	bug495648.rdf \
 	test_bug504311.xul \
 	test_bug514660.xul \
--- a/layout/base/tests/chrome/no_clip_iframe_window.xul
+++ b/layout/base/tests/chrome/no_clip_iframe_window.xul
@@ -3,17 +3,17 @@
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="runTests()">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
-  <script type="text/javascript" src="paint_listener.js"></script>
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
 
   <div id="container" xmlns="http://www.w3.org/1999/xhtml" style="height:400px; overflow:auto; background:gray">
     <div style="height:0">
       <iframe type="content" id="f" src="no_clip_iframe_subdoc.html"
        style="margin-top:50px; border:1px solid black; width:100px; height:100px;"/>
     </div>
     <div id="ref" style="background:gray;">
       <div style="border:1px solid black; margin-top:50px; width:100px; height:100px;">
--- a/layout/base/tests/chrome/test_fixed_bg_scrolling_repaints.html
+++ b/layout/base/tests/chrome/test_fixed_bg_scrolling_repaints.html
@@ -1,14 +1,14 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test that we don't get unnecessary repaints with fixed backgrounds</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="paint_listener.js"></script>
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <!-- Need a timeout here to allow paint unsuppression before we start the test -->
 <body onload="setTimeout(startTest,0)" style="background: url(blue-32x32.png) fixed">
 <div style="height: 2048px"></div>
 <pre id="test">
 <script type="application/javascript">
 SimpleTest.waitForExplicitFinish();
--- a/layout/base/tests/chrome/test_prerendered_transforms.html
+++ b/layout/base/tests/chrome/test_prerendered_transforms.html
@@ -1,14 +1,14 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test that active transformed elements coming into view are prerendered so we don't have to redraw constantly</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="paint_listener.js"></script>
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <body onload="startTest()">
 <div>
 <div id="t" style="position:absolute; left:0; top:500px; -moz-transform: translatex(-100px); width:200px; height:100px; background:yellow;">
   <div style="text-align:right">Hello</div>
   <div style="text-align:left">Kitty</div>
 </div>
--- a/layout/base/tests/chrome/test_scrolling_repaints.html
+++ b/layout/base/tests/chrome/test_scrolling_repaints.html
@@ -1,14 +1,14 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test that we don't get unnecessary repaints due to subpixel shifts</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="paint_listener.js"></script>
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <!-- Need a timeout here to allow paint unsuppression before we start the test -->
 <body onload="setTimeout(startTest,0)">
 <div id="t" style="width:400px; height:100px; background:yellow; overflow:hidden">
   <div style="height:40px;"></div>
   <div id="e" style="height:30px; background:lime"></div>
   <div style="height:60.4px; background:pink"></div>
--- a/layout/base/tests/chrome/test_transformed_scrolling_repaints.html
+++ b/layout/base/tests/chrome/test_transformed_scrolling_repaints.html
@@ -1,14 +1,14 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test that scaled elements with scrolled contents don't repaint unnecessarily when we scroll inside them</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="paint_listener.js"></script>
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <!-- Need a timeout here to allow paint unsuppression before we start the test -->
 <body onload="setTimeout(startTest,0)">
 <div id="t" style="-moz-transform: scale(1.2, 1.2); -moz-transform-origin:top left; width:200px; height:100px; background:yellow; overflow:hidden">
   <div style="height:40px;">Hello</div>
   <div id="e" style="height:30px; background:lime">Kitty</div>
   <div style="height:300px; background:yellow">Kitty</div>
--- a/layout/base/tests/chrome/test_transformed_scrolling_repaints_2.html
+++ b/layout/base/tests/chrome/test_transformed_scrolling_repaints_2.html
@@ -1,14 +1,14 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test that scaled elements with scrolled contents don't repaint unnecessarily when we scroll inside them (1.1 scale)</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="paint_listener.js"></script>
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <!-- Need a timeout here to allow paint unsuppression before we start the test -->
 <body onload="setTimeout(startTest,0)">
 <div id="t" style="-moz-transform: scale(1.1, 1.1); -moz-transform-origin:top left; width:200px; height:100px; background:yellow; overflow:hidden">
   <div style="height:40px;"></div>
   <div id="e" style="height:30px; background:lime"></div>
   <div style="height:300px; background:yellow"></div>
--- a/layout/base/tests/chrome/transformed_scrolling_repaints_3_window.html
+++ b/layout/base/tests/chrome/transformed_scrolling_repaints_3_window.html
@@ -1,13 +1,13 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test that scaled elements with scrolled contents don't repaint unnecessarily when we scroll inside them</title>
-  <script type="text/javascript" src="paint_listener.js"></script>
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
 </head>
 <!-- Need a timeout here to allow paint unsuppression before we start the test -->
 <body onload="setTimeout(startTest,0)" style="background:white;">
 <iframe id="t" style="-moz-transform: scale(0.48979); -moz-transform-origin:top left; width:500px; height:300px;"
         src="data:text/html,
 <body style='background:yellow;'>
 <p>My graduate adviser was the most patient, understanding, and helpful
 person I've ever had the joy of dealing with. That doesn't change that 
--- a/testing/mochitest/jar.mn
+++ b/testing/mochitest/jar.mn
@@ -20,10 +20,11 @@ mochikit.jar:
   content/tests/SimpleTest/specialpowersAPI.js (../specialpowers/content/specialpowersAPI.js)
   content/tests/SimpleTest/setup.js (tests/SimpleTest/setup.js)
   content/tests/SimpleTest/SimpleTest.js (tests/SimpleTest/SimpleTest.js)
   content/tests/SimpleTest/test.css (tests/SimpleTest/test.css)
   content/tests/SimpleTest/TestRunner.js (tests/SimpleTest/TestRunner.js)
   content/tests/SimpleTest/WindowSnapshot.js (tests/SimpleTest/WindowSnapshot.js)
   content/tests/SimpleTest/MockObjects.js (tests/SimpleTest/MockObjects.js)
   content/tests/SimpleTest/NativeKeyCodes.js (tests/SimpleTest/NativeKeyCodes.js)
+  content/tests/SimpleTest/paint_listener.js (tests/SimpleTest/paint_listener.js)
   content/tests/SimpleTest/docshell_helpers.js (../../docshell/test/chrome/docshell_helpers.js)
 
--- a/testing/mochitest/tests/SimpleTest/Makefile.in
+++ b/testing/mochitest/tests/SimpleTest/Makefile.in
@@ -15,15 +15,16 @@ include $(topsrcdir)/config/rules.mk
 			test.css \
 			TestRunner.js \
 			setup.js \
 			EventUtils.js \
 			ChromeUtils.js \
 			WindowSnapshot.js \
 			MockObjects.js \
 			NativeKeyCodes.js \
+			paint_listener.js \
 			$(DEPTH)/testing/specialpowers/content/MozillaLogger.js \
 			$(DEPTH)/docshell/test/chrome/docshell_helpers.js \
 			$(NULL)
 
 libs:: $(_SIMPLETEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/$(relativesrcdir)
 
rename from layout/base/tests/chrome/paint_listener.js
rename to testing/mochitest/tests/SimpleTest/paint_listener.js