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},
"StopIteration",
"String",
"Symbol",
"SyntaxError",
{name: "TypedObject", nightly: true},
"TypeError",
@ -93,6 +92,12 @@ var ecmaGlobals =
// IMPORTANT: Do not change the list above without review from
// 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,
// except to remove items from it!
//

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

@ -52,7 +52,6 @@ var ecmaGlobals =
{name: "SIMD", nightly: true},
"StopIteration",
"String",
"Symbol",
"SyntaxError",
{name: "TypedObject", nightly: true},
"TypeError",
@ -67,6 +66,12 @@ var ecmaGlobals =
// IMPORTANT: Do not change the list above without review from
// 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!
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; 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);
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 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);
if (typeof Symbol === "function") {
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 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
// the fix has propagated out to most apps:

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

@ -2,30 +2,30 @@ load(libdir + "asserts.js");
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 = [];
for (var i = 0; i < LENGTH; i++)
big[i] = (i === SYMBOL_INDEX ? sym() : i);
var progress;
function copy(arr, big) {
for (var i = 0; i < LENGTH; i++) {
arr[i] = big[i];
progress = i;
}
}
var progress;
function copy(arr, big) {
for (var i = 0; i < LENGTH; i++) {
arr[i] = big[i];
progress = i;
}
}
for (var T of [Uint8Array, Uint8ClampedArray, Int16Array, Float32Array]) {
// Typed array constructors convert symbols using ToNumber, which throws.
assertThrowsInstanceOf(() => new T(big), TypeError);
// 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);
for (var T of [Uint8Array, Uint8ClampedArray, Int16Array, Float32Array]) {
// Typed array constructors convert symbols using ToNumber, which throws.
assertThrowsInstanceOf(() => new T(big), TypeError);
// 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;
};
const symbolProtoToString = Symbol.prototype.toString;
const symbolProtoToString = typeof Symbol === "function" ? Symbol.prototype.toString : null;
function getSymbolName(symbol) {
const name = symbolProtoToString.call(symbol).slice("Symbol(".length, -1);