michael@0: // The including script sets this for us michael@0: //var NUM_STEPS; michael@0: michael@0: var plugin; michael@0: var left = 1, top = 1, width = 199, height = 199; michael@0: function movePluginTo(x, y, w, h) { michael@0: left = x; top = y; width = w; height = h; michael@0: plugin.width = w; michael@0: plugin.height = h; michael@0: plugin.style.left = left + "px"; michael@0: plugin.style.top = top + "px"; michael@0: } michael@0: function deltaInBounds(dx,dy, dw,dh) { michael@0: var l = dx + left; michael@0: var r = l + width + dw; michael@0: var t = dy + top; michael@0: var b = t + height + dh; michael@0: return (0 <= l && l <= 20 && michael@0: 0 <= t && t <= 20 && michael@0: 200 <= r && r <= 220 && michael@0: 200 <= b && b <= 220); michael@0: } michael@0: michael@0: var initialFrame; michael@0: function start() { michael@0: window.removeEventListener("MozReftestInvalidate", start, false); michael@0: michael@0: window.addEventListener("MozAfterPaint", step, false); michael@0: window.addEventListener("MozPaintWaitFinished", step, false); michael@0: michael@0: initialFrame = window.mozPaintCount; michael@0: plugin = document.getElementById("plugin"); michael@0: michael@0: movePluginTo(0,0, 200,200); michael@0: } michael@0: michael@0: var steps = 0; michael@0: var which = "move"; // or "grow" michael@0: var dx = 1, dy = 1, dw = 1, dh = 1; michael@0: function step() { michael@0: if (++steps >= NUM_STEPS) { michael@0: window.removeEventListener("MozAfterPaint", step, false); michael@0: window.removeEventListener("MozPaintWaitFinished", step, false); michael@0: return finish(); michael@0: } michael@0: michael@0: var didSomething = false; michael@0: if (which == "grow") { michael@0: if (deltaInBounds(0,0, dw,dh)) { michael@0: movePluginTo(left,top, width+dw, height+dh); michael@0: didSomething = true; michael@0: } else { michael@0: dw = -dw; dh = -dh; michael@0: } michael@0: } else { michael@0: // "move" michael@0: if (deltaInBounds(dx,dy, 0,0)) { michael@0: movePluginTo(left+dx,top+dy, width, height); michael@0: didSomething = true; michael@0: } else { michael@0: dx = -dx; dy = -dy; michael@0: } michael@0: } michael@0: which = (which == "grow") ? "move" : "grow"; michael@0: michael@0: if (!didSomething) { michael@0: step(); michael@0: } michael@0: } michael@0: michael@0: function finish() { michael@0: document.documentElement.removeAttribute("class"); michael@0: } michael@0: michael@0: window.addEventListener("MozReftestInvalidate", start, false);