From 1d0ba580081ee835a6ac509349a8d5bc391078fe Mon Sep 17 00:00:00 2001 From: vinoth Date: Fri, 31 Aug 2018 20:30:52 +0000 Subject: [PATCH] Bug 1482347 - Usage of Eval in specialpowersAPI.js removed. r=bzbarsky Differential Revision: https://phabricator.services.mozilla.com/D4311 --HG-- extra : moz-landing-system : lando --- testing/specialpowers/content/specialpowersAPI.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/testing/specialpowers/content/specialpowersAPI.js b/testing/specialpowers/content/specialpowersAPI.js index 8375f40bb73d..00fc5cacecb5 100644 --- a/testing/specialpowers/content/specialpowersAPI.js +++ b/testing/specialpowers/content/specialpowersAPI.js @@ -37,13 +37,11 @@ ChromeUtils.defineModuleGetter(this, "ServiceWorkerCleanUp", ChromeUtils.defineModuleGetter(this, "PerTestCoverageUtils", "resource://testing-common/PerTestCoverageUtils.jsm"); -// We're loaded with "this" not set to the global in some cases, so we -// have to play some games to get at the global object here. Normally -// we'd try "this" from a function called with undefined this value, -// but this whole file is in strict mode. So instead fall back on -// returning "this" from indirect eval, which returns the global. -if (!(function() { var e = eval; return e("this"); })().File) { // eslint-disable-line no-eval +try { Cu.importGlobalProperties(["DOMParser", "File", "InspectorUtils", "NodeFilter"]); +} catch (e) { + // We are in window scope hence DOMParser, File, InspectorUtils and NodeFilter + // are already defined, So do nothing. } // Allow stuff from this scope to be accessed from non-privileged scopes. This