Bug 1036186 - Reset Migration wizard no longer skips the first step to choose a browser. r=smaug.
☠☠ backed out by 909de22e9dec ☠ ☠
authorPeter Van der Beken <peterv@propagandism.org>
Fri, 08 Aug 2014 15:03:29 +0200
changeset 199455 e349895861e2c9a2b3f46e39605ca105ccab69f2
parent 199454 acf50ee376c3d4e4e22ca2f5da3c663ba57c3591
child 199456 aac02f95733efc96d5230886d0905aa87827e86d
push id47655
push userpvanderbeken@mozilla.com
push dateThu, 14 Aug 2014 11:34:38 +0000
treeherdermozilla-inbound@e349895861e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1036186
milestone34.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 1036186 - Reset Migration wizard no longer skips the first step to choose a browser. r=smaug.
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfo.h
dom/bindings/BindingUtils.cpp
dom/bindings/BindingUtils.h
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -424,17 +424,16 @@ static const nsConstructorFuncMapData kC
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Blob, DOMMultipartFileImpl::NewBlob)
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(File, DOMMultipartFileImpl::NewFile)
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozSmsFilter, SmsFilter::NewSmsFilter)
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XSLTProcessor, XSLTProcessorCtor)
 };
 #undef NS_DEFINE_CONSTRUCTOR_FUNC_DATA
 
 nsIXPConnect *nsDOMClassInfo::sXPConnect = nullptr;
-nsIScriptSecurityManager *nsDOMClassInfo::sSecMan = nullptr;
 bool nsDOMClassInfo::sIsInitialized = false;
 
 
 jsid nsDOMClassInfo::sLocation_id        = JSID_VOID;
 jsid nsDOMClassInfo::sConstructor_id     = JSID_VOID;
 jsid nsDOMClassInfo::sTop_id             = JSID_VOID;
 jsid nsDOMClassInfo::sDocument_id        = JSID_VOID;
 jsid nsDOMClassInfo::sWrappedJSObject_id = JSID_VOID;
@@ -775,29 +774,21 @@ nsDOMClassInfo::Init()
                 "BAD! You'll need to adjust the size of uintptr_t to the "
                 "size of a pointer on your platform.");
 
   NS_ENSURE_TRUE(!sIsInitialized, NS_ERROR_ALREADY_INITIALIZED);
 
   nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
   NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
 
-  nsresult rv = CallGetService(nsIXPConnect::GetCID(), &sXPConnect);
-  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ADDREF(sXPConnect = nsContentUtils::XPConnect());
 
   nsCOMPtr<nsIXPCFunctionThisTranslator> elt = new nsEventListenerThisTranslator();
   sXPConnect->SetFunctionThisTranslator(NS_GET_IID(nsIDOMEventListener), elt);
 
-  nsCOMPtr<nsIScriptSecurityManager> sm =
-    do_GetService("@mozilla.org/scriptsecuritymanager;1", &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  sSecMan = sm;
-  NS_ADDREF(sSecMan);
-
   AutoSafeJSContext cx;
 
   DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
     DOM_CLASSINFO_WINDOW_MAP_ENTRIES
 #ifdef MOZ_WEBSPEECH
     DOM_CLASSINFO_MAP_ENTRY(nsISpeechSynthesisGetter)
 #endif
   DOM_CLASSINFO_MAP_END
@@ -1038,19 +1029,16 @@ nsDOMClassInfo::Init()
   }
 
   for (i = 0; i < eDOMClassInfoIDCount; ++i) {
     RegisterClassProtos(i);
   }
 
   RegisterExternalClasses();
 
-  // Register new DOM bindings
-  mozilla::dom::Register(nameSpaceManager);
-
   sIsInitialized = true;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMClassInfo::GetInterfaces(uint32_t *aCount, nsIID ***aArray)
 {
@@ -1519,21 +1507,18 @@ nsIClassInfo *
 NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID)
 {
   if (aID >= eDOMClassInfoIDCount) {
     NS_ERROR("Bad ID!");
 
     return nullptr;
   }
 
-  if (!nsDOMClassInfo::sIsInitialized) {
-    nsresult rv = nsDOMClassInfo::Init();
-
-    NS_ENSURE_SUCCESS(rv, nullptr);
-  }
+  nsresult rv = RegisterDOMNames();
+  NS_ENSURE_SUCCESS(rv, nullptr);
 
   if (!sClassInfoData[aID].mCachedClassInfo) {
     nsDOMClassInfoData& data = sClassInfoData[aID];
 
     data.mCachedClassInfo = data.u.mConstructorFptr(&data);
     NS_ENSURE_TRUE(data.mCachedClassInfo, nullptr);
 
     NS_ADDREF(data.mCachedClassInfo);
@@ -1584,17 +1569,16 @@ nsDOMClassInfo::ShutDown()
 
   sLocation_id        = JSID_VOID;
   sConstructor_id     = JSID_VOID;
   sTop_id             = JSID_VOID;
   sDocument_id        = JSID_VOID;
   sWrappedJSObject_id = JSID_VOID;
 
   NS_IF_RELEASE(sXPConnect);
-  NS_IF_RELEASE(sSecMan);
   sIsInitialized = false;
 }
 
 // Window helper
 
 NS_IMETHODIMP
 nsWindowSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
                       JSObject *globalObj, JSObject **parentObj)
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -91,16 +91,17 @@ public:
   //
   // Whaaaaa! I wanted to name this method GetClassInfo, but nooo,
   // some of Microsoft devstudio's headers #defines GetClassInfo to
   // GetClassInfoA so I can't, those $%#@^! bastards!!! What gives
   // them the right to do that?
 
   static nsIClassInfo* GetClassInfoInstance(nsDOMClassInfoData* aData);
 
