Bug 1565001 - Part 3: Remove uneval calls when the argument is expected to be convertible to a string. r=evilpie

extensions/clone-complex-object.js
- `pa[i][0]` is `propname`, which is earlier asserted to be a string.

Error/regress-465377.js
- `tmp` is expected to be a String value, but also add an explicit `String` call to handle symbols.
- Drive-by fix: Move `tmp` definition before first use.

Symbol/enumeration.js
- `x` is required to be a string by the spec, add explicit `String` call in case this ever changes.

object/getOwnPropertySymbols-proxy.js
- `key` is required to be a string by the spec, add explicit `String` call in case this ever changes.

object/toPrimitive.js
- `trapName` is required to be a string by the spec, add explicit `String` call in case this ever changes.

regress/regress-407024.js
- Test function `f` should either return `1` or `undefined`, both are convertible to a string.

reflect-parse/Match.js
- `uneval` for only used to quote the string value, so replace by manually quoting `key`.

extensions/shell.js
- `pa[i][0]` is earlier asserted to be a string.

Depends on D56917

Differential Revision: https://phabricator.services.mozilla.com/D56918

--HG--
extra : moz-landing-system : lando
This commit is contained in:
André Bargull 2019-12-12 15:24:43 +00:00
parent c6b63ee8cb
commit 29def25dcd
8 changed files with 14 additions and 14 deletions

View File

@ -40,7 +40,7 @@ function test()
var constructor = this[name];
var tmp = constructor.name;
if (tmp !== name)
throw "Bad value for "+name+".name: "+uneval(tmp);
throw "Bad value for "+name+".name: "+String(tmp);
instances[i] = new constructor();
}
@ -48,11 +48,11 @@ function test()
var instance = instances[i];
var name = instance.name;
var constructor = instance.constructor;
if (constructor !== this[name])
throw "Bad value of (new "+name+").constructor: "+uneval(tmp);
var tmp = constructor.name;
if (constructor !== this[name])
throw "Bad value of (new "+name+").constructor: "+String(tmp);
if (tmp !== name)
throw "Bad value for constructor.name: "+uneval(tmp);
throw "Bad value for constructor.name: "+String(tmp);
if (!(instance instanceof Object))
throw "Bad instanceof Object for "+name;
if (!(instance instanceof Error))

View File

@ -7,20 +7,20 @@ obj[Symbol.for("moon")] = "sun";
obj[Symbol("asleep")] = "awake";
obj[Symbol.iterator] = "List";
for (var x in obj)
throw "FAIL: " + uneval(x);
throw "FAIL: " + String(x);
// This includes inherited properties.
var obj2 = Object.create(obj);
for (var x in obj2)
throw "FAIL: " + uneval(x);
throw "FAIL: " + String(x);
// The same goes for proxies.
var p = new Proxy(obj, {});
for (var x in p)
throw "FAIL: " + uneval(x);
throw "FAIL: " + String(x);
var p2 = new Proxy(obj2, {});
for (var x in p2)
throw "FAIL: " + uneval(x);
throw "FAIL: " + String(x);
// Object.keys() and .getOwnPropertyNames() also skip symbols.
assertEq(Object.keys(obj).length, 0);

View File

@ -78,7 +78,7 @@ function compareProperties(a, b, stack, path) {
pa.splice(i, 1);
i--;
} else {
throw new Error("non-enumerable clone property " + uneval(pa[i][0]) + " " + path);
throw new Error("non-enumerable clone property " + propname + " " + path);
}
}
}

View File

@ -293,7 +293,7 @@
for (var i = 0; i < pa.length; i++) {
assertEq(typeof pa[i][0], "string", "clone should not have E4X properties " + path);
if (!isCloneable(a, pa[i])) {
throw new Error("non-cloneable clone property " + uneval(pa[i][0]) + " " + path);
throw new Error("non-cloneable clone property " + pa[i][0] + " " + path);
}
}

View File

@ -10,7 +10,7 @@ function HandlerProxy() {
return new Proxy({}, {
get: function (t, key) {
if (key !== "ownKeys")
throw new Error("tried to access handler[" + uneval(key) + "]");
throw new Error("tried to access handler[" + String(key) + "]");
hits++;
return t => symbols;
}

View File

@ -90,7 +90,7 @@ function doGet(target, propertyName, receiver) {
var handler = new Proxy({}, {
get(target, trapName, receiver) {
if (trapName !== "get")
throw `FAIL: system tried to access handler method: ${uneval(trapName)}`;
throw `FAIL: system tried to access handler method: ${String(trapName)}`;
return doGet;
}
});

View File

@ -156,7 +156,7 @@ var Match =
if (!(inner instanceof MatchError)) {
throw inner;
}
inner.message = `matching property ${uneval(key)}:\n${inner.message}`;
inner.message = `matching property "${String(key)}":\n${inner.message}`;
throw inner;
}
}

View File

@ -15,6 +15,6 @@ printStatus (summary);
eval("function f(x) { switch (x) { case Array: return 1; }}");
var result = f(Array);
if (result !== 1)
throw "Unexpected result: "+uneval(result);
throw "Unexpected result: "+String(result);
reportCompare(expect, actual, summary);