mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 794943 - Make window.controllers [ChromeOnly], and remove nsISecurityCheckedComponent from nsXULControllers. r=bz
This commit is contained in:
parent
dcfb0e530e
commit
fbe7c83197
@ -83,7 +83,6 @@ DOMCI_DATA(XULControllers, nsXULControllers)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXULControllers)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIControllers)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISecurityCheckedComponent)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIControllers)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XULControllers)
|
||||
NS_INTERFACE_MAP_END
|
||||
@ -255,53 +254,3 @@ nsXULControllers::GetControllerCount(uint32_t *_retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsISecurityCheckedComponent implementation
|
||||
|
||||
static char* cloneAllAccess()
|
||||
{
|
||||
static const char allAccess[] = "AllAccess";
|
||||
return (char*)nsMemory::Clone(allAccess, sizeof(allAccess));
|
||||
}
|
||||
|
||||
static char* cloneUniversalXPConnect()
|
||||
{
|
||||
static const char universalXPConnect[] = "UniversalXPConnect";
|
||||
return (char*)nsMemory::Clone(universalXPConnect, sizeof(universalXPConnect));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULControllers::CanCreateWrapper(const nsIID * iid, char **_retval)
|
||||
{
|
||||
*_retval = cloneAllAccess();
|
||||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULControllers::CanCallMethod(const nsIID * iid, const char16_t *methodName,
|
||||
char **_retval)
|
||||
{
|
||||
// OK if you're cool enough
|
||||
*_retval = cloneUniversalXPConnect();
|
||||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULControllers::CanGetProperty(const nsIID * iid,
|
||||
const char16_t *propertyName,
|
||||
char **_retval)
|
||||
{
|
||||
// OK if you're cool enough
|
||||
*_retval = cloneUniversalXPConnect();
|
||||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULControllers::CanSetProperty(const nsIID * iid,
|
||||
const char16_t *propertyName,
|
||||
char **_retval)
|
||||
{
|
||||
// OK if you're cool enough
|
||||
*_retval = cloneUniversalXPConnect();
|
||||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "nsTArray.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsISecurityCheckedComponent.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
/* non-XPCOM class for holding controllers and their IDs */
|
||||
@ -46,8 +45,7 @@ public:
|
||||
|
||||
nsresult NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult);
|
||||
|
||||
class nsXULControllers : public nsIControllers,
|
||||
public nsISecurityCheckedComponent
|
||||
class nsXULControllers : public nsIControllers
|
||||
{
|
||||
public:
|
||||
friend nsresult
|
||||
@ -56,7 +54,6 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsXULControllers, nsIControllers)
|
||||
NS_DECL_NSICONTROLLERS
|
||||
NS_DECL_NSISECURITYCHECKEDCOMPONENT
|
||||
|
||||
protected:
|
||||
nsXULControllers();
|
||||
|
@ -24,7 +24,7 @@ interface nsIVariant;
|
||||
* @see <http://www.whatwg.org/html/#window>
|
||||
*/
|
||||
|
||||
[scriptable, uuid(b0ebb526-ed69-43c6-8242-b381a1fe79da)]
|
||||
[scriptable, uuid(f2d1d383-f7b5-46f8-aadf-b69a0ebfb16f)]
|
||||
interface nsIDOMWindow : nsISupports
|
||||
{
|
||||
// the current browsing context
|
||||
@ -376,9 +376,8 @@ interface nsIDOMWindow : nsISupports
|
||||
readonly attribute nsIDOMCrypto crypto;
|
||||
readonly attribute nsIDOMPkcs11 pkcs11;
|
||||
|
||||
// XXX Shouldn't this be in nsIDOMChromeWindow?
|
||||
/* [replaceable] controllers */
|
||||
readonly attribute nsIControllers controllers;
|
||||
// Note: this is [ChromeOnly] scriptable via WebIDL.
|
||||
[noscript] readonly attribute nsIControllers controllers;
|
||||
|
||||
readonly attribute float mozInnerScreenX;
|
||||
readonly attribute float mozInnerScreenY;
|
||||
|
@ -260,7 +260,7 @@ partial interface Window {
|
||||
readonly attribute Pkcs11? pkcs11;
|
||||
|
||||
// XXX Shouldn't this be in nsIDOMChromeWindow?
|
||||
[Replaceable, Throws] readonly attribute MozControllers controllers;
|
||||
[ChromeOnly, Replaceable, Throws] readonly attribute MozControllers controllers;
|
||||
|
||||
[Throws] readonly attribute float mozInnerScreenX;
|
||||
[Throws] readonly attribute float mozInnerScreenY;
|
||||
|
@ -77,6 +77,7 @@ const char* const XPCJSRuntime::mStrings[] = {
|
||||
"__iterator__", // IDX_ITERATOR
|
||||
"__exposedProps__", // IDX_EXPOSEDPROPS
|
||||
"eval", // IDX_EVAL
|
||||
"controllers", // IDX_CONTROLLERS
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -533,6 +533,7 @@ public:
|
||||
IDX_ITERATOR ,
|
||||
IDX_EXPOSEDPROPS ,
|
||||
IDX_EVAL ,
|
||||
IDX_CONTROLLERS ,
|
||||
IDX_TOTAL_COUNT // just a count of the above
|
||||
};
|
||||
|
||||
|
@ -18,8 +18,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=912322
|
||||
ok(f in SpecialPowers.wrap(document), f + " should be available to chrome via Xray");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Test window.controllers.
|
||||
ok(typeof window.controllers, 'undefined', "controllers should not be available to content");
|
||||
ok(typeof SpecialPowers.wrap(window).controllers, 'object', "controllers should be available over Xray");
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "WrapperFactory.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
#include "XPCWrapper.h"
|
||||
@ -713,6 +714,32 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wr
|
||||
return resolveDOMCollectionProperty(cx, wrapper, holder, id, desc, flags);
|
||||
}
|
||||
|
||||
|
||||
// The |controllers| property is accessible as a [ChromeOnly] property on
|
||||
// Window.WebIDL, and [noscript] in XPIDL. Chrome needs to see this over
|
||||
// Xray, so we need to special-case it until we move |Window| to WebIDL.
|
||||
nsGlobalWindow *win = nullptr;
|
||||
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_CONTROLLERS) &&
|
||||
AccessCheck::isChrome(wrapper) &&
|
||||
(win = static_cast<nsGlobalWindow*>(As<nsPIDOMWindow>(wrapper))))
|
||||
{
|
||||
nsCOMPtr<nsIControllers> c;
|
||||
nsresult rv = win->GetControllers(getter_AddRefs(c));
|
||||
if (NS_SUCCEEDED(rv) && c) {
|
||||
rv = nsXPConnect::XPConnect()->WrapNativeToJSVal(cx, CurrentGlobalOrNull(cx),
|
||||
c, nullptr, nullptr, true,
|
||||
desc.value().address());
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) || !c) {
|
||||
JS_ReportError(cx, "Failed to invoke GetControllers via Xrays");
|
||||
return false;
|
||||
}
|
||||
|
||||
desc.object().set(wrapper);
|
||||
return true;
|
||||
}
|
||||
|
||||
XPCNativeInterface *iface;
|
||||
XPCNativeMember *member;
|
||||
XPCWrappedNative *wn = getWN(wrapper);
|
||||
|
Loading…
Reference in New Issue
Block a user