diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 61857b34e0867..bafda1fd1dd37 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -63,6 +63,8 @@ #include "nsContentUtils.h" #include "nsJSUtils.h" #include "nsILoadInfo.h" +#include "nsIDOMXULCommandDispatcher.h" +#include "nsITreeSelection.h" // This should be probably defined on some other place... but I couldn't find it #define WEBAPPS_PERM_NAME "webapps-manage" @@ -1208,7 +1210,8 @@ nsScriptSecurityManager::CanCreateWrapper(JSContext *cx, } // We give remote-XUL whitelisted domains a free pass here. See bug 932906. - if (!xpc::AllowContentXBLScope(js::GetContextCompartment(cx))) + JSCompartment* contextCompartment = js::GetContextCompartment(cx); + if (!xpc::AllowContentXBLScope(contextCompartment)) { return NS_OK; } @@ -1218,6 +1221,20 @@ nsScriptSecurityManager::CanCreateWrapper(JSContext *cx, return NS_OK; } + // We want to expose nsIDOMXULCommandDispatcher and nsITreeSelection implementations + // in XBL scopes. + if (xpc::IsContentXBLScope(contextCompartment)) { + nsCOMPtr dispatcher = do_QueryInterface(aObj); + if (dispatcher) { + return NS_OK; + } + + nsCOMPtr treeSelection = do_QueryInterface(aObj); + if (treeSelection) { + return NS_OK; + } + } + //-- Access denied, report an error NS_ConvertUTF8toUTF16 strName("CreateWrapperDenied"); nsAutoCString origin; diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 3f6bbb36cbc36..023acb6f1c680 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -73,10 +73,7 @@ #include "nsMemory.h" // includes needed for the prototype chain interfaces -#include "nsIDOMXULCommandDispatcher.h" -#include "nsIControllers.h" #ifdef MOZ_XUL -#include "nsITreeSelection.h" #include "nsITreeContentView.h" #include "nsITreeView.h" #include "nsIXULTemplateBuilder.h" @@ -180,19 +177,8 @@ static nsDOMClassInfoData sClassInfoData[] = { // XUL classes #ifdef MOZ_XUL - NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULCommandDispatcher, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) -#endif - NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULControllers, nsNonDOMObjectSH, - DEFAULT_SCRIPTABLE_FLAGS) -#ifdef MOZ_XUL - NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(TreeSelection, nsDOMGenericSH, - DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(TreeContentView, nsDOMGenericSH, DEFAULT_SCRIPTABLE_FLAGS) -#endif - -#ifdef MOZ_XUL NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULTemplateBuilder, nsDOMGenericSH, DEFAULT_SCRIPTABLE_FLAGS) @@ -469,27 +455,11 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_END #ifdef MOZ_XUL - DOM_CLASSINFO_MAP_BEGIN(XULCommandDispatcher, nsIDOMXULCommandDispatcher) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandDispatcher) - DOM_CLASSINFO_MAP_END -#endif - - DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULControllers, nsIControllers) - DOM_CLASSINFO_MAP_ENTRY(nsIControllers) - DOM_CLASSINFO_MAP_END - -#ifdef MOZ_XUL - DOM_CLASSINFO_MAP_BEGIN(TreeSelection, nsITreeSelection) - DOM_CLASSINFO_MAP_ENTRY(nsITreeSelection) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(TreeContentView, nsITreeContentView) DOM_CLASSINFO_MAP_ENTRY(nsITreeContentView) DOM_CLASSINFO_MAP_ENTRY(nsITreeView) DOM_CLASSINFO_MAP_END -#endif -#ifdef MOZ_XUL DOM_CLASSINFO_MAP_BEGIN(XULTemplateBuilder, nsIXULTemplateBuilder) DOM_CLASSINFO_MAP_ENTRY(nsIXULTemplateBuilder) DOM_CLASSINFO_MAP_END @@ -1628,6 +1598,9 @@ nsWindowSH::NameStructEnabled(JSContext* aCx, nsGlobalWindow *aWin, #ifdef USE_CONTROLLERS_SHIM static const JSClass ControllersShimClass = { + "Controllers", 0 +}; +static const JSClass XULControllersShimClass = { "XULControllers", 0 }; #endif @@ -1646,15 +1619,22 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx, // Note: We use |obj| rather than |aWin| to get the principal here, because // this is called during Window setup when the Document isn't necessarily // hooked up yet. - if (id == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS) && + if ((id == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS) || + id == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS_CLASS)) && !xpc::IsXrayWrapper(obj) && !nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(obj))) { if (aWin->GetDoc()) { aWin->GetDoc()->WarnOnceAbout(nsIDocument::eWindow_Controllers); } + const JSClass* clazz; + if (id == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS)) { + clazz = &XULControllersShimClass; + } else { + clazz = &ControllersShimClass; + } MOZ_ASSERT(JS_IsGlobalObject(obj)); - JS::Rooted shim(cx, JS_NewObject(cx, &ControllersShimClass)); + JS::Rooted shim(cx, JS_NewObject(cx, clazz)); if (NS_WARN_IF(!shim)) { return NS_ERROR_OUT_OF_MEMORY; } @@ -2038,16 +2018,6 @@ nsDOMConstructorSH::HasInstance(nsIXPConnectWrappedNative *wrapper, return wrapped->HasInstance(wrapper, cx, obj, val, bp, _retval); } -NS_IMETHODIMP -nsNonDOMObjectSH::GetFlags(uint32_t *aFlags) -{ - // This is NOT a DOM Object. Use this helper class for cases when you need - // to do something like implement nsISecurityCheckedComponent in a meaningful - // way. - *aFlags = nsIClassInfo::MAIN_THREAD_ONLY | nsIClassInfo::SINGLETON_CLASSINFO; - return NS_OK; -} - // nsContentFrameMessageManagerSH template diff --git a/dom/base/nsDOMClassInfo.h b/dom/base/nsDOMClassInfo.h index c63044627bdd5..d6f483e696a47 100644 --- a/dom/base/nsDOMClassInfo.h +++ b/dom/base/nsDOMClassInfo.h @@ -257,26 +257,6 @@ class nsDOMConstructorSH : public nsDOMGenericSH } }; -class nsNonDOMObjectSH : public nsDOMGenericSH -{ -protected: - explicit nsNonDOMObjectSH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData) - { - } - - virtual ~nsNonDOMObjectSH() - { - } - -public: - NS_IMETHOD GetFlags(uint32_t *aFlags) override; - - static nsIClassInfo *doCreate(nsDOMClassInfoData* aData) - { - return new nsNonDOMObjectSH(aData); - } -}; - template class nsMessageManagerSH : public Super { diff --git a/dom/base/nsDOMClassInfoID.h b/dom/base/nsDOMClassInfoID.h index 654cee2a0b866..d8bd50118d14a 100644 --- a/dom/base/nsDOMClassInfoID.h +++ b/dom/base/nsDOMClassInfoID.h @@ -21,11 +21,6 @@ enum nsDOMClassInfoID // XUL classes #ifdef MOZ_XUL - eDOMClassInfo_XULCommandDispatcher_id, -#endif - eDOMClassInfo_XULControllers_id, -#ifdef MOZ_XUL - eDOMClassInfo_TreeSelection_id, eDOMClassInfo_TreeContentView_id, #endif diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 35cad79b60a09..981069a8958c0 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -5127,9 +5127,10 @@ nsGlobalWindow::MayResolve(jsid aId) return true; } - if (aId == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS)) { - // We only resolve .controllers in release builds and on non-chrome windows, - // but let's not worry about any of that stuff. + if (aId == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS) || + aId == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS_CLASS)) { + // We only resolve .controllers/.Controllers in release builds and on non-chrome + // windows, but let's not worry about any of that stuff. return true; } diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index a70d578e1c77a..89db6d1c532d1 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1730,7 +1730,7 @@ addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True) addExternalIface('LoadInfo', nativeType='nsILoadInfo', headerFile='nsILoadInfo.h', notflattened=True) addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True) -addExternalIface('MozControllers', nativeType='nsIControllers') +addExternalIface('XULControllers', nativeType='nsIControllers', notflattened=True) addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True) addExternalIface('MozObserver', nativeType='nsIObserver', notflattened=True) addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource', @@ -1742,7 +1742,6 @@ addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h') addExternalIface('MozXULTemplateBuilder', nativeType='nsIXULTemplateBuilder') addExternalIface('nsIBrowserDOMWindow', nativeType='nsIBrowserDOMWindow', notflattened=True) -addExternalIface('nsIControllers', nativeType='nsIControllers') addExternalIface('nsIDOMCrypto', nativeType='nsIDOMCrypto', headerFile='Crypto.h') addExternalIface('nsIFile', nativeType='nsIFile', notflattened=True) @@ -1766,4 +1765,4 @@ addExternalIface('StackFrame', nativeType='nsIStackFrame', headerFile='nsIException.h', notflattened=True) addExternalIface('URI', nativeType='nsIURI', headerFile='nsIURI.h', notflattened=True) -addExternalIface('XULCommandDispatcher') +addExternalIface('XULCommandDispatcher', notflattened=True) diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties index ebb63399c6341..ffd03e8a80807 100644 --- a/dom/locales/en-US/chrome/dom/dom.properties +++ b/dom/locales/en-US/chrome/dom/dom.properties @@ -189,8 +189,8 @@ Window_ContentWarning=window._content is deprecated. Please use window.content # LOCALIZATION NOTE: Do not translate "XMLHttpRequest" SyncXMLHttpRequestWarning=Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/ ImplicitMetaViewportTagFallback=No meta-viewport tag found. Please explicitly specify one to prevent unexpected behavioural changes in future versions. For more help https://developer.mozilla.org/en/docs/Mozilla/Mobile/Viewport_meta_tag -# LOCALIZATION NOTE: Do not translate "window.controllers" -Window_ControllersWarning=window.controllers is deprecated. Do not use it for UA detection. +# LOCALIZATION NOTE: Do not translate "window.controllers/Controllers" +Window_ControllersWarning=window.controllers/Controllers is deprecated. Do not use it for UA detection. ImportXULIntoContentWarning=Importing XUL nodes into a content document is deprecated. This functionality may be removed soon. XMLDocumentLoadPrincipalMismatch=Use of document.load forbidden on Documents that come from other Windows. Only the Window in which a Document was created is allowed to call .load on that Document. Preferably, use XMLHttpRequest instead. # LOCALIZATION NOTE: Do not translate "IndexedDB". diff --git a/dom/tests/mochitest/general/test_interfaces.js b/dom/tests/mochitest/general/test_interfaces.js index 4ee807efb7869..2c4577b30efb7 100644 --- a/dom/tests/mochitest/general/test_interfaces.js +++ b/dom/tests/mochitest/general/test_interfaces.js @@ -195,8 +195,6 @@ var interfaceNamesInGlobalScope = "CompositionEvent", // IMPORTANT: Do not change this list without review from a DOM peer! "ConstantSourceNode", -// IMPORTANT: Do not change this list without review from a DOM peer! - "Controllers", // IMPORTANT: Do not change this list without review from a DOM peer! "ConvolverNode", // IMPORTANT: Do not change this list without review from a DOM peer! @@ -1156,8 +1154,6 @@ var interfaceNamesInGlobalScope = {name: "TreeColumns", xbl: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "TreeContentView", xbl: true}, -// IMPORTANT: Do not change this list without review from a DOM peer! - {name: "TreeSelection", xbl: true}, // IMPORTANT: Do not change this list without review from a DOM peer! "TreeWalker", // IMPORTANT: Do not change this list without review from a DOM peer! @@ -1272,14 +1268,10 @@ var interfaceNamesInGlobalScope = {name: "XULButtonElement", xbl: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "XULCheckboxElement", xbl: true}, -// IMPORTANT: Do not change this list without review from a DOM peer! - {name: "XULCommandDispatcher", xbl: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "XULCommandEvent", xbl: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "XULControlElement", xbl: true}, -// IMPORTANT: Do not change this list without review from a DOM peer! - {name: "XULControllers", xbl: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "XULDocument", xbl: true}, // IMPORTANT: Do not change this list without review from a DOM peer! diff --git a/dom/webidl/HTMLInputElement.webidl b/dom/webidl/HTMLInputElement.webidl index d4e27dd5cc1dc..3fa29e4d40c92 100644 --- a/dom/webidl/HTMLInputElement.webidl +++ b/dom/webidl/HTMLInputElement.webidl @@ -19,7 +19,7 @@ enum SelectionMode { "preserve", }; -interface nsIControllers; +interface XULControllers; [HTMLConstructor] interface HTMLInputElement : HTMLElement { @@ -144,7 +144,7 @@ partial interface HTMLInputElement { partial interface HTMLInputElement { [GetterThrows, ChromeOnly] - readonly attribute nsIControllers controllers; + readonly attribute XULControllers controllers; // Binaryname because we have a FragmentOrElement function named "TextLength()". [NeedsCallerType, BinaryName="inputTextLength"] readonly attribute long textLength; diff --git a/dom/webidl/HTMLTextAreaElement.webidl b/dom/webidl/HTMLTextAreaElement.webidl index c693703c51ccf..6cb2376c8c621 100644 --- a/dom/webidl/HTMLTextAreaElement.webidl +++ b/dom/webidl/HTMLTextAreaElement.webidl @@ -12,7 +12,7 @@ */ interface nsIEditor; -interface MozControllers; +interface XULControllers; [HTMLConstructor] interface HTMLTextAreaElement : HTMLElement { @@ -81,7 +81,7 @@ partial interface HTMLTextAreaElement { // Please make sure to update this list of nsIDOMHTMLTextAreaElement changes. [Throws, ChromeOnly] - readonly attribute MozControllers controllers; + readonly attribute XULControllers controllers; }; partial interface HTMLTextAreaElement { diff --git a/dom/webidl/Window.webidl b/dom/webidl/Window.webidl index bf47ecc6aa267..6a01b101f0f65 100644 --- a/dom/webidl/Window.webidl +++ b/dom/webidl/Window.webidl @@ -24,6 +24,7 @@ interface IID; interface nsIBrowserDOMWindow; interface nsIMessageBroadcaster; interface nsIDOMCrypto; +interface XULControllers; // http://www.whatwg.org/specs/web-apps/current-work/ [PrimaryGlobal, LegacyUnenumerableNamedProperties, NeedResolve] @@ -263,7 +264,7 @@ partial interface Window { [Throws, UnsafeInPrerendering, NeedsCallerType] void sizeToContent(); // XXX Shouldn't this be in nsIDOMChromeWindow? - [ChromeOnly, Replaceable, Throws] readonly attribute MozControllers controllers; + [ChromeOnly, Replaceable, Throws] readonly attribute XULControllers controllers; [ChromeOnly, Throws] readonly attribute Element? realFrameElement; diff --git a/dom/webidl/XULElement.webidl b/dom/webidl/XULElement.webidl index 5e1b67758d0b0..fd5099ae4d843 100644 --- a/dom/webidl/XULElement.webidl +++ b/dom/webidl/XULElement.webidl @@ -4,7 +4,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ -interface MozControllers; +interface XULControllers; interface MozFrameLoader; interface MozRDFCompositeDataSource; interface MozRDFResource; @@ -88,8 +88,8 @@ interface XULElement : Element { readonly attribute MozXULTemplateBuilder? builder; [Throws] readonly attribute MozRDFResource? resource; - [Throws] - readonly attribute MozControllers controllers; + [Throws, ChromeOnly] + readonly attribute XULControllers controllers; [Throws] readonly attribute BoxObject? boxObject; diff --git a/dom/xul/nsXULCommandDispatcher.cpp b/dom/xul/nsXULCommandDispatcher.cpp index 8345c69579f4e..22f9fb974f7a6 100644 --- a/dom/xul/nsXULCommandDispatcher.cpp +++ b/dom/xul/nsXULCommandDispatcher.cpp @@ -30,7 +30,6 @@ #include "nsReadableUtils.h" #include "nsCRT.h" #include "nsError.h" -#include "nsDOMClassInfoID.h" #include "mozilla/BasicEvents.h" #include "mozilla/EventDispatcher.h" #include "mozilla/dom/Element.h" @@ -57,7 +56,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXULCommandDispatcher) NS_INTERFACE_MAP_ENTRY(nsIDOMXULCommandDispatcher) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMXULCommandDispatcher) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XULCommandDispatcher) NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTING_ADDREF(nsXULCommandDispatcher) diff --git a/dom/xul/nsXULControllers.cpp b/dom/xul/nsXULControllers.cpp index 6b795b29a68a5..85e790b16cd20 100644 --- a/dom/xul/nsXULControllers.cpp +++ b/dom/xul/nsXULControllers.cpp @@ -15,7 +15,6 @@ #include "nsIControllers.h" #include "nsIDOMElement.h" #include "nsXULControllers.h" -#include "nsDOMClassInfoID.h" #include "nsIController.h" //---------------------------------------------------------------------- @@ -79,7 +78,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXULControllers) NS_INTERFACE_MAP_ENTRY(nsIControllers) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIControllers) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XULControllers) NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTING_ADDREF(nsXULControllers) diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index cdf3919440283..0a2dfd5cad970 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -96,6 +96,7 @@ const char* const XPCJSRuntime::mStrings[] = { "__exposedProps__", // IDX_EXPOSEDPROPS "eval", // IDX_EVAL "controllers", // IDX_CONTROLLERS + "Controllers", // IDX_CONTROLLERS_CLASS "realFrameElement", // IDX_REALFRAMEELEMENT "length", // IDX_LENGTH "name", // IDX_NAME diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index 502c07e3e8ce6..54aef5a6d41f2 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -442,8 +442,8 @@ class XPCJSContext final : public mozilla::CycleCollectedJSContext // Mapping of often used strings to jsid atoms that live 'forever'. // - // To add a new string: add to this list and to XPCJSContext::mStrings - // at the top of XPCJSContext.cpp + // To add a new string: add to this list and to XPCJSRuntime::mStrings + // at the top of XPCJSRuntime.cpp enum { IDX_CONSTRUCTOR = 0 , IDX_TO_STRING , @@ -464,6 +464,7 @@ class XPCJSContext final : public mozilla::CycleCollectedJSContext IDX_EXPOSEDPROPS , IDX_EVAL , IDX_CONTROLLERS , + IDX_CONTROLLERS_CLASS , IDX_REALFRAMEELEMENT , IDX_LENGTH , IDX_NAME , diff --git a/layout/xul/tree/nsTreeSelection.cpp b/layout/xul/tree/nsTreeSelection.cpp index af35cb0b5ef49..97e71e7698734 100644 --- a/layout/xul/tree/nsTreeSelection.cpp +++ b/layout/xul/tree/nsTreeSelection.cpp @@ -11,7 +11,6 @@ #include "nsITreeView.h" #include "nsString.h" #include "nsIDOMElement.h" -#include "nsDOMClassInfoID.h" #include "nsIContent.h" #include "nsNameSpaceManager.h" #include "nsGkAtoms.h" @@ -266,7 +265,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTreeSelection) NS_INTERFACE_MAP_ENTRY(nsITreeSelection) NS_INTERFACE_MAP_ENTRY(nsINativeTreeSelection) NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(TreeSelection) NS_INTERFACE_MAP_END NS_IMETHODIMP nsTreeSelection::GetTree(nsITreeBoxObject * *aTree)