Back out 4fc776ee6852:6a0ebe4ddd01 (bug 968335) and e7d697004921 (bug 923904) for b2g emulator build bustage
authorPhil Ringnalda <philringnalda@gmail.com>
Fri, 14 Feb 2014 18:35:30 -0800
changeset 186094 1e8c2e85575ae6294de1e6c0a364d193af2591e9
parent 186093 46223ef9b330dc3bced3f52225fb97ddfdb039b8
child 186095 31bc303caa56df7fc5dbdb88ba4d936ff10db3f2
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs968335, 923904
milestone30.0a1
backs out4fc776ee6852dd1a9c4ea7518a7bf5ba0c0ec7cd
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
Back out 4fc776ee6852:6a0ebe4ddd01 (bug 968335) and e7d697004921 (bug 923904) for b2g emulator build bustage CLOSED TREE
b2g/installer/package-manifest.in
browser/installer/package-manifest.in
dom/base/ScriptSettings.cpp
dom/base/ScriptSettings.h
dom/bindings/Bindings.conf
dom/bindings/CallbackObject.cpp
dom/bindings/CallbackObject.h
dom/bindings/Codegen.py
dom/bindings/test/TestInterfaceJS.js
dom/bindings/test/TestInterfaceJS.manifest
dom/bindings/test/mochitest.ini
dom/bindings/test/moz.build
dom/bindings/test/test_bug923904.html
dom/webidl/TestInterfaceJS.webidl
dom/webidl/moz.build
js/xpconnect/idl/xpccomponents.idl
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/nsCxPusher.cpp
js/xpconnect/src/nsCxPusher.h
js/xpconnect/tests/mochitest/mochitest.ini
js/xpconnect/tests/mochitest/test_getWebIDLCaller.html
mobile/android/installer/package-manifest.in
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -560,21 +560,16 @@
 
 @BINPATH@/components/DownloadsAPI.js
 @BINPATH@/components/DownloadsAPI.manifest
 
 ; InputMethod API
 @BINPATH@/components/MozKeyboard.js
 @BINPATH@/components/InputMethod.manifest
 
