Bug 1115437: Part 1 - Update plugin tests to be compatible with asynchronous plugin initialization; r=gfritzsche
authorAaron Klotz <aklotz@mozilla.com>
Thu, 05 Feb 2015 15:00:44 -0700
changeset 230225 afa28e98419f418a7a6aefaa36672726503a8b2d
parent 230224 92279670ec95a00baea69d2bd5a2159f491e45e1
child 230226 850264d2c1c49fdd58d0b8f5645a98eb170f25a8
push id28311
push userphilringnalda@gmail.com
push dateSun, 22 Feb 2015 18:06:18 +0000
treeherdermozilla-central@d1f1624d615c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1115437
milestone38.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 1115437: Part 1 - Update plugin tests to be compatible with asynchronous plugin initialization; r=gfritzsche
dom/plugins/test/mochitest/test_bug854082.html
dom/plugins/test/reftest/border-padding-1.html
dom/plugins/test/reftest/border-padding-2-ref.html
dom/plugins/test/reftest/border-padding-2.html
dom/plugins/test/reftest/border-padding-3.html
dom/plugins/test/reftest/plugin-alpha-opacity.html
dom/plugins/test/reftest/plugin-alpha-zindex.html
dom/plugins/test/reftest/plugin-background.html
dom/plugins/test/reftest/plugin-busy-alpha-zindex.html
dom/plugins/test/reftest/plugin-canvas-alpha-zindex.html
dom/plugins/test/reftest/plugin-sanity.html
dom/plugins/test/reftest/plugin-transform-1-ref.html
dom/plugins/test/reftest/plugin-transform-1.html
dom/plugins/test/reftest/plugin-transform-2.html
dom/plugins/test/reftest/plugin-transform-alpha-zindex.html
dom/plugins/test/reftest/shrink-1-ref.html
dom/plugins/test/reftest/shrink-1.html
dom/plugins/test/reftest/update-1-ref.html
dom/plugins/test/reftest/update-1.html
dom/plugins/test/reftest/utils.js
dom/plugins/test/reftest/windowless-clipping-1-ref.html
dom/plugins/test/reftest/windowless-clipping-1.html
dom/plugins/test/reftest/windowless-layers-ref.html
dom/plugins/test/reftest/windowless-layers.html
--- a/dom/plugins/test/mochitest/test_bug854082.html
+++ b/dom/plugins/test/mochitest/test_bug854082.html
@@ -23,19 +23,16 @@
 
   // The test plugin sets pluginFoundElement on its element inside NPP_New,
   // abuse this to run arbitrary script.
   var setterCalled;
   o.__defineSetter__("pluginFoundElement", function() {
     o.style.display = "none";
     // Access clientTop to force layout flush
     o.clientTop;
+    ok(true, "Setter called and did not crash");
+    SimpleTest.finish();
     setterCalled = true;
   });
   document.body.appendChild(o);
-
-  SimpleTest.executeSoon(function() {
-    ok(setterCalled, "Setter called and did not crash");
-    SimpleTest.finish();
-  });
 </script>
 </body>
 </html>
--- a/dom/plugins/test/reftest/border-padding-1.html
+++ b/dom/plugins/test/reftest/border-padding-1.html
@@ -1,12 +1,16 @@
 <!DOCTYPE html>
-<html>
-<body style="margin:0">
+<html class="reftest-wait">
+<head>
+<script src="utils.js">
+</script>
+</head>
+<body style="margin:0" onLoad="forceLoadPlugin('p1')">
 <object type="application/x-test" drawmode="solid" color="ff00ff00"
         style="width:200px; height:200px; display:block; margin:90px 80px;
                outline:5px dashed blue;
                background:cyan;
                border:dotted black; border-width:4px 8px 4px 8px;
-               padding:3px 1px;">
+               padding:3px 1px;" id="p1">
 </object>
 </body>
 </html>
--- a/dom/plugins/test/reftest/border-padding-2-ref.html
+++ b/dom/plugins/test/reftest/border-padding-2-ref.html
@@ -1,10 +1,17 @@
 <!DOCTYPE html>
-<html>
-<body style="margin:0">
+<html class="reftest-wait">
+<head>
+<script src="utils.js">
+</script>
+</head>
+<body style="margin:0" onLoad="forceLoadPlugin('plugin')">
 <div style="width:184px; height:192px; margin:90px 80px; outline:5px dashed blue;
             border:dotted black; border-width:4px 8px 4px 8px;
             background:cyan;">
