mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1277801 - Remove Object.prototype.toString classname fallback. r=jwalden
Similar to a patch by Robin Templeton <robin@igalia.com> Differential Revision: https://phabricator.services.mozilla.com/D72459
This commit is contained in:
parent
25a8ce26ec
commit
7824fc6e57
@ -18,9 +18,9 @@ add_task(
|
||||
ok(threadFront instanceof ThreadFront, "Thread Front is valid");
|
||||
Assert.equal(threadFront.state, "attached", "Thread Front is resumed");
|
||||
Assert.equal(
|
||||
String(debuggee),
|
||||
"[object Sandbox]",
|
||||
"Debuggee client is valid"
|
||||
Cu.getSandboxMetadata(debuggee),
|
||||
undefined,
|
||||
"Debuggee client is valid (getSandboxMetadata did not fail)"
|
||||
);
|
||||
ok(client instanceof DevToolsClient, "Client is valid");
|
||||
ok(
|
||||
|
@ -648,7 +648,9 @@ bool js::obj_toString(JSContext* cx, unsigned argc, Value* vp) {
|
||||
}
|
||||
|
||||
// Step 14.
|
||||
// Currently omitted for non-standard fallback.
|
||||
if (!builtinTag) {
|
||||
builtinTag = cx->names().objectObject;
|
||||
}
|
||||
|
||||
// Step 15.
|
||||
RootedValue tag(cx);
|
||||
@ -659,21 +661,6 @@ bool js::obj_toString(JSContext* cx, unsigned argc, Value* vp) {
|
||||
|
||||
// Step 16.
|
||||
if (!tag.isString()) {
|
||||
// Non-standard (bug 1277801): Use ClassName as a fallback in the interim
|
||||
if (!builtinTag) {
|
||||
const char* className = GetObjectClassName(cx, obj);
|
||||
StringBuffer sb(cx);
|
||||
if (!sb.append("[object ") || !sb.append(className, strlen(className)) ||
|
||||
!sb.append(']')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
builtinTag = sb.finishAtom();
|
||||
if (!builtinTag) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
args.rval().setString(builtinTag);
|
||||
return true;
|
||||
}
|
||||
|
@ -1548,22 +1548,12 @@ function test(sharedMem) {
|
||||
assertEq(Object.prototype.toString.apply(new DataView(view.buffer)), "[object DataView]");
|
||||
assertEq(Object.prototype.toString.apply(DataView.prototype), "[object DataView]");
|
||||
|
||||
// Technically the spec requires these throw a TypeError -- right now. It's
|
||||
// not clear this is desirable. Once we implement @@toStringTag we can see
|
||||
// whether ES6's desired semantics will work.
|
||||
assertEq(Object.prototype.toString.apply(Uint8Array.prototype), "[object Uint8ArrayPrototype]");
|
||||
assertEq(Object.prototype.toString.apply(Float32Array.prototype), "[object Float32ArrayPrototype]");
|
||||
|
||||
// Same applies for %TypedArray%.prototype, except because of its newness we
|
||||
// give it the thoroughly-inscrutable "???" as its class name so (hopefully)
|
||||
// people won't rely on it. ("???" is the class exposed by
|
||||
// ({ [@@toStringTag]: nonUndefinedNonStringValue }).toString(), so
|
||||
// it has slight precedent even if it's not-to-spec.)
|
||||
checkThrowTODO(() => {
|
||||
var typedArrayPrototype = Object.getPrototypeOf(Float32Array.prototype);
|
||||
assertEq(Object.prototype.toString.apply(typedArrayPrototype),
|
||||
"[object ???]");
|
||||
}, TypeError);
|
||||
// get %TypedArray%.prototype[@@toStringTag] returns undefined thus
|
||||
// Object.prototype.toString falls back to [object Object]
|
||||
assertEq(Object.prototype.toString.apply(Uint8Array.prototype), "[object Object]");
|
||||
assertEq(Object.prototype.toString.apply(Float32Array.prototype), "[object Object]");
|
||||
var typedArrayPrototype = Object.getPrototypeOf(Float32Array.prototype);
|
||||
assertEq(Object.prototype.toString.apply(typedArrayPrototype), "[object Object]");
|
||||
|
||||
// Accessing DataView fields on DataView.prototype should crash
|
||||
checkThrow(() => DataView.prototype.byteLength, TypeError);
|
||||
|
@ -1,14 +0,0 @@
|
||||
[class-string-interface.any.html]
|
||||
[Object.prototype.toString applied to a null-prototype instance]
|
||||
expected: FAIL
|
||||
|
||||
[Object.prototype.toString applied after deleting @@toStringTag]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[class-string-interface.any.worker.html]
|
||||
[Object.prototype.toString applied to a null-prototype instance]
|
||||
expected: FAIL
|
||||
|
||||
[Object.prototype.toString applied after deleting @@toStringTag]
|
||||
expected: FAIL
|
@ -1,15 +1,9 @@
|
||||
[class-string-iterator-prototype-object.any.html]
|
||||
[Object.prototype.toString applied after deleting @@toStringTag]
|
||||
expected: FAIL
|
||||
|
||||
[Object.prototype.toString applied after nulling the prototype]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[class-string-iterator-prototype-object.any.worker.html]
|
||||
[Object.prototype.toString applied after deleting @@toStringTag]
|
||||
expected: FAIL
|
||||
|
||||
[Object.prototype.toString applied after nulling the prototype]
|
||||
expected: FAIL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user