Some tests for bug 626602. a=b
authorChris Jones <jones.chris.g@gmail.com>
Tue, 08 Feb 2011 18:44:14 -0600
changeset 62209 a75cef6e752a983991dc8b127925cacb96ae3968
parent 62208 a96c75dbc1518b048819170162ba2c9bec16cd40
child 62210 c3a4a1970f6cf431770c315fd53d5480e7d42bc9
push idunknown
push userunknown
push dateunknown
reviewersb
bugs626602
milestone2.0b12pre
Some tests for bug 626602. a=b
modules/plugin/test/crashtests/626602-1.html
modules/plugin/test/crashtests/crashtests.list
modules/plugin/test/reftest/plugin-background-1-step.html
modules/plugin/test/reftest/plugin-background-10-step.html
modules/plugin/test/reftest/plugin-background-2-step.html
modules/plugin/test/reftest/plugin-background-5-step.html
modules/plugin/test/reftest/plugin-background-ref.html
modules/plugin/test/reftest/plugin-background.css
modules/plugin/test/reftest/plugin-background.html
modules/plugin/test/reftest/plugin-background.js
modules/plugin/test/reftest/plugin-busy-alpha-zindex.html
modules/plugin/test/reftest/plugin-canvas-alpha-zindex.html
modules/plugin/test/reftest/plugin-transform-alpha-zindex.html
modules/plugin/test/reftest/reftest.list
new file mode 100644
--- /dev/null
+++ b/modules/plugin/test/crashtests/626602-1.html
@@ -0,0 +1,109 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+  <style type="text/css">
+#one {
+  position:absolute;
+  left:0px; top:0px;
+  z-index:4;
+}
+#two {
+  position:absolute;
+  top:100px; left:100px;
+  background-color:rgb(0,0,0,0);
+  z-index:3;
+}
+#three {
+  position:absolute;
+  left:100px; top:100px;
+  width:200px; height:200px;
+  background-color: rgb(255,0,0);
+  opacity:0.6;
+  z-index:2;
+}
+#four {
+  position:absolute;
+  top:100px; left:100px;
+  z-index:1;
+}
+  </style>
+  <script type="text/javascript">
+var plugin, div, canvas;
+function start() {
+  plugin = document.getElementById("four");
+  div = document.getElementById("three");
+  canvas = document.getElementById("two");
+  paintCanvas();
+
+  mozRequestAnimationFrame(moveSomething);
+}
+
+function paintCanvas() {
+  var ctx = canvas.getContext("2d");
+  ctx.fillStyle = "rgba(255,0,0, 0.6)";
+  ctx.fillRect(0,0, 200,200);
+}
+
+var i = 0, numLoops = 20;
+var pluginIn = true, divIn = true, canvasIn = true;
+function moveSomething() {
+  var didSomething = (0 === (i % 2)) ? moveSomethingOut() : moveSomethingIn();
+  if (!didSomething && ++i >= numLoops) {
+    return finish();
+  }
+
+  mozRequestAnimationFrame(moveSomething);
+}
+
+function finish() {
+  document.documentElement.removeAttribute("class");
+}
+
+function moveSomethingOut() {
+  if (pluginIn) {
+    plugin.style.left = "400px";
+    pluginIn = false;
+  } else if (divIn) {
+    div.style.left = "400px";
+    divIn = false;
+  } else if (canvasIn) {
+    canvas.style.left = "400px";
+    canvasIn = false;
+  } else {
+    return false;
+  }
+  return true;
+}
+
+function moveSomethingIn() {
+  if (!pluginIn) {
+    plugin.style.left = "100px";
+    pluginIn = true;
+  } else if (!divIn) {
+    div.style.left = "100px";
+    divIn = true;
+  } else if (!canvasIn) {
+    canvas.style.left = "100px";
+    canvasIn = true;
+  } else {
+    return false;
+  }
+  return true;
+}
+
+function reset() {
+
+}
+  </script>
+</style>
+</head>
+<body onload="start();">
+  <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/modules/plugin/test/crashtests/crashtests.list
+++ b/modules/plugin/test/crashtests/crashtests.list
@@ -4,8 +4,9 @@ load 110650-1.html
 skip-if(browserIsRemote||!haveTestPlugin||cocoaWidget) script 539897-1.html # browserIsRemote is bug XXXXXX
 skip-if(browserIsRemote||!haveTestPlugin) script 540114-1.html # browserIsRemote is bug XXXXXX
 load 570884.html
 # This test relies on the reading of screenX/Y forcing a round trip to
 # the X server, which is a bad assumption for <browser remote>.
 # Plugin arch is going to change anyway with OOP content so skipping
 # this test for now is OK.
 skip-if(browserIsRemote||!haveTestPlugin||http.platform!="X11"||!testPluginIsOOP()) load 598862.html