-  <object style="margin:3px 1px; height:186px; width:182px; display:block;" type="application/x-test"></object>
+  <object style="margin:3px 1px; height:186px; width:182px; display:block;"
+          type="application/x-test"
+          id="plugin">
+  </object>
 </div>
 </body>
 </html>
--- a/dom/plugins/test/reftest/border-padding-2.html
+++ b/dom/plugins/test/reftest/border-padding-2.html
@@ -1,12 +1,17 @@
 <!DOCTYPE html>
-<html>
-<body style="margin:0">
+<html class="reftest-wait">
+<head>
+<script src="utils.js">
+</script>
+</head>
+<body style="margin:0" onLoad="forceLoadPlugin('plugin')">
 <object type="application/x-test"
         style="width:200px; height:200px; display:block; margin:90px 80px;
                outline:5px dashed blue;
                background:cyan;
                border:dotted black; border-width:4px 8px 4px 8px;
-               padding:3px 1px;">
+               padding:3px 1px;"
+        id="plugin">
 </object>
 </body>
 </html>
--- a/dom/plugins/test/reftest/border-padding-3.html
+++ b/dom/plugins/test/reftest/border-padding-3.html
@@ -1,11 +1,15 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
-<body style="margin:0">
+<head>
+<script src="utils.js">
+</script>
+</head>
+<body style="margin:0" onLoad="forceLoadPlugin('plugin', true)">
 <object type="application/x-test" id="plugin"
         drawmode="solid" color="00000000"
         style="width:200px; height:200px; display:block; margin:90px 80px;
                outline:5px dashed blue;
                background:cyan;
                border:dotted black; border-width:4px 8px 4px 8px;
                padding:3px 1px;">
 </object>
--- a/dom/plugins/test/reftest/plugin-alpha-opacity.html
+++ b/dom/plugins/test/reftest/plugin-alpha-opacity.html
@@ -1,10 +1,10 @@
 <!doctype html>
-<html>
+<html class="reftest-wait">
 <head>
 <style type="text/css">
 #one {
   position:absolute;
   left:0px; top:0px;
   width:404px; height:404px;
   border:2px solid blue;
   opacity:.8;
@@ -13,15 +13,17 @@
 #two {
   position:absolute;
   top:100px; left:100px;
   width:200px; height:200px;
   z-index:0;
   background-color: rgb(255,0,0);
 }
 </style>
+<script src="utils.js">
+</script>
 </head>
-<body>
+<body onLoad="forceLoadPlugin('one')">
 <div id="two"></div>
 <embed id="one" type="application/x-test" width="400" height="400" drawmode="solid" color="FFa0a0a0"></embed>
 </body>
 </html>
 
--- a/dom/plugins/test/reftest/plugin-alpha-zindex.html
+++ b/dom/plugins/test/reftest/plugin-alpha-zindex.html
@@ -1,24 +1,26 @@
 <!doctype html>
-<html>
+<html class="reftest-wait">
 <head>
 <style type="text/css">
 #one {
   position:absolute;
   left:0px; top:0px;
   z-index:1;
 }
 #two {
   position:absolute;
   top:100px; left:100px;
   width:200px; height:200px;
   z-index:0;
   background-color: rgb(255,0,0);
 }
 </style>
+<script src="utils.js">
+</script>
 </head>
-<body>
+<body onLoad="forceLoadPlugin('one')">
 <div id="two"></div>
-<embed id="one" type="application/x-test" width="400" height="400" drawmode="solid" color="9900FF00"></embed>
+<embed id="one" type="application/x-test" width="400" height="400" drawmode="solid" color="9900FF00" id="p1"></embed>
 </body>
 </html>
 
--- a/dom/plugins/test/reftest/plugin-background.html
+++ b/dom/plugins/test/reftest/plugin-background.html
@@ -1,14 +1,16 @@
 <!DOCTYPE html>
-<html>
+<html class="reftest-wait">
 <head>
   <link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
 </head>
-<body>
+<script src="utils.js">
+</script>
+<body onLoad="forceLoadPlugin('plugin')">
   <div id="bad">Test some plugin stuff.</div>
   <div id="good"></div>
 
   <embed id="plugin" type="application/x-test" width="199" height="199"
          drawmode="solid" color="330000FF"></embed>
 
   <div id="topbar"></div>
   <div id="leftbar"></div>
--- a/dom/plugins/test/reftest/plugin-busy-alpha-zindex.html
+++ b/dom/plugins/test/reftest/plugin-busy-alpha-zindex.html
@@ -1,10 +1,10 @@
 <!doctype html>
