Bug 1500736 - CreateImageBitmap should throw InvalidStateError when the allocation fails, r=aosmond
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 23 Oct 2018 23:35:43 +0200
changeset 490920 083f0be93a9f9da00b886cba36ca1e48fc168f5b
parent 490919 969fc88ef9a4aa881650668a1ddc16318802ce5c
child 490921 b273730d6149f687c46ed375ccc47674a3ef5afd
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersaosmond
bugs1500736
milestone65.0a1
Bug 1500736 - CreateImageBitmap should throw InvalidStateError when the allocation fails, 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
@@ -477,17 +477,17 @@ GetSurfaceFromElement(nsIGlobalObject* a
   if (!CheckSecurityForHTMLElements(res)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return nullptr;
   }
 
   RefPtr<SourceSurface> surface = res.GetSourceSurface();
 
   if (NS_WARN_IF(!surface)) {
-    aRv.Throw(NS_ERROR_NOT_AVAILABLE);
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
   return surface.forget();
 }
 
 /*
  * The specification doesn't allow to create an ImegeBitmap from a vector image.
--- a/testing/web-platform/meta/2dcontext/imagebitmap/createImageBitmap-invalid-args.html.ini
+++ b/testing/web-platform/meta/2dcontext/imagebitmap/createImageBitmap-invalid-args.html.ini
@@ -1,51 +1,30 @@
 [createImageBitmap-invalid-args.html]
-  [createImageBitmap with an oversized canvas source rejects with a RangeError.]
-    expected: FAIL
-
-  [createImageBitmap with an invalid OffscreenCanvas source rejects with a RangeError.]
-    expected: FAIL
-
-  [createImageBitmap with a broken image source rejects with an InvalidStateError.]
-    expected: FAIL
-
-  [createImageBitmap with an available but undecodable image source rejects with an InvalidStateError.]
-    expected: FAIL
-
   [createImageBitmap with an HTMLCanvasElement source and oversized (unallocatable) crop region]
     expected: FAIL
 
   [createImageBitmap with an HTMLVideoElement source and oversized (unallocatable) crop region]
     expected: FAIL
 
-  [createImageBitmap with an HTMLImageElement source and sw set to 0]
-    expected: FAIL
-
-  [createImageBitmap with an HTMLImageElement source and oversized (unallocatable) crop region]
-    expected: FAIL
-
   [createImageBitmap with an OffscreenCanvas source and sw set to 0]
     expected: FAIL
 
   [createImageBitmap with an OffscreenCanvas source and sh set to 0]
     expected: FAIL
 
   [createImageBitmap with an OffscreenCanvas source and oversized (unallocatable) crop region]
     expected: FAIL
 
   [createImageBitmap with an ImageData source and oversized (unallocatable) crop region]
     expected: FAIL
 
   [createImageBitmap with an ImageBitmap source and oversized (unallocatable) crop region]
     expected: FAIL
 
-  [createImageBitmap with an oversized canvas source.]
-    expected: FAIL
-
   [createImageBitmap with an invalid OffscreenCanvas source.]
     expected: FAIL
 
   [createImageBitmap with a broken image source.]
     expected: FAIL
 
   [createImageBitmap with an available but undecodable image source.]
     expected: FAIL