Bug 1392602 - Remove evaluate function. r=jdescottes draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 28 Aug 2017 14:01:34 +0200
changeset 657248 1e2c90c2949323772087b06a4fd53f143a2e84fc
parent 657247 c9bb637f4b35a8d989f2e04515765ecd0092ca39
child 657249 8f687043e921618e87387664845edd77805fff65
push id77496
push userbmo:poirot.alex@gmail.com
push dateFri, 01 Sep 2017 09:32:27 +0000
reviewersjdescottes
bugs1392602
milestone57.0a1
Bug 1392602 - Remove evaluate function. r=jdescottes MozReview-Commit-ID: MGXxIWUxWF
devtools/shared/base-loader.js
--- a/devtools/shared/base-loader.js
+++ b/devtools/shared/base-loader.js
@@ -186,35 +186,16 @@ const Sandbox = function Sandbox(options
   delete sandbox.Iterator;
   delete sandbox.Components;
   delete sandbox.importFunction;
   delete sandbox.debug;
 
   return sandbox;
 }
 
-// Evaluates code from the given `uri` into given `sandbox`. If
-// `options.source` is passed, then that code is evaluated instead.
-// Optionally following options may be given:
-// - `options.encoding`: Source encoding, defaults to 'UTF-8'.
-// - `options.line`: Line number to start count from for stack traces.
-//    Defaults to 1.
-// - `options.version`: Version of JS used, defaults to '1.8'.
-const evaluate = function evaluate(sandbox, uri, options) {
-  let { source, line, version, encoding } = override({
-    encoding: 'UTF-8',
-    line: 1,
-    version: '1.8',
-    source: null
-  }, options);
-
-  return source ? Cu.evalInSandbox(source, sandbox, version, uri, line)
-                : loadSubScript(uri, sandbox, encoding);
-};
-
 // Populates `exports` of the given CommonJS `module` object, in the context
 // of the given `loader` by evaluating code associated with it.
 const load = function load(loader, module) {
   let { sandboxes, globals, loadModuleHook } = loader;
   let require = Require(loader, module);
 
   // We expose set of properties defined by `CommonJS` specification via
   // prototype of the sandbox. Also globals are deeper in the prototype
@@ -272,17 +253,17 @@ const load = function load(loader, modul
         URI: module.uri
       }
     });
   }
   sandboxes[module.uri] = sandbox;
 
   let originalExports = module.exports;
   try {
-    evaluate(sandbox, module.uri);
+    loadSubScript(module.uri, sandbox, 'UTF-8');
   }
   catch (error) {
     let { message, fileName, lineNumber } = error;
     let stack = error.stack || Error().stack;
     let frames = parseStack(stack).filter(isntLoaderFrame);
     let toString = String(error);
     let file = sourceURI(fileName);