-<html>
+<html class="reftest-wait">
 <head>
   <style type="text/css">
 #one {
   position:absolute;
   left:0px; top:0px;
   z-index:4;
 }
 #two {
@@ -22,27 +22,34 @@
   z-index:2;
 }
 #four {
   position:absolute;
   top:100px; left:100px;
   z-index:1;
 }
   </style>
+  <script src="utils.js" type="text/javascript">
+  </script>
   <script type="text/javascript">
 function paintCanvas() {
   var canvas = document.getElementById("two");
   var ctx = canvas.getContext("2d");
   ctx.fillStyle = "rgba(255,0,0, 0.6)";
   ctx.fillRect(0,0, 200,200);
 }
+
+  function doTest() {
+    paintCanvas();
+    forceLoadPlugin(['one', 'four']);
+  }
   </script>
 </style>
 </head>
-<body onload="paintCanvas();">
+<body onload="doTest();">
   <embed id="four" type="application/x-test" width="200" height="200"
          drawmode="solid" color="FFFF0000"></embed>
   <div id="three"></div>
   <canvas id="two" width="200" height="200"></canvas>
   <embed id="one" type="application/x-test" width="400" height="400"
          drawmode="solid" color="9900FF00"></embed>
 </body>
 </html>
--- a/dom/plugins/test/reftest/plugin-canvas-alpha-zindex.html
+++ b/dom/plugins/test/reftest/plugin-canvas-alpha-zindex.html
@@ -1,34 +1,41 @@
 <!doctype html>
-<html>
+<html class="reftest-wait">
 <head>
   <style type="text/css">
 #one {
   position:absolute;
   left:0px; top:0px;
   z-index:1;
 }
 #two {
   position:absolute;
   top:100px; left:100px;
 // Set these using the canvas API
 //  width:200px; height:200px;
 //  background-color: rgb(255,0,0);
   z-index:0;
 }
   </style>
+  <script src="utils.js" type="text/javascript">
+  </script>
   <script type="text/javascript">
 function paintCanvas() {
   var canvas = document.getElementById("two");
   var ctx = canvas.getContext("2d");
   ctx.fillStyle = "rgb(255,0,0)";
   ctx.fillRect(0,0, 200,200);
 }
+
+  function doTest() {
+    paintCanvas();
+    forceLoadPlugin('one');
+  }
   </script>
 </style>
 </head>
-<body onload="paintCanvas();">
+<body onload="doTest()">
   <canvas width="200" height="200" id="two"></canvas>
   <embed id="one" type="application/x-test" width="400" height="400" drawmode="solid" color="9900FF00"></embed>
 </body>
 </html>
 
--- a/dom/plugins/test/reftest/plugin-sanity.html
+++ b/dom/plugins/test/reftest/plugin-sanity.html
@@ -1,10 +1,13 @@
 <!doctype html>
-<html><head>
+<html class="reftest-wait">
+<head>
 <title>Plugin boxes</title>
+<script src="utils.js">
+</script>
 </head>
-<body>
-<embed type="application/x-test" width="400" height="400" drawmode="solid" color="FFFF0000"></embed> <!-- red -->
-<embed type="application/x-test" width="400" height="400" drawmode="solid" color="FF00FF00"></embed> <!-- green -->
-<embed type="application/x-test" width="400" height="400" drawmode="solid" color="FF0000FF"></embed> <!-- blue -->
-<embed type="application/x-test" width="400" height="400" drawmode="solid" color="FF999999"></embed> <!-- gray -->
+<body onLoad="forceLoadPlugin(['p1', 'p2', 'p3', 'p4'])">
+<embed type="application/x-test" width="400" height="400" drawmode="solid" color="FFFF0000" id="p1"></embed> <!-- red -->
+<embed type="application/x-test" width="400" height="400" drawmode="solid" color="FF00FF00" id="p2"></embed> <!-- green -->
+<embed type="application/x-test" width="400" height="400" drawmode="solid" color="FF0000FF" id="p3"></embed> <!-- blue -->
+<embed type="application/x-test" width="400" height="400" drawmode="solid" color="FF999999" id="p4"></embed> <!-- gray -->
 </body></html>
--- a/dom/plugins/test/reftest/plugin-transform-1-ref.html
+++ b/dom/plugins/test/reftest/plugin-transform-1-ref.html
@@ -1,6 +1,10 @@
 <!DOCTYPE HTML>
