Bug 1500786 - createImageBitmap should throw InvalidStateError with already closed imageBitmap as input, r=aosmond
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 23 Oct 2018 23:35:43 +0200
changeset 490922 dcaf26b9678bf7183892c56fe3dfcb52f7c393d9
parent 490921 b273730d6149f687c46ed375ccc47674a3ef5afd
child 490923 cdc621a21acc1cd486abd0342a5b3fec89f594a5
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersaosmond
bugs1500786
milestone65.0a1
Bug 1500786 - createImageBitmap should throw InvalidStateError with already closed imageBitmap as input, r=aosmond
dom/canvas/ImageBitmap.cpp
testing/web-platform/meta/2dcontext/imagebitmap/createImageBitmap-invalid-args.html.ini
--- a/dom/canvas/ImageBitmap.cpp
+++ b/dom/canvas/ImageBitmap.cpp
@@ -1134,17 +1134,17 @@ ImageBitmap::CreateInternal(nsIGlobalObj
   return ret.forget();
 }
 
 /* static */ already_AddRefed<ImageBitmap>
 ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, ImageBitmap& aImageBitmap,
                             const Maybe<IntRect>& aCropRect, ErrorResult& aRv)
 {
   if (!aImageBitmap.mData) {
-    aRv.Throw(NS_ERROR_NOT_AVAILABLE);
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
   RefPtr<layers::Image> data = aImageBitmap.mData;
   RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data, aImageBitmap.mAlphaType);
 
   // Set the picture rectangle.
   if (ret && aCropRect.isSome()) {
--- a/testing/web-platform/meta/2dcontext/imagebitmap/createImageBitmap-invalid-args.html.ini
+++ b/testing/web-platform/meta/2dcontext/imagebitmap/createImageBitmap-invalid-args.html.ini
@@ -12,19 +12,16 @@
     expected: FAIL
 
   [createImageBitmap with a broken image source.]
     expected: FAIL
 
   [createImageBitmap with an available but undecodable image source.]
     expected: FAIL
 
-  [createImageBitmap with a closed ImageBitmap.]
-    expected: FAIL
-
   [createImageBitmap with a bitmap SVGImageElement source and sw set to 0]
     expected: FAIL
 
   [createImageBitmap with a bitmap SVGImageElement source and sh set to 0]
     expected: FAIL
 
   [createImageBitmap with a vector SVGImageElement source and sw set to 0]
     expected: FAIL