зеркало из 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 s3 = snapshotWindow($("f3").contentWindow);
|
||||
|
||||
ok(!compareSnapshots(s2, s3)[0],
|
||||
ok(!compareSnapshots(s2, s3, true)[0],
|
||||
"Should look different due to different sizing");
|
||||
|
||||
function getDOM(id) {
|
||||
|
@ -101,7 +101,7 @@
|
|||
l4.detach();
|
||||
|
||||
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);
|
||||
|
||||
is(strs["f1"], "f1.pagehide f1.pageshow");
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
var imports = [ "SimpleTest", "is", "isnot", "ok", "snapshotWindow",
|
||||
"compareSnapshots", "onerror" ];
|
||||
var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror" ];
|
||||
for each (var import in imports) {
|
||||
window[import] = window.opener.wrappedJSObject[import];
|
||||
}
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
var imports = [ "SimpleTest", "is", "isnot", "ok", "snapshotWindow",
|
||||
"compareSnapshots", "onerror" ];
|
||||
var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror" ];
|
||||
for each (var import in imports) {
|
||||
window[import] = window.opener.wrappedJSObject[import];
|
||||
}
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
var RemoteCanvas = function(url, id) {
|
||||
this.url = url;
|
||||
this.id = id;
|
||||
this.snapshot = null;
|
||||
};
|
||||
|
||||
RemoteCanvas.CANVAS_WIDTH = 200;
|
||||
RemoteCanvas.CANVAS_HEIGHT = 100;
|
||||
|
||||
RemoteCanvas.prototype.getCanvas = function() {
|
||||
return document.getElementById(this.id + "-canvas");
|
||||
RemoteCanvas.prototype.compare = function(otherCanvas, expected) {
|
||||
return compareSnapshots(this.snapshot, otherCanvas.snapshot, expected)[0];
|
||||
}
|
||||
|
||||
RemoteCanvas.prototype.load = function(callback) {
|
||||
|
@ -19,37 +20,14 @@ RemoteCanvas.prototype.load = function(callback) {
|
|||
iframe.src = this.url;
|
||||
var me = this;
|
||||
iframe.addEventListener("load", function() {
|
||||
window.setTimeout(function() {
|
||||
me.remotePageLoaded(callback);
|
||||
}, 500);
|
||||
}, true);
|
||||
me.remotePageLoaded(callback);
|
||||
}, false);
|
||||
window.document.body.appendChild(iframe);
|
||||
};
|
||||
|
||||
RemoteCanvas.prototype.remotePageLoaded = function(callback) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
|
||||
var ldrFrame = document.getElementById(this.id + "-iframe");
|
||||
var remoteWindow = 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);
|
||||
|
||||
this.snapshot = snapshotWindow(ldrFrame.contentWindow);
|
||||
callback(this);
|
||||
};
|
||||
|
||||
|
@ -83,13 +61,11 @@ function do_test()
|
|||
canvases.push(canvas);
|
||||
|
||||
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 == "==") {
|
||||
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);
|
||||
} 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441782
|
|||
<head>
|
||||
<title>Test for Bug 441782</title>
|
||||
<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" />
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441782
|
|||
<head>
|
||||
<title>Test for Bug 441782</title>
|
||||
<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" />
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441782
|
|||
<head>
|
||||
<title>Test for Bug 441782</title>
|
||||
<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" />
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441782
|
|||
<head>
|
||||
<title>Test for Bug 441782</title>
|
||||
<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" />
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441782
|
|||
<head>
|
||||
<title>Test for Bug 441782</title>
|
||||
<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" />
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -33,7 +33,7 @@ addLoadEvent(function() {
|
|||
s2 = snapshotWindow(window);
|
||||
|
||||
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",
|
||||
"got " + str1 + " but expected " + str2);
|
||||
|
||||
|
@ -49,14 +49,14 @@ addLoadEvent(function() {
|
|||
|
||||
s3 = snapshotWindow(window);
|
||||
|
||||
[equal, str1, str2] = compareSnapshots(s1, s3);
|
||||
[equal, str1, str2] = compareSnapshots(s1, s3, true);
|
||||
ok(equal, "Zoom should have no effect",
|
||||
"got " + str1 + " but expected " + str2);
|
||||
|
||||
$("display").style.display = "none";
|
||||
|
||||
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");
|
||||
|
||||
SimpleTest.finish();
|
||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467672
|
|||
<head>
|
||||
<title>Test for Bug 467672</title>
|
||||
<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" />
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467672
|
|||
<head>
|
||||
<title>Test for Bug 467672</title>
|
||||
<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" />
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467672
|
|||
<head>
|
||||
<title>Test for Bug 467672</title>
|
||||
<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" />
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467672
|
|||
<head>
|
||||
<title>Test for Bug 467672</title>
|
||||
<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" />
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -5,7 +5,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467672
|
|||
<head>
|
||||
<title>Test for Bug 467672</title>
|
||||
<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" />
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -24,24 +24,26 @@ function snapshotWindow(win) {
|
|||
return el;
|
||||
}
|
||||
|
||||
// If the two snapshots aren't equal, returns their serializations as data URIs.
|
||||
function compareSnapshots(s1, s2) {
|
||||
// If the two snapshots don't compare as expected (true for equal, false for
|
||||
// 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');
|
||||
|
||||
var s1Str, s2Str;
|
||||
var equal = false;
|
||||
var correct = false;
|
||||
if (gWindowUtils) {
|
||||
equal = (gWindowUtils.compareCanvases(s1, s2, {}) == 0);
|
||||
correct = ((gWindowUtils.compareCanvases(s1, s2, {}) == 0) == expected);
|
||||
}
|
||||
|
||||
if (!equal) {
|
||||
if (!correct) {
|
||||
s1Str = s1.toDataURL();
|
||||
s2Str = s2.toDataURL();
|
||||
|
||||
if (!gWindowUtils) {
|
||||
equal = (s1Str == s2Str);
|
||||
correct = ((s1Str == s2Str) == expected);
|
||||
}
|
||||
}
|
||||
|
||||
return [equal, s1Str, s2Str];
|
||||
return [correct, s1Str, s2Str];
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
|
||||
//Take snapshots
|
||||
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");
|
||||
finish();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче