зеркало из https://github.com/mozilla/pjs.git
Speed up canvas comparisons in bidi mochitests. No bug
This commit is contained in:
Родитель
e9b2fe026d
Коммит
67f176947f
|
@ -53,7 +53,7 @@
|
||||||
var s2 = snapshotWindow($("f2").contentWindow);
|
var s2 = snapshotWindow($("f2").contentWindow);
|
||||||
var s3 = snapshotWindow($("f3").contentWindow);
|
var s3 = snapshotWindow($("f3").contentWindow);
|
||||||
|
|
||||||
ok(!compareSnapshots(s2, s3)[0],
|
ok(!compareSnapshots(s2, s3, true)[0],
|
||||||
"Should look different due to different sizing");
|
"Should look different due to different sizing");
|
||||||
|
|
||||||
function getDOM(id) {
|
function getDOM(id) {
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
l4.detach();
|
l4.detach();
|
||||||
|
|
||||||
var s1_new = snapshotWindow($("f1").contentWindow);
|
var s1_new = snapshotWindow($("f1").contentWindow);
|
||||||
var [same, first, second] = compareSnapshots(s1_new, s2);
|
var [same, first, second] = compareSnapshots(s1_new, s2, true);
|
||||||
ok(same, "Should reflow on swap", "Expected " + second + " but got " + first);
|
ok(same, "Should reflow on swap", "Expected " + second + " but got " + first);
|
||||||
|
|
||||||
is(strs["f1"], "f1.pagehide f1.pageshow");
|
is(strs["f1"], "f1.pagehide f1.pageshow");
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
|
|
||||||
<!-- test code goes here -->
|
<!-- test code goes here -->
|
||||||
<script type="application/javascript"><![CDATA[
|
<script type="application/javascript"><![CDATA[
|
||||||
var imports = [ "SimpleTest", "is", "isnot", "ok", "snapshotWindow",
|
var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror" ];
|
||||||
"compareSnapshots", "onerror" ];
|
|
||||||
for each (var import in imports) {
|
for each (var import in imports) {
|
||||||
window[import] = window.opener.wrappedJSObject[import];
|
window[import] = window.opener.wrappedJSObject[import];
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
|
|
||||||
<!-- test code goes here -->
|
<!-- test code goes here -->
|
||||||
<script type="application/javascript"><![CDATA[
|
<script type="application/javascript"><![CDATA[
|
||||||
var imports = [ "SimpleTest", "is", "isnot", "ok", "snapshotWindow",
|
var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror" ];
|
||||||
"compareSnapshots", "onerror" ];
|
|
||||||
for each (var import in imports) {
|
for each (var import in imports) {
|
||||||
window[import] = window.opener.wrappedJSObject[import];
|
window[import] = window.opener.wrappedJSObject[import];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
var RemoteCanvas = function(url, id) {
|
var RemoteCanvas = function(url, id) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.snapshot = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
RemoteCanvas.CANVAS_WIDTH = 200;
|
RemoteCanvas.CANVAS_WIDTH = 200;
|
||||||
RemoteCanvas.CANVAS_HEIGHT = 100;
|
RemoteCanvas.CANVAS_HEIGHT = 100;
|
||||||
|
|
||||||
RemoteCanvas.prototype.getCanvas = function() {
|
RemoteCanvas.prototype.compare = function(otherCanvas, expected) {
|
||||||
return document.getElementById(this.id + "-canvas");
|
return compareSnapshots(this.snapshot, otherCanvas.snapshot, expected)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteCanvas.prototype.load = function(callback) {
|
RemoteCanvas.prototype.load = function(callback) {
|
||||||
|
@ -19,37 +20,14 @@ RemoteCanvas.prototype.load = function(callback) {
|
||||||
iframe.src = this.url;
|
iframe.src = this.url;
|
||||||
var me = this;
|
var me = this;
|
||||||
iframe.addEventListener("load", function() {
|
iframe.addEventListener("load", function() {
|
||||||
window.setTimeout(function() {
|
me.remotePageLoaded(callback);
|
||||||
me.remotePageLoaded(callback);
|
}, false);
|
||||||
}, 500);
|
|
||||||
}, true);
|
|
||||||
window.document.body.appendChild(iframe);
|
window.document.body.appendChild(iframe);
|
||||||
};
|
};
|
||||||
|
|
||||||
RemoteCanvas.prototype.remotePageLoaded = function(callback) {
|
RemoteCanvas.prototype.remotePageLoaded = function(callback) {
|
||||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
|
|
||||||
var ldrFrame = document.getElementById(this.id + "-iframe");
|
var ldrFrame = document.getElementById(this.id + "-iframe");
|
||||||
var remoteWindow = ldrFrame.contentWindow;
|
this.snapshot = snapshotWindow(ldrFrame.contentWindow);
|
||||||
|
|
||||||
var canvas = document.createElement("canvas");
|
|
||||||
canvas.id = this.id + "-canvas";
|
|
||||||
canvas.style.width = RemoteCanvas.CANVAS_WIDTH + "px";
|
|
||||||
canvas.style.height = RemoteCanvas.CANVAS_HEIGHT + "px";
|
|
||||||
canvas.width = RemoteCanvas.CANVAS_WIDTH;
|
|
||||||
canvas.height = RemoteCanvas.CANVAS_HEIGHT;
|
|
||||||
|
|
||||||
var ctx = canvas.getContext("2d");
|
|
||||||
ctx.clearRect(0, 0,
|
|
||||||
RemoteCanvas.CANVAS_WIDTH,
|
|
||||||
RemoteCanvas.CANVAS_HEIGHT);
|
|
||||||
ctx.drawWindow(remoteWindow,
|
|
||||||
0, 0,
|
|
||||||
RemoteCanvas.CANVAS_WIDTH,
|
|
||||||
RemoteCanvas.CANVAS_HEIGHT,
|
|
||||||
"rgb(255,255,255)");
|
|
||||||
|
|
||||||
window.document.body.appendChild(canvas);
|
|
||||||
|
|
||||||
callback(this);
|
callback(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,13 +61,11 @@ function do_test()
|
||||||
canvases.push(canvas);
|
canvases.push(canvas);
|
||||||
|
|
||||||
if (canvases.length == 2) { // when both canvases are loaded
|
if (canvases.length == 2) { // when both canvases are loaded
|
||||||
var img_1 = canvases[0].getCanvas().toDataURL("image/png", "");
|
|
||||||
var img_2 = canvases[1].getCanvas().toDataURL("image/png", "");
|
|
||||||
if (passes[currentPass].op == "==") {
|
if (passes[currentPass].op == "==") {
|
||||||
ok(img_1 == img_2, "Rendering of reftest " + fileprefix + passes[currentPass].file +
|
ok(canvases[0].compare(canvases[1], true), "Rendering of reftest " + fileprefix + passes[currentPass].file +
|
||||||
" is different with bidi.numeral == " + passes[currentPass].bidiNumeralValue);
|
" is different with bidi.numeral == " + passes[currentPass].bidiNumeralValue);
|
||||||
} else if (passes[currentPass].op == "!=") {
|
} else if (passes[currentPass].op == "!=") {
|
||||||
ok(img_1 != img_2, "Rendering of reftest " + fileprefix + passes[currentPass].file +
|
ok(canvases[0].compare(canvases[1], false), "Rendering of reftest " + fileprefix + passes[currentPass].file +
|
||||||
" is not different with bidi.numeral == " + passes[currentPass].bidiNumeralValue);
|
" is not different with bidi.numeral == " + passes[currentPass].bidiNumeralValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441782
|
||||||
<head>
|
<head>
|
||||||
<title>Test for Bug 441782</title>
|
<title>Test for Bug 441782</title>
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441782
|
||||||
<head>
|
<head>
|
||||||
<title>Test for Bug 441782</title>
|
<title>Test for Bug 441782</title>
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441782
|
||||||
<head>
|
<head>
|
||||||
<title>Test for Bug 441782</title>
|
<title>Test for Bug 441782</title>
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441782
|
||||||
<head>
|
<head>
|
||||||
<title>Test for Bug 441782</title>
|
<title>Test for Bug 441782</title>
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441782
|
||||||
<head>
|
<head>
|
||||||
<title>Test for Bug 441782</title>
|
<title>Test for Bug 441782</title>
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -33,7 +33,7 @@ addLoadEvent(function() {
|
||||||
s2 = snapshotWindow(window);
|
s2 = snapshotWindow(window);
|
||||||
|
|
||||||
var equal, str1, str2;
|
var equal, str1, str2;
|
||||||
[equal, str1, str2] = compareSnapshots(s1, s2);
|
[equal, str1, str2] = compareSnapshots(s1, s2, true);
|
||||||
ok(equal, "Show/hide should have no effect",
|
ok(equal, "Show/hide should have no effect",
|
||||||
"got " + str1 + " but expected " + str2);
|
"got " + str1 + " but expected " + str2);
|
||||||
|
|
||||||
|
@ -49,14 +49,14 @@ addLoadEvent(function() {
|
||||||
|
|
||||||
s3 = snapshotWindow(window);
|
s3 = snapshotWindow(window);
|
||||||
|
|
||||||
[equal, str1, str2] = compareSnapshots(s1, s3);
|
[equal, str1, str2] = compareSnapshots(s1, s3, true);
|
||||||
ok(equal, "Zoom should have no effect",
|
ok(equal, "Zoom should have no effect",
|
||||||
"got " + str1 + " but expected " + str2);
|
"got " + str1 + " but expected " + str2);
|
||||||
|
|
||||||
$("display").style.display = "none";
|
$("display").style.display = "none";
|
||||||
|
|
||||||
s4 = snapshotWindow(window);
|
s4 = snapshotWindow(window);
|
||||||
[equal, str1, str2] = compareSnapshots(s3, s4);
|
[equal, str1, str2] = compareSnapshots(s3, s4, true);
|
||||||
ok(!equal, "Should be able to see the canary");
|
ok(!equal, "Should be able to see the canary");
|
||||||
|
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467672
|
||||||
<head>
|
<head>
|
||||||
<title>Test for Bug 467672</title>
|
<title>Test for Bug 467672</title>
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467672
|
||||||
<head>
|
<head>
|
||||||
<title>Test for Bug 467672</title>
|
<title>Test for Bug 467672</title>
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467672
|
||||||
<head>
|
<head>
|
||||||
<title>Test for Bug 467672</title>
|
<title>Test for Bug 467672</title>
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467672
|
||||||
<head>
|
<head>
|
||||||
<title>Test for Bug 467672</title>
|
<title>Test for Bug 467672</title>
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467672
|
||||||
<head>
|
<head>
|
||||||
<title>Test for Bug 467672</title>
|
<title>Test for Bug 467672</title>
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -24,24 +24,26 @@ function snapshotWindow(win) {
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the two snapshots aren't equal, returns their serializations as data URIs.
|
// If the two snapshots don't compare as expected (true for equal, false for
|
||||||
function compareSnapshots(s1, s2) {
|
// unequal), returns their serializations as data URIs. In all cases, returns
|
||||||
|
// whether the comparison was as expected.
|
||||||
|
function compareSnapshots(s1, s2, expected) {
|
||||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||||
|
|
||||||
var s1Str, s2Str;
|
var s1Str, s2Str;
|
||||||
var equal = false;
|
var correct = false;
|
||||||
if (gWindowUtils) {
|
if (gWindowUtils) {
|
||||||
equal = (gWindowUtils.compareCanvases(s1, s2, {}) == 0);
|
correct = ((gWindowUtils.compareCanvases(s1, s2, {}) == 0) == expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!equal) {
|
if (!correct) {
|
||||||
s1Str = s1.toDataURL();
|
s1Str = s1.toDataURL();
|
||||||
s2Str = s2.toDataURL();
|
s2Str = s2.toDataURL();
|
||||||
|
|
||||||
if (!gWindowUtils) {
|
if (!gWindowUtils) {
|
||||||
equal = (s1Str == s2Str);
|
correct = ((s1Str == s2Str) == expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [equal, s1Str, s2Str];
|
return [correct, s1Str, s2Str];
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@
|
||||||
|
|
||||||
//Take snapshots
|
//Take snapshots
|
||||||
var manualSnapshot = snapshotWindow(gBrowser.contentWindow);
|
var manualSnapshot = snapshotWindow(gBrowser.contentWindow);
|
||||||
var res = compareSnapshots(findSnapshot, manualSnapshot);
|
var res = compareSnapshots(findSnapshot, manualSnapshot, true);
|
||||||
ok(res[0], "Matches found in iframe correctly highlighted");
|
ok(res[0], "Matches found in iframe correctly highlighted");
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче