Follow-up 2 to bug 1041631 - Make several more tests work when Symbol is not defined. no_r=me, a=RyanVM on a CLOSED TREE.

--HG--
extra : rebase_source : 16b265e2c241278bc15f8aa6a976ed736fcafcac
This commit is contained in:
Jason Orendorff 2014-08-29 11:36:45 -05:00
Родитель a6a05ae91e
Коммит 2cd0c964b7
5 изменённых файлов: 41 добавлений и 29 удалений

Просмотреть файл

@ -78,7 +78,6 @@ var ecmaGlobals =
{name: "SIMD", nightly: true}, {name: "SIMD", nightly: true},
"StopIteration", "StopIteration",
"String", "String",
"Symbol",
"SyntaxError", "SyntaxError",
{name: "TypedObject", nightly: true}, {name: "TypedObject", nightly: true},
"TypeError", "TypeError",
@ -93,6 +92,12 @@ var ecmaGlobals =
// IMPORTANT: Do not change the list above without review from // IMPORTANT: Do not change the list above without review from
// a JavaScript Engine peer! // a JavaScript Engine peer!
// Symbol is conditionally defined.
// If it's defined, insert "Symbol" before "SyntaxError".
if (typeof Symbol === "function") {
ecmaGlobals.splice(ecmaGlobals.indexOf("SyntaxError"), 0, "Symbol");
}
// IMPORTANT: Do not change the list below without review from a DOM peer, // IMPORTANT: Do not change the list below without review from a DOM peer,
// except to remove items from it! // except to remove items from it!
// //

Просмотреть файл