-<html>
-<body>
-<embed type="application/x-test"></embed>
+<html class="reftest-wait">
+<head>
+<script src="utils.js">
+</script>
+</head>
+<body onLoad="forceLoadPlugin('p')">
+<embed type="application/x-test" id="p"></embed>
 </body>
 </html>
--- a/dom/plugins/test/reftest/plugin-transform-1.html
+++ b/dom/plugins/test/reftest/plugin-transform-1.html
@@ -1,6 +1,10 @@
 <!DOCTYPE HTML>
-<html>
-<body>
-<embed type="application/x-test" style="-moz-transform:scale(1)"></embed>
+<html class="reftest-wait">
+<head>
+<script src="utils.js">
+</script>
+</head>
+<body onLoad="forceLoadPlugin('p')">
+<embed type="application/x-test" style="-moz-transform:scale(1)" id="p"></embed>
 </body>
 </html>
--- a/dom/plugins/test/reftest/plugin-transform-2.html
+++ b/dom/plugins/test/reftest/plugin-transform-2.html
@@ -1,8 +1,13 @@
 <!DOCTYPE HTML>
-<html>
-<body>
+<html class="reftest-wait">
+<head>
+<script src="utils.js">
+</script>
+</head>
+<body onLoad="forceLoadPlugin('one')">
 <embed type="application/x-test" drawmode="solid" color="FF00FF00"
        style="width:100px; height:100px; -moz-transform-origin:top left;
-              -moz-transform:scale(2); display:block"></embed>
+       -moz-transform:scale(2); display:block"
+       id="one"></embed>
 </body>
 </html>
--- a/dom/plugins/test/reftest/plugin-transform-alpha-zindex.html
+++ b/dom/plugins/test/reftest/plugin-transform-alpha-zindex.html
@@ -1,10 +1,10 @@
 <!doctype html>
-<html>
+<html class="reftest-wait">
 <head>
 <style type="text/css">
 #one {
   position:absolute;
   left:0px; top:0px;
   z-index:1;
 }
 #two {
@@ -12,15 +12,17 @@
   top:0px; left:0px;
   width:200px; height:200px;
   z-index:0;
   background-color: rgb(255,0,0);
   -moz-transform-origin: 0 0;
   -moz-transform: translate(100px,100px);
 }
 </style>
+<script src="utils.js">
+</script>
 </head>
-<body>
+<body onLoad="forceLoadPlugin('one')">
   <div id="two"></div>
   <embed id="one" type="application/x-test" width="400" height="400" drawmode="solid" color="9900FF00"></embed>
 </body>
 </html>
 
--- a/dom/plugins/test/reftest/shrink-1-ref.html
+++ b/dom/plugins/test/reftest/shrink-1-ref.html
@@ -1,10 +1,12 @@
 <!DOCTYPE html>
-<html>
+<html class="reftest-wait">
 <head>
+<script src="utils.js">
+</script>
 </head>
-<body>
+<body onLoad="forceLoadPlugin('plugin')">
   <embed id="plugin" type="application/x-test"
          width="50px" height="40px">
   </embed>
 </body>
 </html>
--- a/dom/plugins/test/reftest/shrink-1.html
+++ b/dom/plugins/test/reftest/shrink-1.html
@@ -1,23 +1,25 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
 <head>
+  <script src="utils.js">
+  </script>
   <script>
 function doShrink()
 {
   var plugin = document.getElementById("plugin");
   plugin.setSlowPaint(true);
   plugin.width = "50";
   plugin.height = "40";
 
   document.documentElement.removeAttribute("class");
 }
 
 document.addEventListener("MozReftestInvalidate", doShrink, false);
   </script>
 </head>
-<body>
+<body onLoad="forceLoadPlugin('plugin', true)">
   <embed id="plugin" type="application/x-test"
          width="300" height="500">
   </embed>
 </body>
 </html>
--- a/dom/plugins/test/reftest/update-1-ref.html
+++ b/dom/plugins/test/reftest/update-1-ref.html
@@ -1,8 +1,12 @@
 <!DOCTYPE html>
-<html>
-<body>
+<html class="reftest-wait">
+<head>
+<script src="utils.js">
+</script>
+</head>
+<body onLoad="forceLoadPlugin('plugin')">
   <embed id="plugin" type="application/x-test"
          drawmode="solid" color="FFFF0000" width="30" height="50">
   </embed>
 </body>
 </html>
--- a/dom/plugins/test/reftest/update-1.html
+++ b/dom/plugins/test/reftest/update-1.html
@@ -1,12 +1,14 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
 <head>
   <title>Test for bugs 807728 and 810426</title>
