Bug 1191292 - Keep ecma_6/Reflect/apply.js from permafailing when Gecko 42 merges to Aurora. r=Waldo.
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 06 Aug 2015 15:50:06 -0500
changeset 288366 d1c8f4aeedef5d582b88fa84a1a4934fdf89b808
parent 288365 c24075996e1d36cdfa53dc17f464e80a9f1a798b
child 288367 fc5272ac152e8d0fea38ad2e4bd38e6d8aafb744
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1191292
milestone42.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
Bug 1191292 - Keep ecma_6/Reflect/apply.js from permafailing when Gecko 42 merges to Aurora. r=Waldo.
js/src/jit-test/lib/class.js
js/src/tests/ecma_6/Class/shell.js
js/src/tests/ecma_6/Reflect/apply.js
js/src/tests/ecma_6/Reflect/construct.js
js/src/tests/ecma_6/shell.js
--- a/js/src/jit-test/lib/class.js
+++ b/js/src/jit-test/lib/class.js
@@ -1,1 +1,1 @@
-load(libdir + "../../tests/ecma_6/Class/shell.js");
+load(libdir + "../../tests/ecma_6/shell.js");
--- a/js/src/tests/ecma_6/Class/shell.js
+++ b/js/src/tests/ecma_6/Class/shell.js
@@ -1,23 +1,14 @@
 // NOTE: This only turns on 1.8.5 in shell builds.  The browser requires the
 //       futzing in js/src/tests/browser.js (which only turns on 1.8, the most
 //       the browser supports).
 if (typeof version != 'undefined')
   version(185);
 
-function classesEnabled() {
-    try {
-        new Function("class Foo { constructor() { } }");
-        return true;
-    } catch (e if e instanceof SyntaxError) {
-        return false;
-    }
-}
-
 function assertThrownErrorContains(thunk, substr) {
     try {
         thunk();
     } catch (e) {
         if (e.message.indexOf(substr) !== -1)
             return;
         throw new Error("Expected error containing " + substr + ", got " + e);
     }
--- a/js/src/tests/ecma_6/Reflect/apply.js
+++ b/js/src/tests/ecma_6/Reflect/apply.js
@@ -1,17 +1,20 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/licenses/publicdomain/ */
 
 // Reflect.apply calls functions.
 assertEq(Reflect.apply(Math.floor, undefined, [1.75]), 1);
 
 // Reflect.apply requires a target object that's callable.
-class clsX { constructor() {} }  // classes are not callable
-var nonCallable = [{}, [], clsX];
+var nonCallable = [{}, []];
+if (classesEnabled()) {
+    // classes are not callable
+    nonCallable.push(eval("(class clsX { constructor() {} })"));
+}
 for (var value of nonCallable) {
     assertThrowsInstanceOf(() => Reflect.apply(nonCallable), TypeError);
 }
 
 // When target is not callable, Reflect.apply does not try to get argumentList.length before throwing.
 var hits = 0;
 var bogusArgumentList = {get length() { hit++; throw "FAIL";}};
 assertThrowsInstanceOf(() => Reflect.apply({callable: false}, null, bogusArgumentList),
--- a/js/src/tests/ecma_6/Reflect/construct.js
+++ b/js/src/tests/ecma_6/Reflect/construct.js
@@ -25,26 +25,16 @@ assertDeepEq(Reflect.construct(f, [3]), 
 f.prototype = Array.prototype;
 assertDeepEq(Reflect.construct(f, [3]), new f(3));
 
 // Bound functions:
 var bound = f.bind(null, "carrot");
 assertDeepEq(Reflect.construct(bound, []), new bound);
 
 // Classes:
-function classesEnabled(testCode = "class Foo { constructor() {} }") {
-    try {
-        new Function(testCode);
-        return true;
-    } catch (e) {
-        if (!(e instanceof SyntaxError))
-            throw e;
-        return false;
-    }
-}
 if (classesEnabled()) {
     eval(`{
         class Base {
             constructor(...args) {
                 this.args = args;
                 this.newTarget = new.target;
             }
         }
--- a/js/src/tests/ecma_6/shell.js
+++ b/js/src/tests/ecma_6/shell.js
@@ -210,8 +210,19 @@ if (typeof assertWarning === 'undefined'
         enableLastWarning();
         func();
         var warning = getLastWarning();
         assertEq(warning !== null, true);
         assertEq(warning.name, name);
         disableLastWarning();
     }
 }
+
+function classesEnabled(testCode = "class Foo { constructor() {} }") {
+    try {
+        new Function(testCode);
+        return true;
+    } catch (e) {
+        if (!(e instanceof SyntaxError))
+            throw e;
+        return false;
+    }
+}