464556
464556
# HG changeset patch
464556
# User Ehsan Akhgari <ehsan@mozilla.com>
464556
# Date 1489719163 14400
464556
# Node ID 4af7cd795eeef3bce2dd40d5a6e92d21304eaea1
464556
# Parent  dac467924a46c4bbff97c948bf4a7143dada2b19
464556
Bug 1348168 - Disable Mozilla custom ImageBitmap extensions that didn't go through proper API review; r=bzbarsky a=dveditz
464556
464556
diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
464556
--- a/dom/base/nsGlobalWindow.cpp
464556
+++ b/dom/base/nsGlobalWindow.cpp
464556
@@ -14993,16 +14993,20 @@ nsGlobalWindow::CreateImageBitmap(const 
464556
 
464556
 already_AddRefed<mozilla::dom::Promise>
464556
 nsGlobalWindow::CreateImageBitmap(const ImageBitmapSource& aImage,
464556
                                   int32_t aOffset, int32_t aLength,
464556
                                   ImageBitmapFormat aFormat,
464556
                                   const Sequence<ChannelPixelLayout>& aLayout,
464556
                                   ErrorResult& aRv)
464556
 {
464556
+  if (!ImageBitmap::ExtensionsEnabled(nullptr, nullptr)) {
464556
+    aRv.Throw(NS_ERROR_TYPE_ERR);
464556
+    return nullptr;
464556
+  }
464556
   if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
464556
     return ImageBitmap::Create(this, aImage, aOffset, aLength, aFormat, aLayout,
464556
                                aRv);
464556
   } else {
464556
     aRv.Throw(NS_ERROR_TYPE_ERR);
464556
     return nullptr;
464556
   }
464556
 }
464556
diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp
464556
--- a/dom/workers/WorkerScope.cpp
464556
+++ b/dom/workers/WorkerScope.cpp
464556
@@ -471,16 +471,24 @@ WorkerGlobalScope::CreateImageBitmap(con
464556
 
464556
 already_AddRefed<mozilla::dom::Promise>
464556
 WorkerGlobalScope::CreateImageBitmap(const ImageBitmapSource& aImage,
464556
                                      int32_t aOffset, int32_t aLength,
464556
                                      ImageBitmapFormat aFormat,
464556
                                      const Sequence<ChannelPixelLayout>& aLayout,
464556
                                      ErrorResult& aRv)
464556
 {
464556
+  JSContext* cx = GetCurrentThreadJSContext();
464556
+  MOZ_ASSERT(cx);
464556
+
464556
+  if (!ImageBitmap::ExtensionsEnabled(cx, nullptr)) {
464556
+    aRv.Throw(NS_ERROR_TYPE_ERR);
464556
+    return nullptr;
464556
+  }
464556
+
464556
   if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
464556
     return ImageBitmap::Create(this, aImage, aOffset, aLength, aFormat, aLayout,
464556
                                aRv);
464556
   } else {
464556
     aRv.Throw(NS_ERROR_TYPE_ERR);
464556
     return nullptr;
464556
   }
464556
 }
464556
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
464556
--- a/modules/libpref/init/all.js
464556
+++ b/modules/libpref/init/all.js
464556
@@ -831,22 +831,18 @@ pref("ui.scrollToClick", 0);
464556
 pref("canvas.focusring.enabled", true);
464556
 pref("canvas.customfocusring.enabled", false);
464556
 pref("canvas.hitregions.enabled", false);
464556
 pref("canvas.filters.enabled", true);
464556
 // Add support for canvas path objects
464556
 pref("canvas.path.enabled", true);
464556
 pref("canvas.capturestream.enabled", true);
464556
 
464556
-// Disable the ImageBitmap-extensions in the release build.
464556
-#ifdef RELEASE_OR_BETA
464556
+// Disable the ImageBitmap-extensions for now.
464556
 pref("canvas.imagebitmap_extensions.enabled", false);
464556
-#else
464556
-pref("canvas.imagebitmap_extensions.enabled", true);
464556
-#endif
464556
 
464556
 // We want the ability to forcibly disable platform a11y, because
464556
 // some non-a11y-related components attempt to bring it up.  See bug
464556
 // 538530 for details about Windows; we have a pref here that allows it
464556
 // to be disabled for performance and testing resons.
464556
 // See bug 761589 for the crossplatform aspect.
464556
 //
464556
 // This pref is checked only once, and the browser needs a restart to
464556