mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1266808 - throw exception when canvas.drawImage passed closed ImageBitmap r=baku
Fixed breakages with clipped areas disjoint to image Fixed text case that didn't expect exception Fixed coding style Removed expectation of web platform failure test Differential Revision: https://phabricator.services.mozilla.com/D31048
This commit is contained in:
parent
13a3b3527f
commit
07988f4e3a
@ -4422,6 +4422,9 @@ void CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
|
||||
srcSurf = imageBitmap.PrepareForDrawTarget(mTarget);
|
||||
|
||||
if (!srcSurf) {
|
||||
if (imageBitmap.IsClosed()) {
|
||||
aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -141,6 +141,7 @@ class ImageBitmap final : public nsISupports, public nsWrapperCache {
|
||||
void OnShutdown();
|
||||
|
||||
bool IsWriteOnly() const { return mWriteOnly; }
|
||||
bool IsClosed() const { return !mData; };
|
||||
|
||||
protected:
|
||||
/*
|
||||
|
@ -56,10 +56,10 @@ function runTest() {
|
||||
var canvas2 = createCanvas();
|
||||
var ctx2 = canvas2.getContext("2d");
|
||||
var beforeDrawImageDataURL = canvas2.toDataURL();
|
||||
ctx2.drawImage(bmp, 0, 0);
|
||||
var afterDrawImageDataURL = canvas2.toDataURL();
|
||||
ok(beforeDrawImageDataURL == afterDrawImageDataURL,
|
||||
"Drawing operations with a closed ImageBitmap should do nothing.");
|
||||
var _thrown = undefined; try {
|
||||
ctx2.drawImage(bmp, 0, 0);
|
||||
} catch (e) { _thrown = e };
|
||||
ok(_thrown && _thrown.name == "InvalidStateError" && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw InvalidStateError");
|
||||
runTestOnWorker();
|
||||
});
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
[createImageBitmap-drawImage-closed.html]
|
||||
[attempt to draw a closed ImageBitmap to a 2d canvas throws INVALID_STATE_ERR]
|
||||
expected: FAIL
|
||||
|
Loading…
Reference in New Issue
Block a user