mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 08:45:46 +00:00
Backed out 4 changesets (bug 1570147) for causing failures in test_drawSnapshot.html
Backed out changeset b5d442a2f457 (bug 1570147) Backed out changeset 7a24b9027519 (bug 1570147) Backed out changeset 4d528be8bae4 (bug 1570147) Backed out changeset 4b4feec0a4e2 (bug 1570147) --HG-- extra : rebase_source : 853ca7b91ba6973f0ca02641a58773ca2b42d113
This commit is contained in:
parent
81a8266309
commit
ec00d5890e
@ -34,16 +34,12 @@
|
||||
SimpleTest.waitForFocus(runTests, sourceWindow);
|
||||
}
|
||||
|
||||
async function runTests() {
|
||||
function runTests() {
|
||||
var cxInterfaceWrap = SpecialPowers.wrap(CanvasRenderingContext2D);
|
||||
|
||||
let snapshot = function(context, x, y, width, height, bg) {
|
||||
var flags = cxInterfaceWrap.DRAWWINDOW_USE_WIDGET_LAYERS |
|
||||
cxInterfaceWrap.DRAWWINDOW_DRAW_CARET |
|
||||
cxInterfaceWrap.DRAWWINDOW_DRAW_VIEW;
|
||||
context.drawWindow(sourceWindow, x, y, width, height, bg, flags);
|
||||
}
|
||||
await runDrawWindowTests(snapshot, true);
|
||||
var flags = cxInterfaceWrap.DRAWWINDOW_USE_WIDGET_LAYERS |
|
||||
cxInterfaceWrap.DRAWWINDOW_DRAW_CARET |
|
||||
cxInterfaceWrap.DRAWWINDOW_DRAW_VIEW;
|
||||
runDrawWindowTests(sourceWindow, flags, true);
|
||||
|
||||
sourceWindow.close();
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
const CANVAS_WIDTH = 200;
|
||||
const CANVAS_HEIGHT = 100;
|
||||
|
||||
async function runDrawWindowTests(snapshotCallback, transparentBackground) {
|
||||
function runDrawWindowTests(win, drawWindowFlags, transparentBackground) {
|
||||
function make_canvas() {
|
||||
var canvas = document.createElement("canvas");
|
||||
canvas.setAttribute("height", CANVAS_HEIGHT);
|
||||
@ -37,13 +37,14 @@ async function runDrawWindowTests(snapshotCallback, transparentBackground) {
|
||||
// Basic tests of drawing the whole document on a background
|
||||
|
||||
clear("white");
|
||||
await snapshotCallback(
|
||||
testWrapCx,
|
||||
testWrapCx.drawWindow(
|
||||
win,
|
||||
0,
|
||||
0,
|
||||
CANVAS_WIDTH,
|
||||
CANVAS_HEIGHT,
|
||||
"rgb(255, 255, 255)"
|
||||
"rgb(255, 255, 255)",
|
||||
drawWindowFlags
|
||||
);
|
||||
refCx.fillStyle = "fuchsia";
|
||||
refCx.fillRect(10, 10, 20, 20);
|
||||
@ -61,13 +62,14 @@ async function runDrawWindowTests(snapshotCallback, transparentBackground) {
|
||||
);
|
||||
|
||||
clearTest("white");
|
||||
await snapshotCallback(
|
||||
testWrapCx,
|
||||
testWrapCx.drawWindow(
|
||||
win,
|
||||
0,
|
||||
0,
|
||||
CANVAS_WIDTH,
|
||||
CANVAS_HEIGHT,
|
||||
"rgb(255, 255, 0)"
|
||||
"rgb(255, 255, 0)",
|
||||
drawWindowFlags
|
||||
);
|
||||
assertSnapshots(
|
||||
testCanvas,
|
||||
@ -100,7 +102,7 @@ async function runDrawWindowTests(snapshotCallback, transparentBackground) {
|
||||
clear("white");
|
||||
|
||||
testCx.translate(17, 31);
|
||||
await snapshotCallback(testWrapCx, 40, 0, 40, 40, "white");
|
||||
testWrapCx.drawWindow(win, 40, 0, 40, 40, "white", drawWindowFlags);
|
||||
|
||||
refCx.fillStyle = "aqua";
|
||||
refCx.fillRect(17 + 10, 31 + 10, 20, 20);
|
||||
@ -117,7 +119,7 @@ async function runDrawWindowTests(snapshotCallback, transparentBackground) {
|
||||
clear("blue");
|
||||
|
||||
testCx.translate(17, 31);
|
||||
await snapshotCallback(testWrapCx, 40, 0, 35, 45, "green");
|
||||
testWrapCx.drawWindow(win, 40, 0, 35, 45, "green", drawWindowFlags);
|
||||
|
||||
if (transparentBackground) {
|
||||
refCx.fillStyle = "green";
|
||||
@ -141,7 +143,7 @@ async function runDrawWindowTests(snapshotCallback, transparentBackground) {
|
||||
clear("blue");
|
||||
|
||||
testCx.translate(17, 31);
|
||||
await snapshotCallback(testWrapCx, 40, 0, 35, 45, "transparent");
|
||||
testWrapCx.drawWindow(win, 40, 0, 35, 45, "transparent", drawWindowFlags);
|
||||
|
||||
if (!transparentBackground) {
|
||||
refCx.fillStyle = "white";
|
||||
@ -164,12 +166,12 @@ async function runDrawWindowTests(snapshotCallback, transparentBackground) {
|
||||
|
||||
testCx.translate(9, 3);
|
||||
// 5, 8 is 5, 2 from the corner of the fuchsia square
|
||||
await snapshotCallback(testWrapCx, 5, 8, 30, 25, "maroon");
|
||||
testWrapCx.drawWindow(win, 5, 8, 30, 25, "maroon", drawWindowFlags);
|
||||
// 35, 0 is 15, 10 from the corner of the aqua square
|
||||
await snapshotCallback(testWrapCx, 35, 0, 50, 40, "transparent");
|
||||
testWrapCx.drawWindow(win, 35, 0, 50, 40, "transparent", drawWindowFlags);
|
||||
testCx.translate(15, 0);
|
||||
// 85, 5 is 5, 5 from the corner of the yellow square
|
||||
await snapshotCallback(testWrapCx, 85, 5, 30, 25, "transparent");
|
||||
testWrapCx.drawWindow(win, 85, 5, 30, 25, "transparent", drawWindowFlags);
|
||||
|
||||
if (transparentBackground) {
|
||||
refCx.fillStyle = "maroon";
|
||||
|
@ -226,8 +226,6 @@ support-files = captureStream_common.js
|
||||
[test_drawImage_edge_cases.html]
|
||||
[test_drawWindow.html]
|
||||
support-files = file_drawWindow_source.html file_drawWindow_common.js
|
||||
[test_drawSnapshot.html]
|
||||
support-files = file_drawWindow_source.html file_drawWindow_common.js
|
||||
[test_imagebitmap.html]
|
||||
skip-if = android_version == '19' # bug 1336581
|
||||
tags = imagebitmap
|
||||
|
@ -1,38 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for drawSnapshot</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||
<script type="application/javascript" src="file_drawWindow_common.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
window.addEventListener("load", runTests);
|
||||
|
||||
async function runTests(event) {
|
||||
let snapshot = async function(context, x, y, width, height, bg) {
|
||||
let elem = document.getElementById("source");
|
||||
|
||||
var rect = new window.DOMRect(x, y, width, height);
|
||||
|
||||
let image = await SpecialPowers.snapshotContext(elem, rect, bg);
|
||||
context.drawImage(image, 0, 0);
|
||||
}
|
||||
|
||||
// Run the tests with the source document in an <iframe> within this
|
||||
// page, which we expect to have transparency.
|
||||
await runDrawWindowTests(snapshot, true);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
|
||||
<iframe id="source" src="file_drawWindow_source.html" width="200" height="100"></iframe>
|
||||
</body>
|
||||
</html>
|
@ -23,25 +23,23 @@
|
||||
"width=200,height=100");
|
||||
sourceWindow.addEventListener("load", runTests);
|
||||
}
|
||||
|
||||
async function runTests(event) {
|
||||
|
||||
function runTests(event) {
|
||||
if (event.target != sourceWindow.document) {
|
||||
return;
|
||||
}
|
||||
|
||||
let win = document.getElementById("source").contentWindow;
|
||||
let snapshot = function(context, x, y, width, height, bg) {
|
||||
context.drawWindow(win, x, y, width, height, bg, 0);
|
||||
}
|
||||
|
||||
// Run the tests with the source document in an <iframe> within this
|
||||
// page, which we expect to have transparency.
|
||||
await runDrawWindowTests(snapshot, true);
|
||||
runDrawWindowTests(document.getElementById("source").contentWindow,
|
||||
0, true);
|
||||
|
||||
// Run the tests on the same source document, but in a window opened
|
||||
// by window.open. We do not expect this to have transparency.
|
||||
win = sourceWindow;
|
||||
await runDrawWindowTests(snapshot, false);
|
||||
// by window.open. We do not expect this to have transparency...
|
||||
// except on B2G. (This is *probably* a bug in B2G.)
|
||||
var isB2G = /Mobile|Tablet/.test(navigator.userAgent) &&
|
||||
!navigator.userAgent.includes("Android");
|
||||
runDrawWindowTests(sourceWindow, 0, isB2G);
|
||||
|
||||
sourceWindow.close();
|
||||
|
||||
|
@ -1363,17 +1363,6 @@ class SpecialPowersAPI extends JSWindowActorChild {
|
||||
return obj;
|
||||
}
|
||||
|
||||
_browsingContextForTarget(target) {
|
||||
if (BrowsingContext.isInstance(target)) {
|
||||
return target;
|
||||
}
|
||||
if (Element.isInstance(target)) {
|
||||
return target.browsingContext;
|
||||
}
|
||||
|
||||
return BrowsingContext.getFromWindow(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a task in the context of the given frame, and returns a
|
||||
* promise which resolves to the return value of that task.
|
||||
@ -1412,7 +1401,14 @@ class SpecialPowersAPI extends JSWindowActorChild {
|
||||
* change in the future.
|
||||
*/
|
||||
spawn(target, args, task) {
|
||||
let browsingContext = this._browsingContextForTarget(target);
|
||||
let browsingContext;
|
||||
if (BrowsingContext.isInstance(target)) {
|
||||
browsingContext = target;
|
||||
} else if (Element.isInstance(target)) {
|
||||
browsingContext = target.browsingContext;
|
||||
} else {
|
||||
browsingContext = BrowsingContext.getFromWindow(target);
|
||||
}
|
||||
|
||||
return this.sendQuery("Spawn", {
|
||||
browsingContext,
|
||||
@ -1422,18 +1418,6 @@ class SpecialPowersAPI extends JSWindowActorChild {
|
||||
});
|
||||
}
|
||||
|
||||
snapshotContext(target, rect, background) {
|
||||
let browsingContext = this._browsingContextForTarget(target);
|
||||
|
||||
return this.sendQuery("Snapshot", {
|
||||
browsingContext,
|
||||
rect,
|
||||
background,
|
||||
}).then(imageData => {
|
||||
return this.contentWindow.createImageBitmap(imageData);
|
||||
});
|
||||
}
|
||||
|
||||
_spawnTask(task, args, caller, taskId) {
|
||||
let sb = new SpecialPowersSandbox(null, data => {
|
||||
this.sendAsyncMessage("ProxiedAssert", { taskId, data });
|
||||
|
@ -17,7 +17,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
PerTestCoverageUtils: "resource://testing-common/PerTestCoverageUtils.jsm",
|
||||
ServiceWorkerCleanUp: "resource://gre/modules/ServiceWorkerCleanUp.jsm",
|
||||
SpecialPowersSandbox: "resource://specialpowers/SpecialPowersSandbox.jsm",
|
||||
HiddenFrame: "resource://gre/modules/HiddenFrame.jsm",
|
||||
});
|
||||
|
||||
class SpecialPowersError extends Error {
|
||||
@ -860,28 +859,6 @@ class SpecialPowersAPIParent extends JSWindowActorParent {
|
||||
});
|
||||
}
|
||||
|
||||
case "Snapshot": {
|
||||
let { browsingContext, rect, background } = aMessage.data;
|
||||
|
||||
return browsingContext.currentWindowGlobal
|
||||
.drawSnapshot(rect, 1.0, background)
|
||||
.then(async image => {
|
||||
let hiddenFrame = new HiddenFrame();
|
||||
let win = await hiddenFrame.get();
|
||||
|
||||
let canvas = win.document.createElement("canvas");
|
||||
canvas.width = image.width;
|
||||
canvas.height = image.height;
|
||||
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(image, 0, 0);
|
||||
|
||||
let data = ctx.getImageData(0, 0, image.width, image.height);
|
||||
hiddenFrame.destroy();
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
case "ProxiedAssert": {
|
||||
let { taskId, data } = aMessage.data;
|
||||
let actor = this._taskActors.get(taskId);
|
||||
|
Loading…
Reference in New Issue
Block a user