-#ifdef MOZ_DEBUG
-@BINPATH@/components/TestInterfaceJS.js
-@BINPATH@/components/TestInterfaceJS.manifest
-#endif
-
 ; Modules
 @BINPATH@/modules/*
 
 ; Safe Browsing
 @BINPATH@/components/nsURLClassifier.manifest
 @BINPATH@/components/nsUrlClassifierHashCompleter.js
 @BINPATH@/components/nsUrlClassifierListManager.js
 @BINPATH@/components/nsUrlClassifierLib.js
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -579,21 +579,16 @@
 #ifdef MOZ_WEBSPEECH
 @BINPATH@/components/dom_webspeechsynth.xpt
 #endif
 
 ; InputMethod API
 @BINPATH@/components/MozKeyboard.js
 @BINPATH@/components/InputMethod.manifest
 
-#ifdef MOZ_DEBUG
-@BINPATH@/components/TestInterfaceJS.js
-@BINPATH@/components/TestInterfaceJS.manifest
-#endif
-
 ; Modules
 @BINPATH@/browser/modules/*
 @BINPATH@/modules/*
 
 ; Safe Browsing
 #ifdef MOZ_URL_CLASSIFIER
 @BINPATH@/components/nsURLClassifier.manifest
 @BINPATH@/components/nsUrlClassifierHashCompleter.js
--- a/dom/base/ScriptSettings.cpp
+++ b/dom/base/ScriptSettings.cpp
@@ -43,44 +43,34 @@ public:
     mStack.AppendElement(&ScriptSettingsStackEntry::SystemSingleton);
   }
 
   void Pop() {
     MOZ_ASSERT(mStack.Length() > 0);
     mStack.RemoveElementAt(mStack.Length() - 1);
   }
 
-  ScriptSettingsStackEntry* Incumbent() {
+  nsIGlobalObject* Incumbent() {
     if (!mStack.Length()) {
       return nullptr;
     }
-    return mStack.LastElement();
+    return mStack.LastElement()->mGlobalObject;
   }
 
-  nsIGlobalObject* IncumbentGlobal() {
-    ScriptSettingsStackEntry *entry = Incumbent();
-    return entry ? entry->mGlobalObject : nullptr;
-  }
-
-  ScriptSettingsStackEntry* EntryPoint() {
+  nsIGlobalObject* EntryPoint() {
     if (!mStack.Length())
       return nullptr;
     for (int i = mStack.Length() - 1; i >= 0; --i) {
       if (mStack[i]->mIsCandidateEntryPoint) {
-        return mStack[i];
+        return mStack[i]->mGlobalObject;
       }
     }
     MOZ_ASSUME_UNREACHABLE("Non-empty stack should always have an entry point");
   }
 
-  nsIGlobalObject* EntryGlobal() {
-    ScriptSettingsStackEntry *entry = EntryPoint();
-    return entry ? entry->mGlobalObject : nullptr;
-  }
-
 private:
   // These pointers are caller-owned.
   nsTArray<ScriptSettingsStackEntry*> mStack;
 };
 
 void
 InitScriptSettings()
 {
@@ -107,103 +97,64 @@ void DestroyScriptSettings()
 // certain edge cases. It's good enough for some purposes, but not others. If
 // you want to call this function, ping bholley and describe your use-case.
 nsIGlobalObject*
 BrokenGetEntryGlobal()
 {
   // We need the current JSContext in order to check the JS for
   // scripted frames that may have appeared since anyone last
   // manipulated the stack. If it's null, that means that there
-  // must be no entry global on the stack.
+  // must be no entry point on the stack.
   JSContext *cx = nsContentUtils::GetCurrentJSContextForThread();
   if (!cx) {
-    MOZ_ASSERT(ScriptSettingsStack::Ref().EntryGlobal() == nullptr);
+    MOZ_ASSERT(ScriptSettingsStack::Ref().EntryPoint() == nullptr);
     return nullptr;
   }
 
   return nsJSUtils::GetDynamicScriptGlobal(cx);
 }
 
 // Note: When we're ready to expose it, GetEntryGlobal will look similar to
 // GetIncumbentGlobal below.
 
 nsIGlobalObject*
 GetIncumbentGlobal()
 {
   // We need the current JSContext in order to check the JS for
   // scripted frames that may have appeared since anyone last
   // manipulated the stack. If it's null, that means that there
-  // must be no entry global on the stack, and therefore no incumbent
+  // must be no entry point on the stack, and therefore no incumbent
   // global either.
   JSContext *cx = nsContentUtils::GetCurrentJSContextForThread();
   if (!cx) {
-    MOZ_ASSERT(ScriptSettingsStack::Ref().EntryGlobal() == nullptr);
+    MOZ_ASSERT(ScriptSettingsStack::Ref().EntryPoint() == nullptr);
     return nullptr;
   }
 
   // See what the JS engine has to say. If we've got a scripted caller
   // override in place, the JS engine will lie to us and pretend that
   // there's nothing on the JS stack, which will cause us to check the
   // incumbent script stack below.
   JS::RootedScript script(cx);
   if (JS_DescribeScriptedCaller(cx, &script, nullptr)) {
     JS::RootedObject global(cx, JS_GetGlobalFromScript(script));
     MOZ_ASSERT(global);
     return xpc::GetNativeForGlobal(global);
   }
 
   // Ok, nothing from the JS engine. Let's use whatever's on the
   // explicit stack.
-  return ScriptSettingsStack::Ref().IncumbentGlobal();
-}
-
-nsIPrincipal*
-GetWebIDLCallerPrincipal()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  ScriptSettingsStackEntry *entry = ScriptSettingsStack::Ref().EntryPoint();
-
-  // If we have an entry point that is not the system singleton, we know it
-  // must be an AutoEntryScript.
-  if (!entry || entry->IsSystemSingleton()) {
-    return nullptr;
-  }
-  AutoEntryScript* aes = static_cast<AutoEntryScript*>(entry);
-
-  // We can't yet rely on the Script Settings Stack to properly determine the
-  // entry script, because there are still lots of places in the tree where we
-  // don't yet use an AutoEntryScript (bug 951991 tracks this work). In the
-  // mean time though, we can make some observations to hack around the
-  // problem:
-  //
-  // (1) All calls into JS-implemented WebIDL go through CallSetup, which goes
-  //     through AutoEntryScript.
-  // (2) The top candidate entry point in the Script Settings Stack is the
-  //     entry point if and only if no other JSContexts have been pushed on
-  //     top of the push made by that entry's AutoEntryScript.
-  //
-  // Because of (1), all of the cases where we might return a non-null
-  // WebIDL Caller are guaranteed to have put an entry on the Script Settings
-  // Stack, so we can restrict our search to that. Moreover, (2) gives us a
-  // criterion to determine whether an entry in the Script Setting Stack means
-  // that we should return a non-null WebIDL Caller.
-  //
-  // Once we fix bug 951991, this can all be simplified.
-  if (!aes->mCxPusher.ref().IsStackTop()) {
-    return nullptr;
-  }
-
-  return aes->mWebIDLCallerPrincipal;
+  return ScriptSettingsStack::Ref().Incumbent();
 }
 
 AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
                                  bool aIsMainThread,
                                  JSContext* aCx)
-  : ScriptSettingsStackEntry(aGlobalObject, /* aCandidate = */ true)
-  , mStack(ScriptSettingsStack::Ref())
+  : mStack(ScriptSettingsStack::Ref())
+  , mEntry(aGlobalObject, /* aCandidate = */ true)
 {
   MOZ_ASSERT(aGlobalObject);
   if (!aCx) {
     // If the caller didn't provide a cx, hunt one down. This isn't exactly
     // fast, but the callers that care about performance can pass an explicit
     // cx for now. Eventually, the whole cx pushing thing will go away
     // entirely.
     MOZ_ASSERT(aIsMainThread, "cx is mandatory off-main-thread");
@@ -211,47 +162,47 @@ AutoEntryScript::AutoEntryScript(nsIGlob
     if (sgo && sgo->GetScriptContext()) {
       aCx = sgo->GetScriptContext()->GetNativeContext();
     }
     if (!aCx) {
       aCx = nsContentUtils::GetSafeJSContext();
     }
   }
   if (aIsMainThread) {
-    mCxPusher.construct(aCx);
+    mCxPusher.Push(aCx);
   }
   mAc.construct(aCx, aGlobalObject->GetGlobalJSObject());
-  mStack.Push(this);
+  mStack.Push(&mEntry);
 }
 
 AutoEntryScript::~AutoEntryScript()
 {
-  MOZ_ASSERT(mStack.Incumbent() == this);
+  MOZ_ASSERT(mStack.Incumbent() == mEntry.mGlobalObject);
   mStack.Pop();
 }
 
 AutoIncumbentScript::AutoIncumbentScript(nsIGlobalObject* aGlobalObject)
-  : ScriptSettingsStackEntry(aGlobalObject, /* aCandidate = */ false)
-  , mStack(ScriptSettingsStack::Ref())
+  : mStack(ScriptSettingsStack::Ref())
+  , mEntry(aGlobalObject, /* aCandidate = */ false)
   , mCallerOverride(nsContentUtils::GetCurrentJSContextForThread())
 {
-  mStack.Push(this);
+  mStack.Push(&mEntry);
 }
 
 AutoIncumbentScript::~AutoIncumbentScript()
 {
-  MOZ_ASSERT(mStack.Incumbent() == this);
+  MOZ_ASSERT(mStack.Incumbent() == mEntry.mGlobalObject);
   mStack.Pop();
 }
 
 AutoSystemCaller::AutoSystemCaller(bool aIsMainThread)
   : mStack(ScriptSettingsStack::Ref())
 {
   if (aIsMainThread) {
-    mCxPusher.construct(nullptr, /* aAllowNull = */ true);
+    mCxPusher.PushNull();
   }
   mStack.PushSystem();
 }
 
 AutoSystemCaller::~AutoSystemCaller()
 {
   mStack.Pop();
 }
--- a/dom/base/ScriptSettings.h
+++ b/dom/base/ScriptSettings.h
@@ -7,17 +7,16 @@
 /* Utilities for managing the script settings object stack defined in webapps */
 
 #ifndef mozilla_dom_ScriptSettings_h
 #define mozilla_dom_ScriptSettings_h
 
 #include "nsCxPusher.h"
 #include "MainThreadUtils.h"
 #include "nsIGlobalObject.h"
-#include "nsIPrincipal.h"
 
 #include "mozilla/Maybe.h"
 
 class nsIGlobalObject;
 
 namespace mozilla {
 namespace dom {
 
@@ -34,34 +33,16 @@ void DestroyScriptSettings();
 nsIGlobalObject* BrokenGetEntryGlobal();
 
 // Note: We don't yet expose GetEntryGlobal, because in order for it to be
 // correct, we first need to replace a bunch of explicit cx pushing in the
 // browser with AutoEntryScript. But GetIncumbentGlobal is simpler, because it
 // can mostly be inferred from the JS stack.
 nsIGlobalObject* GetIncumbentGlobal();
 
-// JS-implemented WebIDL presents an interesting situation with respect to the
-// subject principal. A regular C++-implemented API can simply examine the
-// compartment of the most-recently-executed script, and use that to infer the
-// responsible party. However, JS-implemented APIs are run with system
-// principal, and thus clobber the subject principal of the script that
-// invoked the API. So we have to do some extra work to keep track of this
-// information.
-//
-// We therefore implement the following behavior:
-// * Each Script Settings Object has an optional WebIDL Caller Principal field.
-//   This defaults to null.
-// * When we push an Entry Point in preparation to run a JS-implemented WebIDL
-//   callback, we grab the subject principal at the time of invocation, and
-//   store that as the WebIDL Caller Principal.
-// * When non-null, callers can query this principal from script via an API on
-//   Components.utils.
-nsIPrincipal* GetWebIDLCallerPrincipal();
-
 class ScriptSettingsStack;
 struct ScriptSettingsStackEntry {
   nsCOMPtr<nsIGlobalObject> mGlobalObject;
   bool mIsCandidateEntryPoint;
 
   ScriptSettingsStackEntry(nsIGlobalObject *aGlobal, bool aCandidate)
     : mGlobalObject(aGlobal)
     , mIsCandidateEntryPoint(aCandidate)
@@ -85,59 +66,55 @@ private:
   ScriptSettingsStackEntry() : mGlobalObject(nullptr)
                              , mIsCandidateEntryPoint(true)
   {}
 };
 
 /*
  * A class that represents a new script entry point.
  */
-class AutoEntryScript : protected ScriptSettingsStackEntry {
+class AutoEntryScript {
 public:
   AutoEntryScript(nsIGlobalObject* aGlobalObject,
                   bool aIsMainThread = NS_IsMainThread(),
                   // Note: aCx is mandatory off-main-thread.
                   JSContext* aCx = nullptr);
   ~AutoEntryScript();
 
-  void SetWebIDLCallerPrincipal(nsIPrincipal *aPrincipal) {
-    mWebIDLCallerPrincipal = aPrincipal;
-  }
-
 private:
   dom::ScriptSettingsStack& mStack;
-  nsCOMPtr<nsIPrincipal> mWebIDLCallerPrincipal;
-  mozilla::Maybe<AutoCxPusher> mCxPusher;
+  dom::ScriptSettingsStackEntry mEntry;
+  nsCxPusher mCxPusher;
   mozilla::Maybe<JSAutoCompartment> mAc; // This can de-Maybe-fy when mCxPusher
                                          // goes away.
-  friend nsIPrincipal* GetWebIDLCallerPrincipal();
 };
 
 /*
  * A class that can be used to force a particular incumbent script on the stack.
  */
-class AutoIncumbentScript : protected ScriptSettingsStackEntry {
+class AutoIncumbentScript {
 public:
   AutoIncumbentScript(nsIGlobalObject* aGlobalObject);
   ~AutoIncumbentScript();
 private:
   dom::ScriptSettingsStack& mStack;
+  dom::ScriptSettingsStackEntry mEntry;
   JS::AutoHideScriptedCaller mCallerOverride;
 };
 
 /*
  * A class used for C++ to indicate that existing entry and incumbent scripts
  * should not apply to anything in scope, and that callees should act as if
  * they were invoked "from C++".
  */
 class AutoSystemCaller {
 public:
   AutoSystemCaller(bool aIsMainThread = NS_IsMainThread());
   ~AutoSystemCaller();
 private:
   dom::ScriptSettingsStack& mStack;
-  mozilla::Maybe<AutoCxPusher> mCxPusher;
+  nsCxPusher mCxPusher;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_ScriptSettings_h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1623,18 +1623,16 @@ DOMInterfaces = {
     'nativeType': 'nsXULElement',
     'resultNotAddRefed': [ 'controllers', 'style' ]
 },
 
 ####################################
 # Test Interfaces of various sorts #
 ####################################
 
-'TestInterfaceJS' : {},
-
 'TestInterface' : {
         # Keep this in sync with TestExampleInterface
         'headerFile': 'TestBindingHeader.h',
         'register': False,
         'resultNotAddRefed': [ 'receiveWeakSelf', 'receiveWeakNullableSelf',
                                'receiveWeakOther', 'receiveWeakNullableOther',
                                'receiveWeakExternal', 'receiveWeakNullableExternal',
                                'ReceiveWeakCallbackInterface',
--- a/dom/bindings/CallbackObject.cpp
+++ b/dom/bindings/CallbackObject.cpp
@@ -44,35 +44,26 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(CallbackObject)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mCallback)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 CallbackObject::CallSetup::CallSetup(CallbackObject* aCallback,
                                      ErrorResult& aRv,
                                      ExceptionHandling aExceptionHandling,
-                                     JSCompartment* aCompartment,
-                                     bool aIsJSImplementedWebIDL)
+                                     JSCompartment* aCompartment)
   : mCx(nullptr)
   , mCompartment(aCompartment)
   , mErrorResult(aRv)
   , mExceptionHandling(aExceptionHandling)
   , mIsMainThread(NS_IsMainThread())
 {
   if (mIsMainThread) {
     nsContentUtils::EnterMicroTask();
   }
-
-  // Compute the caller's subject principal (if necessary) early, before we
-  // do anything that might perturb the relevant state.
-  nsIPrincipal* webIDLCallerPrincipal = nullptr;
-  if (aIsJSImplementedWebIDL) {
-    webIDLCallerPrincipal = nsContentUtils::GetSubjectPrincipal();
-  }
-
   // We need to produce a useful JSContext here.  Ideally one that the callback
   // is in some sense associated with, so that we can sort of treat it as a
   // "script entry point".  Though once we actually have script entry points,
   // we'll need to do the script entry point bits once we have an actual
   // callable.
 
   // First, find the real underlying callback.
   JSObject* realCallback = js::UncheckedUnwrap(aCallback->CallbackPreserveColor());
@@ -116,17 +107,16 @@ CallbackObject::CallSetup::CallSetup(Cal
     // Bail out if there's no useful global. This seems to happen intermittently
     // on gaia-ui tests, probably because nsInProcessTabChildGlobal is returning
     // null in some kind of teardown state.
     if (!globalObject->GetGlobalJSObject()) {
       return;
     }
 
     mAutoEntryScript.construct(globalObject, mIsMainThread, cx);
-    mAutoEntryScript.ref().SetWebIDLCallerPrincipal(webIDLCallerPrincipal);
     if (aCallback->IncumbentGlobalOrNull()) {
       mAutoIncumbentScript.construct(aCallback->IncumbentGlobalOrNull());
     }
 
     // Unmark the callable (by invoking Callback() and not the CallbackPreserveColor()
     // variant), and stick it in a Rooted before it can go gray again.
     // Nothing before us in this function can trigger a CC, so it's safe to wait
     // until here it do the unmark. This allows us to order the following two
--- a/dom/bindings/CallbackObject.h
+++ b/dom/bindings/CallbackObject.h
@@ -149,21 +149,20 @@ protected:
     /**
      * A class that performs whatever setup we need to safely make a
      * call while this class is on the stack, After the constructor
      * returns, the call is safe to make if GetContext() returns
      * non-null.
      */
   public:
     // If aExceptionHandling == eRethrowContentExceptions then aCompartment
-    // needs to be set to the compartment in which exceptions will be rethrown.
+    // needs to be set to the caller's compartment.
     CallSetup(CallbackObject* aCallback, ErrorResult& aRv,
               ExceptionHandling aExceptionHandling,
-              JSCompartment* aCompartment = nullptr,
-              bool aIsJSImplementedWebIDL = false);
+              JSCompartment* aCompartment = nullptr);
     ~CallSetup();
 
     JSContext* GetContext() const
     {
       return mCx;
     }
 
   private:
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -11284,18 +11284,17 @@ class CallbackMember(CGNativeMember):
     def getCallSetup(self):
         if self.needThisHandling:
             # It's been done for us already
             return ""
         callSetup = "CallSetup s(this, aRv"
         if self.rethrowContentException:
             # getArgs doesn't add the aExceptionHandling argument but does add
             # aCompartment for us.
-            callSetup += ", eRethrowContentExceptions, aCompartment, /* aIsJSImplementedWebIDL = */ "
-            callSetup += toStringBool(isJSImplementedDescriptor(self.descriptorProvider))
+            callSetup += ", eRethrowContentExceptions, aCompartment"
         else:
             callSetup += ", aExceptionHandling"
         callSetup += ");"
         return string.Template(
             "${callSetup}\n"
             "JSContext* cx = s.GetContext();\n"
             "if (!cx) {\n"
             "  aRv.Throw(NS_ERROR_UNEXPECTED);\n"
deleted file mode 100644
--- a/dom/bindings/test/TestInterfaceJS.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-const Cu = Components.utils;
-const Ci = Components.interfaces;
-
-"use strict";
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-
-var gGlobal = this;
-function checkGlobal(obj) {
-  if (Object(obj) === obj && Cu.getGlobalForObject(obj) != gGlobal) {
-    // This message may not make it to the caller in a useful form, so dump
-    // as well.
-    var msg = "TestInterfaceJS received an object from a different scope!";
-    dump(msg + "\n");
-    throw new Error(msg);
-  }
-}
-
-function TestInterfaceJS(anyArg, objectArg) {}
-
-TestInterfaceJS.prototype = {
-  classID: Components.ID("{2ac4e026-cf25-47d5-b067-78d553c3cad8}"),
-  contractID: "@mozilla.org/dom/test-interface-js;1",
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
-
-  __init: function (anyArg, objectArg) {
-    this._anyAttr = undefined;
-    this._objectAttr = null;
-    this._anyArg = anyArg;
-    this._objectArg = objectArg;
-    checkGlobal(anyArg);
-    checkGlobal(objectArg);
-  },
-
-  get anyArg() { return this._anyArg; },
-  get objectArg() { return this._objectArg; },
-  get anyAttr() { return this._anyAttr; },
-  set anyAttr(val) { checkGlobal(val); this._anyAttr = val; },
-  get objectAttr() { return this._objectAttr; },
-  set objectAttr(val) { checkGlobal(val); this._objectAttr = val; },
-  pingPongAny: function(any) { checkGlobal(any); return any; },
-  pingPongObject: function(obj) { checkGlobal(obj); return obj; },
-
-  getCallerPrincipal: function() { return Cu.getWebIDLCallerPrincipal().origin; }
-};
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TestInterfaceJS])
deleted file mode 100644
--- a/dom/bindings/test/TestInterfaceJS.manifest
+++ /dev/null
@@ -1,2 +0,0 @@
-component {2ac4e026-cf25-47d5-b067-78d553c3cad8} TestInterfaceJS.js
-contract @mozilla.org/dom/test-interface-js;1 {2ac4e026-cf25-47d5-b067-78d553c3cad8}
--- a/dom/bindings/test/mochitest.ini
+++ b/dom/bindings/test/mochitest.ini
@@ -11,20 +11,16 @@ support-files =
 [test_bug560072.html]
 [test_bug707564.html]
 [test_bug742191.html]
 [test_bug759621.html]
 [test_bug773326.html]
 [test_bug788369.html]
 [test_bug852846.html]
 [test_bug862092.html]
-# When bug 923904 lands, this test can be turned on, but only for debug builds
-# where we have our test component. So this should become skip-if = debug == false.
-[test_bug923904.html]
-skip-if = true
 [test_barewordGetsWindow.html]
 [test_callback_default_thisval.html]
 [test_cloneAndImportNode.html]
 [test_defineProperty.html]
 [test_enums.html]
 [test_exceptionThrowing.html]
 [test_exception_messages.html]
 [test_forOf.html]
--- a/dom/bindings/test/moz.build
+++ b/dom/bindings/test/moz.build
@@ -5,21 +5,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 LIBXUL_LIBRARY = True
 # Do NOT export this library.  We don't actually want our test code
 # being added to libxul or anything.
 
 LIBRARY_NAME = 'dombindings_test_s'
 
-EXTRA_COMPONENTS += [
-    'TestInterfaceJS.js',
-    'TestInterfaceJS.manifest',
-]
-
 MOCHITEST_MANIFESTS += ['mochitest.ini']
 
 MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
 
 TEST_WEBIDL_FILES += [
     'TestDictionary.webidl',
     'TestJSImplInheritanceGen.webidl',
     'TestTypedef.webidl',
deleted file mode 100644
--- a/dom/bindings/test/test_bug923904.html
+++ /dev/null
@@ -1,66 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=923904
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 923904</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript">
-
-  /** Test for cloning of |any| and |object| for JS-Implemented WebIDL. **/
-  SimpleTest.waitForExplicitFinish();
-  SpecialPowers.pushPrefEnv({set: [['dom.expose_test_interfaces', true]]}, go);
-
-  function go() {
-    var someAny = { a: 11 };
-    var someObj = { b: 22, c: "str" };
-    var t = new TestInterfaceJS(someAny, someObj);
-    is(Object.getPrototypeOf(t), TestInterfaceJS.prototype, "Prototype setup works correctly");
-    is(t.anyArg.toSource(), someAny.toSource(), "anyArg comes back looking like what we sent");
-    is(t.objectArg.toSource(), someObj.toSource(), "objectArg comes back looking like what we sent");
-    isnot(t.anyArg, t.anyArg, "get a new anyArg each time");
-    isnot(t.objectArg, t.objectArg, "get a new objectArg each time");
-
-    t.anyAttr = 2;
-    is(t.anyAttr, 2, "ping-pong works");
-    testObjectCloned(t, 'anyAttr');
-    testObjectCloned(t, 'objectAttr');
-
-    is(someAny.toSource(), t.pingPongAny(someAny).toSource(), "ping-pong works with any");
-    is(someObj.toSource(), t.pingPongObject(someObj).toSource(), "ping-pong works with obj");
-    isnot(someAny, t.pingPongAny(someAny), "Clone works for ping-pong any");
-    isnot(someObj, t.pingPongObject(someObj), "Clone works for ping-pong obj");
-
-    SimpleTest.finish();
-  }
-
-  function testObjectCloned(iface, propname) {
-    var obj = { prop: 42 };
-    iface[propname] = obj;
-    is(iface[propname].prop, 42, "objects come back as well");
-    is(iface[propname].__proto__, Object.prototype, "vanilla object");
-    isnot(iface[propname], obj, "Should not be the original object");
-    isnot(iface[propname], iface[propname], "Should get cloned each time");
-    try {
-      iface[propname] = { stringProp: "hi", reflectorProp: document };
-      ok(false, "Should throw when trying to clone reflector");
-    } catch (e) {
-      ok(/cloned/.test(e), "Should throw clone error: " + e);
-    }
-  }
-
-  </script>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=923904">Mozilla Bug 923904</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/dom/webidl/TestInterfaceJS.webidl
+++ /dev/null
@@ -1,20 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-[JSImplementation="@mozilla.org/dom/test-interface-js;1",
- Pref="dom.expose_test_interfaces",
- Constructor(optional any anyArg, optional object objectArg)]
-interface TestInterfaceJS {
-  readonly attribute any anyArg;
-  readonly attribute object objectArg;
-  attribute any anyAttr;
-  attribute object objectAttr;
-  any pingPongAny(any arg);
-  object pingPongObject(any obj);
-
-  // For testing bug 968335.
-  DOMString getCallerPrincipal();
-};
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -505,21 +505,16 @@ WEBIDL_FILES += [
     'RecordErrorEvent.webidl',
     'SmartCardEvent.webidl',
     'StorageEvent.webidl',
     'StyleRuleChangeEvent.webidl',
     'StyleSheetApplicableStateChangeEvent.webidl',
     'StyleSheetChangeEvent.webidl',
 ]
 
-# We only expose our prefable test interfaces in debug builds, just to be on
-# the safe side.
-if CONFIG['MOZ_DEBUG']:
-    WEBIDL_FILES += ['TestInterfaceJS.webidl']
-
 if CONFIG['MOZ_B2G_BT']:
     WEBIDL_FILES += [
         'BluetoothAdapter.webidl',
         'BluetoothDevice.webidl',
         'BluetoothManager.webidl',
     ]
 
 if CONFIG['MOZ_B2G_RIL']:
--- a/js/xpconnect/idl/xpccomponents.idl
+++ b/js/xpconnect/idl/xpccomponents.idl
@@ -9,17 +9,16 @@
 #include "jspubtd.h"
 %}
 
 interface xpcIJSWeakReference;
 interface nsIClassInfo;
 interface nsIComponentManager;
 interface nsIJSCID;
 interface nsIJSIID;
-interface nsIPrincipal;
 interface nsIStackFrame;
 
 /**
 * interface of Components.interfacesByID
 * (interesting stuff only reflected into JavaScript)
 */
 [scriptable, uuid(c99cffac-5aed-4267-ad2f-f4a4c9d4a081)]
 interface nsIXPCComponents_InterfacesByID : nsISupports
@@ -116,17 +115,17 @@ interface nsIXPCComponents_utils_Sandbox
 interface ScheduledGCCallback : nsISupports
 {
     void callback();
 };
 
 /**
 * interface of Components.utils
 */
-[scriptable, uuid(f4b12240-02aa-47e5-99d5-43cd50fbd4b7)]
+[scriptable, uuid(cd4bccf4-3433-492e-8dfd-dfdb3fe9efa1)]
 interface nsIXPCComponents_Utils : nsISupports
 {
 
     /* reportError is designed to be called from JavaScript only.
      *
      * It will report a JS Error object to the JS console, and return. It
      * is meant for use in exception handler blocks which want to "eat"
      * an exception, but still want to report it to the console.
@@ -557,32 +556,16 @@ interface nsIXPCComponents_Utils : nsISu
      * Clone an object into a scope.
      * The 3rd argument is an optional options object:
      * - cloneFunction: boolean. If true, any function in the value is are
      *   wrapped in a function forwarder that appears to be a native function in
      *   the content scope.
      */
     [implicit_jscontext]
     jsval cloneInto(in jsval value, in jsval scope, [optional] in jsval options);
-
-    /*
-     * When C++-Implemented code does security checks, it can generally query
-     * the subject principal (i.e. the principal of the most-recently-executed
-     * script) in order to determine the responsible party. However, when an API
-     * is implemented in JS, this doesn't work - the most-recently-executed
-     * script is always the System-Principaled API implementation. So we need
-     * another mechanism.
-     *
-     * Hence the notion of the "WebIDL Caller". If the current Entry Script on
-     * the Script Settings Stack represents the invocation of JS-implemented
-     * WebIDL, this API returns the principal of the caller at the time
-     * of invocation. Otherwise (i.e. outside of JS-implemented WebIDL), this
-     * function throws. If it throws, you probably shouldn't be using it.
-     */
-    nsIPrincipal getWebIDLCallerPrincipal();
 };
 
 /**
 * Interface for the 'Components' object.
 *
 * The first interface contains things that are available to non-chrome XBL code
 * that runs in a scope with an nsExpandedPrincipal. The second interface
 * includes members that are only exposed to chrome.
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -3621,29 +3621,16 @@ nsXPCComponents_Utils::CloneInto(HandleV
     }
 
     if (!JS_WrapValue(aCx, aCloned))
         return NS_ERROR_FAILURE;
 
     return NS_OK;
 }
 
-NS_IMETHODIMP
-nsXPCComponents_Utils::GetWebIDLCallerPrincipal(nsIPrincipal **aResult)
-{
-    // This API may only be when the Entry Settings Object corresponds to a
-    // JS-implemented WebIDL call. In all other cases, the value will be null,
-    // and we throw.
-    nsCOMPtr<nsIPrincipal> callerPrin = mozilla::dom::GetWebIDLCallerPrincipal();
-    if (!callerPrin)
-        return NS_ERROR_NOT_AVAILABLE;
-    callerPrin.forget(aResult);
-    return NS_OK;
-}
-
 /***************************************************************************/
 /***************************************************************************/
 /***************************************************************************/
 
 
 nsXPCComponentsBase::nsXPCComponentsBase(XPCWrappedNativeScope* aScope)
     :   mScope(aScope)
 {
--- a/js/xpconnect/src/nsCxPusher.cpp
+++ b/js/xpconnect/src/nsCxPusher.cpp
@@ -110,17 +110,16 @@ AutoCxPusher::AutoCxPusher(JSContext* cx
   // (and therefore not in use). See nsJSContext::DestroyJSContext().
   if (cx)
     mScx = GetScriptContextFromJSContext(cx);
 
   XPCJSContextStack *stack = XPCJSRuntime::Get()->GetJSContextStack();
   if (!stack->Push(cx)) {
     MOZ_CRASH();
   }
-  mStackDepthAfterPush = stack->Count();
 
 #ifdef DEBUG
   mPushedContext = cx;
   mCompartmentDepthOnEntry = cx ? js::GetEnterCompartmentDepth(cx) : 0;
 #endif
 
   // Enter a request and a compartment for the duration that the cx is on the
   // stack if non-null.
@@ -159,24 +158,16 @@ AutoCxPusher::~AutoCxPusher()
   MOZ_ASSERT_IF(mPushedContext, mCompartmentDepthOnEntry ==
                                 js::GetEnterCompartmentDepth(mPushedContext));
   DebugOnly<JSContext*> stackTop;
   MOZ_ASSERT(mPushedContext == nsXPConnect::XPConnect()->GetCurrentJSContext());
   XPCJSRuntime::Get()->GetJSContextStack()->Pop();
   mScx = nullptr;
 }
 
-bool
-AutoCxPusher::IsStackTop()
-{
-  uint32_t currentDepth = XPCJSRuntime::Get()->GetJSContextStack()->Count();
-  MOZ_ASSERT(currentDepth >= mStackDepthAfterPush);
-  return currentDepth == mStackDepthAfterPush;
-}
-
 AutoJSContext::AutoJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)
   : mCx(nullptr)
 {
   Init(false MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT);
 }
 
 AutoJSContext::AutoJSContext(bool aSafe MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
   : mCx(nullptr)
--- a/js/xpconnect/src/nsCxPusher.h
+++ b/js/xpconnect/src/nsCxPusher.h
@@ -26,25 +26,20 @@ class MOZ_STACK_CLASS AutoCxPusher
 {
 public:
   AutoCxPusher(JSContext *aCx, bool aAllowNull = false);
   // XPCShell uses an nsCxPusher, which contains an AutoCxPusher.
   NS_EXPORT ~AutoCxPusher();
 
   nsIScriptContext* GetScriptContext() { return mScx; }
 
-  // Returns true if this AutoCxPusher performed the push that is currently at
-  // the top of the cx stack.
-  bool IsStackTop();
-
 private:
   mozilla::Maybe<JSAutoRequest> mAutoRequest;
   mozilla::Maybe<JSAutoCompartment> mAutoCompartment;
   nsCOMPtr<nsIScriptContext> mScx;
-  uint32_t mStackDepthAfterPush;
 #ifdef DEBUG
   JSContext* mPushedContext;
   unsigned mCompartmentDepthOnEntry;
 #endif
 };
 
 } /* namespace mozilla */
 
--- a/js/xpconnect/tests/mochitest/mochitest.ini
+++ b/js/xpconnect/tests/mochitest/mochitest.ini
@@ -84,13 +84,10 @@ support-files =
 [test_bug871887.html]
 [test_bug912322.html]
 [test_bug916945.html]
 [test_bug92773.html]
 [test_bug940783.html]
 [test_bug965082.html]
 [test_crosscompartment_weakmap.html]
 [test_frameWrapping.html]
-# The JS test component we use below is only available in debug builds.
-[test_getWebIDLCaller.html]
-skip-if = debug == false
 [test_nac.xhtml]
 [test_sameOriginPolicy.html]
deleted file mode 100644
--- a/js/xpconnect/tests/mochitest/test_getWebIDLCaller.html
+++ /dev/null
@@ -1,49 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=968335
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 968335</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript">
-
-  /** Test for Cu.getCallerPrincipal (within JS-implemented WebIDL). **/
-
-  SimpleTest.waitForExplicitFinish();
-  SpecialPowers.pushPrefEnv({set: [['dom.expose_test_interfaces', true]]}, go);
-
-
-  function go() {
-    var t = new TestInterfaceJS();
-    is(t.getCallerPrincipal(), location.origin,
-       "Cu.getCallerPrincipal works right within JS-implemented WebIDL");
-
-    try {
-      SpecialPowers.Cu.getWebIDLCallerPrincipal();
-      ok(false, "Should have thrown");
-    } catch (e) {
-      ok(/NOT_AVAILABLE/.test(SpecialPowers.wrap(e)),
-         "API should throw when invoked outside of JS-implemented WebIDL");
-    }
-
-    SimpleTest.finish();
-  }
-
-
-
-
-  </script>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=968335">Mozilla Bug 968335</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-</pre>
-</body>
-</html>
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -420,21 +420,16 @@
 @BINPATH@/components/CaptivePortalDetectComponents.manifest
 @BINPATH@/components/captivedetect.js
 #endif
 
 #ifdef MOZ_WEBSPEECH
 @BINPATH@/components/dom_webspeechsynth.xpt
 #endif
 
-#ifdef MOZ_DEBUG
-@BINPATH@/components/TestInterfaceJS.js
-@BINPATH@/components/TestInterfaceJS.manifest
-#endif
-
 ; Modules
 @BINPATH@/modules/*
 
 #ifdef MOZ_SAFE_BROWSING
 ; Safe Browsing
 @BINPATH@/components/nsURLClassifier.manifest
 @BINPATH@/components/nsUrlClassifierHashCompleter.js
 @BINPATH@/components/nsUrlClassifierListManager.js