Skip to content

Commit

Permalink
Bug 1415483 - Apply the new options to reject-importGlobalProperties …
Browse files Browse the repository at this point in the history
…across the codebase, remove unnecessary importGlobalProperties. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D13754

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Standard8 committed Dec 11, 2018
1 parent e2234d6 commit 0304564
Show file tree
Hide file tree
Showing 59 changed files with 12 additions and 119 deletions.
18 changes: 0 additions & 18 deletions accessible/tests/mochitest/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,6 @@ const nsIDOMWindow = Ci.nsIDOMWindow;

const nsIPropertyElement = Ci.nsIPropertyElement;

// Testing "'Node' in this" doesn't do the right thing because there are cases
// when our "this" is not the global even though we're at toplevel. In those
// cases, the import could fail because our global is a Window and we in fact
// have a Node all along.
//
// We could get the global via the (function() { return this; })() trick, but
// that might break any time if people switch us to strict mode. So let's just
// test the thing we care about directly: does bareword Node exist?
let needToImportNode = false;
try {
Node;
} catch (e) {
needToImportNode = true;
}
if (needToImportNode) {
Cu.importGlobalProperties(["Node"]);
}

// //////////////////////////////////////////////////////////////////////////////
// OS detect

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ add_task(async function test_displayURI_camera() {

add_task(async function test_displayURI_geo_blob() {
await check(async function() {
Cu.importGlobalProperties(["Blob"]);
let text = "<script>navigator.geolocation.getCurrentPosition(() => {})</script>";
let blob = new Blob([text], {type: "text/html"});
let url = content.URL.createObjectURL(blob);
Expand All @@ -102,11 +101,9 @@ add_task(async function test_displayURI_geo_blob() {

add_task(async function test_displayURI_camera_blob() {
await check(async function() {
Cu.importGlobalProperties(["Blob"]);
let text = "<script>navigator.mediaDevices.getUserMedia({video: true, fake: true})</script>";
let blob = new Blob([text], {type: "text/html"});
let url = content.URL.createObjectURL(blob);
content.location.href = url;
}, {skipOnExtension: true});
});

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ add_task(async function() {
"https://example.com") + "dummy_page.html";
await BrowserTestUtils.withNewTab(uri, async (browser) => {
await ContentTask.spawn(browser, null, async () => {
Cu.importGlobalProperties(["Blob", "URL"]);
let debug = {hello: "world"};
let blob = new Blob([JSON.stringify(debug, null, 2)], {type: "application/json"});
let blobUri = URL.createObjectURL(blob);
Expand Down
3 changes: 0 additions & 3 deletions browser/modules/test/unit/test_LiveBookmarkMigrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const {PlacesUtils} =
const {LiveBookmarkMigrator} =
ChromeUtils.import("resource:///modules/LiveBookmarkMigrator.jsm", {});

Cu.importGlobalProperties(["URL"]);

const kTestData = {
guid: PlacesUtils.bookmarks.toolbarGuid,
children: [
Expand Down Expand Up @@ -164,4 +162,3 @@ add_task(async function check_replace_bookmarks_correctly() {
}
}
});

1 change: 1 addition & 0 deletions dom/filesystem/compat/tests/script_entries.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mozilla/frame-script */
// eslint-disable-next-line mozilla/reject-importGlobalProperties
Cu.importGlobalProperties(["File", "Directory"]);
ChromeUtils.import("resource://gre/modules/Services.jsm");
var tmpFile, tmpDir;
Expand Down
1 change: 1 addition & 0 deletions dom/filesystem/tests/script_fileList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mozilla/frame-script */
// eslint-disable-next-line mozilla/reject-importGlobalProperties
Cu.importGlobalProperties(["File"]);
ChromeUtils.import("resource://gre/modules/Services.jsm");
function createProfDFile() {
Expand Down
2 changes: 1 addition & 1 deletion dom/indexedDB/test/test_message_manager_ipc.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
const blobText = blobData.join("");
const blobType = "text/plain";

Cu.importGlobalProperties(["indexedDB", "Blob"]);
Cu.importGlobalProperties(["indexedDB"]);

function info(msg) {
sendAsyncMessage(mmName, { op: "info", msg });
Expand Down
4 changes: 1 addition & 3 deletions dom/indexedDB/test/unit/xpcshell-head-parent-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ var { "classes": Cc, "interfaces": Ci, "utils": Cu } = Components;

ChromeUtils.import("resource://gre/modules/Services.jsm");

Cu.importGlobalProperties(["Blob"]);

if (!("self" in this)) {
this.self = this;
}
Expand Down Expand Up @@ -49,7 +47,7 @@ if (!this.runTest) {
enableExperimental();
}

Cu.importGlobalProperties(["indexedDB", "Blob", "File", "FileReader"]);
Cu.importGlobalProperties(["indexedDB"]);

do_test_pending();
testGenerator.next();
Expand Down
2 changes: 0 additions & 2 deletions mobile/android/tests/browser/robocop/testVideoControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/SimpleServiceDiscovery.jsm");

Cu.importGlobalProperties(["InspectorUtils"]);

// The chrome window
var chromeWin;

Expand Down
2 changes: 0 additions & 2 deletions netwerk/test/httpserver/test/test_default_index_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ XPCOMUtils.defineLazyGetter(this, "BASE_URL", function() {
return "http://localhost:" + srv.identity.primaryPort + "/";
});

Cu.importGlobalProperties(["DOMParser"]);

function run_test() {
createTestDirectory();

Expand Down
2 changes: 0 additions & 2 deletions security/sandbox/test/browser_bug1393259.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ add_task(async function() {

// Get a list of fonts being used to display the web content.
let fontList = await ContentTask.spawn(aBrowser, {}, async function() {
Cu.importGlobalProperties(["InspectorUtils"]);

let window = content.window.wrappedJSObject;
let range = window.document.createRange();
let contentDiv = window.document.getElementById("content");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ var { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm", {});
var { FileUtils } = ChromeUtils.import("resource://gre/modules/FileUtils.jsm", {});
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});

Cu.importGlobalProperties(["XMLHttpRequest"]);

var gCertDB = Cc["@mozilla.org/security/x509certdb;1"]
.getService(Ci.nsIX509CertDB);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");

Cu.importGlobalProperties(["XMLHttpRequest"]);

const SOURCE = "https://chromium.googlesource.com/chromium/src/net/+/master/http/transport_security_state_static.json?format=TEXT";
const TOOL_SOURCE = "https://hg.mozilla.org/mozilla-central/file/tip/taskcluster/docker/periodic-updates/scripts/getHSTSPreloadList.js";
const OUTPUT = "nsSTSPreloadList.inc";
Expand Down
2 changes: 0 additions & 2 deletions testing/marionette/test/unit/test_navigate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

Cu.importGlobalProperties(["URL"]);

ChromeUtils.import("chrome://marionette/content/navigate.js");

add_test(function test_isLoadEventExpected() {
Expand Down
2 changes: 0 additions & 2 deletions testing/mochitest/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ function loadChromeScripts(win) {

// ///// Android ///////

Cu.importGlobalProperties(["TextDecoder"]);

const windowTracker = {
init() {
Services.obs.addObserver(this, "chrome-document-global-created");
Expand Down
2 changes: 0 additions & 2 deletions testing/modules/TestUtils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ var EXPORTED_SYMBOLS = [
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Timer.jsm");

Cu.importGlobalProperties(["Element"]);

var TestUtils = {
executeSoon(callbackFn) {
Services.tm.dispatchToMainThread(callbackFn);
Expand Down
1 change: 0 additions & 1 deletion testing/specialpowers/content/SpecialPowersObserver.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
var EXPORTED_SYMBOLS = ["SpecialPowersObserver"];

ChromeUtils.import("resource://gre/modules/Services.jsm");
Cu.importGlobalProperties(["File"]);

const CHILD_SCRIPT_API = "resource://specialpowers/specialpowersFrameScript.js";
const CHILD_LOGGER_SCRIPT = "resource://specialpowers/MozillaLogger.js";
Expand Down
9 changes: 0 additions & 9 deletions testing/specialpowers/content/specialpowersAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ ChromeUtils.defineModuleGetter(this, "ServiceWorkerCleanUp",
ChromeUtils.defineModuleGetter(this, "PerTestCoverageUtils",
"resource://testing-common/PerTestCoverageUtils.jsm");

try {
Cu.importGlobalProperties(["DOMParser", "File", "InspectorUtils",
"NodeFilter", "PromiseDebugging"]);
} catch (e) {
// We are in window scope hence DOMParser, File, InspectorUtils, NodeFilter,
// and PromiseDebugging are already defined, So do nothing.
}

// Allow stuff from this scope to be accessed from non-privileged scopes. This
// would crash if used outside of automation.
Cu.forcePermissiveCOWs();
Expand Down Expand Up @@ -517,7 +509,6 @@ SpecialPowersAPI.prototype = {
var mc = new window.MessageChannel();
sb.port = mc.port1;
try {
Cu.importGlobalProperties(["URL", "Blob"]);
let blob = new Blob([str], {type: "application/javascript"});
let blobUrl = URL.createObjectURL(blob);
Services.scriptloader.loadSubScript(blobUrl, sb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ this.sessionrestore = class extends ExtensionAPI {
// Because we're running this part of the test in the parent process, we
// pull those arguments from the top window directly. This is mainly so
// that TalosParentProfiler knows where to save the profile.
// eslint-disable-next-line mozilla/reject-importGlobalProperties
Cu.importGlobalProperties(["URL"]);
let url = new URL(args.queryElementAt(0, Ci.nsISupportsString).data);
this.TalosParentProfiler.initFromURLQueryParams(url.search);
Expand Down
2 changes: 0 additions & 2 deletions testing/talos/talos/talos-powers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "resProto",
"@mozilla.org/network/protocol;1?name=resource",
"nsISubstitutingProtocolHandler");

Cu.importGlobalProperties(["TextEncoder"]);

const Cm = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);

let frameScriptURL;
Expand Down
2 changes: 0 additions & 2 deletions testing/xpcshell/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ let _NetUtil = ChromeUtils.import("resource://gre/modules/NetUtil.jsm", null).Ne

let _XPCOMUtils = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", null).XPCOMUtils;

Cu.importGlobalProperties(["XMLHttpRequest"]);

// Support a common assertion library, Assert.jsm.
var AssertCls = ChromeUtils.import("resource://testing-common/Assert.jsm", null).Assert;
// Pass a custom report function for xpcshell-test style reporting.
Expand Down
1 change: 1 addition & 0 deletions toolkit/components/extensions/child/ext-userScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var USERSCRIPT_DISABLED_ERRORMSG = `userScripts APIs are currently experimental

XPCOMUtils.defineLazyPreferenceGetter(this, "userScriptsEnabled", USERSCRIPT_PREFNAME, false);

// eslint-disable-next-line mozilla/reject-importGlobalProperties
Cu.importGlobalProperties(["crypto", "TextEncoder"]);

var {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var EXPORTED_SYMBOLS = ["webrequest_test"];

Cu.importGlobalProperties(["fetch", "XMLHttpRequest"]);
Cu.importGlobalProperties(["fetch"]);

var webrequest_test = {
testFetch(url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ const {escaped} = ChromeUtils.import("resource://testing-common/AddonTestUtils.j

const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);

Cu.importGlobalProperties(["URL"]);

// Make sure media pre-loading is enabled on Android so that our <audio> and
// <video> elements trigger the expected requests.
Services.prefs.setIntPref("media.autoplay.default", Ci.nsIAutoplay.ALLOWED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ server.registerDirectory("/data/", do_get_file("data"));

const BASE_URL = `http://localhost:${server.identity.primaryPort}/data`;

Cu.importGlobalProperties(["XMLHttpRequest"]);

const {
createAppInfo,
promiseShutdownManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

PromiseTestUtils.whitelistRejectionsGlobally(/Message manager disconnected/);

Cu.importGlobalProperties(["Blob", "URL"]);

ChromeUtils.import("resource://gre/modules/ExtensionCommon.jsm");
const {ExtensionAPI} = ExtensionCommon;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"use strict";

Cu.importGlobalProperties(["XMLHttpRequest"]);

const proxy = createHttpServer();

// accept proxy connections for mozilla.org
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"use strict";

Cu.importGlobalProperties(["XMLHttpRequest"]);

const proxy = createHttpServer();

// accept proxy connections for mozilla.org
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Tests whether we can redirect to a moz-extension: url.
ChromeUtils.defineModuleGetter(this, "TestUtils",
"resource://testing-common/TestUtils.jsm");
Cu.importGlobalProperties(["XMLHttpRequest"]);

PromiseTestUtils.whitelistRejectionsGlobally(/Message manager disconnected/);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
ChromeUtils.import("resource://gre/modules/ExtensionCommon.jsm");
const {ExtensionAPI} = ExtensionCommon;

Cu.importGlobalProperties(["Blob", "URL"]);

add_task(async function() {
const schema = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
ChromeUtils.import("resource://gre/modules/ExtensionCommon.jsm");
const {ExtensionAPI} = ExtensionCommon;

Cu.importGlobalProperties(["Blob", "URL"]);

AddonTestUtils.init(this);
AddonTestUtils.overrideCertDB();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"use strict";

Cu.importGlobalProperties(["URL"]);

const HOSTS = new Set([
"example.com",
]);
Expand Down
1 change: 0 additions & 1 deletion toolkit/components/osfile/modules/ospath_unix.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
// Boilerplate used to be able to import this module both from the main
// thread and from worker threads.
if (typeof Components != "undefined") {
Cu.importGlobalProperties(["URL"]);
// Global definition of |exports|, to keep everybody happy.
// In non-main thread, |exports| is provided by the module
// loader.
Expand Down
1 change: 0 additions & 1 deletion toolkit/components/osfile/modules/ospath_win.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
// Boilerplate used to be able to import this module both from the main
// thread and from worker threads.
if (typeof Components != "undefined") {
Cu.importGlobalProperties(["URL"]);
// Global definition of |exports|, to keep everybody happy.
// In non-main thread, |exports| is provided by the module
// loader.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

"use strict";

Cu.importGlobalProperties(["URL"]);

add_task(async function test_getFieldOverrides() {
let recipes = new Set([
{ // path doesn't match but otherwise good
Expand Down
2 changes: 0 additions & 2 deletions toolkit/components/places/tests/PlacesTestUtils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ var EXPORTED_SYMBOLS = [
"PlacesTestUtils",
];

Cu.importGlobalProperties(["URL"]);

ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.defineModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
Expand Down
2 changes: 0 additions & 2 deletions toolkit/components/places/tests/head_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const TRANSITION_RELOAD = Ci.nsINavHistoryService.TRANSITION_RELOAD;

const TITLE_LENGTH_MAX = 4096;

Cu.importGlobalProperties(["URL"]);

ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
FileUtils: "resource://gre/modules/FileUtils.jsm",
Expand Down
3 changes: 0 additions & 3 deletions toolkit/components/places/tests/history/test_remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

"use strict";

Cu.importGlobalProperties(["URL"]);


// Test removing a single page
add_task(async function test_remove_single() {
await PlacesUtils.history.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

"use strict";

Cu.importGlobalProperties(["URL"]);

ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm", this);

add_task(async function test_removeVisitsByFilter() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Cu.importGlobalProperties(["URL", "crypto"]);
Cu.importGlobalProperties(["crypto"]);

const { TYPE_BOOKMARK, TYPE_FOLDER } = Ci.nsINavBookmarksService;
const { EXPIRE_NEVER, TYPE_INT32 } = Ci.nsIAnnotationService;
Expand Down
Loading

0 comments on commit 0304564

Please sign in to comment.