mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1069416 - Part 2: Remove JS_HAS_SYMBOLS from js tests. r=evilpie,mrbkap
This commit is contained in:
parent
102aa30542
commit
ee95717e31
@ -5,8 +5,7 @@
|
||||
|
||||
load(libdir + "asserts.js");
|
||||
|
||||
const JS_HAS_SYMBOLS = typeof Symbol === "function";
|
||||
const std_iterator = JS_HAS_SYMBOLS ? Symbol.iterator : '@@iterator';
|
||||
const std_iterator = Symbol.iterator;
|
||||
|
||||
if (typeof assertIteratorResult === 'undefined') {
|
||||
var assertIteratorResult = function assertIteratorResult(result, value, done) {
|
||||
|
@ -110,10 +110,9 @@ check("o[- (o)]");
|
||||
// A few one off tests
|
||||
check_one("6", (function () { 6() }), " is not a function");
|
||||
check_one("Array.prototype.reverse.call(...)", (function () { Array.prototype.reverse.call('123'); }), " is read-only");
|
||||
var ITERATOR = JS_HAS_SYMBOLS ? "Symbol.iterator" : "'@@iterator'";
|
||||
check_one(`(intermediate value)[${ITERATOR}](...).next(...).value`,
|
||||
check_one(`(intermediate value)[Symbol.iterator](...).next(...).value`,
|
||||
function () { var [{ x }] = [null, {}]; }, " is null");
|
||||
check_one(`(intermediate value)[${ITERATOR}](...).next(...).value`,
|
||||
check_one(`(intermediate value)[Symbol.iterator](...).next(...).value`,
|
||||
function () { ieval("let (x) { var [a, b, [c0, c1]] = [x, x, x]; }") }, " is undefined");
|
||||
|
||||
// Check fallback behavior
|
||||
|
@ -7,7 +7,7 @@ function test(constructor) {
|
||||
var proto = Object.getPrototypeOf(constructor()[std_iterator]());
|
||||
var names = Object.getOwnPropertyNames(proto);
|
||||
names.sort();
|
||||
assertDeepEq(names, JS_HAS_SYMBOLS ? ['next'] : ['@@iterator', 'next']);
|
||||
assertDeepEq(names, ['next']);
|
||||
assertEq(proto.hasOwnProperty(std_iterator), true);
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(proto, 'next');
|
||||
|
@ -56,9 +56,8 @@ var iterProto = Object.getPrototypeOf(iter);
|
||||
// StringIterator.prototype inherits from Object.prototype
|
||||
assertEq(Object.getPrototypeOf(iterProto), Object.prototype);
|
||||
|
||||
// Own properties for StringIterator.prototype: "next" and @@iterator
|
||||
arraysEqual(Object.getOwnPropertyNames(iterProto).sort(),
|
||||
JS_HAS_SYMBOLS ? ["next"] : ["@@iterator", "next"]);
|
||||
// Own properties for StringIterator.prototype: "next"
|
||||
arraysEqual(Object.getOwnPropertyNames(iterProto).sort(), ["next"]);
|
||||
assertEq(iterProto.hasOwnProperty(std_iterator), true);
|
||||
|
||||
// StringIterator.prototype[@@iterator] is a built-in function
|
||||
|
@ -65,8 +65,6 @@ function TestGeneratorObjectPrototype() {
|
||||
GeneratorObjectPrototype);
|
||||
|
||||
var expected_property_names = ["next", "return", "throw", "constructor"];
|
||||
if (!JS_HAS_SYMBOLS)
|
||||
expected_property_names.push(std_iterator);
|
||||
var found_property_names =
|
||||
Object.getOwnPropertyNames(GeneratorObjectPrototype);
|
||||
|
||||
|
@ -26,8 +26,7 @@ function test()
|
||||
var [a, b, [c0, c1]] = [x, x, x];
|
||||
}
|
||||
|
||||
var ITERATOR = JS_HAS_SYMBOLS ? "Symbol.iterator" : "'@@iterator'";
|
||||
expect = `TypeError: (intermediate value)[${ITERATOR}](...).next(...).value is null`;
|
||||
expect = `TypeError: (intermediate value)[Symbol.iterator](...).next(...).value is null`;
|
||||
actual = 'No Error';
|
||||
try
|
||||
{
|
||||
|
@ -9,8 +9,7 @@ function check(code) {
|
||||
s = exc.message;
|
||||
}
|
||||
|
||||
var ITERATOR = JS_HAS_SYMBOLS ? "Symbol.iterator" : "'@@iterator'";
|
||||
assertEq(s, `x[${ITERATOR}] is not a function`);
|
||||
assertEq(s, `x[Symbol.iterator] is not a function`);
|
||||
}
|
||||
|
||||
x = {};
|
||||
|
@ -877,5 +877,4 @@ function OptLevel( i ) {
|
||||
}
|
||||
/* end of Rhino functions */
|
||||
|
||||
var JS_HAS_SYMBOLS = typeof Symbol === "function";
|
||||
var std_iterator = JS_HAS_SYMBOLS ? Symbol.iterator : "@@iterator";
|
||||
var std_iterator = Symbol.iterator;
|
||||
|
@ -145,8 +145,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
|
||||
var version = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo).version;
|
||||
var isNightlyBuild = version.endsWith("a1");
|
||||
var isReleaseBuild = !version.contains("a");
|
||||
const jsHasSymbols = typeof Symbol === "function";
|
||||
const kIteratorSymbol = jsHasSymbols ? Symbol.iterator : "@@iterator";
|
||||
var gPrototypeProperties = {};
|
||||
gPrototypeProperties['Date'] =
|
||||
["getTime", "getTimezoneOffset", "getYear", "getFullYear", "getUTCFullYear",
|
||||
@ -169,7 +167,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
|
||||
["length", "toSource", "toString", "toLocaleString", "join", "reverse", "sort", "push",
|
||||
"pop", "shift", "unshift", "splice", "concat", "slice", "lastIndexOf", "indexOf",
|
||||
"forEach", "map", "reduce", "reduceRight", "filter", "some", "every", "find",
|
||||
"findIndex", "copyWithin", "fill", kIteratorSymbol, "entries", "keys", "constructor"];
|
||||
"findIndex", "copyWithin", "fill", Symbol.iterator, "entries", "keys", "constructor"];
|
||||
if (isNightlyBuild) {
|
||||
gPrototypeProperties['Array'].push('includes');
|
||||
}
|
||||
@ -177,7 +175,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
|
||||
gPrototypeProperties[c] = ["constructor", "BYTES_PER_ELEMENT"];
|
||||
}
|
||||
gPrototypeProperties['TypedArray'] =
|
||||
["length", "buffer", "byteLength", "byteOffset", kIteratorSymbol, "subarray",
|
||||
["length", "buffer", "byteLength", "byteOffset", Symbol.iterator, "subarray",
|
||||
"set", "copyWithin", "find", "findIndex", "forEach","indexOf", "lastIndexOf", "reverse",
|
||||
"join", "every", "some", "reduce", "reduceRight", "entries", "keys", "values"];
|
||||
if (isNightlyBuild) {
|
||||
@ -275,12 +273,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
|
||||
gPrototypeProperties[classname].filter(id => typeof id === "string").toSource(),
|
||||
"A property on the " + classname +
|
||||
" prototype has changed! You need a security audit from an XPConnect peer");
|
||||
if (jsHasSymbols) {
|
||||
is(Object.getOwnPropertySymbols(localProto).map(uneval).sort().toSource(),
|
||||
gPrototypeProperties[classname].filter(id => typeof id !== "string").map(uneval).sort().toSource(),
|
||||
"A symbol-keyed property on the " + classname +
|
||||
" prototype has been changed! You need a security audit from an XPConnect peer");
|
||||
}
|
||||
is(Object.getOwnPropertySymbols(localProto).map(uneval).sort().toSource(),
|
||||
gPrototypeProperties[classname].filter(id => typeof id !== "string").map(uneval).sort().toSource(),
|
||||
"A symbol-keyed property on the " + classname +
|
||||
" prototype has been changed! You need a security audit from an XPConnect peer");
|
||||
|
||||
let protoProps = filterOut(desiredProtoProps, propsToSkip);
|
||||
let protoCallables = protoProps.filter(name => propertyIsGetter(localProto, name, classname) ||
|
||||
@ -294,11 +290,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
|
||||
testProtoCallables(protoCallables, xray, xrayProto, localProto);
|
||||
is(Object.getOwnPropertyNames(xrayProto).sort().toSource(),
|
||||
protoProps.toSource(), "getOwnPropertyNames works");
|
||||
if (jsHasSymbols) {
|
||||
is(Object.getOwnPropertySymbols(xrayProto).map(uneval).sort().toSource(),
|
||||
gPrototypeProperties[classname].filter(id => typeof id !== "string").map(uneval).sort().toSource(),
|
||||
protoProps.toSource(), "getOwnPropertySymbols works");
|
||||
}
|
||||
is(Object.getOwnPropertySymbols(xrayProto).map(uneval).sort().toSource(),
|
||||
gPrototypeProperties[classname].filter(id => typeof id !== "string").map(uneval).sort().toSource(),
|
||||
protoProps.toSource(), "getOwnPropertySymbols works");
|
||||
|
||||
is(xrayProto.constructor, iwin[classname], "constructor property works");
|
||||
|
||||
@ -330,11 +324,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
|
||||
|
||||
// Construct an object full of tricky things.
|
||||
let symbolProps = '';
|
||||
if (jsHasSymbols) {
|
||||
uniqueSymbol = iwin.eval('var uniqueSymbol = Symbol("uniqueSymbol"); uniqueSymbol');
|
||||
symbolProps = `, [uniqueSymbol]: 43,
|
||||
[Symbol.for("registrySymbolProp")]: 44`;
|
||||
}
|
||||
uniqueSymbol = iwin.eval('var uniqueSymbol = Symbol("uniqueSymbol"); uniqueSymbol');
|
||||
symbolProps = `, [uniqueSymbol]: 43,
|
||||
[Symbol.for("registrySymbolProp")]: 44`;
|
||||
var trickyObject =
|
||||
iwin.eval(`(function() {
|
||||
var o = new Object({
|
||||
@ -366,11 +358,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
|
||||
testXray('Array', new iwin.Array(20), new iwin.Array(), propsToSkip);
|
||||
|
||||
let symbolProps = '';
|
||||
if (jsHasSymbols) {
|
||||
uniqueSymbol = iwin.eval('var uniqueSymbol = Symbol("uniqueSymbol"); uniqueSymbol');
|
||||
symbolProps = `trickyArray[uniqueSymbol] = 43;
|
||||
trickyArray[Symbol.for("registrySymbolProp")] = 44;`;
|
||||
}
|
||||
uniqueSymbol = iwin.eval('var uniqueSymbol = Symbol("uniqueSymbol"); uniqueSymbol');
|
||||
symbolProps = `trickyArray[uniqueSymbol] = 43;
|
||||
trickyArray[Symbol.for("registrySymbolProp")] = 44;`;
|
||||
var trickyArray =
|
||||
iwin.eval(`var trickyArray = [];
|
||||
trickyArray.primitiveProp = 42;
|
||||
@ -423,21 +413,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
|
||||
expectedNames.push('length');
|
||||
is(Object.getOwnPropertyNames(trickyObject).sort().toSource(),
|
||||
expectedNames.sort().toSource(), "getOwnPropertyNames should be filtered correctly");
|
||||
if (jsHasSymbols) {
|
||||
var expectedSymbols = [Symbol.for("registrySymbolProp"), uniqueSymbol];
|
||||
is(Object.getOwnPropertySymbols(trickyObject).map(uneval).sort().toSource(),
|
||||
expectedSymbols.map(uneval).sort().toSource(),
|
||||
"getOwnPropertySymbols should be filtered correctly");
|
||||
}
|
||||
var expectedSymbols = [Symbol.for("registrySymbolProp"), uniqueSymbol];
|
||||
is(Object.getOwnPropertySymbols(trickyObject).map(uneval).sort().toSource(),
|
||||
expectedSymbols.map(uneval).sort().toSource(),
|
||||
"getOwnPropertySymbols should be filtered correctly");
|
||||
|
||||
// Test that cloning uses the Xray view.
|
||||
var cloned = Cu.cloneInto(trickyObject, this);
|
||||
is(Object.getOwnPropertyNames(cloned).sort().toSource(),
|
||||
expectedNames.sort().toSource(), "structured clone should use the Xray view");
|
||||
if (jsHasSymbols) {
|
||||
is(Object.getOwnPropertySymbols(cloned).map(uneval).sort().toSource(),
|
||||
"[]", "structured cloning doesn't clone symbol-keyed properties yet");
|
||||
}
|
||||
is(Object.getOwnPropertySymbols(cloned).map(uneval).sort().toSource(),
|
||||
"[]", "structured cloning doesn't clone symbol-keyed properties yet");
|
||||
|
||||
// Test iteration and in-place modification. Beware of 'expando', which is the property
|
||||
// we placed on the xray proto.
|
||||
|
Loading…
Reference in New Issue
Block a user