Backed out changeset 2c51cdd42834 (bug 1252211) for bustage

This commit is contained in:
Carsten "Tomcat" Book 2017-06-13 12:20:33 +02:00
parent cf1c3b467a
commit 4a5a3d9f30
17 changed files with 100 additions and 51 deletions

View File

@ -63,8 +63,6 @@
#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"
@ -1210,8 +1208,7 @@ nsScriptSecurityManager::CanCreateWrapper(JSContext *cx,
}
// We give remote-XUL whitelisted domains a free pass here. See bug 932906.
JSCompartment* contextCompartment = js::GetContextCompartment(cx);
if (!xpc::AllowContentXBLScope(contextCompartment))
if (!xpc::AllowContentXBLScope(js::GetContextCompartment(cx)))
{
return NS_OK;
}
@ -1221,20 +1218,6 @@ nsScriptSecurityManager::CanCreateWrapper(JSContext *cx,
return NS_OK;
}
// We want to expose nsIDOMXULCommandDispatcher and nsITreeSelection implementations
// in XBL scopes.
if (xpc::IsContentXBLScope(contextCompartment)) {
nsCOMPtr<nsIDOMXULCommandDispatcher> dispatcher = do_QueryInterface(aObj);
if (dispatcher) {
return NS_OK;
}
nsCOMPtr<nsITreeSelection> treeSelection = do_QueryInterface(aObj);
if (treeSelection) {
return NS_OK;
}
}
//-- Access denied, report an error
NS_ConvertUTF8toUTF16 strName("CreateWrapperDenied");
nsAutoCString origin;

View File

@ -73,7 +73,10 @@
#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"
@ -177,8 +180,19 @@ 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)
@ -455,11 +469,27 @@ 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
@ -1598,9 +1628,6 @@ nsWindowSH::NameStructEnabled(JSContext* aCx, nsGlobalWindow *aWin,
#ifdef USE_CONTROLLERS_SHIM
static const JSClass ControllersShimClass = {
"Controllers", 0
};
static const JSClass XULControllersShimClass = {
"XULControllers", 0
};
#endif
@ -1619,22 +1646,15 @@ 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) ||
id == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS_CLASS)) &&
if (id == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS) &&
!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<JSObject*> shim(cx, JS_NewObject(cx, clazz));
JS::Rooted<JSObject*> shim(cx, JS_NewObject(cx, &ControllersShimClass));
if (NS_WARN_IF(!shim)) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -2018,6 +2038,16 @@ 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<typename Super>

View File

@ -257,6 +257,26 @@ public:
}
};
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<typename Super>
class nsMessageManagerSH : public Super
{

View File

@ -21,6 +21,11 @@ enum nsDOMClassInfoID
// XUL classes
#ifdef MOZ_XUL
eDOMClassInfo_XULCommandDispatcher_id,
#endif
eDOMClassInfo_XULControllers_id,
#ifdef MOZ_XUL
eDOMClassInfo_TreeSelection_id,
eDOMClassInfo_TreeContentView_id,
#endif

View File

@ -5127,10 +5127,9 @@ nsGlobalWindow::MayResolve(jsid aId)
return true;
}
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.
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.
return true;
}

View File

@ -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('XULControllers', nativeType='nsIControllers', notflattened=True)
addExternalIface('MozControllers', nativeType='nsIControllers')
addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
addExternalIface('MozObserver', nativeType='nsIObserver', notflattened=True)
addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource',
@ -1742,6 +1742,7 @@ 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)
@ -1765,4 +1766,4 @@ addExternalIface('StackFrame', nativeType='nsIStackFrame',
headerFile='nsIException.h', notflattened=True)
addExternalIface('URI', nativeType='nsIURI', headerFile='nsIURI.h',
notflattened=True)
addExternalIface('XULCommandDispatcher', notflattened=True)
addExternalIface('XULCommandDispatcher')

View File

@ -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 users 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/Controllers"
Window_ControllersWarning=window.controllers/Controllers is deprecated. Do not use it for UA detection.
# LOCALIZATION NOTE: Do not translate "window.controllers"
Window_ControllersWarning=window.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".

