Bug 1500733 - Remove the support for BufferSource in createImageBitmap, r=aosmond
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 23 Oct 2018 23:35:43 +0200
changeset 490924 dac317f3cd311d70772b55ee65c5ba3051e60fe3
parent 490923 cdc621a21acc1cd486abd0342a5b3fec89f594a5
child 490925 3c81d4cb6aea693144608f2f78eb4b893b2687f3
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersaosmond
bugs1500733
milestone65.0a1
Bug 1500733 - Remove the support for BufferSource in createImageBitmap, r=aosmond
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowInner.h
dom/canvas/ImageBitmap.cpp
dom/canvas/ImageBitmap.h
dom/canvas/ImageBitmapSource.h
dom/webidl/ImageBitmap.webidl
dom/webidl/WindowOrWorkerGlobalScope.webidl
dom/workers/WorkerScope.cpp
dom/workers/WorkerScope.h
testing/web-platform/meta/2dcontext/imagebitmap/createImageBitmap-invalid-args.html.ini
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -7711,58 +7711,28 @@ nsGlobalWindowInner::FireOnNewGlobalObje
 #error "Never include windows.h in this file!"
 #endif
 
 already_AddRefed<Promise>
 nsGlobalWindowInner::CreateImageBitmap(JSContext* aCx,
                                        const ImageBitmapSource& aImage,
                                        ErrorResult& aRv)
 {
-  if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
-    aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-    return nullptr;
-  }
-
   return ImageBitmap::Create(this, aImage, Nothing(), aRv);
 }
 
 already_AddRefed<Promise>
 nsGlobalWindowInner::CreateImageBitmap(JSContext* aCx,
                                        const ImageBitmapSource& aImage,
                                        int32_t aSx, int32_t aSy, int32_t aSw, int32_t aSh,
                                        ErrorResult& aRv)
 {
-  if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
-    aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-    return nullptr;
-  }
-
   return ImageBitmap::Create(this, aImage, Some(gfx::IntRect(aSx, aSy, aSw, aSh)), aRv);
 }
 
-already_AddRefed<mozilla::dom::Promise>
-nsGlobalWindowInner::CreateImageBitmap(JSContext* aCx,
-                                       const ImageBitmapSource& aImage,
-                                       int32_t aOffset, int32_t aLength,
-                                       ImageBitmapFormat aFormat,
-                                       const Sequence<ChannelPixelLayout>& aLayout,
-                                       ErrorResult& aRv)
-{
-  if (!StaticPrefs::canvas_imagebitmap_extensions_enabled()) {
-    aRv.Throw(NS_ERROR_TYPE_ERR);
-    return nullptr;
-  }
-  if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
-    return ImageBitmap::Create(this, aImage, aOffset, aLength, aFormat, aLayout,
-                               aRv);
-  }
-  aRv.Throw(NS_ERROR_TYPE_ERR);
-  return nullptr;
-}
-
 mozilla::dom::TabGroup*
 nsGlobalWindowInner::TabGroupInner()
 {
   // If we don't have a TabGroup yet, try to get it from the outer window and
   // cache it.
   if (!mTabGroup) {
     nsGlobalWindowOuter* outer = GetOuterWindowInternal();
     // This will never be called without either an outer window, or a cached tab group.
--- a/dom/base/nsGlobalWindowInner.h
+++ b/dom/base/nsGlobalWindowInner.h
@@ -919,25 +919,16 @@ public:
                     mozilla::ErrorResult& aRv);
 
   already_AddRefed<mozilla::dom::Promise>
   CreateImageBitmap(JSContext* aCx,
                     const mozilla::dom::ImageBitmapSource& aImage,
                     int32_t aSx, int32_t aSy, int32_t aSw, int32_t aSh,
                     mozilla::ErrorResult& aRv);
 
-  already_AddRefed<mozilla::dom::Promise>
-  CreateImageBitmap(JSContext* aCx,
-                    const mozilla::dom::ImageBitmapSource& aImage,
-                    int32_t aOffset, int32_t aLength,
-                    mozilla::dom::ImageBitmapFormat aFormat,
-                    const mozilla::dom::Sequence<mozilla::dom::ChannelPixelLayout>& aLayout,
-                    mozilla::ErrorResult& aRv);
-
-
   // ChromeWindow bits.  Do NOT call these unless your window is in
   // fact chrome.
   uint16_t WindowState();
   bool IsFullyOccluded();
   nsIBrowserDOMWindow* GetBrowserDOMWindow(mozilla::ErrorResult& aError);
   void SetBrowserDOMWindow(nsIBrowserDOMWindow* aBrowserWindow,
                            mozilla::ErrorResult& aError);
   void GetAttention(mozilla::ErrorResult& aError);
--- a/dom/canvas/ImageBitmap.cpp
+++ b/dom/canvas/ImageBitmap.cpp
@@ -1433,17 +1433,17 @@ ImageBitmap::Create(nsIGlobalObject* aGl
                "Creating ImageBitmap from CanvasRenderingContext2D off the main thread.");
     imageBitmap = CreateInternal(aGlobal, aSrc.GetAsCanvasRenderingContext2D(), aCropRect, aRv);
   } else if (aSrc.IsImageBitmap()) {
     imageBitmap = CreateInternal(aGlobal, aSrc.GetAsImageBitmap(), aCropRect, aRv);
   } else if (aSrc.IsBlob()) {
     AsyncCreateImageBitmapFromBlob(promise, aGlobal, aSrc.GetAsBlob(), aCropRect);
     return promise.forget();
   } else {
-    aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+    MOZ_CRASH("Unsupported type!");
     return nullptr;
   }
 
   if (!aRv.Failed()) {
     AsyncFulfillImageBitmapPromise(promise, imageBitmap);
   }
 
   return promise.forget();
@@ -1835,312 +1835,16 @@ ImageBitmap::MapDataInto(JSContext* aCx,
       return promise.forget();
     }
   }
 
   AsyncMapDataIntoBufferSource(aCx, promise, this, aBuffer, aOffset, aFormat);
   return promise.forget();
 }
 
-// ImageBitmapFactories extensions.
-static SurfaceFormat
-ImageFormatToSurfaceFromat(mozilla::dom::ImageBitmapFormat aFormat)
-{
-  switch(aFormat) {
-  case ImageBitmapFormat::RGBA32:
-    return SurfaceFormat::R8G8B8A8;
-  case ImageBitmapFormat::BGRA32:
-    return SurfaceFormat::B8G8R8A8;
-  case ImageBitmapFormat::RGB24:
-    return SurfaceFormat::R8G8B8;
-  case ImageBitmapFormat::BGR24:
-    return SurfaceFormat::B8G8R8;
-  case ImageBitmapFormat::GRAY8:
-    return SurfaceFormat::A8;
-  case ImageBitmapFormat::HSV:
-    return SurfaceFormat::HSV;
-  case ImageBitmapFormat::Lab:
-    return SurfaceFormat::Lab;
-  case ImageBitmapFormat::DEPTH:
-    return SurfaceFormat::Depth;
-  default:
-    return SurfaceFormat::UNKNOWN;
-  }
-}
-
-static already_AddRefed<layers::Image>
-CreateImageFromBufferSourceRawData(const uint8_t*aBufferData,
-                                   uint32_t aBufferLength,
-                                   mozilla::dom::ImageBitmapFormat aFormat,
-                                   const Sequence<ChannelPixelLayout>& aLayout)
-{
-  MOZ_ASSERT(aBufferData);
-  MOZ_ASSERT(aBufferLength > 0);
-
-  switch(aFormat) {
-  case ImageBitmapFormat::RGBA32:
-  case ImageBitmapFormat::BGRA32:
-  case ImageBitmapFormat::RGB24:
-  case ImageBitmapFormat::BGR24:
-  case ImageBitmapFormat::GRAY8:
-  case ImageBitmapFormat::HSV:
-  case ImageBitmapFormat::Lab:
-  case ImageBitmapFormat::DEPTH:
-  {
-    const nsTArray<ChannelPixelLayout>& channels = aLayout;
-    MOZ_ASSERT(channels.Length() != 0, "Empty Channels.");
-
-    const SurfaceFormat srcFormat = ImageFormatToSurfaceFromat(aFormat);
-    const uint32_t srcStride = channels[0].mStride;
-    const IntSize srcSize(channels[0].mWidth, channels[0].mHeight);
-
-    RefPtr<DataSourceSurface> dstDataSurface =
-      Factory::CreateDataSourceSurfaceWithStride(srcSize, srcFormat, srcStride);
-
-    if (NS_WARN_IF(!dstDataSurface)) {
-      return nullptr;
-    }
-
-    // Copy the raw data into the newly created DataSourceSurface.
-    DataSourceSurface::ScopedMap dstMap(dstDataSurface, DataSourceSurface::WRITE);
-    if (NS_WARN_IF(!dstMap.IsMapped())) {
-      return nullptr;
-    }
-
-    const uint8_t* srcBufferPtr = aBufferData;
-    uint8_t* dstBufferPtr = dstMap.GetData();
-
-    for (int i = 0; i < srcSize.height; ++i) {
-      memcpy(dstBufferPtr, srcBufferPtr, srcStride);
-      srcBufferPtr += srcStride;
-      dstBufferPtr += dstMap.GetStride();
-    }
-
-    // Create an Image from the BGRA SourceSurface.
-    RefPtr<SourceSurface> surface = dstDataSurface;
-    RefPtr<layers::Image> image = CreateImageFromSurface(surface);
-
-    if (NS_WARN_IF(!image)) {
-      return nullptr;
-    }
-
-    return image.forget();
-  }
-  case ImageBitmapFormat::YUV444P:
-  case ImageBitmapFormat::YUV422P:
-  case ImageBitmapFormat::YUV420P:
-  case ImageBitmapFormat::YUV420SP_NV12:
-  case ImageBitmapFormat::YUV420SP_NV21:
-  {
-    // Prepare the PlanarYCbCrData.
-    const ChannelPixelLayout& yLayout = aLayout[0];
-    const ChannelPixelLayout& uLayout = aFormat != ImageBitmapFormat::YUV420SP_NV21 ? aLayout[1] : aLayout[2];
-    const ChannelPixelLayout& vLayout = aFormat != ImageBitmapFormat::YUV420SP_NV21 ? aLayout[2] : aLayout[1];
-
-    layers::PlanarYCbCrData data;
-
-    // Luminance buffer
-    data.mYChannel = const_cast<uint8_t*>(aBufferData + yLayout.mOffset);
-    data.mYStride = yLayout.mStride;
-    data.mYSize = gfx::IntSize(yLayout.mWidth, yLayout.mHeight);
-    data.mYSkip = yLayout.mSkip;
-
-    // Chroma buffers
-    data.mCbChannel = const_cast<uint8_t*>(aBufferData + uLayout.mOffset);
-    data.mCrChannel = const_cast<uint8_t*>(aBufferData + vLayout.mOffset);
-    data.mCbCrStride = uLayout.mStride;
-    data.mCbCrSize = gfx::IntSize(uLayout.mWidth, uLayout.mHeight);
-    data.mCbSkip = uLayout.mSkip;
-    data.mCrSkip = vLayout.mSkip;
-
-    // Picture rectangle.
-    // We set the picture rectangle to exactly the size of the source image to
-    // keep the full original data.
-    data.mPicX = 0;
-    data.mPicY = 0;
-    data.mPicSize = data.mYSize;
-
-    // Create a layers::Image and set data.
-    if (aFormat == ImageBitmapFormat::YUV444P ||
-        aFormat == ImageBitmapFormat::YUV422P ||
-        aFormat == ImageBitmapFormat::YUV420P) {
-      RefPtr<layers::PlanarYCbCrImage> image =
-        new layers::RecyclingPlanarYCbCrImage(new layers::BufferRecycleBin());
-
-      if (NS_WARN_IF(!image)) {
-        return nullptr;
-      }
-
-      // Set Data.
-      if (NS_WARN_IF(!image->CopyData(data))) {
-        return nullptr;
-      }
-
-      return image.forget();
-    } else {
-      RefPtr<layers::NVImage>image = new layers::NVImage();
-
-      if (NS_WARN_IF(!image)) {
-        return nullptr;
-      }
-
-      // Set Data.
-      if (NS_WARN_IF(!image->SetData(data))) {
-        return nullptr;
-      }
-
-      return image.forget();
-    }
-  }
-  default:
-    return nullptr;
-  }
-}
-
-/*
- * This is a synchronous task.
- * This class is used to create a layers::CairoImage from raw data in the main
- * thread. While creating an ImageBitmap from an BufferSource, we need to create
- * a SouceSurface from the BufferSource raw data and then set the SourceSurface
- * into a layers::CairoImage. However, the layers::CairoImage asserts the
- * setting operation in the main thread, so if we are going to create an
- * ImageBitmap from an BufferSource off the main thread, we post an event to the
- * main thread to create a layers::CairoImage from an BufferSource raw data.
- *
- * TODO: Once the layers::CairoImage is constructible off the main thread, which
- *       means the SouceSurface could be released anywhere, we do not need this
- *       task anymore.
- */
-class CreateImageFromBufferSourceRawDataInMainThreadSyncTask final :
-  public WorkerMainThreadRunnable
-{
-public:
-  CreateImageFromBufferSourceRawDataInMainThreadSyncTask(const uint8_t* aBuffer,
-                                                         uint32_t aBufferLength,
-                                                         mozilla::dom::ImageBitmapFormat aFormat,
-                                                         const Sequence<ChannelPixelLayout>& aLayout,
-                                                         /*output*/ layers::Image** aImage)
-  : WorkerMainThreadRunnable(GetCurrentThreadWorkerPrivate(),
-                             NS_LITERAL_CSTRING("ImageBitmap-extensions :: Create Image from BufferSource Raw Data"))
-  , mImage(aImage)
-  , mBuffer(aBuffer)
-  , mBufferLength(aBufferLength)
-  , mFormat(aFormat)
-  , mLayout(aLayout)
-  {
-    MOZ_ASSERT(!(*aImage), "Don't pass an existing Image into CreateImageFromBufferSourceRawDataInMainThreadSyncTask.");
-  }
-
-  bool MainThreadRun() override
-  {
-    RefPtr<layers::Image> image =
-      CreateImageFromBufferSourceRawData(mBuffer, mBufferLength, mFormat, mLayout);
-
-    if (NS_WARN_IF(!image)) {
-      return true;
-    }
-
-    image.forget(mImage);
-
-    return true;
-  }
-
-private:
-  layers::Image** mImage;
-  const uint8_t* mBuffer;
-  uint32_t mBufferLength;
-  mozilla::dom::ImageBitmapFormat mFormat;
-  const Sequence<ChannelPixelLayout>& mLayout;
-};
-
-/*static*/ already_AddRefed<Promise>
-ImageBitmap::Create(nsIGlobalObject* aGlobal,
-                    const ImageBitmapSource& aBuffer,
-                    int32_t aOffset, int32_t aLength,
-                    mozilla::dom::ImageBitmapFormat aFormat,
-                    const Sequence<ChannelPixelLayout>& aLayout,
-                    ErrorResult& aRv)
-{
-  MOZ_ASSERT(aGlobal);
-
-  RefPtr<Promise> promise = Promise::Create(aGlobal, aRv);
-
-  if (NS_WARN_IF(aRv.Failed())) {
-    return nullptr;
-  }
-
-  uint8_t* bufferData = nullptr;
-  uint32_t bufferLength = 0;
-
-  if (aBuffer.IsArrayBuffer()) {
-    const ArrayBuffer& buffer = aBuffer.GetAsArrayBuffer();
-    buffer.ComputeLengthAndData();
-    bufferData = buffer.Data();
-    bufferLength = buffer.Length();
-  } else if (aBuffer.IsArrayBufferView()) {
-    const ArrayBufferView& bufferView = aBuffer.GetAsArrayBufferView();
-    bufferView.ComputeLengthAndData();
-    bufferData = bufferView.Data();
-    bufferLength = bufferView.Length();
-  } else {
-    aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-    return promise.forget();
-  }
-
-  MOZ_ASSERT(bufferData && bufferLength > 0, "Cannot read data from BufferSource.");
-
-  // Check the buffer.
-  if (((uint32_t)(aOffset + aLength) > bufferLength)) {
-    aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
-    return promise.forget();
-  }
-
-  // Create and Crop the raw data into a layers::Image
-  RefPtr<layers::Image> data;
-  if (NS_IsMainThread()) {
-    data = CreateImageFromBufferSourceRawData(bufferData + aOffset, bufferLength,
-                                              aFormat, aLayout);
-  } else {
-    RefPtr<CreateImageFromBufferSourceRawDataInMainThreadSyncTask> task =
-      new CreateImageFromBufferSourceRawDataInMainThreadSyncTask(bufferData + aOffset,
-                                                                 bufferLength,
-                                                                 aFormat,
-                                                                 aLayout,
-                                                                 getter_AddRefs(data));
-    task->Dispatch(Canceling, aRv);
-    if (aRv.Failed()) {
-      return promise.forget();
-    }
-  }
-
-  if (NS_WARN_IF(!data)) {
-    aRv.Throw(NS_ERROR_NOT_AVAILABLE);
-    return promise.forget();
-  }
-
-  // Create an ImageBimtap.
-  // Assume the data from an external buffer is not alpha-premultiplied.
-  RefPtr<ImageBitmap> imageBitmap = new ImageBitmap(aGlobal, data,
-                                                    gfxAlphaType::NonPremult);
-
-  imageBitmap->mAllocatedImageData = true;
-
-  // We don't need to call SetPictureRect() here because there is no cropping
-  // supported and the ImageBitmap's mPictureRect is the size of the source
-  // image in default
-
-  // We don't need to set mIsCroppingAreaOutSideOfSourceImage here because there
-  // is no cropping supported and the mIsCroppingAreaOutSideOfSourceImage is
-  // false in default.
-
-  AsyncFulfillImageBitmapPromise(promise, imageBitmap);
-
-  return promise.forget();
-}
-
 size_t
 ImageBitmap::GetAllocatedSize() const
 {
   if (!mAllocatedImageData) {
     return 0;
   }
 
   // Calculate how many bytes are used.
--- a/dom/canvas/ImageBitmap.h
+++ b/dom/canvas/ImageBitmap.h
@@ -36,17 +36,16 @@ namespace layers {
 class Image;
 }
 
 namespace dom {
 class OffscreenCanvas;
 
 class ArrayBufferViewOrArrayBuffer;
 class CanvasRenderingContext2D;
-struct ChannelPixelLayout;
 class CreateImageBitmapFromBlob;
 class CreateImageBitmapFromBlobTask;
 class CreateImageBitmapFromBlobWorkerTask;
 class File;
 class HTMLCanvasElement;
 class HTMLImageElement;
 class HTMLVideoElement;
 enum class ImageBitmapFormat : uint8_t;
@@ -130,24 +129,16 @@ public:
   CreateFromOffscreenCanvas(nsIGlobalObject* aGlobal,
                             OffscreenCanvas& aOffscreenCanvas,
                             ErrorResult& aRv);
 
   static already_AddRefed<Promise>
   Create(nsIGlobalObject* aGlobal, const ImageBitmapSource& aSrc,
          const Maybe<gfx::IntRect>& aCropRect, ErrorResult& aRv);
 
-  static already_AddRefed<Promise>
-  Create(nsIGlobalObject* aGlobal,
-         const ImageBitmapSource& aBuffer,
-         int32_t aOffset, int32_t aLength,
-         mozilla::dom::ImageBitmapFormat aFormat,
-         const Sequence<mozilla::dom::ChannelPixelLayout>& aLayout,
-         ErrorResult& aRv);
-
   static JSObject*
   ReadStructuredClone(JSContext* aCx,
                       JSStructuredCloneReader* aReader,
                       nsIGlobalObject* aParent,
                       const nsTArray<RefPtr<gfx::DataSourceSurface>>& aClonedSurfaces,
                       uint32_t aIndex);
 
   static bool
--- a/dom/canvas/ImageBitmapSource.h
+++ b/dom/canvas/ImageBitmapSource.h
@@ -6,16 +6,15 @@
 
 #ifndef mozilla_dom_ImageBitmapSource_h
 #define mozilla_dom_ImageBitmapSource_h
 
 namespace mozilla {
 namespace dom {
 
 // So we don't have to forward declare this elsewhere.
-class HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrCanvasRenderingContext2DOrImageBitmapOrArrayBufferViewOrArrayBuffer;
-typedef HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrCanvasRenderingContext2DOrImageBitmapOrArrayBufferViewOrArrayBuffer
-        ImageBitmapSource;
+class HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmapOrBlobOrCanvasRenderingContext2DOrImageData;
+typedef HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmapOrBlobOrCanvasRenderingContext2DOrImageData ImageBitmapSource;
 
 }
 }
 
 #endif
--- a/dom/webidl/ImageBitmap.webidl
+++ b/dom/webidl/ImageBitmap.webidl
@@ -5,35 +5,27 @@
  *
  * The origin of this IDL file is
  * https://html.spec.whatwg.org/multipage/webappapis.html#images
  *
  * The origin of the extended IDL file is
  * http://w3c.github.io/mediacapture-worker/#imagebitmap-extensions
  */
 
-// Extensions
-// Bug 1141979 - [FoxEye] Extend ImageBitmap with interfaces to access its
-// underlying image data
-//
-// Note:
-// Our overload resolution implementation doesn't deal with a union as the
-// distinguishing argument which means we cannot overload functions via union
-// types, a.k.a. we cannot overload createImageBitmap() via ImageBitmapSource
-// and BufferSource. Here, we work around this issue by adding the BufferSource
-// into ImageBitmapSource.
+// This is needed because we don't support SVG element as canvas image source.
+// See bug 1500768.
+typedef (HTMLImageElement or
+         HTMLCanvasElement or
+         HTMLVideoElement or
+         ImageBitmap) CanvasImageSourceExcludedSVG;
 
-typedef (HTMLImageElement or
-         HTMLVideoElement or
-         HTMLCanvasElement or
+typedef (CanvasImageSourceExcludedSVG or
          Blob or
-         ImageData or
-         CanvasRenderingContext2D or
-         ImageBitmap or
-         BufferSource) ImageBitmapSource;
+         CanvasRenderingContext2D or // This is out of spec.
+         ImageData) ImageBitmapSource;
 
 [Exposed=(Window,Worker)]
 interface ImageBitmap {
   [Constant]
   readonly attribute unsigned long width;
   [Constant]
   readonly attribute unsigned long height;
 };
--- a/dom/webidl/WindowOrWorkerGlobalScope.webidl
+++ b/dom/webidl/WindowOrWorkerGlobalScope.webidl
@@ -60,23 +60,8 @@ partial interface WindowOrWorkerGlobalSc
    readonly attribute IDBFactory? indexedDB;
 };
 
 // https://w3c.github.io/ServiceWorker/#self-caches
 partial interface WindowOrWorkerGlobalScope {
   [Throws, Func="mozilla::dom::DOMPrefs::dom_caches_enabled", SameObject]
   readonly attribute CacheStorage caches;
 };
-
-// Mozilla extensions
-partial interface WindowOrWorkerGlobalScope {
-  // Extensions to ImageBitmap bits.
-  // Bug 1141979 - [FoxEye] Extend ImageBitmap with interfaces to access its
-  // underlying image data
-  //
-  // Note:
-  // Overloaded functions cannot have different "extended attributes",
-  // so I cannot add preference on the extended version of createImageBitmap().
-  // To work around, I will then check the preference at run time and throw if
-  // the preference is set to be false.
-  [Throws]
-  Promise<ImageBitmap> createImageBitmap(ImageBitmapSource aImage, long aOffset, long aLength, ImageBitmapFormat aFormat, ImagePixelLayout aLayout);
-};
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -479,60 +479,28 @@ WorkerGlobalScope::GetIndexedDB(ErrorRes
   return indexedDB.forget();
 }
 
 already_AddRefed<Promise>
 WorkerGlobalScope::CreateImageBitmap(JSContext* aCx,
                                      const ImageBitmapSource& aImage,
                                      ErrorResult& aRv)
 {
-  if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
-    aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-    return nullptr;
-  }
-
   return ImageBitmap::Create(this, aImage, Nothing(), aRv);
 }
 
 already_AddRefed<Promise>
 WorkerGlobalScope::CreateImageBitmap(JSContext* aCx,
                                      const ImageBitmapSource& aImage,
                                      int32_t aSx, int32_t aSy, int32_t aSw, int32_t aSh,
                                      ErrorResult& aRv)
 {
-  if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
-    aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-    return nullptr;
-  }
-
   return ImageBitmap::Create(this, aImage, Some(gfx::IntRect(aSx, aSy, aSw, aSh)), aRv);
 }
 
