Bug 1403959, part 2 - Automatically generated eslint fixes. r=froydnj

These were generated with |./mach eslint --fix xpcom| with the
.eslintignore and xpcom/tests/unit/.eslintrc.js changes from the next
patch.

MozReview-Commit-ID: 8pKkICSK3JQ

--HG--
extra : rebase_source : bbc98050928f27160d8ca63d38aa0c383be95878
This commit is contained in:
Andrew McCreight 2017-09-28 15:49:04 -07:00
parent ae916ca971
commit 4ae455cdc5
36 changed files with 209 additions and 322 deletions

View File

@ -15,9 +15,9 @@ function INIProcessorFactory() {
INIProcessorFactory.prototype = {
classID: Components.ID("{6ec5f479-8e13-4403-b6ca-fe4c2dca14fd}"),
QueryInterface : XPCOMUtils.generateQI([Ci.nsIINIParserFactory]),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIINIParserFactory]),
createINIParser : function (aINIFile) {
createINIParser(aINIFile) {
return new INIProcessor(aINIFile);
}
@ -35,9 +35,9 @@ function INIProcessor(aFile) {
}
INIProcessor.prototype = {
QueryInterface : XPCOMUtils.generateQI([Ci.nsIINIParser, Ci.nsIINIParserWriter]),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIINIParser, Ci.nsIINIParserWriter]),
__utf8Converter : null, // UCS2 <--> UTF8 string conversion
__utf8Converter: null, // UCS2 <--> UTF8 string conversion
get _utf8Converter() {
if (!this.__utf8Converter) {
this.__utf8Converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
@ -47,7 +47,7 @@ INIProcessor.prototype = {
return this.__utf8Converter;
},
__utf16leConverter : null, // UCS2 <--> UTF16LE string conversion
__utf16leConverter: null, // UCS2 <--> UTF16LE string conversion
get _utf16leConverter() {
if (!this.__utf16leConverter) {
this.__utf16leConverter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
@ -57,18 +57,18 @@ INIProcessor.prototype = {
return this.__utf16leConverter;
},
_utfConverterReset : function() {
_utfConverterReset() {
this.__utf8Converter = null;
this.__utf16leConverter = null;
},
_iniFile : null,
_iniData : null,
_iniFile: null,
_iniData: null,
/*
* Reads the INI file and stores the data internally.
*/
_readFile : function() {
_readFile() {
// If file doesn't exist, there's nothing to do.
if (!this._iniFile.exists() || 0 == this._iniFile.fileSize)
return;
@ -85,14 +85,14 @@ INIProcessor.prototype = {
// nsIINIParser
getSections : function() {
getSections() {
let sections = [];
for (let section in this._iniData)
sections.push(section);
return new stringEnumerator(sections);
},
getKeys : function(aSection) {
getKeys(aSection) {
let keys = [];
if (aSection in this._iniData)
for (let key in this._iniData[aSection])
@ -100,7 +100,7 @@ INIProcessor.prototype = {
return new stringEnumerator(keys);
},
getString : function(aSection, aKey) {
getString(aSection, aKey) {
if (!(aSection in this._iniData))
throw Cr.NS_ERROR_FAILURE;
if (!(aKey in this._iniData[aSection]))
@ -111,7 +111,7 @@ INIProcessor.prototype = {
// nsIINIParserWriter
setString : function(aSection, aKey, aValue) {
setString(aSection, aKey, aValue) {
const isSectionIllegal = /[\0\r\n\[\]]/;
const isKeyValIllegal = /[\0\r\n=]/;
@ -128,7 +128,7 @@ INIProcessor.prototype = {
this._iniData[aSection][aKey] = aValue;
},
writeFile : function(aFile, aFlags) {
writeFile(aFile, aFlags) {
let converter;
function writeLine(data) {
@ -152,7 +152,7 @@ INIProcessor.prototype = {
outputStream.QueryInterface(Ci.nsISafeOutputStream); // for .finish()
if (Ci.nsIINIParserWriter.WRITE_UTF16 == aFlags
&& 'nsIWindowsRegKey' in Ci) {
&& "nsIWindowsRegKey" in Ci) {
outputStream.write("\xFF\xFE", 2);
converter = this._utf16leConverter;
} else {
@ -174,16 +174,16 @@ function stringEnumerator(stringArray) {
this._strings = stringArray;
}
stringEnumerator.prototype = {
QueryInterface : XPCOMUtils.generateQI([Ci.nsIUTF8StringEnumerator]),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIUTF8StringEnumerator]),
_strings : null,
_strings: null,
_enumIndex: 0,
hasMore : function() {
hasMore() {
return (this._enumIndex < this._strings.length);
},
getNext : function() {
getNext() {
return this._strings[this._enumIndex++];
}
};

View File

@ -14,4 +14,4 @@
Please update your links.
</center>
</body>
</html>
</html>

View File

@ -5,8 +5,7 @@
function X() { dump("X\n"); }
function Y() { dump("Y\n"); }
function boom()
{
function boom() {
dump("Start9\n");
var div = document.getElementById("v");
@ -15,7 +14,7 @@ function boom()
div.appendChild(textNode);
document.addEventListener("DOMCharacterDataModified", X, true);
textNode.data += 'B';
textNode.data += "B";
document.removeEventListener("DOMCharacterDataModified", X, true);
document.addEventListener("DOMAttrModified", Y, true);

View File

@ -9,8 +9,7 @@
const nsIWindowsRegKey = Components.interfaces.nsIWindowsRegKey;
const BASE_PATH = "SOFTWARE\\Mozilla\\Firefox";
function idump(indent, str)
{
function idump(indent, str) {
for (var j = 0; j < indent; ++j)
dump(" ");
dump(str);
@ -25,11 +24,11 @@ function list_values(indent, key) {
if (key.getValueType(vn) == nsIWindowsRegKey.TYPE_STRING) {
val = key.readStringValue(vn);
}
if (vn == "")
if (vn == "")
idump(indent + 1, "(Default): \"" + val + "\"\n");
else
idump(indent + 1, vn + ": \"" + val + "\"\n");
}
}
idump(indent, "}\n");
}

View File

@ -13,7 +13,7 @@ TestProcessDirective.prototype = {
type: Components.interfaces.nsISupportsString.TYPE_STRING,
data: "child process",
toString: function() {
toString() {
return this.data;
}
};

View File

@ -13,7 +13,7 @@ TestProcessDirective.prototype = {
type: Components.interfaces.nsISupportsString.TYPE_STRING,
data: "main process",
toString: function() {
toString() {
return this.data;
}
};

View File

@ -1,13 +1,11 @@
function get_test_program(prog)
{
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()
{
function set_process_running_environment() {
var envSvc = Components.classes["@mozilla.org/process/environment;1"].
getService(Components.interfaces.nsIEnvironment);
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"].
@ -16,6 +14,6 @@ function set_process_running_environment()
envSvc.set("DYLD_LIBRARY_PATH", greBinDir.path);
// For Linux
envSvc.set("LD_LIBRARY_PATH", greBinDir.path);
//XXX: handle windows
// XXX: handle windows
}

View File

@ -5,7 +5,7 @@ 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({
uri: ios.newFileURI(dataFile, null, null),
@ -65,7 +65,6 @@ function run_test() {
try {
properties2.load(inp);
do_throw("load() didn't fail");
}
catch (e) {
} catch (e) {
}
}

View File

@ -1,5 +1,4 @@
function run_test()
{
function run_test() {
var dirEntries = do_get_cwd().directoryEntries;
while (dirEntries.hasMoreElements())

View File

@ -11,15 +11,13 @@ var nameArray = [
"\uD801\uDC0F\uD801\uDC2D\uD801\uDC3B\uD801\uDC2B" // Deseret
];
function getTempDir()
{
function getTempDir() {
var dirService = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties);
return dirService.get("TmpD", Ci.nsIFile);
}
function create_file(fileName)
{
function create_file(fileName) {
var outFile = getTempDir();
outFile.append(fileName);
outFile.createUnique(outFile.NORMAL_FILE_TYPE, 0o600);
@ -35,16 +33,14 @@ function create_file(fileName)
return outFile;
}
function test_create(fileName)
{
function test_create(fileName) {
var file1 = create_file(fileName);
var file2 = create_file(fileName);
file1.remove(false);
file2.remove(false);
}
function run_test()
{
function run_test() {
for (var i = 0; i < nameArray.length; ++i) {
test_create(nameArray[i]);
}

View File

@ -6,20 +6,20 @@ var removedTopic = "xpcom-category-entry-removed";
var testCategory = "bug-test-category";
var testEntry = "@mozilla.org/bug-test-entry;1";
var testValue= "check validity";
var testValue = "check validity";
var result = "";
var expected = "add remove add remove ";
var timer;
var observer = {
QueryInterface: function(iid) {
QueryInterface(iid) {
if (iid.equals(Ci.nsISupports) || iid.equals(Ci.nsIObserver))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
},
observe: function(subject, topic, data) {
observe(subject, topic, data) {
if (topic == "timer-callback") {
do_check_eq(result, expected);

View File

@ -12,7 +12,7 @@ var gFound = false;
const kConsoleListener = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIConsoleListener]),
observe: function listener_observe(message) {
if (gMessageExpected.test(message.message))
gFound = true;
@ -24,7 +24,7 @@ function run_test() {
getService(Ci.nsIConsoleService);
cs.registerListener(kConsoleListener);
let manifest = do_get_file('components/bug656331.manifest');
let manifest = do_get_file("components/bug656331.manifest");
registerAppManifest(manifest);
do_check_false("{f18fb09b-28b4-4435-bc5b-8027f18df743}" in Components.classesByID);

View File

@ -7,7 +7,7 @@ var Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/Services.jsm");
const manifest = do_get_file('bug725015.manifest');
const manifest = do_get_file("bug725015.manifest");
const contract = "@bug725015.test.contract";
const observerTopic = "xpcom-category-entry-added";
const category = "bug725015-test-category";
@ -19,14 +19,13 @@ function observe_category(subj, topic, data) {
do_check_eq(topic, observerTopic);
if (data != category)
return;
var thisentry = subj.QueryInterface(Ci.nsISupportsCString).data;
do_check_eq(thisentry, entry);
do_check_eq(Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager).getCategoryEntry(category, entry), contract);
do_check_true(Cc[contract].equals(cid));
}
catch (e) {
} catch (e) {
do_throw(e);
}
do_test_finished();

View File

@ -1,6 +1,5 @@
Components.utils.import("resource://gre/modules/FileUtils.jsm");
function run_test()
{
function run_test() {
do_check_true(FileUtils.File("~").equals(FileUtils.getDir("Home", [])));
}

View File

@ -12,11 +12,10 @@
var Cu = Components.utils;
const { byteSize } = Cu.getJSTestingFunctions();
function run_test()
{
function run_test() {
const objects = [
{},
{ w: 1, x: 2, y: 3, z:4, a: 5 },
{ w: 1, x: 2, y: 3, z: 4, a: 5 },
[],
Array(10).fill(null),
new RegExp("(2|two) problems", "g"),

View File

@ -7,8 +7,7 @@ var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
function run_test()
{
function run_test() {
// Generate a leaf name that is 255 characters long.
var longLeafName = new Array(256).join("T");
@ -21,8 +20,7 @@ function run_test()
try {
tempFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
do_throw("Creating an item in a folder with a very long name should throw");
}
catch (e) {
} catch (e) {
if (!(e instanceof Ci.nsIException &&
e.result == Cr.NS_ERROR_FILE_UNRECOGNIZED_PATH)) {
throw e;

View File

@ -10,13 +10,11 @@ var Ci = Components.interfaces;
var CC = Components.Constructor;
var LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
function run_test()
{
function run_test() {
test_normalized_vs_non_normalized();
}
function test_normalized_vs_non_normalized()
{
function test_normalized_vs_non_normalized() {
// get a directory that exists on all platforms
var dirProvider = Components.classes["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
var tmp1 = dirProvider.get("TmpD", Ci.nsIFile);

View File

@ -6,50 +6,49 @@
var Cc = Components.classes;
var Ci = Components.interfaces;
function run_test()
{
function run_test() {
// Create the base directory.
let base = Cc['@mozilla.org/file/directory_service;1']
let base = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get('TmpD', Ci.nsIFile);
base.append('renameTesting');
.get("TmpD", Ci.nsIFile);
base.append("renameTesting");
if (base.exists()) {
base.remove(true);
}
base.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt('0777', 8));
base.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt("0777", 8));
// Create a sub directory under the base.
let subdir = base.clone();
subdir.append('subdir');
subdir.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt('0777', 8));
subdir.append("subdir");
subdir.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt("0777", 8));
// Create a file under the sub directory.
let tempFile = subdir.clone();
tempFile.append('file0.txt');
tempFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt('0777', 8));
tempFile.append("file0.txt");
tempFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt("0777", 8));
// Test renameTo in the base directory
tempFile.renameTo(null, 'file1.txt');
do_check_true(exists(subdir, 'file1.txt'));
tempFile.renameTo(null, "file1.txt");
do_check_true(exists(subdir, "file1.txt"));
// Test moving across directories
tempFile = subdir.clone();
tempFile.append('file1.txt');
tempFile.renameTo(base, '');
do_check_true(exists(base, 'file1.txt'));
tempFile.append("file1.txt");
tempFile.renameTo(base, "");
do_check_true(exists(base, "file1.txt"));
// Test moving across directories and renaming at the same time
tempFile = base.clone();
tempFile.append('file1.txt');
tempFile.renameTo(subdir, 'file2.txt');
do_check_true(exists(subdir, 'file2.txt'));
tempFile.append("file1.txt");
tempFile.renameTo(subdir, "file2.txt");
do_check_true(exists(subdir, "file2.txt"));
// Test moving a directory
subdir.renameTo(base, 'renamed');
do_check_true(exists(base, 'renamed'));
subdir.renameTo(base, "renamed");
do_check_true(exists(base, "renamed"));
let renamed = base.clone();
renamed.append('renamed');
do_check_true(exists(renamed, 'file2.txt'));
renamed.append("renamed");
do_check_true(exists(renamed, "file2.txt"));
base.remove(true);
}

View File

@ -12,12 +12,12 @@ function parserForFile(filename) {
do_check_true(!!file);
parser = factory.createINIParser(file);
do_check_true(!!parser);
} catch(e) {
} catch (e) {
dump("INFO | caught error: " + e);
// checkParserOutput will handle a null parser when it's expected.
}
return parser;
}
function checkParserOutput(parser, expected) {
@ -84,13 +84,13 @@ var testdata = [
{ filename: "data/iniparser11.ini", reference: { section1: { name1: "value1" } } },
{ filename: "data/iniparser12.ini", reference: { section1: { name1: "value1" } } },
{ filename: "data/iniparser13.ini", reference: { section1: { name1: "value1" } } },
{ filename: "data/iniparser14.ini", reference:
{ filename: "data/iniparser14.ini", reference:
{ section1: { name1: "value1", name2: "value2" },
section2: { name1: "value1", name2: "foopy" }} },
{ filename: "data/iniparser15.ini", reference:
{ filename: "data/iniparser15.ini", reference:
{ section1: { name1: "newValue1" },
section2: { name1: "foopy" }} },
{ filename: "data/iniparser16.ini", reference:
{ filename: "data/iniparser16.ini", reference:
{ "☺♫": { "♫": "☻", "♪": "♥" },
"☼": { "♣": "♠", "♦": "♥" }} },
@ -131,7 +131,7 @@ var testdata = [
let os = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime).OS;
if("WINNT" === os) {
if ("WINNT" === os) {
testdata.push( { filename: "data/iniparser01-utf16leBOM.ini",
reference: testdata[0].reference } );
testdata.push( { filename: "data/iniparser02-utf16leBOM.ini",
@ -175,7 +175,7 @@ do_check_true(!!factory);
// and read it back to ensure that nothing changed.
while (testnum < testdata.length) {
dump("\nINFO | test #" + ++testnum);
let filename = testdata[testnum -1].filename;
let filename = testdata[testnum - 1].filename;
dump(", filename " + filename + "\n");
let parser = parserForFile(filename);
checkParserOutput(parser, testdata[testnum - 1].reference);
@ -282,7 +282,7 @@ caughtError = false;
try { parser.SetString("ok", "ok", "bad="); } catch (e) { caughtError = true; }
do_check_true(caughtError);
} catch(e) {
} catch (e) {
throw "FAILED in test #" + testnum + " -- " + e;
}
}

View File

@ -9,8 +9,7 @@ var Cr = Components.results;
const util = Cc["@mozilla.org/io-util;1"].getService(Ci.nsIIOUtil);
function run_test()
{
function run_test() {
try {
util.inputStreamIsBuffered(null);
do_throw("inputStreamIsBuffered should have thrown");

View File

@ -13,8 +13,7 @@ const MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
var LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
function run_test()
{
function run_test() {
test_toplevel_parent_is_null();
test_normalize_crash_if_media_missing();
test_file_modification_time();
@ -22,10 +21,8 @@ function run_test()
test_diskSpaceAvailable();
}
function test_toplevel_parent_is_null()
{
try
{
function test_toplevel_parent_is_null() {
try {
var lf = new LocalFile("C:\\");
// not required by API, but a property on which the implementation of
@ -33,33 +30,25 @@ function test_toplevel_parent_is_null()
do_check_true(lf.path.length == 2);
do_check_true(lf.parent === null);
}
catch (e)
{
} catch (e) {
// not Windows
do_check_eq(e.result, Cr.NS_ERROR_FILE_UNRECOGNIZED_PATH);
}
}
function test_normalize_crash_if_media_missing()
{
const a="a".charCodeAt(0);
const z="z".charCodeAt(0);
for (var i = a; i <= z; ++i)
{
try
{
LocalFile(String.fromCharCode(i)+":.\\test").normalize();
}
catch (e)
{
function test_normalize_crash_if_media_missing() {
const a = "a".charCodeAt(0);
const z = "z".charCodeAt(0);
for (var i = a; i <= z; ++i) {
try {
LocalFile(String.fromCharCode(i) + ":.\\test").normalize();
} catch (e) {
}
}
}
// Tests that changing a file's modification time is possible
function test_file_modification_time()
{
// Tests that changing a file's modification time is possible
function test_file_modification_time() {
var file = do_get_profile();
file.append("testfile");
@ -97,9 +86,8 @@ function test_file_modification_time()
file.remove(true);
}
// Tests that changing a directory's modification time is possible
function test_directory_modification_time()
{
// Tests that changing a directory's modification time is possible
function test_directory_modification_time() {
var dir = do_get_profile();
dir.append("testdir");
@ -131,8 +119,7 @@ function test_directory_modification_time()
dir.remove(true);
}
function test_diskSpaceAvailable()
{
function test_diskSpaceAvailable() {
let file = do_get_profile();
file.QueryInterface(Ci.nsIFile);

View File

@ -1,18 +1,18 @@
function run_test() {
// this is a hack to skip the rest of the code on non-Mac platforms,
function run_test() {
// this is a hack to skip the rest of the code on non-Mac platforms,
// since #ifdef is not available to xpcshell tests...
if (mozinfo.os != "mac") {
return;
}
// OK, here's the real part of the test:
// make sure these two test bundles are recognized as bundles (or "packages")
// make sure these two test bundles are recognized as bundles (or "packages")
var keynoteBundle = do_get_file("data/presentation.key");
var appBundle = do_get_file("data/SmallApp.app");
do_check_true(keynoteBundle instanceof Components.interfaces.nsILocalFileMac);
do_check_true(appBundle instanceof Components.interfaces.nsILocalFileMac);
do_check_true(keynoteBundle.isPackage());
do_check_true(appBundle.isPackage());
}

View File

@ -13,8 +13,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const kCID = Components.ID("{1f9f7181-e6c5-4f4c-8f71-08005cec8468}");
const kContract = "@testing/notxpcomtest";
function run_test()
{
function run_test() {
let manifest = do_get_file("xpcomtest.manifest");
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.autoRegister(manifest);
@ -28,15 +27,15 @@ function run_test()
Ci.ScriptableWithNotXPCOM,
Ci.ScriptableWithNotXPCOMBase]),
method1: function() {
method1() {
method1Called = true;
},
method2: function() {
method2() {
ok(false, "method2 should not have been called!");
},
method3: function() {
method3() {
ok(false, "mehod3 should not have been called!");
},
@ -46,7 +45,7 @@ function run_test()
let factory = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]),
createInstance: function(outer, iid) {
createInstance(outer, iid) {
if (outer) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
@ -68,8 +67,7 @@ function run_test()
try {
xpcomObject.QueryInterface(Ci.ScriptableWithNotXPCOM);
ok(false, "Should not have implemented ScriptableWithNotXPCOM");
}
catch(e) {
} catch (e) {
ok(true, "Should not have implemented ScriptableWithNotXPCOM. Correctly threw error: " + e);
}
strictEqual(xpcomObject.method2, undefined);
@ -77,8 +75,7 @@ function run_test()
try {
xpcomObject.QueryInterface(Ci.ScriptableWithNotXPCOMBase);
ok(false, "Should not have implemented ScriptableWithNotXPCOMBase");
}
catch (e) {
} catch (e) {
ok(true, "Should not have implemented ScriptableWithNotXPCOMBase. Correctly threw error: " + e);
}
strictEqual(xpcomObject.method3, undefined);

View File

@ -10,10 +10,9 @@ 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)
{
function create_n_element_array(n) {
var arr = new MutableArray();
for (let i=0; i<n; i++) {
for (let i = 0; i < n; i++) {
let str = new SupportsString();
str.data = "element " + i;
arr.appendElement(str);
@ -21,16 +20,14 @@ function create_n_element_array(n)
return arr;
}
function test_appending_null_actually_inserts()
{
function test_appending_null_actually_inserts() {
var arr = new MutableArray();
do_check_eq(0, arr.length);
arr.appendElement(null);
do_check_eq(1, arr.length);
}
function test_object_gets_appended()
{
function test_object_gets_appended() {
var arr = new MutableArray();
var str = new SupportsString();
str.data = "hello";
@ -40,8 +37,7 @@ function test_object_gets_appended()
do_check_eq(str, obj);
}
function test_insert_at_beginning()
{
function test_insert_at_beginning() {
var arr = create_n_element_array(5);
// just a sanity check
do_check_eq(5, arr.length);
@ -52,14 +48,13 @@ function test_insert_at_beginning()
var obj = arr.queryElementAt(0, Ci.nsISupportsString);
do_check_eq(str, obj);
// check the data of all the other objects
for (let i=1; i<arr.length; i++) {
for (let i = 1; i < arr.length; i++) {
let obj = arr.queryElementAt(i, Ci.nsISupportsString);
do_check_eq("element " + (i-1), obj.data);
do_check_eq("element " + (i - 1), obj.data);
}
}
function test_replace_element()
{
function test_replace_element() {
var arr = create_n_element_array(5);
// just a sanity check
do_check_eq(5, arr.length);
@ -83,8 +78,7 @@ function test_replace_element()
// AFAIK there's no way to check the empty elements, since you can't QI them.
}
function test_clear()
{
function test_clear() {
var arr = create_n_element_array(5);
// just a sanity check
do_check_eq(5, arr.length);
@ -92,8 +86,7 @@ function test_clear()
do_check_eq(0, arr.length);
}
function test_enumerate()
{
function test_enumerate() {
var arr = create_n_element_array(5);
do_check_eq(5, arr.length);
var en = arr.enumerate();

View File

@ -12,10 +12,9 @@ const TEST_UNICODE_ARGS = ["M\u00F8z\u00EEll\u00E5",
// test if a process can be started, polled for its running status
// and then killed
function test_kill()
{
function test_kill() {
var file = get_test_program("TestBlockingProcess");
var process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
process.init(file);
@ -25,8 +24,7 @@ function test_kill()
try {
process.kill();
do_throw("Attempting to kill a not-running process should throw");
}
catch (e) { }
} catch (e) { }
process.run(false, [], 0);
@ -39,55 +37,49 @@ function test_kill()
try {
process.kill();
do_throw("Attempting to kill a not-running process should throw");
}
catch (e) { }
} catch (e) { }
}
// test if we can get an exit value from an application that is
// guaranteed to return an exit value of 42
function test_quick()
{
function test_quick() {
var file = get_test_program("TestQuickReturn");
var process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
process.init(file);
// to get an exit value it must be a blocking process
process.run(true, [], 0);
do_check_eq(process.exitValue, 42);
}
function test_args(file, args, argsAreASCII)
{
function test_args(file, args, argsAreASCII) {
var process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
process.init(file);
if (argsAreASCII)
if (argsAreASCII)
process.run(true, args, args.length);
else
else
process.runw(true, args, args.length);
do_check_eq(process.exitValue, 0);
}
// test if an argument can be successfully passed to an application
// that will return 0 if "mozilla" is the only argument
function test_arguments()
{
function test_arguments() {
test_args(get_test_program("TestArguments"), TEST_ARGS, true);
}
// test if Unicode arguments can be successfully passed to an application
function test_unicode_arguments()
{
function test_unicode_arguments() {
test_args(get_test_program("TestUnicodeArguments"), TEST_UNICODE_ARGS, false);
}
function rename_and_test(asciiName, unicodeName, args, argsAreASCII)
{
function rename_and_test(asciiName, unicodeName, args, argsAreASCII) {
var asciiFile = get_test_program(asciiName);
var asciiLeaf = asciiFile.leafName;
var unicodeLeaf = asciiLeaf.replace(asciiName, unicodeName);
@ -102,8 +94,7 @@ function rename_and_test(asciiName, unicodeName, args, argsAreASCII)
}
// test passing ASCII and Unicode arguments to an application with a Unicode name
function test_unicode_app()
{
function test_unicode_app() {
rename_and_test("TestArguments",
// "Unicode" in Tamil
"\u0BAF\u0BC1\u0BA9\u0BBF\u0B95\u0BCB\u0B9F\u0BCD",
@ -116,8 +107,7 @@ function test_unicode_app()
}
// test if we get notified about a blocking process
function test_notify_blocking()
{
function test_notify_blocking() {
var file = get_test_program("TestQuickReturn");
var process = Components.classes["@mozilla.org/process/util;1"]
@ -125,7 +115,7 @@ function test_notify_blocking()
process.init(file);
process.runAsync([], 0, {
observe: function(subject, topic, data) {
observe(subject, topic, data) {
process = subject.QueryInterface(Components.interfaces.nsIProcess);
do_check_eq(topic, "process-finished");
do_check_eq(process.exitValue, 42);
@ -135,8 +125,7 @@ function test_notify_blocking()
}
// test if we get notified about a non-blocking process
function test_notify_nonblocking()
{
function test_notify_nonblocking() {
var file = get_test_program("TestArguments");
var process = Components.classes["@mozilla.org/process/util;1"]
@ -144,7 +133,7 @@ function test_notify_nonblocking()
process.init(file);
process.runAsync(TEST_ARGS, TEST_ARGS.length, {
observe: function(subject, topic, data) {
observe(subject, topic, data) {
process = subject.QueryInterface(Components.interfaces.nsIProcess);
do_check_eq(topic, "process-finished");
do_check_eq(process.exitValue, 0);
@ -154,8 +143,7 @@ function test_notify_nonblocking()
}
// test if we get notified about a killed process
function test_notify_killed()
{
function test_notify_killed() {
var file = get_test_program("TestBlockingProcess");
var process = Components.classes["@mozilla.org/process/util;1"]
@ -163,7 +151,7 @@ function test_notify_killed()
process.init(file);
process.runAsync([], 0, {
observe: function(subject, topic, data) {
observe(subject, topic, data) {
process = subject.QueryInterface(Components.interfaces.nsIProcess);
do_check_eq(topic, "process-finished");
do_test_finished();

View File

@ -14,8 +14,7 @@ function run_test() {
try {
process.kill();
}
catch (e) { }
} catch (e) { }
// We need to ensure that we process any events on the main thread -
// this allow threads to clean up properly and avoid out of memory

View File

@ -11,30 +11,24 @@ var CC = Components.Constructor;
var Pipe = CC("@mozilla.org/pipe;1", "nsIPipe", "init");
function run_test()
{
function run_test() {
test_not_initialized();
test_ends_are_threadsafe();
}
function test_not_initialized()
{
function test_not_initialized() {
var p = Cc["@mozilla.org/pipe;1"]
.createInstance(Ci.nsIPipe);
try
{
try {
var dummy = p.outputStream;
throw Cr.NS_ERROR_FAILURE;
}
catch (e)
{
} catch (e) {
if (e.result != Cr.NS_ERROR_NOT_INITIALIZED)
do_throw("using a pipe before initializing it should throw NS_ERROR_NOT_INITIALIZED");
}
}
function test_ends_are_threadsafe()
{
function test_ends_are_threadsafe() {
var p, is, os;
p = new Pipe(true, true, 1024, 1, null);

View File

@ -3,8 +3,7 @@ var Cc = Components.classes;
Components.utils.import("resource://gre/modules/Services.jsm");
function run_test()
{
function run_test() {
Components.manager.autoRegister(do_get_file("data/process_directive.manifest"));
let isChild = Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT;

View File

@ -111,7 +111,7 @@ function test_multiplex_streams() {
var caught = false;
try {
seekable.seek(Ci.nsISeekableStream.NS_SEEK_END, 15);
} catch(e) {
} catch (e) {
caught = true;
}
do_check_eq(caught, true);

View File

@ -8,8 +8,7 @@ var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
function run_test()
{
function run_test() {
test1();
test2();
test3();
@ -20,8 +19,7 @@ function run_test()
* Checks that getting an input stream from a storage stream which has never had
* anything written to it throws a not-initialized exception.
*/
function test1()
{
function test1() {
var ss = Cc["@mozilla.org/storagestream;1"]
.createInstance(Ci.nsIStorageStream);
ss.init(1024, 1024, null);
@ -53,20 +51,16 @@ function test1()
* Checks that getting an input stream from a storage stream to which 0 bytes of
* data have been explicitly written doesn't throw an exception.
*/
function test2()
{
function test2() {
var ss = Cc["@mozilla.org/storagestream;1"]
.createInstance(Ci.nsIStorageStream);
ss.init(1024, 1024, null);
var out = ss.getOutputStream(0);
out.write("", 0);
try
{
try {
var inp2 = ss.newInputStream(0);
}
catch (e)
{
} catch (e) {
do_throw("shouldn't throw exception when new input stream created");
}
}
@ -75,33 +69,26 @@ function test2()
* Checks that reading any non-zero amount of data from a storage stream
* which has had 0 bytes written to it explicitly works correctly.
*/
function test3()
{
function test3() {
var ss = Cc["@mozilla.org/storagestream;1"]
.createInstance(Ci.nsIStorageStream);
ss.init(1024, 1024, null);
var out = ss.getOutputStream(0);
out.write("", 0);
try
{
try {
var inp = ss.newInputStream(0);
}
catch (e)
{
} catch (e) {
do_throw("newInputStream(0) shouldn't throw if write() is called: " + e);
}
do_check_true(inp.isNonBlocking(), "next test expects a non-blocking stream");
try
{
try {
var threw = false;
var bis = BIS(inp);
var dummy = bis.readByteArray(5);
}
catch (e)
{
} catch (e) {
if (e.result != Cr.NS_BASE_STREAM_WOULD_BLOCK)
do_throw("wrong error thrown: " + e);
threw = true;
@ -114,8 +101,7 @@ function test3()
* Basic functionality test for storagestream: write data to it, get an input
* stream, and read the data back to see that it matches.
*/
function test4()
{
function test4() {
var bytes = [65, 66, 67, 68, 69, 70, 71, 72, 73, 74];
var ss = Cc["@mozilla.org/storagestream;1"]
@ -135,19 +121,15 @@ function test4()
var bis = BIS(inp);
var count = 0;
while (count < bytes.length)
{
while (count < bytes.length) {
var data = bis.read8(1);
do_check_eq(data, bytes[count++]);
}
var threw = false;
try
{
try {
data = bis.read8(1);
}
catch (e)
{
} catch (e) {
if (e.result != Cr.NS_ERROR_FAILURE)
do_throw("wrong error thrown: " + e);
threw = true;
@ -157,8 +139,7 @@ function test4()
}
function BIS(input)
{
function BIS(input) {
var bis = Cc["@mozilla.org/binaryinputstream;1"]
.createInstance(Ci.nsIBinaryInputStream);
bis.setInputStream(input);

View File

@ -29,7 +29,7 @@ function test_binary_streams() {
const LargeNum = Math.pow(2, 18) + Math.pow(2, 12) + 1;
const HugeNum = Math.pow(2, 62);
const HelloStr = "Hello World";
const HelloArray = Array.map(HelloStr, function(c) {return c.charCodeAt(0)});
const HelloArray = Array.map(HelloStr, function(c) { return c.charCodeAt(0) });
var countObj = {};
var msg = {};
var buffer = new ArrayBuffer(HelloArray.length);
@ -122,7 +122,7 @@ function test_binary_streams() {
do_check_eq(typeof msg, typeof HelloArray);
do_check_eq(msg.toSource(), HelloArray.toSource());
do_check_eq(is.available(), 0);
// Test for invalid actions.
os.close();
is.close();

View File

@ -7,8 +7,7 @@ var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
function run_test()
{
function run_test() {
var s = Cc["@mozilla.org/io/string-input-stream;1"]
.createInstance(Ci.nsIStringInputStream);
var body = "This is a test";

View File

@ -36,8 +36,7 @@ function makeSymLink(from, toName, relative) {
if (relative) {
createSymLink(from.leafName, to.path);
}
else {
} else {
createSymLink(from.path, to.path);
}
@ -52,8 +51,7 @@ function makeSymLink(from, toName, relative) {
// XXXjag wish I could set followLinks to false so we'd just get
// the symlink's direct target instead of the final target.
do_check_eq(from.target, to.target);
}
else {
} else {
do_check_eq(from.path, to.target);
}
@ -94,8 +92,7 @@ function setupTestDir(testDir, relative) {
try {
makeSymLink(loop, LOOP_LINK, relative);
do_check_true(false);
}
catch (e) {
} catch (e) {
}
}

View File

@ -28,8 +28,7 @@ var equality = [
"1.0+"
];
function run_test()
{
function run_test() {
var vc = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
.getService(Components.interfaces.nsIVersionComparator);
@ -39,12 +38,10 @@ function run_test()
if (i == j) {
if (result != 0)
do_throw(comparisons[i] + " should be the same as itself");
}
else if (i < j) {
} else if (i < j) {
if (!(result < 0))
do_throw(comparisons[i] + " should be less than " + comparisons[j]);
}
else if (!(result > 0)) {
} else if (!(result > 0)) {
do_throw(comparisons[i] + " should be greater than " + comparisons[j]);
}
}

View File

@ -14,9 +14,8 @@ 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).
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.
@ -28,10 +27,10 @@ function run_test()
//* check that the valueCount/getValueName functions work for the values we just wrote
test_value_functions(testKey);
//* check that the get* functions work for the values we just wrote.
test_reading_functions(testKey);
//* check that the get* functions fail with the right exception codes if we ask for the wrong type or if the value name doesn't exist at all
test_invalidread_functions(testKey);
@ -44,15 +43,13 @@ function run_test()
cleanup_test_run(testKey, keyName);
}
function setup_test_run(testKey, keyName)
{
function setup_test_run(testKey, keyName) {
do_print("Setup test run");
try {
testKey.open(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, keyName, nsIWindowsRegKey.ACCESS_READ);
do_print("Test key exists. Needs cleanup.");
cleanup_test_run(testKey, keyName);
}
catch (e) {
} catch (e) {
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
throw e;
}
@ -61,8 +58,7 @@ function setup_test_run(testKey, keyName)
testKey.create(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, keyName, nsIWindowsRegKey.ACCESS_ALL);
}
function test_writing_functions(testKey)
{
function test_writing_functions(testKey) {
strictEqual(testKey.valueCount, 0);
strictEqual(testKey.hasValue(TESTDATA_STRNAME), false);
@ -79,8 +75,7 @@ function test_writing_functions(testKey)
testKey.writeBinaryValue(TESTDATA_BINARYNAME, TESTDATA_BINARYVALUE);
}
function test_value_functions(testKey)
{
function test_value_functions(testKey) {
strictEqual(testKey.valueCount, 4);
strictEqual(testKey.getValueName(0), TESTDATA_STRNAME);
strictEqual(testKey.getValueName(1), TESTDATA_INTNAME);
@ -88,23 +83,21 @@ function test_value_functions(testKey)
strictEqual(testKey.getValueName(3), TESTDATA_BINARYNAME);
}
function test_reading_functions(testKey)
{
function test_reading_functions(testKey) {
strictEqual(testKey.getValueType(TESTDATA_STRNAME), nsIWindowsRegKey.TYPE_STRING);
strictEqual(testKey.readStringValue(TESTDATA_STRNAME), TESTDATA_STRVALUE);
strictEqual(testKey.getValueType(TESTDATA_INTNAME), nsIWindowsRegKey.TYPE_INT);
strictEqual(testKey.readIntValue(TESTDATA_INTNAME), TESTDATA_INTVALUE);
strictEqual(testKey.getValueType(TESTDATA_INT64NAME), nsIWindowsRegKey.TYPE_INT64);
strictEqual( testKey.readInt64Value(TESTDATA_INT64NAME), TESTDATA_INT64VALUE);
strictEqual(testKey.getValueType(TESTDATA_BINARYNAME), nsIWindowsRegKey.TYPE_BINARY);
strictEqual( testKey.readBinaryValue(TESTDATA_BINARYNAME), TESTDATA_BINARYVALUE);
}
function test_invalidread_functions(testKey)
{
function test_invalidread_functions(testKey) {
try {
testKey.readIntValue(TESTDATA_STRNAME);
do_throw("Reading an integer from a string registry value should throw.");
@ -143,11 +136,10 @@ function test_invalidread_functions(testKey)
}
function test_childkey_functions(testKey)
{
function test_childkey_functions(testKey) {
strictEqual(testKey.childCount, 0);
strictEqual(testKey.hasChild(TESTDATA_CHILD_KEY), false);
let childKey = testKey.createChild(TESTDATA_CHILD_KEY, nsIWindowsRegKey.ACCESS_ALL);
childKey.close();
@ -161,14 +153,13 @@ function test_childkey_functions(testKey)
strictEqual(testKey.hasChild(TESTDATA_CHILD_KEY), false);
}
function test_watching_functions(testKey)
{
function test_watching_functions(testKey) {
strictEqual(testKey.isWatching(), false);
strictEqual(testKey.hasChanged(), false);
testKey.startWatching(true);
strictEqual(testKey.isWatching(), true);
testKey.stopWatching();
strictEqual(testKey.isWatching(), false);
@ -184,14 +175,13 @@ function test_watching_functions(testKey)
strictEqual(testKey.hasChanged(), true);
testKey.stopWatching();
strictEqual(testKey.isWatching(), false);
childKey.removeValue(TESTDATA_INTNAME);
childKey.close();
testKey.removeChild(TESTDATA_CHILD_KEY);
}
function cleanup_test_run(testKey, keyName)
{
function cleanup_test_run(testKey, keyName) {
do_print("Cleaning up test.");
for (var i = 0; i < testKey.childCount; i++) {

View File

@ -15,8 +15,7 @@ const LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
Cu.import("resource://gre/modules/Services.jsm");
function run_test()
{
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) {
@ -39,20 +38,17 @@ function run_test()
}
}
function test_create_noargs(tempDir)
{
function test_create_noargs(tempDir) {
let shortcutFile = tempDir.clone();
shortcutFile.append("shouldNeverExist.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
try
{
try {
win.setShortcut();
do_throw("Creating a shortcut with no args (no target) should throw");
}
catch(e) {
} catch (e) {
if (!(e instanceof Ci.nsIException
&& e.result == Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)) {
throw e;
@ -60,23 +56,20 @@ function test_create_noargs(tempDir)
}
}
function test_create_notarget(tempDir)
{
function test_create_notarget(tempDir) {
let shortcutFile = tempDir.clone();
shortcutFile.append("shouldNeverExist2.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
try
{
try {
win.setShortcut(null,
do_get_cwd(),
"arg1 arg2",
"Shortcut with no target");
do_throw("Creating a shortcut with no target should throw");
}
catch(e) {
} catch (e) {
if (!(e instanceof Ci.nsIException
&& e.result == Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)) {
throw e;
@ -84,8 +77,7 @@ function test_create_notarget(tempDir)
}
}
function test_create_targetonly(tempDir)
{
function test_create_targetonly(tempDir) {
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@ -102,8 +94,7 @@ function test_create_targetonly(tempDir)
do_check_true(shortcutTarget.equals(targetFile));
}
function test_create_normal(tempDir)
{
function test_create_normal(tempDir) {
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@ -123,8 +114,7 @@ function test_create_normal(tempDir)
do_check_true(shortcutTarget.equals(targetFile))
}
function test_create_unicode(tempDir)
{
function test_create_unicode(tempDir) {
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@ -144,8 +134,7 @@ function test_create_unicode(tempDir)
do_check_true(shortcutTarget.equals(targetFile))
}
function test_update_noargs(tempDir)
{
function test_update_noargs(tempDir) {
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@ -167,8 +156,7 @@ function test_update_noargs(tempDir)
do_check_true(shortcutTarget.equals(targetFile))
}
function test_update_notarget(tempDir)
{
function test_update_notarget(tempDir) {
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@ -193,8 +181,7 @@ function test_update_notarget(tempDir)
do_check_true(shortcutTarget.equals(targetFile))
}
function test_update_targetonly(tempDir)
{
function test_update_targetonly(tempDir) {
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@ -220,8 +207,7 @@ function test_update_targetonly(tempDir)
do_check_true(shortcutTarget.equals(newTargetFile))
}
function test_update_normal(tempDir)
{
function test_update_normal(tempDir) {
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@ -250,8 +236,7 @@ function test_update_normal(tempDir)
do_check_true(shortcutTarget.equals(newTargetFile))
}
function test_update_unicode(tempDir)
{
function test_update_unicode(tempDir) {
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);