mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-27 02:47:31 +09:00
1333045 - Update Location object properties to current spec.
Specifically, three changes: 1) valueOf should be non-enumerable. 2) valueOf should be === to Object.prototype.valueOf. 3) There should be no toJSON.
This commit is contained in:
parent
337cdbd0ce
commit
1af9026a89
9 changed files with 72 additions and 24 deletions
|
|
@ -1183,14 +1183,6 @@ GetInterfaceImpl(JSContext* aCx, nsIInterfaceRequestor* aRequestor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
UnforgeableValueOf(JSContext* cx, unsigned argc, JS::Value* vp)
|
|
||||||
{
|
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
|
||||||
args.rval().set(args.thisv());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ThrowingConstructor(JSContext* cx, unsigned argc, JS::Value* vp)
|
ThrowingConstructor(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2044,9 +2044,6 @@ GetInterface(JSContext* aCx, T* aThis, nsIJSID* aIID,
|
||||||
GetInterfaceImpl(aCx, aThis, aThis, aIID, aRetval, aError);
|
GetInterfaceImpl(aCx, aThis, aThis, aIID, aRetval, aError);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
UnforgeableValueOf(JSContext* cx, unsigned argc, JS::Value* vp);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ThrowingConstructor(JSContext* cx, unsigned argc, JS::Value* vp);
|
ThrowingConstructor(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2390,11 +2390,10 @@ class MethodDefiner(PropertyDefiner):
|
||||||
# Synthesize our valueOf method
|
# Synthesize our valueOf method
|
||||||
self.regular.append({
|
self.regular.append({
|
||||||
"name": 'valueOf',
|
"name": 'valueOf',
|
||||||
"nativeName": "UnforgeableValueOf",
|
"selfHostedName": "Object_valueOf",
|
||||||
"methodInfo": False,
|
"methodInfo": False,
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"flags": "JSPROP_ENUMERATE", # readonly/permanent added
|
"flags": "0", # readonly/permanent added automatically.
|
||||||
# automatically.
|
|
||||||
"condition": MemberCondition()
|
"condition": MemberCondition()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -3456,19 +3455,15 @@ def InitUnforgeablePropertiesOnHolder(descriptor, properties, failureCode,
|
||||||
"nsContentUtils::ThreadsafeIsCallerChrome()"))
|
"nsContentUtils::ThreadsafeIsCallerChrome()"))
|
||||||
|
|
||||||
if descriptor.interface.getExtendedAttribute("Unforgeable"):
|
if descriptor.interface.getExtendedAttribute("Unforgeable"):
|
||||||
# We do our undefined toJSON and toPrimitive here, not as a regular
|
# We do our undefined toPrimitive here, not as a regular property
|
||||||
# property because we don't have a concept of value props anywhere in
|
# because we don't have a concept of value props anywhere in IDL.
|
||||||
# IDL.
|
|
||||||
unforgeables.append(CGGeneric(fill(
|
unforgeables.append(CGGeneric(fill(
|
||||||
"""
|
"""
|
||||||
JS::RootedId toPrimitive(aCx,
|
JS::RootedId toPrimitive(aCx,
|
||||||
SYMBOL_TO_JSID(JS::GetWellKnownSymbol(aCx, JS::SymbolCode::toPrimitive)));
|
SYMBOL_TO_JSID(JS::GetWellKnownSymbol(aCx, JS::SymbolCode::toPrimitive)));
|
||||||
if (!JS_DefinePropertyById(aCx, ${holderName}, toPrimitive,
|
if (!JS_DefinePropertyById(aCx, ${holderName}, toPrimitive,
|
||||||
JS::UndefinedHandleValue,
|
JS::UndefinedHandleValue,
|
||||||
JSPROP_READONLY | JSPROP_PERMANENT) ||
|
JSPROP_READONLY | JSPROP_PERMANENT)) {
|
||||||
!JS_DefineProperty(aCx, ${holderName}, "toJSON",
|
|
||||||
JS::UndefinedHandleValue,
|
|
||||||
JSPROP_READONLY | JSPROP_ENUMERATE | JSPROP_PERMANENT)) {
|
|
||||||
$*{failureCode}
|
$*{failureCode}
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1041626
|
||||||
|
|
||||||
ok(Cu.isXrayWrapper(window[0].location), "Location is Xrayed");
|
ok(Cu.isXrayWrapper(window[0].location), "Location is Xrayed");
|
||||||
let xrayOwnProperties = Object.getOwnPropertyNames(window[0].location);
|
let xrayOwnProperties = Object.getOwnPropertyNames(window[0].location);
|
||||||
todo(xrayOwnProperties.indexOf('toJSON') != -1,
|
|
||||||
"dummy toJSON on Location should show up in Xrayable properties");
|
|
||||||
xrayOwnProperties.push('toJSON');
|
|
||||||
|
|
||||||
let realOwnProperties = Object.getOwnPropertyNames(window[0].wrappedJSObject.location);
|
let realOwnProperties = Object.getOwnPropertyNames(window[0].wrappedJSObject.location);
|
||||||
ok(realOwnProperties.length > 2);
|
ok(realOwnProperties.length > 2);
|
||||||
|
|
|
||||||
|
|
@ -18165,6 +18165,18 @@
|
||||||
"path": "html/browsers/history/the-location-interface/location-stringifier.html",
|
"path": "html/browsers/history/the-location-interface/location-stringifier.html",
|
||||||
"url": "/html/browsers/history/the-location-interface/location-stringifier.html"
|
"url": "/html/browsers/history/the-location-interface/location-stringifier.html"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "html/browsers/history/the-location-interface/location-symbol-toprimitive.html",
|
||||||
|
"url": "/html/browsers/history/the-location-interface/location-symbol-toprimitive.html"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "html/browsers/history/the-location-interface/location-tojson.html",
|
||||||
|
"url": "/html/browsers/history/the-location-interface/location-tojson.html"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "html/browsers/history/the-location-interface/location-valueof.html",
|
||||||
|
"url": "/html/browsers/history/the-location-interface/location-valueof.html"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "html/browsers/history/the-location-interface/location_assign.html",
|
"path": "html/browsers/history/the-location-interface/location_assign.html",
|
||||||
"url": "/html/browsers/history/the-location-interface/location_assign.html"
|
"url": "/html/browsers/history/the-location-interface/location_assign.html"
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,17 @@
|
||||||
<div id=log></div>
|
<div id=log></div>
|
||||||
<script>
|
<script>
|
||||||
test_stringifier_attribute(location, "href", true);
|
test_stringifier_attribute(location, "href", true);
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
const prop1 = Object.getOwnPropertyDescriptor(location, "toString"),
|
||||||
|
prop2 = Object.getOwnPropertyDescriptor(location, "href")
|
||||||
|
|
||||||
|
assert_true(prop1.enumerable)
|
||||||
|
assert_false(prop1.writable)
|
||||||
|
assert_false(prop1.configurable)
|
||||||
|
|
||||||
|
assert_true(prop2.enumerable)
|
||||||
|
assert_false(prop2.configurable)
|
||||||
|
assert_equals(typeof prop2.get, "function")
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Location Symbol.toPrimitive</title>
|
||||||
|
<script src=/resources/testharness.js></script>
|
||||||
|
<script src=/resources/testharnessreport.js></script>
|
||||||
|
<div id=log></div>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
assert_equals(location[Symbol.toPrimitive], undefined)
|
||||||
|
const prop = Object.getOwnPropertyDescriptor(location, Symbol.toPrimitive)
|
||||||
|
assert_false(prop.enumerable)
|
||||||
|
assert_false(prop.writable)
|
||||||
|
assert_false(prop.configurable)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Location has no toJSON</title>
|
||||||
|
<script src=/resources/testharness.js></script>
|
||||||
|
<script src=/resources/testharnessreport.js></script>
|
||||||
|
<div id=log></div>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
assert_equals(location.toJSON, undefined)
|
||||||
|
assert_equals(Object.getOwnPropertyDescriptor(location, "toJSON"), undefined)
|
||||||
|
assert_false(location.hasOwnProperty("toJSON"))
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<!-- See https://github.com/whatwg/html/pull/2294 for context. (And the HTML Standard of course.) -->
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Location valueOf</title>
|
||||||
|
<script src=/resources/testharness.js></script>
|
||||||
|
<script src=/resources/testharnessreport.js></script>
|
||||||
|
<div id=log></div>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
assert_equals(location.valueOf, Object.prototype.valueOf)
|
||||||
|
assert_equals(typeof location.valueOf.call(5), "object")
|
||||||
|
const prop = Object.getOwnPropertyDescriptor(location, "valueOf")
|
||||||
|
assert_false(prop.enumerable)
|
||||||
|
assert_false(prop.writable)
|
||||||
|
assert_false(prop.configurable)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue