diff options
author | Pale Moon <git-repo@palemoon.org> | 2015-06-03 16:35:13 +0200 |
---|---|---|
committer | Pale Moon <git-repo@palemoon.org> | 2015-06-03 16:35:13 +0200 |
commit | c5ae685a00f82017b66db0f19c1628df2ff75510 (patch) | |
tree | 58cb883b3d6e7e302f621be366b8db96ffebed72 /dom | |
parent | 5ae69ddc87d82e956dfb5d6c997a78fd42ec24f2 (diff) | |
download | palemoon-gre-c5ae685a00f82017b66db0f19c1628df2ff75510.tar.gz |
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)
Diffstat (limited to 'dom')
-rw-r--r-- | dom/base/nsDOMClassInfo.cpp | 57 | ||||
-rw-r--r-- | dom/base/nsDOMClassInfoClasses.h | 8 | ||||
-rw-r--r-- | dom/base/nsScriptNameSpaceManager.cpp | 69 | ||||
-rw-r--r-- | dom/base/nsScriptNameSpaceManager.h | 1 | ||||
-rw-r--r-- | dom/base/test/test_window_enumeration.html | 5 | ||||
-rw-r--r-- | dom/src/geolocation/nsGeolocation.cpp | 1 | ||||
-rw-r--r-- | dom/tests/mochitest/general/test_interfaces.html | 56 |
7 files changed, 71 insertions, 126 deletions
diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 02ec54b6c..9a3fce322 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -101,6 +101,13 @@ #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" // HTMLFormElement helper includes #include "nsIForm.h" @@ -378,6 +385,13 @@ 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, \ @@ -782,6 +796,21 @@ static nsDOMClassInfoData sClassInfoData[] = { 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) \ @@ -1862,6 +1891,34 @@ nsDOMClassInfo::Init() 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!"); diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 53ccd69f9..ddc4b77b0 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -184,3 +184,11 @@ 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) 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<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) { @@ -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<nsICategoryManager> cm = diff --git a/dom/base/nsScriptNameSpaceManager.h b/dom/base/nsScriptNameSpaceManager.h index a8adc4fbd..bbcce5d94 100644 --- a/dom/base/nsScriptNameSpaceManager.h +++ b/dom/base/nsScriptNameSpaceManager.h @@ -174,7 +174,6 @@ private: nsresult FillHash(nsICategoryManager *aCategoryManager, const char *aCategory); - nsresult FillHashWithDOMInterfaces(); nsresult RegisterInterface(const char* aIfName, const nsIID *aIfIID, bool* aFoundOld); diff --git a/dom/base/test/test_window_enumeration.html b/dom/base/test/test_window_enumeration.html index 584bcddf5..646e86af5 100644 --- a/dom/base/test/test_window_enumeration.html +++ b/dom/base/test/test_window_enumeration.html @@ -19,8 +19,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=807222 <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) { diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index f312a25f4..d50a88879 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -222,6 +222,7 @@ private: //////////////////////////////////////////////////// // PositionError //////////////////////////////////////////////////// +DOMCI_DATA(GeoPositionError, PositionError) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PositionError) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html index e1996b8ad..372416f17 100644 --- a/dom/tests/mochitest/general/test_interfaces.html +++ b/dom/tests/mochitest/general/test_interfaces.html @@ -53,13 +53,9 @@ var interfaceNamesInGlobalScope = "CommandEvent", "Comment", "CompositionEvent", - "Contact", - "ContactManager", "Controllers", - "Counter", "CRMFObject", "Crypto", - "CryptoDialogs", "CSS2Properties", "CSSCharsetRule", "CSSConditionRule", @@ -77,13 +73,11 @@ var interfaceNamesInGlobalScope = "CSSStyleRule", "CSSStyleSheet", "CSSSupportsRule", - "CSSUnknownRule", "CSSValue", "CSSValueList", "CustomEvent", "DataChannel", "DataContainerEvent", - "DataErrorEvent", "DataTransfer", "DesktopNotification", "DesktopNotificationCenter", @@ -98,9 +92,7 @@ var interfaceNamesInGlobalScope = "DeviceStorageCursor", "Document", "DocumentFragment", - "DocumentTouch", "DocumentType", - "DocumentXBL", "DOMCursor", "DOMError", "DOMException", @@ -113,11 +105,9 @@ var interfaceNamesInGlobalScope = "DOMTransactionEvent", "DragEvent", "Element", - "ElementCSSInlineStyle", "ElementReplaceEvent", "ElementTimeControl", "Event", - "EventListener", "EventListenerInfo", "EventSource", "EventTarget", @@ -127,23 +117,12 @@ var interfaceNamesInGlobalScope = "FileReader", "FileRequest", "FocusEvent", - "FontFace", - "FontFaceList", "FormData", "Gamepad", "GamepadAxisMoveEvent", "GamepadButtonEvent", "GamepadEvent", - "GeoGeolocation", - "GeoPosition", - "GeoPositionCallback", - "GeoPositionCoords", "GeoPositionError", - "GeoPositionErrorCallback", - "GetUserMediaErrorCallback", - "GetUserMediaSuccessCallback", - "GlobalObjectConstructor", - "GlobalPropertyInitializer", "HashChangeEvent", "History", "HTMLAnchorElement", @@ -154,7 +133,6 @@ var interfaceNamesInGlobalScope = "HTMLBodyElement", "HTMLBRElement", "HTMLButtonElement", - "HTMLByteRanges", "HTMLCanvasElement", "HTMLCollection", "HTMLCommandElement", @@ -228,9 +206,7 @@ var interfaceNamesInGlobalScope = "IDBVersionChangeEvent", "ImageData", "JSON", - "JSWindow", "KeyEvent", - "LinkStyle", "LoadStatus", "LocalMediaStream", "Location", @@ -239,7 +215,6 @@ var interfaceNamesInGlobalScope = "MediaError", "MediaList", "MediaQueryList", - "MediaQueryListListener", "MediaStream", "MessageEvent", "MimeType", @@ -247,10 +222,8 @@ var interfaceNamesInGlobalScope = "ModalContentWindow", "MouseEvent", "MouseScrollEvent", - "MozAlarmsManager", "MozApplicationEvent", "MozBlobBuilder", - "MozBrowserFrame", "MozCanvasPrintState", "MozConnection", "MozContactChangeEvent", @@ -281,7 +254,6 @@ var interfaceNamesInGlobalScope = "MozTimeManager", "MozTouchEvent", "MozWakeLock", - "MozWakeLockListener", "MutationEvent", "MutationObserver", "MutationRecord", @@ -298,23 +270,16 @@ var interfaceNamesInGlobalScope = "NodeSelector", "NotifyAudioAvailableEvent", "NotifyPaintEvent", - "NSEditableElement", - "NSEvent", "NSRGBAColor", - "NSXPathExpression", "OfflineResourceList", "OpenWindowEventDetail", "PageTransitionEvent", "PaintRequest", "PaintRequestList", - "Parser", - "ParserJS", "PaymentRequestInfo", "Performance", "PerformanceNavigation", "PerformanceTiming", - "PermissionSettings", - "Pkcs11", "Plugin", "PluginArray", "PopStateEvent", @@ -322,10 +287,8 @@ var interfaceNamesInGlobalScope = "ProcessingInstruction", "ProgressEvent", "PropertyNodeList", - "PushManager", "Range", "Rect", - "RequestService", "RGBColor", "RTCIceCandidate", "RTCPeerConnection", @@ -333,7 +296,6 @@ var interfaceNamesInGlobalScope = "Screen", "ScrollAreaEvent", "Selection", - "Serializer", "SettingsLock", "SettingsManager", "SimpleGestureEvent", @@ -343,9 +305,7 @@ var interfaceNamesInGlobalScope = "SpeechSynthesisEvent", "Storage", "StorageEvent", - "StorageIndexedDB", "StorageItem", - "StorageManager", "StorageObsolete", "StyleRuleChangeEvent", "StyleSheet", @@ -487,7 +447,6 @@ var interfaceNamesInGlobalScope = "TextMetrics", "TimeEvent", "TimeRanges", - "ToString", "Touch", "TouchEvent", "TouchList", @@ -508,9 +467,6 @@ var interfaceNamesInGlobalScope = "WebSocket", "WheelEvent", "Window", - "WindowCollection", - "WindowInternal", - "WindowPerformance", "WindowUtils", "XMLDocument", "XMLHttpRequest", @@ -526,25 +482,13 @@ var interfaceNamesInGlobalScope = "XULCheckboxElement", "XULCommandDispatcher", "XULCommandEvent", - "XULContainerElement", - "XULContainerItemElement", "XULControlElement", - "XULDescriptionElement", "XULDocument", "XULElement", - "XULImageElement", "XULLabeledControlElement", - "XULLabelElement", - "XULMenuListElement", - "XULMultiSelectControlElement", "XULPopupElement", - "XULRelatedElement", - "XULSelectControlElement", - "XULSelectControlItemElement", "XULTemplateBuilder", - "XULTextBoxElement", "XULTreeBuilder", - "XULTreeElement", ] // IMPORTANT: Do not change this list without review from a DOM peer! |