michael@0: // Canvas related code stolen from http://developer.mozilla.org/en/docs/Code_snippets:Canvas michael@0: var RemoteCanvas = function(url, id) { michael@0: this.url = url; michael@0: this.id = id; michael@0: this.snapshot = null; michael@0: }; michael@0: michael@0: RemoteCanvas.CANVAS_WIDTH = 200; michael@0: RemoteCanvas.CANVAS_HEIGHT = 100; michael@0: michael@0: RemoteCanvas.prototype.compare = function(otherCanvas, expected) { michael@0: return compareSnapshots(this.snapshot, otherCanvas.snapshot, expected)[0]; michael@0: } michael@0: michael@0: RemoteCanvas.prototype.load = function(callback) { michael@0: var iframe = document.createElement("iframe"); michael@0: iframe.id = this.id + "-iframe"; michael@0: iframe.width = RemoteCanvas.CANVAS_WIDTH + "px"; michael@0: iframe.height = RemoteCanvas.CANVAS_HEIGHT + "px"; michael@0: iframe.src = this.url; michael@0: var me = this; michael@0: iframe.addEventListener("load", function() { michael@0: me.remotePageLoaded(callback); michael@0: }, false); michael@0: window.document.body.appendChild(iframe); michael@0: }; michael@0: michael@0: RemoteCanvas.prototype.remotePageLoaded = function(callback) { michael@0: var ldrFrame = document.getElementById(this.id + "-iframe"); michael@0: this.snapshot = snapshotWindow(ldrFrame.contentWindow); michael@0: callback(this); michael@0: }; michael@0: michael@0: function bidiNumeral(val) { michael@0: if (typeof val == "undefined") michael@0: return SpecialPowers.getIntPref("bidi.numeral"); michael@0: else michael@0: SpecialPowers.setIntPref("bidi.numeral", val); michael@0: } michael@0: michael@0: var bidiNumeralDefault = bidiNumeral(); michael@0: michael@0: var currentPass = 0; michael@0: michael@0: function run() michael@0: { michael@0: SimpleTest.waitForExplicitFinish(); michael@0: michael@0: do_test(); michael@0: } michael@0: michael@0: function do_test() michael@0: { michael@0: var canvases = []; michael@0: function callbackTestCanvas(canvas) michael@0: { michael@0: canvases.push(canvas); michael@0: michael@0: if (canvases.length == 2) { // when both canvases are loaded michael@0: if (passes[currentPass].op == "==") { michael@0: ok(canvases[0].compare(canvases[1], true), "Rendering of reftest " + fileprefix + passes[currentPass].file + michael@0: " is different with bidi.numeral == " + passes[currentPass].bidiNumeralValue); michael@0: } else if (passes[currentPass].op == "!=") { michael@0: ok(canvases[0].compare(canvases[1], false), "Rendering of reftest " + fileprefix + passes[currentPass].file + michael@0: " is not different with bidi.numeral == " + passes[currentPass].bidiNumeralValue); michael@0: } michael@0: michael@0: bidiNumeral(bidiNumeralDefault); michael@0: michael@0: if (currentPass < passes.length - 1) { michael@0: ++currentPass; michael@0: do_test(); michael@0: } else { michael@0: SimpleTest.finish(); michael@0: } michael@0: } michael@0: } michael@0: michael@0: var fileprefix = passes[currentPass].prefix + "-"; michael@0: var file = passes[currentPass].file; michael@0: michael@0: var header = document.createElement("p"); michael@0: header.appendChild(document.createTextNode("Testing reftest " + fileprefix + file + michael@0: " with bidi.numeral == " + passes[currentPass].bidiNumeralValue + michael@0: " expecting " + passes[currentPass].op)); michael@0: document.body.appendChild(header); michael@0: michael@0: bidiNumeral(passes[currentPass].bidiNumeralValue); michael@0: michael@0: var testCanvas = new RemoteCanvas(fileprefix + file + ".html", "test-" + currentPass); michael@0: testCanvas.load(callbackTestCanvas); michael@0: michael@0: var refCanvas = new RemoteCanvas(fileprefix + file + "-ref.html", "ref-" + currentPass); michael@0: refCanvas.load(callbackTestCanvas); michael@0: } michael@0: michael@0: run();