From c5ae685a00f82017b66db0f19c1628df2ff75510 Mon Sep 17 00:00:00 2001 From: Pale Moon Date: Wed, 3 Jun 2015 16:35:13 +0200 Subject: Remove implicit access to internal/XUL interfaces and classes from the global window instance. (This will also fix sites that incorrectly try to use it, i.e.: issue #89 will be solved) --- dom/base/nsScriptNameSpaceManager.cpp | 69 +---------------------------------- 1 file changed, 1 insertion(+), 68 deletions(-) (limited to 'dom/base/nsScriptNameSpaceManager.cpp') diff --git a/dom/base/nsScriptNameSpaceManager.cpp b/dom/base/nsScriptNameSpaceManager.cpp index ac32f4cd1..bf7e2af65 100644 --- a/dom/base/nsScriptNameSpaceManager.cpp +++ b/dom/base/nsScriptNameSpaceManager.cpp @@ -213,69 +213,6 @@ nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager, } -// 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 - 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 domInterfaces; - nsresult rv = - iim->EnumerateInterfacesWhoseNamesStartWith(NS_DOM_INTERFACE_PREFIX, - getter_AddRefs(domInterfaces)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr 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 if_info; - const char *if_name = nullptr; - const nsIID *iid; - - for ( ; - domInterfaces->IsDone() == static_cast(NS_ENUMERATOR_FALSE); - domInterfaces->Next()) { - rv = domInterfaces->CurrentItem(getter_AddRefs(entry)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr 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) { @@ -340,10 +277,6 @@ nsScriptNameSpaceManager::RegisterExternalInterfaces(bool aAsProto) 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; @@ -426,7 +359,7 @@ nsScriptNameSpaceManager::Init() nsresult rv = NS_OK; - rv = FillHashWithDOMInterfaces(); + rv = RegisterExternalInterfaces(false); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr cm = -- cgit v1.2.3