Bug 898817 - Stop exposing nsIDOM* interfaces on the global automatically. r=bz
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Tue, 30 Jul 2013 22:26:27 +0900
changeset 152842 2480ee8346d6007f910aabecb1d5682be8c094df
parent 152841 1f738fae18a278145a365f3182a1ab57e204d7be
child 152843 a8762aa7ab20fb1ac648e7613d9e72d5ed553f8f
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs898817
milestone25.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 898817 - Stop exposing nsIDOM* interfaces on the global automatically. r=bz
content/events/test/Makefile.in
content/events/test/test_bug716822.html
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/base/nsScriptNameSpaceManager.cpp
dom/base/nsScriptNameSpaceManager.h
dom/base/test/test_window_enumeration.html
dom/src/geolocation/nsGeolocation.cpp
--- a/content/events/test/Makefile.in
+++ b/content/events/test/Makefile.in
@@ -91,17 +91,16 @@ MOCHITEST_FILES = \
 		test_dom_keyboard_event.html \
 		test_dom_mouse_event.html \
 		test_dom_wheel_event.html \
 		test_continuous_wheel_events.html \
 		test_moz_mouse_pixel_scroll_event.html \
 		test_wheel_default_action.html \
 		window_wheel_default_action.html \
 		test_bug603008.html \
-		test_bug716822.html \
 		test_bug742376.html \
 		test_dragstart.html \
 		test_bug812744.html \
 		test_addEventListenerExtraArg.html \
 		test_focus_disabled.html \
 		test_bug847597.html \
 		test_bug855741.html \
 		test_dblclick_explicit_original_target.html \
deleted file mode 100644
--- a/content/events/test/test_bug716822.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=716822
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 716822</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=716822">Mozilla Bug 716822</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script type="application/javascript">
-/** Test for Bug 716822 **/
-for (var p in window.NSEvent) {
-  ok(p in window.Event, p + " should be in Event.");
-  is(window.NSEvent[p], window.Event[p], "Value of " + p);
-}
-</script>
-</pre>
-</body>
-</html>
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -93,16 +93,23 @@
 #include "nsIDOMChromeWindow.h"
 #include "nsIDOMConstructor.h"
 
 // DOM core includes
 #include "nsError.h"
 #include "nsIDOMDOMException.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMDOMStringList.h"
+#include "nsIDOMUserDataHandler.h"
+#include "nsIDOMGeoPositionError.h"
+#include "nsIDOMLoadStatus.h"
+#include "nsIDOMXPathNamespace.h"
+#include "nsIDOMXULButtonElement.h"
+#include "nsIDOMXULCheckboxElement.h"
+#include "nsIDOMXULPopupElement.h"
 
 // Event related includes
 #include "nsEventListenerManager.h"
 #include "nsIDOMEventTarget.h"
 
 // CSS related includes
 #include "nsCSSRules.h"
 #include "nsIDOMStyleSheet.h"
@@ -321,16 +328,23 @@ DOMCI_DATA_NO_CLASS(Crypto)
 
 DOMCI_DATA_NO_CLASS(ContentFrameMessageManager)
 DOMCI_DATA_NO_CLASS(ChromeMessageBroadcaster)
 DOMCI_DATA_NO_CLASS(ChromeMessageSender)
 
 DOMCI_DATA_NO_CLASS(DOMPrototype)
 DOMCI_DATA_NO_CLASS(DOMConstructor)
 
