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.
authorJason Orendorff <jorendorff@mozilla.com>
Fri, 29 Aug 2014 11:36:45 -0500
changeset 224002 74637aa07226e3360d6890bace2a91c337f78340
parent 224001 979e8914ba48801ef0e750e8f673c5505dfa4c1f
child 224003 11e4f1678eaba483e926440ab2ef8fe0e0dde99e
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersRyanVM
bugs1041631
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
dom/tests/mochitest/general/test_interfaces.html
dom/workers/test/test_worker_interfaces.js
js/src/jit-test/tests/asm.js/testGlobals.js
js/src/jit-test/tests/symbol/typed-arrays.js
toolkit/devtools/server/actors/script.js
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -73,31 +73,36 @@ var ecmaGlobals =
     "RangeError",
     "ReferenceError",
     "RegExp",
     "Set",
     {name: "SharedArrayBuffer", nightly: true},
     {name: "SIMD", nightly: true},
     "StopIteration",
     "String",
-    "Symbol",
     "SyntaxError",
     {name: "TypedObject", nightly: true},
     "TypeError",
     "Uint16Array",
     "Uint32Array",
     "Uint8Array",
     "Uint8ClampedArray",
     "URIError",
     "WeakMap",
     "WeakSet",
   ];
 // 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!
 //
 // This is a list of interfaces that were prefixed with 'moz' instead of 'Moz'.
 // We should never to that again, interfaces in the DOM start with an uppercase
 // letter. If you think you need to add an interface here, DON'T. Rename your
 // interface.
 var legacyMozPrefixedInterfaces =
--- a/dom/workers/test/test_worker_interfaces.js
+++ b/dom/workers/test/test_worker_interfaces.js
@@ -47,31 +47,36 @@ var ecmaGlobals =
     "RangeError",
     "ReferenceError",
     "RegExp",
     "Set",
     {name: "SharedArrayBuffer", nightly: true},
     {name: "SIMD", nightly: true},
     "StopIteration",
     "String",
-    "Symbol",
     "SyntaxError",
     {name: "TypedObject", nightly: true},
     "TypeError",
     "Uint16Array",
     "Uint32Array",
     "Uint8Array",
     "Uint8ClampedArray",
     "URIError",
     "WeakMap",
     "WeakSet",
   ];
 // 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 =
   [
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "Blob",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "DedicatedWorkerGlobalScope",
 // IMPORTANT: Do not change this list without review from a DOM peer!
--- a/js/src/jit-test/tests/asm.js/testGlobals.js
+++ b/js/src/jit-test/tests/asm.js/testGlobals.js
@@ -118,19 +118,21 @@ assertEq(asmLink(asmCompile('global', 'i
 assertEq(asmLink(asmCompile('global', 'imp', USE_ASM + "var i=+imp.i; function f() { return +i } return f")(this, {i:1.4})), 1.4);
 assertEq(asmLink(asmCompile('global', 'imp', USE_ASM + "const i=+imp.i; function f() { return +i } return f")(this, {i:1.4})), 1.4);
 assertEq(asmLink(asmCompile(USE_ASM + "var g=0; function f() { var i=42; while (1) { break; } g = i; return g|0 } return f"))(), 42);
 assertAsmLinkFail(asmCompile('glob','foreign', USE_ASM + 'var i = +foreign.x; function f() {} return f'), null, {x:{valueOf:function() { return 42 }}});
 assertAsmLinkFail(asmCompile('glob','foreign', USE_ASM + 'var i = foreign.x|0; function f() {} return f'), null, {x:{valueOf:function() { return 42 }}});
 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:
 assertEq(asmLink(asmCompile('glob','foreign', USE_ASM + 'var i = foreign.i|0; function f() { return i|0} return f'), null, {i:function(){}})(), 0);
 assertEq(asmLink(asmCompile('glob','foreign', USE_ASM + 'var i = +foreign.i; function f() { return +i} return f'), null, {i:function(){}})(), NaN);
 assertEq(asmLink(asmCompile('glob','foreign', USE_ASM + 'var tof = glob.Math.fround; var i = tof(foreign.i); function f() { return +i} return f'), this, {i:function(){}})(), NaN);
 var module = asmCompile('glob','foreign', USE_ASM + 'var i = foreign.i|0; function f() { return i|0} return f');
 var fun = function() {}
--- a/js/src/jit-test/tests/symbol/typed-arrays.js
+++ b/js/src/jit-test/tests/symbol/typed-arrays.js
@@ -1,31 +1,31 @@
 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);
-    }
-}
--- a/toolkit/devtools/server/actors/script.js
+++ b/toolkit/devtools/server/actors/script.js
@@ -5415,17 +5415,17 @@ function makeDebuggeeValueIfNeeded(obj, 
   return value;
 }
 
 function getInnerId(window) {
   return window.QueryInterface(Ci.nsIInterfaceRequestor).
                 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);
   return name || undefined;
 }
 
 exports.register = function(handle) {
   ThreadActor.breakpointStore = new BreakpointStore();