--- a/xpcom/tests/unit/head_xpcom.js
+++ b/xpcom/tests/unit/head_xpcom.js
@@ -1,19 +1,22 @@
+let {Constructor: CC, classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
+
function get_test_program(prog) {
var progPath = do_get_cwd();
progPath.append(prog);
progPath.leafName = progPath.leafName + mozinfo.bin_suffix;
return progPath;
}
function set_process_running_environment() {
var envSvc = Components.classes["@mozilla.org/process/environment;1"].
getService(Components.interfaces.nsIEnvironment);
+ // Importing Services here messes up appInfo for some of the tests.
+ // eslint-disable-next-line mozilla/use-services
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties);
var greBinDir = dirSvc.get("GreBinD", Components.interfaces.nsIFile);
envSvc.set("DYLD_LIBRARY_PATH", greBinDir.path);
// For Linux
envSvc.set("LD_LIBRARY_PATH", greBinDir.path);
// XXX: handle windows
}
-
--- a/xpcom/tests/unit/test_bug121341.js
+++ b/xpcom/tests/unit/test_bug121341.js
@@ -1,10 +1,8 @@
-var Ci = Components.interfaces;
-var Cu = Components.utils;
Cu.import("resource://gre/modules/NetUtil.jsm");
function run_test() {
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
var dataFile = do_get_file("data/bug121341.properties");
var channel = NetUtil.newChannel({
--- a/xpcom/tests/unit/test_bug325418.js
+++ b/xpcom/tests/unit/test_bug325418.js
@@ -1,11 +1,8 @@
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-
// 5 seconds.
const kExpectedDelay1 = 5;
// 1 second.
const kExpectedDelay2 = 1;
var gStartTime1;
var gStartTime2;
var timer;
--- a/xpcom/tests/unit/test_bug332389.js
+++ b/xpcom/tests/unit/test_bug332389.js
@@ -1,11 +1,8 @@
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-
function run_test() {
var f =
Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).get("CurProcD", Ci.nsIFile);
var terminated = false;
for (var i = 0; i < 100; i++) {
if (f == null) {
--- a/xpcom/tests/unit/test_bug364285-1.js
+++ b/xpcom/tests/unit/test_bug364285-1.js
@@ -1,11 +1,8 @@
-var Ci = Components.interfaces;
-var Cc = Components.classes;
-
var nameArray = [
"ascii", // ASCII
"fran\u00E7ais", // Latin-1
"\u0420\u0443\u0441\u0441\u043A\u0438\u0439", // Cyrillic
"\u65E5\u672C\u8A9E", // Japanese
"\u4E2D\u6587", // Chinese
"\uD55C\uAD6D\uC5B4", // Korean
"\uD801\uDC0F\uD801\uDC2D\uD801\uDC3B\uD801\uDC2B" // Deseret
--- a/xpcom/tests/unit/test_bug374754.js
+++ b/xpcom/tests/unit/test_bug374754.js
@@ -1,11 +1,8 @@
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-
var addedTopic = "xpcom-category-entry-added";
var removedTopic = "xpcom-category-entry-removed";
var testCategory = "bug-test-category";
var testEntry = "@mozilla.org/bug-test-entry;1";
var testValue = "check validity";
var result = "";
var expected = "add remove add remove ";
--- a/xpcom/tests/unit/test_bug476919.js
+++ b/xpcom/tests/unit/test_bug476919.js
@@ -1,11 +1,8 @@
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-
/* global __LOCATION__ */
function run_test() {
// skip this test on Windows
if (mozinfo.os != "win") {
var testDir = __LOCATION__.parent;
// create a test file, then symlink it, then check that we think it's a symlink
var targetFile = testDir.clone();
--- a/xpcom/tests/unit/test_bug656331.js
+++ b/xpcom/tests/unit/test_bug656331.js
@@ -1,15 +1,12 @@
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
/* global registerAppManifest */
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-
function info(s) {
dump("TEST-INFO | test_bug656331.js | " + s + "\n");
}
var gMessageExpected = /Native module.*has version 3.*expected/;
var gFound = false;
const kConsoleListener = {
--- a/xpcom/tests/unit/test_bug725015.js
+++ b/xpcom/tests/unit/test_bug725015.js
@@ -1,15 +1,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-
Components.utils.import("resource://gre/modules/Services.jsm");
const manifest = do_get_file("bug725015.manifest");
const contract = "@bug725015.test.contract";
const observerTopic = "xpcom-category-entry-added";
const category = "bug725015-test-category";
const entry = "bug725015-category-entry";
const cid = Components.ID("{05070380-6e6e-42ba-aaa5-3289fc55ca5a}");
--- a/xpcom/tests/unit/test_debugger_malloc_size_of.js
+++ b/xpcom/tests/unit/test_debugger_malloc_size_of.js
@@ -4,17 +4,16 @@
* 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/. */
// This is just a sanity test that Gecko is giving SpiderMonkey a MallocSizeOf
// function for new JSRuntimes. There is more extensive testing around the
// expected byte sizes within SpiderMonkey's jit-tests, we just want to make
// sure that Gecko is providing SpiderMonkey with the callback it needs.
-var Cu = Components.utils;
const { byteSize } = Cu.getJSTestingFunctions();
function run_test() {
const objects = [
{},
{ w: 1, x: 2, y: 3, z: 4, a: 5 },
[],
Array(10).fill(null),
--- a/xpcom/tests/unit/test_file_createUnique.js
+++ b/xpcom/tests/unit/test_file_createUnique.js
@@ -1,17 +1,13 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cr = Components.results;
-
function run_test() {
// Generate a leaf name that is 255 characters long.
var longLeafName = new Array(256).join("T");
// Generate the path for a file located in a directory with a long name.
var tempFile = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
tempFile.append(longLeafName);
--- a/xpcom/tests/unit/test_file_equality.js
+++ b/xpcom/tests/unit/test_file_equality.js
@@ -1,18 +1,14 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Cr = Components.results;
-var Ci = Components.interfaces;
-
-var CC = Components.Constructor;
var LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
function run_test() {
test_normalized_vs_non_normalized();
}
function test_normalized_vs_non_normalized() {
// get a directory that exists on all platforms
--- a/xpcom/tests/unit/test_file_renameTo.js
+++ b/xpcom/tests/unit/test_file_renameTo.js
@@ -1,16 +1,13 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-
function run_test() {
// Create the base directory.
let base = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("TmpD", Ci.nsIFile);
base.append("renameTesting");
if (base.exists()) {
base.remove(true);
--- a/xpcom/tests/unit/test_hidden_files.js
+++ b/xpcom/tests/unit/test_hidden_files.js
@@ -1,10 +1,8 @@
-var Ci = Components.interfaces;
-var Cc = Components.classes;
const NS_OS_TEMP_DIR = "TmpD";
const CWD = do_get_cwd();
var hiddenUnixFile;
function createUNIXHiddenFile() {
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
var tmpDir = dirSvc.get(NS_OS_TEMP_DIR, Ci.nsIFile);
@@ -20,9 +18,8 @@ function createUNIXHiddenFile() {
function run_test() {
// Skip this test on Windows
if (mozinfo.os == "win")
return;
do_check_true(createUNIXHiddenFile());
do_check_true(hiddenUnixFile.isHidden());
}
-
--- a/xpcom/tests/unit/test_home.js
+++ b/xpcom/tests/unit/test_home.js
@@ -1,11 +1,8 @@
-var Ci = Components.interfaces;
-var Cc = Components.classes;
-
const CWD = do_get_cwd();
function checkOS(os) {
const nsILocalFile_ = "nsILocalFile" + os;
return nsILocalFile_ in Components.interfaces &&
CWD instanceof Components.interfaces[nsILocalFile_];
}
const isWin = checkOS("Win");
--- a/xpcom/tests/unit/test_iniProcessor.js
+++ b/xpcom/tests/unit/test_iniProcessor.js
@@ -1,12 +1,8 @@
-var Ci = Components.interfaces;
-var Cc = Components.classes;
-var Cr = Components.results;
-
var testnum = 0;
var factory;
function parserForFile(filename) {
let parser = null;
try {
let file = do_get_file(filename);
do_check_true(!!file);
--- a/xpcom/tests/unit/test_ioutil.js
+++ b/xpcom/tests/unit/test_ioutil.js
@@ -1,17 +1,13 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cr = Components.results;
-
const util = Cc["@mozilla.org/io-util;1"].getService(Ci.nsIIOUtil);
function run_test() {
try {
util.inputStreamIsBuffered(null);
do_throw("inputStreamIsBuffered should have thrown");
} catch (e) {
do_check_eq(e.result, Cr.NS_ERROR_INVALID_POINTER);
--- a/xpcom/tests/unit/test_localfile.js
+++ b/xpcom/tests/unit/test_localfile.js
@@ -1,18 +1,14 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Cr = Components.results;
-var CC = Components.Constructor;
-var Ci = Components.interfaces;
-
const MAX_TIME_DIFFERENCE = 2500;
const MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
var LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
function run_test() {
test_toplevel_parent_is_null();
test_normalize_crash_if_media_missing();
--- a/xpcom/tests/unit/test_notxpcom_scriptable.js
+++ b/xpcom/tests/unit/test_notxpcom_scriptable.js
@@ -1,18 +1,13 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cu = Components.utils;
-var Cr = Components.results;
-
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const kCID = Components.ID("{1f9f7181-e6c5-4f4c-8f71-08005cec8468}");
const kContract = "@testing/notxpcomtest";
function run_test() {
let manifest = do_get_file("xpcomtest.manifest");
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
@@ -75,9 +70,8 @@ function run_test() {
try {
xpcomObject.QueryInterface(Ci.ScriptableWithNotXPCOMBase);
ok(false, "Should not have implemented ScriptableWithNotXPCOMBase");
} catch (e) {
ok(true, "Should not have implemented ScriptableWithNotXPCOMBase. Correctly threw error: " + e);
}
strictEqual(xpcomObject.method3, undefined);
}
-
--- a/xpcom/tests/unit/test_nsIMutableArray.js
+++ b/xpcom/tests/unit/test_nsIMutableArray.js
@@ -1,17 +1,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Ci = Components.interfaces;
-var Cr = Components.results;
-var Cc = Components.classes;
-var CC = Components.Constructor;
-
var MutableArray = CC("@mozilla.org/array;1", "nsIMutableArray");
var SupportsString = CC("@mozilla.org/supports-string;1", "nsISupportsString");
function create_n_element_array(n) {
var arr = new MutableArray();
for (let i = 0; i < n; i++) {
let str = new SupportsString();
str.data = "element " + i;
--- a/xpcom/tests/unit/test_pipe.js
+++ b/xpcom/tests/unit/test_pipe.js
@@ -1,19 +1,14 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cr = Components.results;
-var CC = Components.Constructor;
-
var Pipe = CC("@mozilla.org/pipe;1", "nsIPipe", "init");
function run_test() {
test_not_initialized();
test_ends_are_threadsafe();
}
function test_not_initialized() {
--- a/xpcom/tests/unit/test_process_directives.js
+++ b/xpcom/tests/unit/test_process_directives.js
@@ -1,11 +1,8 @@
-var Ci = Components.interfaces;
-var Cc = Components.classes;
-
Components.utils.import("resource://gre/modules/Services.jsm");
function run_test() {
Components.manager.autoRegister(do_get_file("data/process_directive.manifest"));
let isChild = Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT;
if (isChild) {
--- a/xpcom/tests/unit/test_seek_multiplex.js
+++ b/xpcom/tests/unit/test_seek_multiplex.js
@@ -1,17 +1,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Ci = Components.interfaces;
-var Cr = Components.results;
-var CC = Components.Constructor;
-var Cc = Components.classes;
-
// The string we use as data.
const data = "0123456789";
// Number of streams in the multiplex stream.
const count = 10;
function test_multiplex_streams() {
var MultiplexStream = CC("@mozilla.org/io/multiplex-input-stream;1",
"nsIMultiplexInputStream");
@@ -155,9 +150,8 @@ function test_multiplex_bug797871() {
seekable.seek(Ci.nsISeekableStream.NS_SEEK_SET, 20);
do_check_eq(seekable.tell(), 20);
}
function run_test() {
test_multiplex_streams();
test_multiplex_bug797871();
}
-
--- a/xpcom/tests/unit/test_storagestream.js
+++ b/xpcom/tests/unit/test_storagestream.js
@@ -1,20 +1,16 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "unusedVariable" }] */
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cr = Components.results;
-
function run_test() {
test1();
test2();
test3();
test4();
}
/**
--- a/xpcom/tests/unit/test_streams.js
+++ b/xpcom/tests/unit/test_streams.js
@@ -1,16 +1,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Ci = Components.interfaces;
-var Cr = Components.results;
-var CC = Components.Constructor;
-
var Pipe = CC("@mozilla.org/pipe;1",
"nsIPipe",
"init");
var BinaryOutput = CC("@mozilla.org/binaryoutputstream;1",
"nsIBinaryOutputStream",
"setOutputStream");
var BinaryInput = CC("@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream",
--- a/xpcom/tests/unit/test_stringstream.js
+++ b/xpcom/tests/unit/test_stringstream.js
@@ -1,17 +1,13 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cr = Components.results;
-
function run_test() {
var s = Cc["@mozilla.org/io/string-input-stream;1"]
.createInstance(Ci.nsIStringInputStream);
var body = "This is a test";
s.setData(body, body.length);
do_check_eq(s.available(), body.length);
var sis = Cc["@mozilla.org/scriptableinputstream;1"]
--- a/xpcom/tests/unit/test_windows_cmdline_file.js
+++ b/xpcom/tests/unit/test_windows_cmdline_file.js
@@ -1,9 +1,8 @@
-let { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm");
let executableFile = Services.dirsvc.get("CurProcD", Ci.nsIFile);
executableFile.append("xpcshell.exe");
function run_test() {
let quote = '"'; // Windows' cmd processor doesn't actually use single quotes.
for (let suffix of ["", " -osint", ` --blah "%PROGRAMFILES%"`]) {
let cmdline = quote + executableFile.path + quote + suffix;
--- a/xpcom/tests/unit/test_windows_registry.js
+++ b/xpcom/tests/unit/test_windows_registry.js
@@ -1,21 +1,15 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-const Cr = Components.results;
-const Ci = Components.interfaces;
-const Cc = Components.classes;
-const Cu = Components.utils;
-const CC = Components.Constructor;
-
const nsIWindowsRegKey = Ci.nsIWindowsRegKey;
let regKeyComponent = Cc["@mozilla.org/windows-registry-key;1"];
function run_test() {
//* create a key structure in a spot that's normally writable (somewhere under HKCU).
let testKey = regKeyComponent.createInstance(nsIWindowsRegKey);
// If it's already present because a previous test crashed or didn't clean up properly, clean it up first.
--- a/xpcom/tests/unit/test_windows_shortcut.js
+++ b/xpcom/tests/unit/test_windows_shortcut.js
@@ -1,21 +1,15 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
-var Cr = Components.results;
-var Ci = Components.interfaces;
-var Cc = Components.classes;
-var Cu = Components.utils;
-var CC = Components.Constructor;
-
const LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
Cu.import("resource://gre/modules/Services.jsm");
function run_test() {
// This test makes sense only on Windows, so skip it on other platforms
if ("nsILocalFileWin" in Ci
&& do_get_cwd() instanceof Ci.nsILocalFileWin) {