+DOMCI_DATA_NO_CLASS(UserDataHandler)
+DOMCI_DATA_NO_CLASS(LoadStatus)
+DOMCI_DATA_NO_CLASS(XPathNamespace)
+DOMCI_DATA_NO_CLASS(XULButtonElement)
+DOMCI_DATA_NO_CLASS(XULCheckboxElement)
+DOMCI_DATA_NO_CLASS(XULPopupElement)
+
 #define NS_DEFINE_CLASSINFO_DATA_WITH_NAME(_class, _name, _helper,            \
                                            _flags)                            \
   { #_name,                                                                   \
     nullptr,                                                                   \
     { _helper::doCreate },                                                    \
     nullptr,                                                                   \
     nullptr,                                                                   \
     nullptr,                                                                   \
@@ -684,16 +698,31 @@ static nsDOMClassInfoData sClassInfoData
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(AsyncScrollEventDetail, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(LockedFile, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CSSFontFeatureValuesRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
+
+  NS_DEFINE_CLASSINFO_DATA(UserDataHandler, nsDOMGenericSH,
+                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
+  NS_DEFINE_CLASSINFO_DATA(GeoPositionError, nsDOMGenericSH,
+                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
+  NS_DEFINE_CLASSINFO_DATA(LoadStatus, nsDOMGenericSH,
+                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
+  NS_DEFINE_CLASSINFO_DATA(XPathNamespace, nsDOMGenericSH,
+                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
+  NS_DEFINE_CLASSINFO_DATA(XULButtonElement, nsDOMGenericSH,
+                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
+  NS_DEFINE_CLASSINFO_DATA(XULCheckboxElement, nsDOMGenericSH,
+                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
+  NS_DEFINE_CLASSINFO_DATA(XULPopupElement, nsDOMGenericSH,
+                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
 };
 
 #define NS_DEFINE_CONTRACT_CTOR(_class, _contract_id)                           \
   static nsresult                                                               \
   _class##Ctor(nsISupports** aInstancePtrResult)                                \
   {                                                                             \
     nsresult rv = NS_OK;                                                        \
     nsCOMPtr<nsISupports> native = do_CreateInstance(_contract_id, &rv);        \
@@ -1624,16 +1653,44 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_BEGIN(LockedFile, nsIDOMLockedFile)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMLockedFile)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(CSSFontFeatureValuesRule, nsIDOMCSSFontFeatureValuesRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFeatureValuesRule)
   DOM_CLASSINFO_MAP_END
 
+  DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(UserDataHandler, nsIDOMUserDataHandler)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMUserDataHandler)
+  DOM_CLASSINFO_MAP_END
+
+  DOM_CLASSINFO_MAP_BEGIN(GeoPositionError, nsIDOMGeoPositionError)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionError)
+  DOM_CLASSINFO_MAP_END
+
+  DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(LoadStatus, nsIDOMLoadStatus)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMLoadStatus)
+  DOM_CLASSINFO_MAP_END
+
+  DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XPathNamespace, nsIDOMXPathNamespace)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathNamespace)
+  DOM_CLASSINFO_MAP_END
+
+  DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULButtonElement, nsIDOMXULButtonElement)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULButtonElement)
+  DOM_CLASSINFO_MAP_END
+
+  DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULCheckboxElement, nsIDOMXULCheckboxElement)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCheckboxElement)
+  DOM_CLASSINFO_MAP_END
+
+  DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULPopupElement, nsIDOMXULPopupElement)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULPopupElement)
+  DOM_CLASSINFO_MAP_END
+
   MOZ_STATIC_ASSERT(MOZ_ARRAY_LENGTH(sClassInfoData) == eDOMClassInfoIDCount,
                     "The number of items in sClassInfoData doesn't match the "
                     "number of nsIDOMClassInfo ID's, this is bad! Fix it!");
 
 #ifdef DEBUG
   for (size_t i = 0; i < eDOMClassInfoIDCount; i++) {
     if (!sClassInfoData[i].u.mConstructorFptr ||
         sClassInfoData[i].mDebugID != i) {
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -157,8 +157,16 @@ DOMCI_CLASS(CameraControl)
 DOMCI_CLASS(CameraCapabilities)
 
 DOMCI_CLASS(OpenWindowEventDetail)
 DOMCI_CLASS(AsyncScrollEventDetail)
 
 DOMCI_CLASS(LockedFile)
 
 DOMCI_CLASS(CSSFontFeatureValuesRule)
+
+DOMCI_CLASS(UserDataHandler)
+DOMCI_CLASS(GeoPositionError)
+DOMCI_CLASS(LoadStatus)
+DOMCI_CLASS(XPathNamespace)
+DOMCI_CLASS(XULButtonElement)
+DOMCI_CLASS(XULCheckboxElement)
+DOMCI_CLASS(XULPopupElement)
--- a/dom/base/nsScriptNameSpaceManager.cpp
+++ b/dom/base/nsScriptNameSpaceManager.cpp
@@ -209,79 +209,16 @@ nsScriptNameSpaceManager::FillHash(nsICa
       return rv;
     }
   }
 
   return NS_OK;
 }
 
 
