From 4ae455cdc5b3d6e5f4249185690c4f68955a50a1 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Thu, 28 Sep 2017 15:49:04 -0700 Subject: [PATCH] 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 --- xpcom/ds/nsINIProcessor.js | 38 ++++++------- xpcom/libxpt/xptcall/porting.html | 2 +- xpcom/string/crashtests/395651-1.html | 5 +- xpcom/tests/TestWinReg.js | 7 ++- .../data/child_process_directive_service.js | 2 +- .../data/main_process_directive_service.js | 2 +- xpcom/tests/unit/head_xpcom.js | 8 ++- xpcom/tests/unit/test_bug121341.js | 5 +- xpcom/tests/unit/test_bug333505.js | 3 +- xpcom/tests/unit/test_bug364285-1.js | 12 ++--- xpcom/tests/unit/test_bug374754.js | 6 +-- xpcom/tests/unit/test_bug656331.js | 4 +- xpcom/tests/unit/test_bug725015.js | 9 ++-- xpcom/tests/unit/test_bug745466.js | 3 +- .../unit/test_debugger_malloc_size_of.js | 5 +- xpcom/tests/unit/test_file_createUnique.js | 6 +-- xpcom/tests/unit/test_file_equality.js | 6 +-- xpcom/tests/unit/test_file_renameTo.js | 43 ++++++++------- xpcom/tests/unit/test_iniProcessor.js | 16 +++--- xpcom/tests/unit/test_ioutil.js | 3 +- xpcom/tests/unit/test_localfile.js | 45 ++++++---------- xpcom/tests/unit/test_mac_bundle.js | 12 ++--- xpcom/tests/unit/test_notxpcom_scriptable.js | 17 +++--- xpcom/tests/unit/test_nsIMutableArray.js | 27 ++++------ xpcom/tests/unit/test_nsIProcess.js | 54 ++++++++----------- xpcom/tests/unit/test_nsIProcess_stress.js | 3 +- xpcom/tests/unit/test_pipe.js | 16 ++---- xpcom/tests/unit/test_process_directives.js | 3 +- xpcom/tests/unit/test_seek_multiplex.js | 2 +- xpcom/tests/unit/test_storagestream.js | 49 ++++++----------- xpcom/tests/unit/test_streams.js | 4 +- xpcom/tests/unit/test_stringstream.js | 3 +- xpcom/tests/unit/test_symlinks.js | 9 ++-- xpcom/tests/unit/test_versioncomparator.js | 9 ++-- xpcom/tests/unit/test_windows_registry.js | 48 +++++++---------- xpcom/tests/unit/test_windows_shortcut.js | 45 ++++++---------- 36 files changed, 209 insertions(+), 322 deletions(-) diff --git a/xpcom/ds/nsINIProcessor.js b/xpcom/ds/nsINIProcessor.js index 832f35a5f3ed..48ab20c76079 100644 --- a/xpcom/ds/nsINIProcessor.js +++ b/xpcom/ds/nsINIProcessor.js @@ -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++]; } }; diff --git a/xpcom/libxpt/xptcall/porting.html b/xpcom/libxpt/xptcall/porting.html index 84465306ea70..2950d845694d 100644 --- a/xpcom/libxpt/xptcall/porting.html +++ b/xpcom/libxpt/xptcall/porting.html @@ -14,4 +14,4 @@ Please update your links. - \ No newline at end of file + diff --git a/xpcom/string/crashtests/395651-1.html b/xpcom/string/crashtests/395651-1.html index 3f89a0836e40..bbed371fd676 100644 --- a/xpcom/string/crashtests/395651-1.html +++ b/xpcom/string/crashtests/395651-1.html @@ -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); diff --git a/xpcom/tests/TestWinReg.js b/xpcom/tests/TestWinReg.js index 5bde37900612..d9a4370de4ba 100644 --- a/xpcom/tests/TestWinReg.js +++ b/xpcom/tests/TestWinReg.js @@ -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"); } diff --git a/xpcom/tests/unit/data/child_process_directive_service.js b/xpcom/tests/unit/data/child_process_directive_service.js index aa3f03df1dee..ffecafc7ab19 100644 --- a/xpcom/tests/unit/data/child_process_directive_service.js +++ b/xpcom/tests/unit/data/child_process_directive_service.js @@ -13,7 +13,7 @@ TestProcessDirective.prototype = { type: Components.interfaces.nsISupportsString.TYPE_STRING, data: "child process", - toString: function() { + toString() { return this.data; } }; diff --git a/xpcom/tests/unit/data/main_process_directive_service.js b/xpcom/tests/unit/data/main_process_directive_service.js index a5f40b286869..66f0c25ecd9c 100644 --- a/xpcom/tests/unit/data/main_process_directive_service.js +++ b/xpcom/tests/unit/data/main_process_directive_service.js @@ -13,7 +13,7 @@ TestProcessDirective.prototype = { type: Components.interfaces.nsISupportsString.TYPE_STRING, data: "main process", - toString: function() { + toString() { return this.data; } }; diff --git a/xpcom/tests/unit/head_xpcom.js b/xpcom/tests/unit/head_xpcom.js index eacd5b4e6ad9..2bbf70c777f4 100644 --- a/xpcom/tests/unit/head_xpcom.js +++ b/xpcom/tests/unit/head_xpcom.js @@ -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 } diff --git a/xpcom/tests/unit/test_bug121341.js b/xpcom/tests/unit/test_bug121341.js index 3aa04186e988..449e36afd1c5 100644 --- a/xpcom/tests/unit/test_bug121341.js +++ b/xpcom/tests/unit/test_bug121341.js @@ -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) { } } diff --git a/xpcom/tests/unit/test_bug333505.js b/xpcom/tests/unit/test_bug333505.js index 856468605b2b..02254a17dc5e 100644 --- a/xpcom/tests/unit/test_bug333505.js +++ b/xpcom/tests/unit/test_bug333505.js @@ -1,5 +1,4 @@ -function run_test() -{ +function run_test() { var dirEntries = do_get_cwd().directoryEntries; while (dirEntries.hasMoreElements()) diff --git a/xpcom/tests/unit/test_bug364285-1.js b/xpcom/tests/unit/test_bug364285-1.js index c620a4de956e..6c16f0641156 100644 --- a/xpcom/tests/unit/test_bug364285-1.js +++ b/xpcom/tests/unit/test_bug364285-1.js @@ -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]); } diff --git a/xpcom/tests/unit/test_bug374754.js b/xpcom/tests/unit/test_bug374754.js index 0c530c1da86c..9d22003e49c7 100644 --- a/xpcom/tests/unit/test_bug374754.js +++ b/xpcom/tests/unit/test_bug374754.js @@ -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); diff --git a/xpcom/tests/unit/test_bug656331.js b/xpcom/tests/unit/test_bug656331.js index 2d3856752204..045bd03e7fd6 100644 --- a/xpcom/tests/unit/test_bug656331.js +++ b/xpcom/tests/unit/test_bug656331.js @@ -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); diff --git a/xpcom/tests/unit/test_bug725015.js b/xpcom/tests/unit/test_bug725015.js index b210a21e9c6f..35a9aecb8f9d 100644 --- a/xpcom/tests/unit/test_bug725015.js +++ b/xpcom/tests/unit/test_bug725015.js @@ -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(); diff --git a/xpcom/tests/unit/test_bug745466.js b/xpcom/tests/unit/test_bug745466.js index 22a911ac524e..dc46085b205c 100644 --- a/xpcom/tests/unit/test_bug745466.js +++ b/xpcom/tests/unit/test_bug745466.js @@ -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", []))); } diff --git a/xpcom/tests/unit/test_debugger_malloc_size_of.js b/xpcom/tests/unit/test_debugger_malloc_size_of.js index 450d6279307e..6a1732a18d21 100644 --- a/xpcom/tests/unit/test_debugger_malloc_size_of.js +++ b/xpcom/tests/unit/test_debugger_malloc_size_of.js @@ -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"), diff --git a/xpcom/tests/unit/test_file_createUnique.js b/xpcom/tests/unit/test_file_createUnique.js index 27be196e58e5..ca7d3edf9457 100644 --- a/xpcom/tests/unit/test_file_createUnique.js +++ b/xpcom/tests/unit/test_file_createUnique.js @@ -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; diff --git a/xpcom/tests/unit/test_file_equality.js b/xpcom/tests/unit/test_file_equality.js index 54156ee6dd35..560f29903bdc 100644 --- a/xpcom/tests/unit/test_file_equality.js +++ b/xpcom/tests/unit/test_file_equality.js @@ -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); diff --git a/xpcom/tests/unit/test_file_renameTo.js b/xpcom/tests/unit/test_file_renameTo.js index f78ec446409b..945389204ed7 100644 --- a/xpcom/tests/unit/test_file_renameTo.js +++ b/xpcom/tests/unit/test_file_renameTo.js @@ -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); } diff --git a/xpcom/tests/unit/test_iniProcessor.js b/xpcom/tests/unit/test_iniProcessor.js index 3d3886d35baa..2a136ab98b2e 100644 --- a/xpcom/tests/unit/test_iniProcessor.js +++ b/xpcom/tests/unit/test_iniProcessor.js @@ -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; } } diff --git a/xpcom/tests/unit/test_ioutil.js b/xpcom/tests/unit/test_ioutil.js index ef27f584ff65..85ecd44c9f22 100644 --- a/xpcom/tests/unit/test_ioutil.js +++ b/xpcom/tests/unit/test_ioutil.js @@ -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"); diff --git a/xpcom/tests/unit/test_localfile.js b/xpcom/tests/unit/test_localfile.js index 6f087b3aa2fc..e29bf865107b 100644 --- a/xpcom/tests/unit/test_localfile.js +++ b/xpcom/tests/unit/test_localfile.js @@ -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); diff --git a/xpcom/tests/unit/test_mac_bundle.js b/xpcom/tests/unit/test_mac_bundle.js index 550a4abd6c74..1045d9c32593 100644 --- a/xpcom/tests/unit/test_mac_bundle.js +++ b/xpcom/tests/unit/test_mac_bundle.js @@ -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()); } diff --git a/xpcom/tests/unit/test_notxpcom_scriptable.js b/xpcom/tests/unit/test_notxpcom_scriptable.js index 5d5e24bd93c0..fe83de55eeae 100644 --- a/xpcom/tests/unit/test_notxpcom_scriptable.js +++ b/xpcom/tests/unit/test_notxpcom_scriptable.js @@ -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); diff --git a/xpcom/tests/unit/test_nsIMutableArray.js b/xpcom/tests/unit/test_nsIMutableArray.js index f9c91a217ed0..3a70e105b9b3 100644 --- a/xpcom/tests/unit/test_nsIMutableArray.js +++ b/xpcom/tests/unit/test_nsIMutableArray.js @@ -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 0)) { + } else if (!(result > 0)) { do_throw(comparisons[i] + " should be greater than " + comparisons[j]); } } diff --git a/xpcom/tests/unit/test_windows_registry.js b/xpcom/tests/unit/test_windows_registry.js index bd61659c1cc1..8d03ae4adcaf 100644 --- a/xpcom/tests/unit/test_windows_registry.js +++ b/xpcom/tests/unit/test_windows_registry.js @@ -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++) { diff --git a/xpcom/tests/unit/test_windows_shortcut.js b/xpcom/tests/unit/test_windows_shortcut.js index bcb23ec06022..3c317bdc48b1 100644 --- a/xpcom/tests/unit/test_windows_shortcut.js +++ b/xpcom/tests/unit/test_windows_shortcut.js @@ -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);