-already_AddRefed<mozilla::dom::Promise>
-WorkerGlobalScope::CreateImageBitmap(JSContext* aCx,
-                                     const ImageBitmapSource& aImage,
-                                     int32_t aOffset, int32_t aLength,
-                                     ImageBitmapFormat aFormat,
-                                     const Sequence<ChannelPixelLayout>& aLayout,
-                                     ErrorResult& aRv)
-{
-  if (!StaticPrefs::canvas_imagebitmap_extensions_enabled()) {
-    aRv.Throw(NS_ERROR_TYPE_ERR);
-    return nullptr;
-  }
-
-  if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
-    return ImageBitmap::Create(this, aImage, aOffset, aLength, aFormat, aLayout,
-                               aRv);
-  } else {
-    aRv.Throw(NS_ERROR_TYPE_ERR);
-    return nullptr;
-  }
-}
-
 nsresult
 WorkerGlobalScope::Dispatch(TaskCategory aCategory,
                             already_AddRefed<nsIRunnable>&& aRunnable)
 {
   return EventTargetFor(aCategory)->Dispatch(std::move(aRunnable),
                                              NS_DISPATCH_NORMAL);
 }
 
--- a/dom/workers/WorkerScope.h
+++ b/dom/workers/WorkerScope.h
@@ -186,24 +186,16 @@ public:
                     const ImageBitmapSource& aImage, ErrorResult& aRv);
 
   already_AddRefed<Promise>
   CreateImageBitmap(JSContext* aCx,
                     const ImageBitmapSource& aImage,
                     int32_t aSx, int32_t aSy, int32_t aSw, int32_t aSh,
                     ErrorResult& aRv);
 
-  already_AddRefed<mozilla::dom::Promise>
-  CreateImageBitmap(JSContext* aCx,
-                    const ImageBitmapSource& aImage,
-                    int32_t aOffset, int32_t aLength,
-                    mozilla::dom::ImageBitmapFormat aFormat,
-                    const mozilla::dom::Sequence<mozilla::dom::ChannelPixelLayout>& aLayout,
-                    mozilla::ErrorResult& aRv);
-
   bool
   WindowInteractionAllowed() const
   {
     return mWindowInteractionsAllowed > 0;
   }
 
   void
   AllowWindowInteraction()
--- a/testing/web-platform/meta/2dcontext/imagebitmap/createImageBitmap-invalid-args.html.ini
+++ b/testing/web-platform/meta/2dcontext/imagebitmap/createImageBitmap-invalid-args.html.ini
@@ -27,14 +27,8 @@
     expected: FAIL
 
   [createImageBitmap with a vector SVGImageElement source and sh set to 0]
     expected: FAIL
 
   [createImageBitmap with CanvasRenderingContext2D image source.]
     expected: FAIL
 
-  [createImageBitmap with Uint8Array image source.]
-    expected: FAIL
-
-  [createImageBitmap with ArrayBuffer image source.]
-    expected: FAIL
-