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:
aardgoose 2020-07-06 17:21:37 +00:00
parent 13a3b3527f
commit 07988f4e3a
4 changed files with 8 additions and 8 deletions

View File

@ -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;
}

View File

@ -141,6 +141,7 @@ class ImageBitmap final : public nsISupports, public nsWrapperCache {
void OnShutdown();
bool IsWriteOnly() const { return mWriteOnly; }
bool IsClosed() const { return !mData; };
protected:
/*

View File

@ -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();
});
}

View File

@ -1,4 +0,0 @@
[createImageBitmap-drawImage-closed.html]
[attempt to draw a closed ImageBitmap to a 2d canvas throws INVALID_STATE_ERR]
expected: FAIL