+  static nsresult Init();
   static void ShutDown();
 
   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
   {
     return new nsDOMClassInfo(aData);
   }
 
   /*
@@ -122,43 +123,37 @@ public:
   static bool ObjectIsNativeWrapper(JSContext* cx, JSObject* obj);
 
   static nsISupports *GetNative(nsIXPConnectWrappedNative *wrapper, JSObject *obj);
 
   static nsIXPConnect *XPConnect()
   {
     return sXPConnect;
   }
-  static nsIScriptSecurityManager *ScriptSecurityManager()
-  {
-    return sSecMan;
-  }
 
 protected:
   friend nsIClassInfo* NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID);
 
   const nsDOMClassInfoData* mData;
 
   virtual void PreserveWrapper(nsISupports *aNative) MOZ_OVERRIDE
   {
   }
 
   virtual uint32_t GetInterfacesBitmap() MOZ_OVERRIDE
   {
     return mData->mInterfacesBitmap;
   }
 
-  static nsresult Init();
   static nsresult RegisterClassProtos(int32_t aDOMClassInfoID);
   static nsresult RegisterExternalClasses();
   nsresult ResolveConstructor(JSContext *cx, JSObject *obj,
                               JSObject **objp);
 
   static nsIXPConnect *sXPConnect;
-  static nsIScriptSecurityManager *sSecMan;
 
   // nsIXPCScriptable code
   static nsresult DefineStaticJSVals(JSContext *cx);
 
   static bool sIsInitialized;
 
 public:
   static jsid sLocation_id;
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -38,16 +38,17 @@
 #include "mozilla/dom/DOMErrorBinding.h"
 #include "mozilla/dom/HTMLObjectElement.h"
 #include "mozilla/dom/HTMLObjectElementBinding.h"
 #include "mozilla/dom/HTMLSharedObjectElement.h"
 #include "mozilla/dom/HTMLEmbedElementBinding.h"
 #include "mozilla/dom/HTMLAppletElementBinding.h"
 #include "mozilla/dom/Promise.h"
 #include "WorkerPrivate.h"
+#include "nsDOMClassInfo.h"
 
 namespace mozilla {
 namespace dom {
 
 JSErrorFormatString ErrorFormatString[] = {
 #define MSG_DEF(_name, _argc, _str) \
   { _str, _argc, JSEXN_TYPEERR },
 #include "mozilla/dom/Errors.msg"
@@ -2556,16 +2557,44 @@ ConvertExceptionToPromise(JSContext* cx,
 
 /* static */
 void
 CreateGlobalOptions<nsGlobalWindow>::TraceGlobal(JSTracer* aTrc, JSObject* aObj)
 {
   xpc::TraceXPCGlobal(aTrc, aObj);
 }
 
+static bool sRegisteredDOMNames = false;
+
+nsresult
+RegisterDOMNames()
+{
+  if (sRegisteredDOMNames) {
+    return NS_OK;
+  }
+
+  nsresult rv = nsDOMClassInfo::Init();
+  if (NS_FAILED(rv)) {
+    NS_ERROR("Could not initialize nsDOMClassInfo");
+    return rv;
+  }
+
+  // Register new DOM bindings
+  nsScriptNameSpaceManager* nameSpaceManager = GetNameSpaceManager();
+  if (!nameSpaceManager) {
+    NS_ERROR("Could not initialize nsScriptNameSpaceManager");
+    return NS_ERROR_FAILURE;
+  }
+  mozilla::dom::Register(nameSpaceManager);
+
+  sRegisteredDOMNames = true;
+
+  return NS_OK;
+}
+
 /* static */
 bool
 CreateGlobalOptions<nsGlobalWindow>::PostCreateGlobal(JSContext* aCx,
                                                       JS::Handle<JSObject*> aGlobal)
 {
   // Invoking the XPCWrappedNativeScope constructor automatically hooks it
   // up to the compartment of aGlobal.
   (void) new XPCWrappedNativeScope(aCx, aGlobal);
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -2803,23 +2803,31 @@ struct CreateGlobalOptions<nsGlobalWindo
 {
   static MOZ_CONSTEXPR_VAR ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind =
     ProtoAndIfaceCache::WindowLike;
   static MOZ_CONSTEXPR_VAR bool ForceInitStandardClassesToFalse = false;
   static void TraceGlobal(JSTracer* aTrc, JSObject* aObj);
   static bool PostCreateGlobal(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
 };
 
+nsresult
+RegisterDOMNames();
+
 template <class T, ProtoGetter GetProto>
 bool
 CreateGlobal(JSContext* aCx, T* aNative, nsWrapperCache* aCache,
              const JSClass* aClass, JS::CompartmentOptions& aOptions,
              JSPrincipals* aPrincipal, bool aInitStandardClasses,
              JS::MutableHandle<JSObject*> aGlobal)
 {
+  nsresult rv = RegisterDOMNames();
+  if (NS_FAILED(rv)) {
+    return Throw(aCx, rv);
+  }
+
   aOptions.setTrace(CreateGlobalOptions<T>::TraceGlobal);
 
   aGlobal.set(JS_NewGlobalObject(aCx, aClass, aPrincipal,
                                  JS::DontFireOnNewGlobalHook, aOptions));
   if (!aGlobal) {
     NS_WARNING("Failed to create global");
     return false;
   }