+  <script src="utils.js">
+  </script>
   <script>
 function start()
 {
     document.removeEventListener("MozReftestInvalidate", start, false);
 
     var plugin = document.getElementById("plugin");
     var color = "FF000000";
     var color_count = 0;
@@ -44,14 +46,14 @@ function start()
 
     wait_for_paints();
 }
 
 // MozReftestInvalidate is delivered after initial painting has settled.
 document.addEventListener("MozReftestInvalidate", start, false);
   </script>
 </head>
-<body>
+<body onLoad="forceLoadPlugin('plugin', true)">
   <embed id="plugin" type="application/x-test"
          drawmode="solid" color="FF000000" width="30" height="50">
   </embed>
 </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/dom/plugins/test/reftest/utils.js
@@ -0,0 +1,18 @@
+function forceLoadPluginElement(id) {
+  var e = document.getElementById(id);
+  var found = e.pluginFoundElement;
+}
+
+function forceLoadPlugin(ids, skipRemoveAttribute) {
+  if (Array.isArray(ids)) {
+    ids.forEach(function(element, index, array) {
+      forceLoadPluginElement(element);
+    });
+  } else {
+    forceLoadPluginElement(ids);
+  }
+  if (skipRemoveAttribute) {
+    return;
+  }
+  document.documentElement.removeAttribute("class");
+}
--- a/dom/plugins/test/reftest/windowless-clipping-1-ref.html
+++ b/dom/plugins/test/reftest/windowless-clipping-1-ref.html
@@ -1,10 +1,14 @@
-<html>
-<body>
+<html class="reftest-wait">
+<head>
+<script src="utils.js">
+</script>
+</head>
+<body onLoad="forceLoadPlugin('p1')">
 <div style="width:100px; height:100px; overflow:auto;">
   <div style="width:100px; height:100px; overflow:hidden;">
-    <embed type="application/x-test" style="width:200px;"></embed>
+    <embed type="application/x-test" style="width:200px;" id="p1"></embed>
   </div>
 </div>
 <div style="width:100px; height:100px; background-color:lime;"></div>
 </body>
 </html>
--- a/dom/plugins/test/reftest/windowless-clipping-1.html
+++ b/dom/plugins/test/reftest/windowless-clipping-1.html
@@ -1,11 +1,15 @@
-<html>
-<body>
+<html class="reftest-wait">
+<head>
+<script src="utils.js">
+</script>
+</head>
+<body onLoad="forceLoadPlugin('p1')">
 <div style="width:100px; height:100px; overflow:hidden;">
   <embed type="application/x-test" style="width:200px;"></embed>
 </div>
 <div style="width:100px; height:100px; overflow:hidden;">
   <embed type="application/x-test" style="width:200px;"
-         drawmode="solid" color="ff00ff00"></embed>
+         drawmode="solid" color="ff00ff00" id="p1"></embed>
 </div>
 </body>
 </html>
--- a/dom/plugins/test/reftest/windowless-layers-ref.html
+++ b/dom/plugins/test/reftest/windowless-layers-ref.html
@@ -1,6 +1,10 @@
 <!DOCTYPE html>
-<html>
-<body>
-  <embed type="application/x-test" style="width:200px; height:200px;">
+<html class="reftest-wait">
+<head>
+<script src="utils.js">
+</script>
+</head>
+<body onLoad="forceLoadPlugin('p1')">
+  <embed type="application/x-test" style="width:200px; height:200px;" id="p1">
 </body>
 </html>
--- a/dom/plugins/test/reftest/windowless-layers.html
+++ b/dom/plugins/test/reftest/windowless-layers.html
@@ -1,11 +1,15 @@
 <!DOCTYPE html>
-<html>
-<body>
+<html class="reftest-wait">
+<head>
+<script src="utils.js">
+</script>
+</head>
+<body onLoad="forceLoadPlugin(['p1', 'p2'])">
   <div style="width:200px; height:200px; overflow:hidden; position:absolute; z-index:1">
-    <embed type="application/x-test" style="width:200px; height:200px;">
+    <embed type="application/x-test" style="width:200px; height:200px;" id="p1">
   </div>
   <div style="width:200px; height:100px; overflow:hidden; position:absolute; z-index:2">
-    <embed type="application/x-test" style="width:200px; height:200px;">
+    <embed type="application/x-test" style="width:200px; height:200px;" id="p2">
   </div>
 </body>
 </html>