Bug 920840 - Crash when JS-implemented WebIDL's init method returns a value other than undefined. r=bz
authorAndrew McCreight <amccreight@mozilla.com>
Thu, 26 Sep 2013 16:46:42 -0700
changeset 149452 133d0dee12eefccbccf8a4cbe1ed47253182cf55
parent 149451 d26e3ed73e410964cabc2c4711ca098b767800b9
child 149453 6682ed134766597270c1a33fb563c8970ed4499c
push id25389
push userryanvm@gmail.com
push dateTue, 01 Oct 2013 20:35:30 +0000
treeherdermozilla-central@4364824a4cab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs920840
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 920840 - Crash when JS-implemented WebIDL's init method returns a value other than undefined. r=bz
dom/bindings/BindingUtils.cpp
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -2035,18 +2035,23 @@ ConstructJSImplementation(JSContext* aCx
       do_QueryInterface(implISupports);
     if (gpi) {
       JS::Rooted<JS::Value> initReturn(aCx);
       nsresult rv = gpi->Init(window, initReturn.address());
       if (NS_FAILED(rv)) {
         aRv.Throw(rv);
         return nullptr;
       }
-      MOZ_ASSERT(initReturn.isUndefined(),
-                 "nsIDOMGlobalPropertyInitializer should return undefined");
+      // With JS-implemented WebIDL, the return value of init() is not used to determine
+      // if init() failed, so init() should only return undefined. Any kind of permission
+      // or pref checking must happen by adding an attribute to the WebIDL interface.
+      if (!initReturn.isUndefined()) {
+        MOZ_ASSERT(false, "The init() method for JS-implemented WebIDL should not return anything");
+        MOZ_CRASH();
+      }
     }
     // Extract the JS implementation from the XPCOM object.
     nsCOMPtr<nsIXPConnectWrappedJS> implWrapped =
       do_QueryInterface(implISupports);
     MOZ_ASSERT(implWrapped, "Failed to get wrapped JS from XPCOM component.");
     if (!implWrapped) {
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;