Bug 1339406 - Part 3: Change top-level shell.js and browser.js IIFE to strict mode. r=arai
authorAndré Bargull <andre.bargull@gmail.com>
Tue, 14 Feb 2017 10:26:11 -0800
changeset 342911 fb11e452585acf4962614232a8c80da891896ad3
parent 342910 f34ed6a5b9cae8a4147fde4710ce7f9ec4933058
child 342912 509ba75cce2b4ad687aeb7f9da68b5961a1cee4e
push id31366
push usercbook@mozilla.com
push dateWed, 15 Feb 2017 11:25:19 +0000
treeherdermozilla-central@c0807d6938c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1339406
milestone54.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 1339406 - Part 3: Change top-level shell.js and browser.js IIFE to strict mode. r=arai
js/src/tests/browser.js
js/src/tests/shell.js
--- a/js/src/tests/browser.js
+++ b/js/src/tests/browser.js
@@ -8,16 +8,18 @@
 //       nested shell.js/browser.js.  Second, can you instead add it to
 //       shell.js?  Our goal is to unify these two files for readability, and
 //       the plan is to empty out this file into that one over time.  Third,
 //       supposing you must add to this file, please add it to this IIFE for
 //       better modularity/resilience against tests that must do particularly
 //       bizarre things that might break the harness.
 
 (function initializeUtilityExports(global, parent) {
+  "use strict";
+
   /**********************************************************************
    * CACHED PRIMORDIAL FUNCTIONALITY (before a test might overwrite it) *
    **********************************************************************/
 
   var Error = global.Error;
   var String = global.String;
   var GlobalEval = global.eval;
   var ReflectApply = global.Reflect.apply;
@@ -190,16 +192,18 @@
       ReflectApply(WorkerPrototypePostMessage, worker, ["detach", [arrayBuffer]]);
     };
 
     global.detachArrayBuffer = detachArrayBuffer;
   }
 })(this);
 
 (function(global) {
+  "use strict";
+
   /**********************************************************************
    * CACHED PRIMORDIAL FUNCTIONALITY (before a test might overwrite it) *
    **********************************************************************/
 
   var ReflectApply = global.Reflect.apply;
 
   // BEWARE: ObjectGetOwnPropertyDescriptor is only safe to use if its result
   //         is inspected using own-property-examining functionality.  Directly
--- a/js/src/tests/shell.js
+++ b/js/src/tests/shell.js
@@ -5,25 +5,27 @@
 
 // NOTE: If you're adding new test harness functionality -- first, should you
 //       at all?  Most stuff is better in specific tests, or in nested shell.js
 //       or browser.js.  Second, supposing you should, please add it to this
 //       IIFE for better modularity/resilience against tests that must do
 //       particularly bizarre things that might break the harness.
 
 (function(global) {
+  "use strict";
+
   /**********************************************************************
    * CACHED PRIMORDIAL FUNCTIONALITY (before a test might overwrite it) *
    **********************************************************************/
 
   var undefined; // sigh
 
   var document = global.document;
   var Error = global.Error;
-  var eval = global.eval;
+  var Function = global.Function;
   var Number = global.Number;
   var RegExp = global.RegExp;
   var String = global.String;
   var Symbol = global.Symbol;
   var TypeError = global.TypeError;
 
   var ArrayIsArray = global.Array.isArray;
   var MathAbs = global.Math.abs;
@@ -643,19 +645,19 @@
 
     reportCompare(expectP, actualP, summary);
 
     // actual must be compilable if expect is?
     try {
       var expectCompile = 'No Error';
       var actualCompile;
 
-      eval(expect);
+      Function(expect);
       try {
-        eval(actual);
+        Function(actual);
         actualCompile = 'No Error';
       } catch(ex1) {
         actualCompile = ex1 + '';
       }
       reportCompare(expectCompile, actualCompile,
                     summary + ': compile actual');
     } catch(ex) {
     }
@@ -749,19 +751,21 @@
       dump('jsTestDriverEnd ' + ex);
     }
 
     for (var i = 0; i < gTestcases.length; i++) {
       gTestcases[i].dump();
     }
   }
   global.jsTestDriverEnd = jsTestDriverEnd;
-})(this);
 
-(function(global) {
+  /************************************
+   * PROMISE TESTING FUNCTION EXPORTS *
+   ************************************/
+
   function getPromiseResult(promise) {
     var result, error, caught = false;
     promise.then(r => { result = r; },
                  e => { caught = true; error = e; });
     drainJobQueue();
     if (caught)
       throw error;
     return result;