View File

@ -195,6 +195,8 @@ 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!
@ -1154,6 +1156,8 @@ 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!
@ -1268,10 +1272,14 @@ 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!

View File

@ -19,7 +19,7 @@ enum SelectionMode {
"preserve",
};
interface XULControllers;
interface nsIControllers;
[HTMLConstructor]
interface HTMLInputElement : HTMLElement {
@ -144,7 +144,7 @@ partial interface HTMLInputElement {
partial interface HTMLInputElement {
[GetterThrows, ChromeOnly]
readonly attribute XULControllers controllers;
readonly attribute nsIControllers controllers;
// Binaryname because we have a FragmentOrElement function named "TextLength()".
[NeedsCallerType, BinaryName="inputTextLength"]
readonly attribute long textLength;

View File

@ -12,7 +12,7 @@
*/
interface nsIEditor;
interface XULControllers;
interface MozControllers;
[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 XULControllers controllers;
readonly attribute MozControllers controllers;
};
partial interface HTMLTextAreaElement {

View File

@ -24,7 +24,6 @@ interface IID;
interface nsIBrowserDOMWindow;
interface nsIMessageBroadcaster;
interface nsIDOMCrypto;
interface XULControllers;
// http://www.whatwg.org/specs/web-apps/current-work/
[PrimaryGlobal, LegacyUnenumerableNamedProperties, NeedResolve]
@ -264,7 +263,7 @@ partial interface Window {
[Throws, UnsafeInPrerendering, NeedsCallerType] void sizeToContent();
// XXX Shouldn't this be in nsIDOMChromeWindow?
[ChromeOnly, Replaceable, Throws] readonly attribute XULControllers controllers;
[ChromeOnly, Replaceable, Throws] readonly attribute MozControllers controllers;
[ChromeOnly, Throws] readonly attribute Element? realFrameElement;

View File

@ -4,7 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
interface XULControllers;
interface MozControllers;
interface MozFrameLoader;
interface MozRDFCompositeDataSource;
interface MozRDFResource;
@ -88,8 +88,8 @@ interface XULElement : Element {
readonly attribute MozXULTemplateBuilder? builder;
[Throws]
readonly attribute MozRDFResource? resource;
[Throws, ChromeOnly]
readonly attribute XULControllers controllers;
[Throws]
readonly attribute MozControllers controllers;
[Throws]
readonly attribute BoxObject? boxObject;

View File

@ -30,6 +30,7 @@
#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"
@ -56,6 +57,7 @@ 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)

View File

@ -15,6 +15,7 @@
#include "nsIControllers.h"
#include "nsIDOMElement.h"
#include "nsXULControllers.h"
#include "nsDOMClassInfoID.h"
#include "nsIController.h"
//----------------------------------------------------------------------
@ -78,6 +79,7 @@ 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)

View File

@ -96,7 +96,6 @@ 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

View File

@ -442,8 +442,8 @@ public:
// Mapping of often used strings to jsid atoms that live 'forever'.
//
// To add a new string: add to this list and to XPCJSRuntime::mStrings
// at the top of XPCJSRuntime.cpp
// To add a new string: add to this list and to XPCJSContext::mStrings
// at the top of XPCJSContext.cpp
enum {
IDX_CONSTRUCTOR = 0 ,
IDX_TO_STRING ,
@ -464,7 +464,6 @@ public:
IDX_EXPOSEDPROPS ,
IDX_EVAL ,
IDX_CONTROLLERS ,
IDX_CONTROLLERS_CLASS ,
IDX_REALFRAMEELEMENT ,
IDX_LENGTH ,
IDX_NAME ,

View File

@ -11,6 +11,7 @@
#include "nsITreeView.h"
#include "nsString.h"
#include "nsIDOMElement.h"
#include "nsDOMClassInfoID.h"
#include "nsIContent.h"
#include "nsNameSpaceManager.h"
#include "nsGkAtoms.h"
@ -265,6 +266,7 @@ 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)