summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/widgets/videocontrols_direction_test.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 /toolkit/content/tests/widgets/videocontrols_direction_test.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 'toolkit/content/tests/widgets/videocontrols_direction_test.js')
-rw-r--r--toolkit/content/tests/widgets/videocontrols_direction_test.js90
1 files changed, 90 insertions, 0 deletions
diff --git a/toolkit/content/tests/widgets/videocontrols_direction_test.js b/toolkit/content/tests/widgets/videocontrols_direction_test.js
new file mode 100644
index 000000000..8ad76c064
--- /dev/null
+++ b/toolkit/content/tests/widgets/videocontrols_direction_test.js
@@ -0,0 +1,90 @@
+var RemoteCanvas = function(url, id) {
+ this.url = url;
+ this.id = id;
+ this.snapshot = null;
+};
+
+RemoteCanvas.CANVAS_WIDTH = 200;
+RemoteCanvas.CANVAS_HEIGHT = 200;
+
+RemoteCanvas.prototype.compare = function(otherCanvas, expected) {
+ return compareSnapshots(this.snapshot, otherCanvas.snapshot, expected)[0];
+}
+
+RemoteCanvas.prototype.load = function(callback) {
+ var iframe = document.createElement("iframe");
+ iframe.id = this.id + "-iframe";
+ iframe.width = RemoteCanvas.CANVAS_WIDTH + "px";
+ iframe.height = RemoteCanvas.CANVAS_HEIGHT + "px";
+ iframe.src = this.url;
+ var me = this;
+ iframe.addEventListener("load", function() {
+ info("iframe loaded");
+ var m = iframe.contentDocument.getElementById("av");
+ m.addEventListener("suspend", function(aEvent) {
+ m.removeEventListener("suspend", arguments.callee, false);
+ setTimeout(function() {
+ me.remotePageLoaded(callback);
+ }, 0);
+ }, false);
+ m.src = m.getAttribute("source");
+ }, false);
+ window.document.body.appendChild(iframe);
+};
+
+RemoteCanvas.prototype.remotePageLoaded = function(callback) {
+ var ldrFrame = document.getElementById(this.id + "-iframe");
+ this.snapshot = snapshotWindow(ldrFrame.contentWindow);
+ this.snapshot.id = this.id + "-canvas";
+ window.document.body.appendChild(this.snapshot);
+ callback(this);
+};
+
+RemoteCanvas.prototype.cleanup = function() {
+ var iframe = document.getElementById(this.id + "-iframe");
+ iframe.parentNode.removeChild(iframe);
+ var canvas = document.getElementById(this.id + "-canvas");
+ canvas.parentNode.removeChild(canvas);
+};
+
+function runTest(index) {
+ var canvases = [];
+ function testCallback(canvas) {
+ canvases.push(canvas);
+
+ if (canvases.length == 2) { // when both canvases are loaded
+ var expectedEqual = currentTest.op == "==";
+ var result = canvases[0].compare(canvases[1], expectedEqual);
+ ok(result, "Rendering of reftest " + currentTest.test + " should " +
+ (expectedEqual ? "not " : "") + "be different to the reference");
+
+ if (result) {
+ canvases[0].cleanup();
+ canvases[1].cleanup();
+ }
+ else {
+ info("Snapshot of canvas 1: " + canvases[0].snapshot.toDataURL());
+ info("Snapshot of canvas 2: " + canvases[1].snapshot.toDataURL());
+ }
+
+ if (index < tests.length - 1)
+ runTest(index + 1);
+ else
+ SimpleTest.finish();
+ }
+ }
+
+ var currentTest = tests[index];
+ var testCanvas = new RemoteCanvas(currentTest.test, "test-" + index);
+ testCanvas.load(testCallback);
+
+ var refCanvas = new RemoteCanvas(currentTest.ref, "ref-" + index);
+ refCanvas.load(testCallback);
+}
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestCompleteLog();
+
+window.addEventListener("load", function() {
+ SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, function() { runTest(0); });
+}, true);