-// This method enumerates over all installed interfaces (in .xpt
-// files) and finds ones that start with "nsIDOM" and has constants
-// defined in the interface itself (inherited constants doesn't
-// count), once such an interface is found the "nsIDOM" prefix is cut
-// off the name and the rest of the name is added into the hash for
-// global names. This makes things like 'Node.ELEMENT_NODE' work in
-// JS. See nsCommonWindowSH::GlobalResolve() for detais on how this is used.
-
-nsresult
-nsScriptNameSpaceManager::FillHashWithDOMInterfaces()
-{
-  nsCOMPtr<nsIInterfaceInfoManager>
-    iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
-  NS_ENSURE_TRUE(iim, NS_ERROR_UNEXPECTED);
-
-  // First look for all interfaces whose name starts with nsIDOM
-  nsCOMPtr<nsIEnumerator> domInterfaces;
-  nsresult rv =
-    iim->EnumerateInterfacesWhoseNamesStartWith(NS_DOM_INTERFACE_PREFIX,
-                                                getter_AddRefs(domInterfaces));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsISupports> entry;
-
-  rv = domInterfaces->First();
-
-  if (NS_FAILED(rv)) {
-    // Empty interface list?
-
-    NS_WARNING("What, no nsIDOM interfaces installed?");
-
-    return NS_OK;
-  }
-
-  bool found_old;
-  nsCOMPtr<nsIInterfaceInfo> if_info;
-  const char *if_name = nullptr;
-  const nsIID *iid;
-
-  for ( ;
-       domInterfaces->IsDone() == static_cast<nsresult>(NS_ENUMERATOR_FALSE);
-       domInterfaces->Next()) {
-    rv = domInterfaces->CurrentItem(getter_AddRefs(entry));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    nsCOMPtr<nsIInterfaceInfo> if_info(do_QueryInterface(entry));
-    if_info->GetNameShared(&if_name);
-    if_info->GetIIDShared(&iid);
-    rv = RegisterInterface(if_name + sizeof(NS_DOM_INTERFACE_PREFIX) - 1,
-                           iid, &found_old);
-
-#ifdef DEBUG
-    NS_ASSERTION(!found_old,
-                 "Whaaa, interface name already in hash!");
-#endif
-  }
-
-  // Next, look for externally registered DOM interfaces
-  rv = RegisterExternalInterfaces(false);
-
-  return rv;
-}
-
 nsresult
 nsScriptNameSpaceManager::RegisterExternalInterfaces(bool aAsProto)
 {
   nsresult rv;
   nsCOMPtr<nsICategoryManager> cm =
     do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -336,20 +273,16 @@ nsScriptNameSpaceManager::RegisterExtern
       }
 
       if_info->GetNameShared(&if_name);
       dom_prefix = (strncmp(if_name, NS_DOM_INTERFACE_PREFIX,
                             sizeof(NS_DOM_INTERFACE_PREFIX) - 1) == 0);
 
       const char* name;
       if (dom_prefix) {
-        if (!aAsProto) {
-          // nsIDOM* interfaces have already been registered.
-          break;
-        }
         name = if_name + sizeof(NS_DOM_INTERFACE_PREFIX) - 1;
       } else {
         name = if_name + sizeof(NS_INTERFACE_PREFIX) - 1;
       }
 
       if (aAsProto) {
         RegisterClassProto(name, iid, &found_old);
       } else {
@@ -422,17 +355,17 @@ nsScriptNameSpaceManager::Init()
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   mReporter = new ScriptNameSpaceManagerReporter(this);
   NS_RegisterMemoryReporter(mReporter);
 
   nsresult rv = NS_OK;
 
-  rv = FillHashWithDOMInterfaces();
+  rv = RegisterExternalInterfaces(false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsICategoryManager> cm =
     do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = FillHash(cm, JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/base/nsScriptNameSpaceManager.h
+++ b/dom/base/nsScriptNameSpaceManager.h
@@ -170,17 +170,16 @@ private:
                                 const PRUnichar **aClassName = nullptr)
   {
     NS_ConvertASCIItoUTF16 key(aKey);
     return AddToHash(aTable, &key, aClassName);
   }
 
   nsresult FillHash(nsICategoryManager *aCategoryManager,
                     const char *aCategory);
-  nsresult FillHashWithDOMInterfaces();
   nsresult RegisterInterface(const char* aIfName,
                              const nsIID *aIfIID,
                              bool* aFoundOld);
 
   /**
    * Add a new category entry into the hash table.
    * Only some categories can be added (see the beginning of the definition).
    * The other ones will be ignored.
--- a/dom/base/test/test_window_enumeration.html
+++ b/dom/base/test/test_window_enumeration.html
@@ -14,18 +14,21 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 807222 **/
-var expectedProps = [ "Image", "Audio", "Option", "USSDReceivedEvent",
+var expectedProps = [ "Image", "Audio", "Option",
                       "PerformanceTiming", "CSS2Properties", "SVGElement" ];
+if (navigator.mozTelephony) {
+  expectedProps.push("USSDReceivedEvent");
+}
 var actualProps = Object.getOwnPropertyNames(window);
 
 for (var i = 0; i < expectedProps.length; ++i) {
   isnot(actualProps.indexOf(expectedProps[i]), -1,
         "getOwnPropertyNames should include " + expectedProps[i]);
 }
 </script>
 </pre>
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -220,16 +220,17 @@ public:
 
 private:
   nsRefPtr<nsGeolocationRequest> mRequest;
 };
 
 ////////////////////////////////////////////////////
 // PositionError
 ////////////////////////////////////////////////////
+DOMCI_DATA(GeoPositionError, PositionError)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PositionError)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPositionError)
   NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionError)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(PositionError, mParent)