Skip to content

Commit

Permalink
Follow-up 2 to bug 1041631 - Make several more tests work when Symbol…
Browse files Browse the repository at this point in the history
… is not defined. no_r=me, a=RyanVM on a CLOSED TREE.

--HG--
extra : rebase_source : 16b265e2c241278bc15f8aa6a976ed736fcafcac
  • Loading branch information
Jason Orendorff committed Aug 29, 2014
1 parent a6a05ae commit 2cd0c96
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 27 deletions.
7 changes: 6 additions & 1 deletion dom/tests/mochitest/general/test_interfaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
{name: "SIMD", nightly: true},
"StopIteration",
"String",
"Symbol",
"SyntaxError",
{name: "TypedObject", nightly: true},
"TypeError",
Expand All @@ -93,6 +92,12 @@
// 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!
//
Expand Down
7 changes: 6 additions & 1 deletion dom/workers/test/test_worker_interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ var ecmaGlobals =
{name: "SIMD", nightly: true},
"StopIteration",
"String",
"Symbol",
"SyntaxError",
{name: "TypedObject", nightly: true},
"TypeError",
Expand All @@ -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 =
[
Expand Down
8 changes: 5 additions & 3 deletions js/src/jit-test/tests/asm.js/testGlobals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
42 changes: 21 additions & 21 deletions js/src/jit-test/tests/symbol/typed-arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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);
// 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);
}
}
}
2 changes: 1 addition & 1 deletion toolkit/devtools/server/actors/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2cd0c96

Please sign in to comment.