зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1588980 - Part 1: Hide HTMLCanvasElement.mozGetAsFile behind a preference; r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D60283 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d02527e65d
Коммит
6ba1137eeb
|
@ -193,6 +193,7 @@ tags = imagebitmap
|
||||||
[test_ImageData_ctor.html]
|
[test_ImageData_ctor.html]
|
||||||
[test_isPointInStroke.html]
|
[test_isPointInStroke.html]
|
||||||
[test_mozGetAsFile.html]
|
[test_mozGetAsFile.html]
|
||||||
|
prefs = canvas.mozgetasfile.enabled=true
|
||||||
[test_strokeText_throw.html]
|
[test_strokeText_throw.html]
|
||||||
[test_toBlob.html]
|
[test_toBlob.html]
|
||||||
[test_toBlob_zero_dimension.html]
|
[test_toBlob_zero_dimension.html]
|
||||||
|
|
|
@ -14,7 +14,7 @@ function BlobListener(type, canvas, callback, file)
|
||||||
reader.onload =
|
reader.onload =
|
||||||
function(e) {
|
function(e) {
|
||||||
is(e.target.result, canvas.toDataURL(type),
|
is(e.target.result, canvas.toDataURL(type),
|
||||||
"<canvas>.mozGetAsFile().getAsDataURL() should equal <canvas>.toDataURL()");
|
"<canvas>.toBlob() should equal <canvas>.toDataURL()");
|
||||||
callback(canvas);
|
callback(canvas);
|
||||||
};
|
};
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
|
|
|
@ -135,7 +135,11 @@ function testBlob(file, contents, testName) {
|
||||||
function testSlice(file, size, type, contents, fileType, range) {
|
function testSlice(file, size, type, contents, fileType, range) {
|
||||||
is(file.type, type, fileType + " file is correct type");
|
is(file.type, type, fileType + " file is correct type");
|
||||||
is(file.size, size, fileType + " file is correct size");
|
is(file.size, size, fileType + " file is correct size");
|
||||||
ok(file instanceof File, fileType + " file is a File");
|
if (fileType == "fileFile") {
|
||||||
|
ok(file instanceof File, fileType + " file is a File");
|
||||||
|
} else if (fileType == "memFile") {
|
||||||
|
ok(!(file instanceof File), fileType + " file is not a File");
|
||||||
|
}
|
||||||
ok(file instanceof Blob, fileType + " file is also a Blob");
|
ok(file instanceof Blob, fileType + " file is also a Blob");
|
||||||
|
|
||||||
let slice = file.slice(0, size);
|
let slice = file.slice(0, size);
|
||||||
|
@ -377,3 +381,15 @@ function createFile(data, name) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toBlobPromise(canvas) {
|
||||||
|
function BlobListener(callback, file) {
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.onload = () => callback(file);
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise(resolve => {
|
||||||
|
canvas.toBlob(BlobListener.bind(undefined, resolve));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -21,7 +21,12 @@ SimpleTest.requestLongerTimeout(4);
|
||||||
createCanvasURL()
|
createCanvasURL()
|
||||||
.then(data => {
|
.then(data => {
|
||||||
let cx = $("canvas").getContext('2d');
|
let cx = $("canvas").getContext('2d');
|
||||||
let memFile = cx.canvas.mozGetAsFile("image/png");
|
return Promise.all([toBlobPromise(cx.canvas),
|
||||||
|
Promise.resolve(data)]);
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(args => {
|
||||||
|
let [memFile, data] = args;
|
||||||
return testSlice(memFile, data.length, "image/png", data, "memFile", RANGE_1);
|
return testSlice(memFile, data.length, "image/png", data, "memFile", RANGE_1);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,12 @@ SimpleTest.requestLongerTimeout(4);
|
||||||
createCanvasURL()
|
createCanvasURL()
|
||||||
.then(data => {
|
.then(data => {
|
||||||
let cx = $("canvas").getContext('2d');
|
let cx = $("canvas").getContext('2d');
|
||||||
let memFile = cx.canvas.mozGetAsFile("image/png");
|
return Promise.all([toBlobPromise(cx.canvas),
|
||||||
|
Promise.resolve(data)]);
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(args => {
|
||||||
|
let [memFile, data] = args;
|
||||||
return testSlice(memFile, data.length, "image/png", data, "memFile", RANGE_2);
|
return testSlice(memFile, data.length, "image/png", data, "memFile", RANGE_2);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ interface HTMLCanvasElement : HTMLElement {
|
||||||
partial interface HTMLCanvasElement {
|
partial interface HTMLCanvasElement {
|
||||||
[Pure, SetterThrows]
|
[Pure, SetterThrows]
|
||||||
attribute boolean mozOpaque;
|
attribute boolean mozOpaque;
|
||||||
[Throws, NeedsSubjectPrincipal]
|
[Throws, NeedsSubjectPrincipal, Pref="canvas.mozgetasfile.enabled"]
|
||||||
File mozGetAsFile(DOMString name, optional DOMString? type = null);
|
File mozGetAsFile(DOMString name, optional DOMString? type = null);
|
||||||
// A Mozilla-only extension to get a canvas context backed by double-buffered
|
// A Mozilla-only extension to get a canvas context backed by double-buffered
|
||||||
// shared memory. Only privileged callers can call this.
|
// shared memory. Only privileged callers can call this.
|
||||||
|
|
|
@ -9,7 +9,7 @@ load 570451.png
|
||||||
# Bug 1390704 - Skip on debug because it triggers a quadratic behavior that makes it take
|
# Bug 1390704 - Skip on debug because it triggers a quadratic behavior that makes it take
|
||||||
# so much time that it can trip on the reftest timeout of 5 minutes.
|
# so much time that it can trip on the reftest timeout of 5 minutes.
|
||||||
skip-if(Android||isDebugBuild) load 694165-1.xhtml
|
skip-if(Android||isDebugBuild) load 694165-1.xhtml
|
||||||
load 681190.html
|
pref(canvas.mozgetasfile.enabled,true) load 681190.html
|
||||||
load 732319-1.html
|
load 732319-1.html
|
||||||
load 844403-1.html
|
load 844403-1.html
|
||||||
load 856616.gif
|
load 856616.gif
|
||||||
|
|
|
@ -1063,6 +1063,12 @@
|
||||||
value: false
|
value: false
|
||||||
mirror: always
|
mirror: always
|
||||||
|
|
||||||
|
# Provide ability to turn on support for canvas mozGetAsFile API.
|
||||||
|
- name: canvas.mozgetasfile.enabled
|
||||||
|
type: bool
|
||||||
|
value: false
|
||||||
|
mirror: always
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Prefs starting with "channelclassifier."
|
# Prefs starting with "channelclassifier."
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
Загрузка…
Ссылка в новой задаче