+load 626602-1.html
new file mode 100644
--- /dev/null
+++ b/modules/plugin/test/reftest/plugin-background-1-step.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+  <link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
+  <script type="text/javascript">
+var NUM_STEPS = 1;
+  </script>
+  <script type="text/javascript" src="plugin-background.js"></script>
+</head>
+<body>
+  <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>
+  <div id="rightbar"></div>
+  <div id="bottombar"></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/modules/plugin/test/reftest/plugin-background-10-step.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+  <link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
+  <script type="text/javascript">
+var NUM_STEPS = 10;
+  </script>
+  <script type="text/javascript" src="plugin-background.js"></script>
+</head>
+<body>
+  <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>
+  <div id="rightbar"></div>
+  <div id="bottombar"></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/modules/plugin/test/reftest/plugin-background-2-step.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+  <link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
+  <script type="text/javascript">
+var NUM_STEPS = 2;
+  </script>
+  <script type="text/javascript" src="plugin-background.js"></script>
+</head>
+<body>
+  <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>
+  <div id="rightbar"></div>
+  <div id="bottombar"></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/modules/plugin/test/reftest/plugin-background-5-step.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+  <link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
+  <script type="text/javascript">
+var NUM_STEPS = 5;
+  </script>
+  <script type="text/javascript" src="plugin-background.js"></script>
+</head>
+<body>
+  <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>
+  <div id="rightbar"></div>
+  <div id="bottombar"></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/modules/plugin/test/reftest/plugin-background-ref.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
+</head>
+<body>
+  <div id="bad">Test some plugin stuff.</div>
+  <div id="good"></div>
+
+  <div id="plugin"></div>
+
+  <div id="topbar"></div>
+  <div id="leftbar"></div>
+  <div id="rightbar"></div>
+  <div id="bottombar"></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/modules/plugin/test/reftest/plugin-background.css
@@ -0,0 +1,58 @@
+div {
+  position: absolute;
+}
+#bad {
+  left:220px; top:0px;
+  z-index: 0;
+}
+#good {
+  left:0px; top:0px;
+  width:220px; height:220px;
+  background-color: rgba(0,255,0, 0.6);
+  z-index: 0;
+}
+
+#topbar {
+  left:0px; top:0px;
+  width:220px; height:20px;
+  background-color: rgb(0,0,0);
+  z-index: 2;
+}
+#topbar {
+  left:0px; top:0px;
+  width:220px; height:20px;
+  background-color: rgb(0,0,0);
+  z-index: 2;
+}
+#leftbar {
+  left:0px; top:0px;
+  width:20px; height:220px;
+  background-color: rgb(0,0,0);
+  z-index: 2;
+}
+#rightbar {
+  left:200px; top:0px;
+  width:20px; height:220px;
+  background-color: rgb(0,0,0);
+  z-index: 2;
+}
+#bottombar {
+  left:0px; top:200px;
+  width:220px; height:20px;
+  background-color: rgb(0,0,0);
+  z-index: 2;
+}
+
+div#plugin {
+  position: absolute;
+  left:1px; top:1px;
+  width:199px; height:199px;
+  background-color: rgba(0,0,255, 0.2);
+  z-index: 1;
+}
+
+embed#plugin {
+  position: absolute;
+  left:1px; top:1px;
+  z-index: 1;
+}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/modules/plugin/test/reftest/plugin-background.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
+</head>
+<body>
+  <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>
+  <div id="rightbar"></div>
+  <div id="bottombar"></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/modules/plugin/test/reftest/plugin-background.js
@@ -0,0 +1,75 @@
+// The including script sets this for us
+//var NUM_STEPS;
+
+var plugin;
+var left = 1, top = 1, width = 199, height = 199;
+function movePluginTo(x, y, w, h) {
+    left = x; top = y;  width = w; height = h;
+    plugin.width = w;
+    plugin.height = h;
+    plugin.style.left = left + "px";
+    plugin.style.top = top + "px";
+}
+function deltaInBounds(dx,dy, dw,dh) {
+    var l = dx + left;
+    var r = l + width + dw;
+    var t = dy + top;
+    var b = t + height + dh;
+    return (0 <= l && l <= 20 &&
+            0 <= t && t <= 20 &&
+            200 <= r && r <= 220 &&
+            200 <= b && b <= 220);
+}
+
+var initialFrame;
+function start() {
+    window.removeEventListener("MozReftestInvalidate", start, false);
+
+    window.addEventListener("MozAfterPaint", step, false);
+    window.addEventListener("MozPaintWaitFinished", step, false);
+
+    initialFrame = window.mozPaintCount;
+    plugin = document.getElementById("plugin");
+
+    movePluginTo(0,0, 200,200);
+}
+
+var steps = 0;
+var which = "move"; // or "grow"
+var dx = 1, dy = 1, dw = 1, dh = 1;
+function step() {
+    if (++steps >= NUM_STEPS) {
+        window.removeEventListener("MozAfterPaint", step, false);
+        window.removeEventListener("MozPaintWaitFinished", step, false);
+        return finish();
+    }
+
+    var didSomething = false;
+    if (which == "grow") {
+        if (deltaInBounds(0,0, dw,dh)) {
+            movePluginTo(left,top, width+dw, height+dh);
+            didSomething = true;
+        } else {
+            dw = -dw;  dh = -dh;
+        }
+    } else {
+        // "move"
+        if (deltaInBounds(dx,dy, 0,0)) {
+            movePluginTo(left+dx,top+dy, width, height);
+            didSomething = true;
+        } else {
+            dx = -dx;  dy = -dy;
+        }
+    }
+    which = (which == "grow") ? "move" : "grow";
+
+    if (!didSomething) {
+        step();
+    }
+}
+
+function finish() {
+    document.documentElement.removeAttribute("class");
+}
+
+window.addEventListener("MozReftestInvalidate", start, false);
new file mode 100644
--- /dev/null
+++ b/modules/plugin/test/reftest/plugin-busy-alpha-zindex.html
@@ -0,0 +1,49 @@
+<!doctype html>
+<html>
+<head>
+  <style type="text/css">
+#one {
+  position:absolute;
+  left:0px; top:0px;
+  z-index:4;
+}
+#two {
+  position:absolute;
+  top:100px; left:100px;
+  background-color:rgb(0,0,0,0);
+  z-index:3;
+}
+#three {
+  position:absolute;
+  left:100px; top:100px;
+  width:200px; height:200px;
+  background-color: rgb(255,0,0);
+  opacity:0.6;
+  z-index:2;
+}
+#four {
+  position:absolute;
+  top:100px; left:100px;
+  z-index:1;
+}
+  </style>
+  <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);
+}
+  </script>
+</style>
+</head>
+<body onload="paintCanvas();">
+  <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>
+
new file mode 100644
--- /dev/null
+++ b/modules/plugin/test/reftest/plugin-canvas-alpha-zindex.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<html>
+<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 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);
+}
+  </script>
+</style>
+</head>
+<body onload="paintCanvas();">
+  <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>
+
new file mode 100644
--- /dev/null
+++ b/modules/plugin/test/reftest/plugin-transform-alpha-zindex.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<html>
+<head>
+<style type="text/css">
+#one {
+  position:absolute;
+  left:0px; top:0px;
+  z-index:1;
+}
+#two {
+  position:absolute;
+  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>
+</head>
+<body>
+  <div id="two"></div>
+  <embed id="one" type="application/x-test" width="400" height="400" drawmode="solid" color="9900FF00"></embed>
+</body>
+</html>
+
--- a/modules/plugin/test/reftest/reftest.list
+++ b/modules/plugin/test/reftest/reftest.list
@@ -4,8 +4,16 @@ fails-if(!haveTestPlugin) == plugin-sani
 fails-if(!haveTestPlugin) == plugin-alpha-zindex.html div-alpha-zindex.html
 fails-if(!haveTestPlugin) == plugin-alpha-opacity.html div-alpha-opacity.html
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == windowless-clipping-1.html windowless-clipping-1-ref.html # bug 631832
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == border-padding-1.html border-padding-1-ref.html # bug 629430
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == border-padding-2.html border-padding-2-ref.html # bug 629430
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == border-padding-3.html border-padding-3-ref.html # bug 629430
 random-if(cocoaWidget||d2d) fails-if(!haveTestPlugin) skip-if(!testPluginIsOOP()) == pluginproblemui-direction-1.html pluginproblemui-direction-1-ref.html
 fails-if(!haveTestPlugin) skip-if(!testPluginIsOOP()) == pluginproblemui-direction-2.html pluginproblemui-direction-2-ref.html
+fails-if(!haveTestPlugin) == plugin-canvas-alpha-zindex.html div-alpha-zindex.html
+fails-if(!haveTestPlugin) == plugin-transform-alpha-zindex.html div-alpha-zindex.html
+random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-busy-alpha-zindex.html div-alpha-zindex.html
+fails-if(!haveTestPlugin) == plugin-background.html plugin-background-ref.html
+random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-background-1-step.html plugin-background-ref.html
+random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-background-2-step.html plugin-background-ref.html
+fails-if(!haveTestPlugin) == plugin-background-5-step.html plugin-background-ref.html
+fails-if(!haveTestPlugin) == plugin-background-10-step.html plugin-background-ref.html