mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1012798 part 2. Stop defining a value property named "window" on the global. r=peterv
This commit is contained in:
parent
4e904df02d
commit
c617f3e3b9
@ -2612,11 +2612,14 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
xpc::Scriptability::Get(GetWrapperPreserveColor()).SetDocShellAllowsScript(allow);
|
||||
|
||||
if (!aState) {
|
||||
JS::Rooted<JSObject*> rootedWrapper(cx, GetWrapperPreserveColor());
|
||||
if (!JS_DefineProperty(cx, newInnerGlobal, "window", rootedWrapper,
|
||||
JSPROP_ENUMERATE | JSPROP_READONLY |
|
||||
JSPROP_PERMANENT,
|
||||
JS_STUBGETTER, JS_STUBSETTER)) {
|
||||
// Get the "window" property once so it will be cached on our inner. We
|
||||
// have to do this here, not in binding code, because this has to happen
|
||||
// after we've created the outer window proxy and stashed it in the outer
|
||||
// nsGlobalWindow, so GetWrapperPreserveColor() on that outer
|
||||
// nsGlobalWindow doesn't return null and nsGlobalWindow::OuterObject
|
||||
// works correctly.
|
||||
JS::Rooted<JS::Value> unused(cx);
|
||||
if (!JS_GetProperty(cx, newInnerGlobal, "window", &unused)) {
|
||||
NS_ERROR("can't create the 'window' property");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -3509,11 +3512,9 @@ nsGlobalWindow::GetDocument(nsIDOMDocument** aDocument)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMWindow*
|
||||
nsGlobalWindow::GetWindow(ErrorResult& aError)
|
||||
nsGlobalWindow*
|
||||
nsGlobalWindow::Window()
|
||||
{
|
||||
FORWARD_TO_OUTER_OR_THROW(GetWindow, (aError), aError, nullptr);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -3521,10 +3522,12 @@ NS_IMETHODIMP
|
||||
nsGlobalWindow::GetWindow(nsIDOMWindow** aWindow)
|
||||
{
|
||||
ErrorResult rv;
|
||||
nsCOMPtr<nsIDOMWindow> window = GetWindow(rv);
|
||||
FORWARD_TO_OUTER_OR_THROW(GetWindow, (aWindow), rv, rv.ErrorCode());
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window = Window();
|
||||
window.forget(aWindow);
|
||||
|
||||
return rv.ErrorCode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMWindow*
|
||||
|
@ -799,7 +799,7 @@ public:
|
||||
static JSObject*
|
||||
CreateNamedPropertiesObject(JSContext *aCx, JS::Handle<JSObject*> aProto);
|
||||
|
||||
nsIDOMWindow* GetWindow(mozilla::ErrorResult& aError);
|
||||
nsGlobalWindow* Window();
|
||||
nsIDOMWindow* GetSelf(mozilla::ErrorResult& aError);
|
||||
nsIDocument* GetDocument()
|
||||
{
|
||||
|
@ -75,10 +75,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=946067
|
||||
"Our subframe's top should still be our top");
|
||||
|
||||
is(frames[0].window, frames[0], "window getter should work");
|
||||
// "window" is not a getter property yet
|
||||
//is(doGet("window", frames[0]), frames[0], "window getter should still work");
|
||||
todo_isnot(Object.getOwnPropertyDescriptor(window, "window").get, undefined,
|
||||
"Should have a getter here");
|
||||
is(doGet("window", frames[0]), frames[0], "window getter should still work");
|
||||
isnot(Object.getOwnPropertyDescriptor(window, "window").get, undefined,
|
||||
"Should have a getter here");
|
||||
|
||||
// Finally, check that we can set the location
|
||||
frames[0].location = "about:blank";
|
||||
|
@ -3427,6 +3427,12 @@ class CGUpdateMemberSlotsMethod(CGAbstractStaticMethod):
|
||||
"JSJitGetterCallArgs args(&temp);\n")
|
||||
for m in self.descriptor.interface.members:
|
||||
if m.isAttr() and m.getExtendedAttribute("StoreInSlot"):
|
||||
# Skip doing this for the "window" attribute on the Window
|
||||
# interface, because that can't be gotten safely until we have
|
||||
# hooked it up correctly to the outer window.
|
||||
if (self.descriptor.interface.identifier.name == "Window" and
|
||||
m.identifier.name == "window"):
|
||||
continue
|
||||
body += fill(
|
||||
"""
|
||||
|
||||
|
@ -27,8 +27,8 @@ typedef any Transferable;
|
||||
[PrimaryGlobal, NeedResolve]
|
||||
/*sealed*/ interface Window : EventTarget {
|
||||
// the current browsing context
|
||||
[Unforgeable, Throws,
|
||||
CrossOriginReadable] readonly attribute WindowProxy window;
|
||||
[Unforgeable, Constant, StoreInSlot,
|
||||
CrossOriginReadable] readonly attribute Window window;
|
||||
[Replaceable, Throws,
|
||||
CrossOriginReadable] readonly attribute WindowProxy self;
|
||||
[Unforgeable, StoreInSlot, Pure] readonly attribute Document? document;
|
||||
|
@ -53,7 +53,3 @@
|
||||
|
||||
[Window attribute: onstorage]
|
||||
expected: FAIL
|
||||
|
||||
[Window unforgeable attribute: window]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -2886,9 +2886,6 @@
|
||||
[Window interface: attribute localStorage]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: window must have own property "window"]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: window must inherit property "self" with the proper type (1)]
|
||||
expected: FAIL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user