Skip to content

Commit

Permalink
Bug 1561435 - Format xpcom/, a=automatic-formatting
Browse files Browse the repository at this point in the history
# ignore-this-changeset

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

--HG--
extra : source : 5a77e5b70e89a23705d3767c223420be2587ae0e
  • Loading branch information
Victor Porof committed Jul 17, 2019
1 parent 16bc84f commit f0f66bc
Show file tree
Hide file tree
Showing 40 changed files with 996 additions and 665 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ module.exports = {
"overrides": [{
"files": [
"devtools/**",
"xpcom/**",
"xpfe/**",
],
"rules": {
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ toolkit/components/telemetry/datareporting-prefs.js
toolkit/components/telemetry/healthreport-prefs.js

# Ignore all top-level directories for now.
xpcom/**
xpfe/**

# Ignore all devtools directories for now, except the debugger.
Expand Down
31 changes: 20 additions & 11 deletions xpcom/tests/TestWinReg.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ const nsIWindowsRegKey = Ci.nsIWindowsRegKey;
const BASE_PATH = "SOFTWARE\\Mozilla\\Firefox";

function idump(indent, str) {
for (var j = 0; j < indent; ++j)
for (var j = 0; j < indent; ++j) {
dump(" ");
}
dump(str);
}

Expand All @@ -24,10 +25,11 @@ function list_values(indent, key) {
if (key.getValueType(vn) == nsIWindowsRegKey.TYPE_STRING) {
val = key.readStringValue(vn);
}
if (vn == "")
idump(indent + 1, "(Default): \"" + val + "\"\n");
else
idump(indent + 1, vn + ": \"" + val + "\"\n");
if (vn == "") {
idump(indent + 1, '(Default): "' + val + '"\n');
} else {
idump(indent + 1, vn + ': "' + val + '"\n');
}
}
idump(indent, "}\n");
}
Expand All @@ -44,13 +46,20 @@ function list_children(indent, key) {
}

// enumerate everything under BASE_PATH
var key = Cc["@mozilla.org/windows-registry-key;1"].
createInstance(nsIWindowsRegKey);
key.open(nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE, BASE_PATH,
nsIWindowsRegKey.ACCESS_READ);
var key = Cc["@mozilla.org/windows-registry-key;1"].createInstance(
nsIWindowsRegKey
);
key.open(
nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
BASE_PATH,
nsIWindowsRegKey.ACCESS_READ
);
list_children(1, key);

key.close();
key.open(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, BASE_PATH,
nsIWindowsRegKey.ACCESS_READ);
key.open(
nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
BASE_PATH,
nsIWindowsRegKey.ACCESS_READ
);
list_children(1, key);
5 changes: 3 additions & 2 deletions xpcom/tests/unit/data/child_process_directive_service.js
Original file line number Diff line number Diff line change
@@ -1,11 +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/. */
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);

function TestProcessDirective() {}
TestProcessDirective.prototype = {

/* Boilerplate */
QueryInterface: ChromeUtils.generateQI([Ci.nsIProperty]),
contractID: "@mozilla.org/xpcom/tests/ChildProcessDirectiveTest;1",
Expand Down
5 changes: 3 additions & 2 deletions xpcom/tests/unit/data/main_process_directive_service.js
Original file line number Diff line number Diff line change
@@ -1,11 +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/. */
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);

function TestProcessDirective() {}
TestProcessDirective.prototype = {

/* Boilerplate */
QueryInterface: ChromeUtils.generateQI([Ci.nsIProperty]),
contractID: "@mozilla.org/xpcom/tests/MainProcessDirectiveTest;1",
Expand Down
10 changes: 6 additions & 4 deletions xpcom/tests/unit/head_xpcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ function get_test_program(prog) {
}

function set_process_running_environment() {
var envSvc = Cc["@mozilla.org/process/environment;1"].
getService(Ci.nsIEnvironment);
var envSvc = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
// Importing Services here messes up appInfo for some of the tests.
// eslint-disable-next-line mozilla/use-services
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(
Ci.nsIProperties
);
var greBinDir = dirSvc.get("GreBinD", Ci.nsIFile);
envSvc.set("DYLD_LIBRARY_PATH", greBinDir.path);
// For Linux
Expand Down
7 changes: 3 additions & 4 deletions xpcom/tests/unit/test_bug121341.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

function run_test() {
var dataFile = do_get_file("data/bug121341.properties");
Expand Down Expand Up @@ -59,6 +59,5 @@ function run_test() {
try {
properties2.load(inp);
do_throw("load() didn't fail");
} catch (e) {
}
} catch (e) {}
}
2 changes: 1 addition & 1 deletion xpcom/tests/unit/test_bug1434856.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/ */

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

function run_test() {
let complete = false;
Expand Down
30 changes: 21 additions & 9 deletions xpcom/tests/unit/test_bug325418.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ var observer1 = {
timer.cancel();

// Actual delay may not be exact, so convert to seconds and round.
Assert.equal(Math.round((Date.now() - gStartTime1) / 1000),
kExpectedDelay1);
Assert.equal(
Math.round((Date.now() - gStartTime1) / 1000),
kExpectedDelay1
);

timer = null;

info("1st timer triggered (before being cancelled). Should not have happened!");
info(
"1st timer triggered (before being cancelled). Should not have happened!"
);
Assert.ok(false);
}
},
Expand All @@ -32,8 +36,10 @@ var observer2 = {
timer.cancel();

// Actual delay may not be exact, so convert to seconds and round.
Assert.equal(Math.round((Date.now() - gStartTime2) / 1000),
kExpectedDelay2);
Assert.equal(
Math.round((Date.now() - gStartTime2) / 1000),
kExpectedDelay2
);

timer = null;

Expand All @@ -49,12 +55,18 @@ function run_test() {

// Initialize the timer (with some delay), then cancel it.
gStartTime1 = Date.now();
timer.init(observer1, kExpectedDelay1 * 1000,
timer.TYPE_REPEATING_PRECISE_CAN_SKIP);
timer.init(
observer1,
kExpectedDelay1 * 1000,
timer.TYPE_REPEATING_PRECISE_CAN_SKIP
);
timer.cancel();

// Re-initialize the timer (with a different delay).
gStartTime2 = Date.now();
timer.init(observer2, kExpectedDelay2 * 1000,
timer.TYPE_REPEATING_PRECISE_CAN_SKIP);
timer.init(
observer2,
kExpectedDelay2 * 1000,
timer.TYPE_REPEATING_PRECISE_CAN_SKIP
);
}
2 changes: 1 addition & 1 deletion xpcom/tests/unit/test_bug332389.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

function run_test() {
var f = Services.dirsvc.get("CurProcD", Ci.nsIFile);
Expand Down
3 changes: 2 additions & 1 deletion xpcom/tests/unit/test_bug333505.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
function run_test() {
var dirEntries = do_get_cwd().directoryEntries;

while (dirEntries.hasMoreElements())
while (dirEntries.hasMoreElements()) {
dirEntries.getNext();
}

// We ensure there is no crash
dirEntries.hasMoreElements();
Expand Down
53 changes: 27 additions & 26 deletions xpcom/tests/unit/test_bug364285-1.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

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
"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
];

function getTempDir() {
return Services.dirsvc.get("TmpD", Ci.nsIFile);
return Services.dirsvc.get("TmpD", Ci.nsIFile);
}

function create_file(fileName) {
var outFile = getTempDir();
outFile.append(fileName);
outFile.createUnique(outFile.NORMAL_FILE_TYPE, 0o600);
var outFile = getTempDir();
outFile.append(fileName);
outFile.createUnique(outFile.NORMAL_FILE_TYPE, 0o600);

var stream = Cc["@mozilla.org/network/file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream);
stream.init(outFile, 0x02 | 0x08 | 0x20, 0o600, 0);
stream.write("foo", 3);
stream.close();
var stream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(
Ci.nsIFileOutputStream
);
stream.init(outFile, 0x02 | 0x08 | 0x20, 0o600, 0);
stream.write("foo", 3);
stream.close();

Assert.equal(outFile.leafName.substr(0, fileName.length), fileName);
Assert.equal(outFile.leafName.substr(0, fileName.length), fileName);

return outFile;
return outFile;
}

function test_create(fileName) {
var file1 = create_file(fileName);
var file2 = create_file(fileName);
file1.remove(false);
file2.remove(false);
var file1 = create_file(fileName);
var file2 = create_file(fileName);
file1.remove(false);
file2.remove(false);
}

function run_test() {
for (var i = 0; i < nameArray.length; ++i) {
test_create(nameArray[i]);
}
for (var i = 0; i < nameArray.length; ++i) {
test_create(nameArray[i]);
}
}
29 changes: 23 additions & 6 deletions xpcom/tests/unit/test_bug374754.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

var addedTopic = "xpcom-category-entry-added";
var removedTopic = "xpcom-category-entry-removed";
Expand All @@ -25,13 +25,18 @@ var observer = {
timer = null;
}

if (subject.QueryInterface(Ci.nsISupportsCString).data != testEntry || data != testCategory)
if (
subject.QueryInterface(Ci.nsISupportsCString).data != testEntry ||
data != testCategory
) {
return;
}

if (topic == addedTopic)
if (topic == addedTopic) {
result += "add ";
else if (topic == removedTopic)
} else if (topic == removedTopic) {
result += "remove ";
}
},
};

Expand All @@ -41,8 +46,20 @@ function run_test() {
Services.obs.addObserver(observer, addedTopic);
Services.obs.addObserver(observer, removedTopic);

Services.catMan.addCategoryEntry(testCategory, testEntry, testValue, false, true);
Services.catMan.addCategoryEntry(testCategory, testEntry, testValue, false, true);
Services.catMan.addCategoryEntry(
testCategory,
testEntry,
testValue,
false,
true
);
Services.catMan.addCategoryEntry(
testCategory,
testEntry,
testValue,
false,
true
);
Services.catMan.deleteCategoryEntry(testCategory, testEntry, false);

timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
Expand Down
10 changes: 7 additions & 3 deletions xpcom/tests/unit/test_bug476919.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ function run_test() {
// create a test file, then symlink it, then check that we think it's a symlink
var targetFile = testDir.clone();
targetFile.append("target.txt");
if (!targetFile.exists())
if (!targetFile.exists()) {
targetFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
}

var link = testDir.clone();
link.append("link");
if (link.exists())
if (link.exists()) {
link.remove(false);
}

var ln = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
ln.initWithPath("/bin/ln");
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
var process = Cc["@mozilla.org/process/util;1"].createInstance(
Ci.nsIProcess
);
process.init(ln);
var args = ["-s", targetFile.path, link.path];
process.run(true, args, args.length);
Expand Down
3 changes: 1 addition & 2 deletions xpcom/tests/unit/test_bug478086.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

function run_test() {
var nsIFile = Ci.nsIFile;
var root = Cc["@mozilla.org/file/local;1"].
createInstance(nsIFile);
var root = Cc["@mozilla.org/file/local;1"].createInstance(nsIFile);

// copied from http://mxr.mozilla.org/mozilla-central/source/image/test/unit/test_imgtools.js#135
// nsIXULRuntime.OS doesn't seem to be available in xpcshell, so we'll use
Expand Down
Loading

0 comments on commit f0f66bc

Please sign in to comment.