@ -52,7 +52,6 @@ var ecmaGlobals =
{name: "SIMD", nightly: true}, {name: "SIMD", nightly: true},
"StopIteration", "StopIteration",
"String", "String",
"Symbol",
"SyntaxError", "SyntaxError",
{name: "TypedObject", nightly: true}, {name: "TypedObject", nightly: true},
"TypeError", "TypeError",
@ -67,6 +66,12 @@ var ecmaGlobals =
// IMPORTANT: Do not change the list above without review from // IMPORTANT: Do not change the list above without review from
// a JavaScript Engine peer! // a JavaScript Engine peer!
// Symbol is conditionally defined.
// If it's defined, insert "Symbol" before "SyntaxError".
if (typeof Symbol === "function") {
ecmaGlobals.splice(ecmaGlobals.indexOf("SyntaxError"), 0, "Symbol");
}
// IMPORTANT: Do not change the list below without review from a DOM peer! // IMPORTANT: Do not change the list below without review from a DOM peer!
var interfaceNamesInGlobalScope = var interfaceNamesInGlobalScope =
[ [

Просмотреть файл

@ -123,9 +123,11 @@ assertAsmLinkFail(asmCompile('glob','foreign', USE_ASM + 'var i = foreign.x|0; f
assertEq(asmLink(asmCompile('glob','foreign', USE_ASM + 'var i = foreign.x|0; function f() { return i|0} return f'), null, {x:"blah"})(), 0); assertEq(asmLink(asmCompile('glob','foreign', USE_ASM + 'var i = foreign.x|0; function f() { return i|0} return f'), null, {x:"blah"})(), 0);
assertEq(asmLink(asmCompile('glob','foreign', USE_ASM + 'var i = +foreign.x; function f() { return +i} return f'), null, {x:"blah"})(), NaN); assertEq(asmLink(asmCompile('glob','foreign', USE_ASM + 'var i = +foreign.x; function f() { return +i} return f'), null, {x:"blah"})(), NaN);
assertEq(asmLink(asmCompile('glob','foreign', USE_ASM + 'var tof = glob.Math.fround; var i = tof(foreign.x); function f() { return +i} return f'), this, {x:"blah"})(), NaN); assertEq(asmLink(asmCompile('glob','foreign', USE_ASM + 'var tof = glob.Math.fround; var i = tof(foreign.x); function f() { return +i} return f'), this, {x:"blah"})(), NaN);
assertThrowsInstanceOf(() => asmCompile('glob','foreign',USE_ASM + 'var i = foreign.x|0; function f() { return i|0} return f')(null, {x:Symbol("blah")}), TypeError); if (typeof Symbol === "function") {
assertThrowsInstanceOf(() => asmCompile('glob','foreign',USE_ASM + 'var i = +foreign.x; function f() { return +i} return f')(null, {x:Symbol("blah")}), TypeError); assertThrowsInstanceOf(() => asmCompile('glob','foreign',USE_ASM + 'var i = foreign.x|0; function f() { return i|0} return f')(null, {x:Symbol("blah")}), TypeError);
assertThrowsInstanceOf(() => asmCompile('glob','foreign',USE_ASM + 'var tof = glob.Math.fround; var i = tof(foreign.x); function f() { return +i} return f')(this, {x:Symbol("blah")}), TypeError); assertThrowsInstanceOf(() => asmCompile('glob','foreign',USE_ASM + 'var i = +foreign.x; function f() { return +i} return f')(null, {x:Symbol("blah")}), TypeError);
assertThrowsInstanceOf(() => asmCompile('glob','foreign',USE_ASM + 'var tof = glob.Math.fround; var i = tof(foreign.x); function f() { return +i} return f')(this, {x:Symbol("blah")}), TypeError);
}
// Temporary workaround; this test can be removed when Emscripten is fixed and // Temporary workaround; this test can be removed when Emscripten is fixed and
// the fix has propagated out to most apps: // the fix has propagated out to most apps:

Просмотреть файл

@ -2,30 +2,30 @@ load(libdir + "asserts.js");
var LENGTH = 1024, SYMBOL_INDEX = 999; var LENGTH = 1024, SYMBOL_INDEX = 999;
var sym = this.Symbol ? () => Symbol.for("comet") : () => NaN; if (typeof Symbol === "function") {
var big = [];
for (var i = 0; i < LENGTH; i++)
big[i] = (i === SYMBOL_INDEX ? Symbol.for("comet") : i);
var big = []; var progress;
for (var i = 0; i < LENGTH; i++) function copy(arr, big) {
big[i] = (i === SYMBOL_INDEX ? sym() : i); for (var i = 0; i < LENGTH; i++) {
arr[i] = big[i];
progress = i;
}
}
var progress; for (var T of [Uint8Array, Uint8ClampedArray, Int16Array, Float32Array]) {
function copy(arr, big) { // Typed array constructors convert symbols using ToNumber, which throws.
for (var i = 0; i < LENGTH; i++) { assertThrowsInstanceOf(() => new T(big), TypeError);
arr[i] = big[i];
progress = i; // Element assignment does the same.
} var arr = new T(big.length);
} for (var k = 0; k < 3; k++) {
progress = -1;
for (var T of [Uint8Array, Uint8ClampedArray, Int16Array, Float32Array]) { assertThrowsInstanceOf(() => copy(arr, big), TypeError);
// Typed array constructors convert symbols using ToNumber, which throws. assertEq(progress, SYMBOL_INDEX - 1);
assertThrowsInstanceOf(() => new T(big), TypeError); assertEq(arr[SYMBOL_INDEX], 0);
}
// Element assignment does the same.
var arr = new T(big.length);
for (var k = 0; k < 3; k++) {
progress = -1;
assertThrowsInstanceOf(() => copy(arr, big), TypeError);
assertEq(progress, SYMBOL_INDEX - 1);
assertEq(arr[SYMBOL_INDEX], 0);
} }
} }

Просмотреть файл

@ -5420,7 +5420,7 @@ function getInnerId(window) {
getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID; getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
}; };
const symbolProtoToString = Symbol.prototype.toString; const symbolProtoToString = typeof Symbol === "function" ? Symbol.prototype.toString : null;
function getSymbolName(symbol) { function getSymbolName(symbol) {
const name = symbolProtoToString.call(symbol).slice("Symbol(".length, -1); const name = symbolProtoToString.call(symbol).slice("Symbol(".length, -1);