summaryrefslogtreecommitdiffstats
path: root/dom/plugins/test/reftest/plugin-background.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/plugins/test/reftest/plugin-background.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/plugins/test/reftest/plugin-background.js')
-rw-r--r--dom/plugins/test/reftest/plugin-background.js75
1 files changed, 75 insertions, 0 deletions
diff --git a/dom/plugins/test/reftest/plugin-background.js b/dom/plugins/test/reftest/plugin-background.js
new file mode 100644
index 000000000..5d24562cf
--- /dev/null
+++ b/dom/plugins/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);