mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1151940 part 2. Add a convenience function in nsGlobalWindow for replacing a property on the window with a new value. r=smaug
This commit is contained in:
parent
e6531d3705
commit
4b776e2bc5
@ -4541,18 +4541,7 @@ nsGlobalWindow::SetOpener(JSContext* aCx, JS::Handle<JS::Value> aOpener,
|
||||
// get reset on navigation. This is just like replaceable properties, but
|
||||
// we're not quite readonly.
|
||||
if (!aOpener.isNull() && !nsContentUtils::IsCallerChrome()) {
|
||||
JS::Rooted<JSObject*> thisObj(aCx, GetWrapperPreserveColor());
|
||||
if (!thisObj) {
|
||||
aError.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!JS_WrapObject(aCx, &thisObj) ||
|
||||
!JS_DefineProperty(aCx, thisObj, "opener", aOpener, JSPROP_ENUMERATE,
|
||||
JS_STUBGETTER, JS_STUBSETTER)) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
RedefineProperty(aCx, "opener", aOpener, aError);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -13974,18 +13963,9 @@ nsGlobalWindow::GetConsole(JSContext* aCx,
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::SetConsole(JSContext* aCx, JS::Handle<JS::Value> aValue)
|
||||
{
|
||||
JS::Rooted<JSObject*> thisObj(aCx, GetWrapper());
|
||||
if (!thisObj) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (!JS_WrapObject(aCx, &thisObj) ||
|
||||
!JS_DefineProperty(aCx, thisObj, "console", aValue, JSPROP_ENUMERATE,
|
||||
JS_STUBGETTER, JS_STUBSETTER)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
ErrorResult rv;
|
||||
RedefineProperty(aCx, "console", aValue, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
Console*
|
||||
@ -14145,6 +14125,24 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
|
||||
}
|
||||
#endif // MOZ_B2G
|
||||
|
||||
void
|
||||
nsGlobalWindow::RedefineProperty(JSContext* aCx, const char* aPropName,
|
||||
JS::Handle<JS::Value> aValue,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
JS::Rooted<JSObject*> thisObj(aCx, GetWrapperPreserveColor());
|
||||
if (!thisObj) {
|
||||
aError.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!JS_WrapObject(aCx, &thisObj) ||
|
||||
!JS_DefineProperty(aCx, thisObj, aPropName, aValue, JSPROP_ENUMERATE,
|
||||
JS_STUBGETTER, JS_STUBSETTER)) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS_
|
||||
#error "Never include windows.h in this file!"
|
||||
#endif
|
||||
|
@ -1087,6 +1087,15 @@ public:
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
protected:
|
||||
// Web IDL helpers
|
||||
|
||||
// Redefine the property called aPropName on this window object to be a value
|
||||
// property with the value aValue, much like we would do for a [Replaceable]
|
||||
// property in IDL.
|
||||
void RedefineProperty(JSContext* aCx, const char* aPropName,
|
||||
JS::Handle<JS::Value> aValue,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
// Array of idle observers that are notified of idle events.
|
||||
nsTObserverArray<IdleObserverHolder> mIdleObservers;
|
||||
|
||||
|
@ -1,20 +1,5 @@
|
||||
[window-properties.html]
|
||||
type: testharness
|
||||
[EventTarget method: addEventListener]
|
||||
expected: FAIL
|
||||
|
||||
[EventTarget method: removeEventListener]
|
||||
expected: FAIL
|
||||
|
||||
[EventTarget method: dispatchEvent]
|
||||
expected: FAIL
|
||||
|
||||
[Window readonly attribute: parent]
|
||||
expected: FAIL
|
||||
|
||||
[Window readonly attribute: external]
|
||||
expected: FAIL
|
||||
|
||||
[Window readonly attribute: innerWidth]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -42,7 +42,7 @@ var unforgeableAttributes = [
|
||||
"top"
|
||||
];
|
||||
|
||||
var replacableAttributes = [
|
||||
var replaceableAttributes = [
|
||||
"self",
|
||||
"locationbar",
|
||||
"menubar",
|
||||
@ -51,7 +51,16 @@ var replacableAttributes = [
|
||||
"statusbar",
|
||||
"toolbar",
|
||||
"frames",
|
||||
"length"
|
||||
"parent",
|
||||
"external",
|
||||
"length",
|
||||
|
||||
// CSSOM-View
|
||||
"screen",
|
||||
"scrollX",
|
||||
"scrollY",
|
||||
"pageXOffset",
|
||||
"pageYOffset",
|
||||
];
|
||||
|
||||
var methods = [
|
||||
@ -98,10 +107,8 @@ if ("showModalDialog" in window) {
|
||||
|
||||
var readonlyAttributes = [
|
||||
"history",
|
||||
"parent",
|
||||
"frameElement",
|
||||
"navigator",
|
||||
"external",
|
||||
"applicationCache",
|
||||
|
||||
// WindowSessionStorage
|
||||
@ -111,13 +118,8 @@ var readonlyAttributes = [
|
||||
"localStorage",
|
||||
|
||||
// CSSOM-View
|
||||
"screen",
|
||||
"innerWidth",
|
||||
"innerHeight",
|
||||
"scrollX",
|
||||
"pageXOffset",
|
||||
"scrollY",
|
||||
"pageYOffset",
|
||||
"screenX",
|
||||
"screenY",
|
||||
"outerWidth",
|
||||
@ -259,8 +261,7 @@ test(function() {
|
||||
assert_equals(window[id], EventTargetProto[id]);
|
||||
assert_data_propdesc(Object.getOwnPropertyDescriptor(EventTargetProto, id),
|
||||
true, true, true);
|
||||
assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
|
||||
true, true, true);
|
||||
assert_equals(Object.getOwnPropertyDescriptor(window, id), undefined);
|
||||
}, "EventTarget method: " + id);
|
||||
});
|
||||
}, "EventTarget interface");
|
||||
@ -303,7 +304,7 @@ test(function() {
|
||||
id === "location", true, false);
|
||||
}, "Window unforgeable attribute: " + id);
|
||||
});
|
||||
replacableAttributes.forEach(function(id) {
|
||||
replaceableAttributes.forEach(function(id) {
|
||||
test(function() {
|
||||
var WindowProto = Window.prototype;
|
||||
assert_true(id in window, id + " in window");
|
||||
|
Loading…
Reference in New Issue
Block a user