Bug 1015887 - Expose realFrameElement to Chrome JS. r=bholley

This commit is contained in:
Vivien Nicolas 2014-06-04 20:11:05 +02:00
parent 3f7c34e2b2
commit c3d13fd34a
5 changed files with 28 additions and 2 deletions

View File

@ -967,6 +967,7 @@ public:
void SizeToContent(mozilla::ErrorResult& aError);
nsIDOMCrypto* GetCrypto(mozilla::ErrorResult& aError);
nsIControllers* GetControllers(mozilla::ErrorResult& aError);
mozilla::dom::Element* GetRealFrameElement(mozilla::ErrorResult& aError);
float GetMozInnerScreenX(mozilla::ErrorResult& aError);
float GetMozInnerScreenY(mozilla::ErrorResult& aError);
float GetDevicePixelRatio(mozilla::ErrorResult& aError);
@ -1374,8 +1375,6 @@ protected:
nsGlobalWindow* InnerForSetTimeoutOrInterval(mozilla::ErrorResult& aError);
mozilla::dom::Element* GetRealFrameElement(mozilla::ErrorResult& aError);
void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const nsAString& aTargetOrigin,
JS::Handle<JS::Value> aTransfer,

View File

@ -285,6 +285,8 @@ partial interface Window {
// XXX Shouldn't this be in nsIDOMChromeWindow?
[ChromeOnly, Replaceable, Throws] readonly attribute MozControllers controllers;
[ChromeOnly, Throws] readonly attribute Element? realFrameElement;
[Throws] readonly attribute float mozInnerScreenX;
[Throws] readonly attribute float mozInnerScreenY;
[Throws] readonly attribute float devicePixelRatio;

View File

@ -81,6 +81,7 @@ const char* const XPCJSRuntime::mStrings[] = {
"__exposedProps__", // IDX_EXPOSEDPROPS
"eval", // IDX_EVAL
"controllers", // IDX_CONTROLLERS
"realFrameElement", // IDX_REALFRAMEELEMENT
};
/***************************************************************************/

View File

@ -479,6 +479,7 @@ public:
IDX_EXPOSEDPROPS ,
IDX_EVAL ,
IDX_CONTROLLERS ,
IDX_REALFRAMEELEMENT ,
IDX_TOTAL_COUNT // just a count of the above
};

View File

@ -10,6 +10,7 @@
#include "nsIContent.h"
#include "nsIControllers.h"
#include "mozilla/dom/Element.h"
#include "nsContentUtils.h"
#include "XPCWrapper.h"
@ -1090,6 +1091,28 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wr
return true;
}
// The |realFrameElement| 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.
if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_REALFRAMEELEMENT) &&
AccessCheck::isChrome(wrapper) &&
(win = AsWindow(cx, wrapper)))
{
ErrorResult rv;
Element* f = win->GetRealFrameElement(rv);
if (!f) {
desc.object().set(nullptr);
return true;
}
if (!WrapNewBindingObject(cx, f, desc.value())) {
return false;
}
desc.object().set(wrapper);
return true;
}
XPCNativeInterface *iface;
XPCNativeMember *member;
XPCWrappedNative *wn = getWN(wrapper);