--- a/xpcom/ds/nsINIProcessor.js
+++ b/xpcom/ds/nsINIProcessor.js
@@ -10,19 +10,19 @@ const Cu = Components.utils;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
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);
}
}; // end of INIProcessorFactory implementation
const MODE_WRONLY = 0x02;
const MODE_CREATE = 0x08;
const MODE_TRUNCATE = 0x20;
@@ -30,110 +30,110 @@ const MODE_TRUNCATE = 0x20;
// nsIINIParser implementation
function INIProcessor(aFile) {
this._iniFile = aFile;
this._iniData = {};
this._readFile();
}
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"].
createInstance(Ci.nsIScriptableUnicodeConverter);
this.__utf8Converter.charset = "UTF-8";
}
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"].
createInstance(Ci.nsIScriptableUnicodeConverter);
this.__utf16leConverter.charset = "UTF-16LE";
}
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;
let iniParser = Cc["@mozilla.org/xpcom/ini-parser-factory;1"]
.getService(Ci.nsIINIParserFactory).createINIParser(this._iniFile);
for (let section of XPCOMUtils.IterStringEnumerator(iniParser.getSections())) {
this._iniData[section] = {};
for (let key of XPCOMUtils.IterStringEnumerator(iniParser.getKeys(section))) {
this._iniData[section][key] = iniParser.getString(section, key);
}
}
},
// 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])
keys.push(key);
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]))
throw Cr.NS_ERROR_FAILURE;
return this._iniData[aSection][aKey];
},
// nsIINIParserWriter
- setString : function(aSection, aKey, aValue) {
+ setString(aSection, aKey, aValue) {
const isSectionIllegal = /[\0\r\n\[\]]/;
const isKeyValIllegal = /[\0\r\n=]/;
if (isSectionIllegal.test(aSection))
throw Components.Exception("bad character in section name",
Cr.ERROR_ILLEGAL_VALUE);
if (isKeyValIllegal.test(aKey) || isKeyValIllegal.test(aValue))
throw Components.Exception("bad character in key/value",
Cr.ERROR_ILLEGAL_VALUE);
if (!(aSection in this._iniData))
this._iniData[aSection] = {};
this._iniData[aSection][aKey] = aValue;
},
- writeFile : function(aFile, aFlags) {
+ writeFile(aFile, aFlags) {
let converter;
function writeLine(data) {
data += "\n";
data = converter.ConvertFromUnicode(data);
data += converter.Finish();
outputStream.write(data, data.length);
}
@@ -147,17 +147,17 @@ INIProcessor.prototype = {
0o600, null);
var outputStream = Cc["@mozilla.org/network/buffered-output-stream;1"].
createInstance(Ci.nsIBufferedOutputStream);
outputStream.init(safeStream, 8192);
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 {
converter = this._utf8Converter;
}
for (let section in this._iniData) {
writeLine("[" + section + "]");
@@ -169,24 +169,24 @@ INIProcessor.prototype = {
outputStream.finish();
}
};
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++];
}
};
var component = [INIProcessorFactory];
this.NSGetFactory = XPCOMUtils.generateNSGetFactory(component);
--- a/xpcom/libxpt/xptcall/porting.html
+++ b/xpcom/libxpt/xptcall/porting.html
@@ -9,9 +9,9 @@
<body bgcolor = "white">
<center>The xptcall porting document has been moved to:
<P>
<a href="http://lxr.mozilla.org/mozilla/source/xpcom/reflect/xptcall/porting.html">http://lxr.mozilla.org/mozilla/source/xpcom/reflect/xptcall/porting.html</a>
<P>
Please update your links.
</center>
</body>
-</html>
\ No newline at end of file
+</html>
--- a/xpcom/string/crashtests/395651-1.html
+++ b/xpcom/string/crashtests/395651-1.html
@@ -1,26 +1,25 @@
<html>
<head>
<script>
function X() { dump("X\n"); }
function Y() { dump("Y\n"); }
-function boom()
-{
+function boom() {
dump("Start9\n");
var div = document.getElementById("v");
var textNode = document.createTextNode(String.fromCharCode(0xDAAF)); // high surrogate
div.appendChild(textNode);
document.addEventListener("DOMCharacterDataModified", X, true);
- textNode.data += 'B';
+ textNode.data += "B";
document.removeEventListener("DOMCharacterDataModified", X, true);
document.addEventListener("DOMAttrModified", Y, true);
textNode.data += String.fromCharCode(0xDF53); // low surrogate
document.removeEventListener("DOMAttrModified", Y, true);
}
</script>
--- a/xpcom/tests/TestWinReg.js
+++ b/xpcom/tests/TestWinReg.js
@@ -4,37 +4,36 @@
/*
* This script is intended to be run using xpcshell
*/
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);
}
function list_values(indent, key) {
idump(indent, "{\n");
var count = key.valueCount;
for (var i = 0; i < count; ++i) {
var vn = key.getValueName(i);
var val = "";
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");
}
function list_children(indent, key) {
list_values(indent, key);
var count = key.childCount;
for (var i = 0; i < count; ++i) {
--- a/xpcom/tests/unit/data/child_process_directive_service.js
+++ b/xpcom/tests/unit/data/child_process_directive_service.js
@@ -8,14 +8,14 @@ TestProcessDirective.prototype = {
/* Boilerplate */
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISupportsString]),
contractID: "@mozilla.org/xpcom/tests/ChildProcessDirectiveTest;1",
classID: Components.ID("{4bd1ba60-45c4-11e4-916c-0800200c9a66}"),
type: Components.interfaces.nsISupportsString.TYPE_STRING,
data: "child process",
- toString: function() {
+ toString() {
return this.data;
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TestProcessDirective]);
--- a/xpcom/tests/unit/data/main_process_directive_service.js
+++ b/xpcom/tests/unit/data/main_process_directive_service.js
@@ -8,14 +8,14 @@ TestProcessDirective.prototype = {
/* Boilerplate */
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISupportsString]),
contractID: "@mozilla.org/xpcom/tests/MainProcessDirectiveTest;1",
classID: Components.ID("{9b6f4160-45be-11e4-916c-0800200c9a66}"),
type: Components.interfaces.nsISupportsString.TYPE_STRING,
data: "main process",
- toString: function() {
+ toString() {
return this.data;
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TestProcessDirective]);
--- a/xpcom/tests/unit/head_xpcom.js
+++ b/xpcom/tests/unit/head_xpcom.js
@@ -1,21 +1,19 @@
-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"].
getService(Components.interfaces.nsIProperties);
var greBinDir = dirSvc.get("GreBinD", Components.interfaces.nsIFile);
envSvc.set("DYLD_LIBRARY_PATH", greBinDir.path);
// For Linux
envSvc.set("LD_LIBRARY_PATH", greBinDir.path);
- //XXX: handle windows
+ // XXX: handle windows
}
--- a/xpcom/tests/unit/test_bug121341.js
+++ b/xpcom/tests/unit/test_bug121341.js
@@ -1,16 +1,16 @@
var Ci = Components.interfaces;
var Cu = Components.utils;
Cu.import("resource://gre/modules/NetUtil.jsm");
function run_test() {
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
-
+
var dataFile = do_get_file("data/bug121341.properties");
var channel = NetUtil.newChannel({
uri: ios.newFileURI(dataFile, null, null),
loadUsingSystemPrincipal: true
});
var inp = channel.open2();
var properties = Components.classes["@mozilla.org/persistent-properties;1"].
@@ -60,12 +60,11 @@ function run_test() {
});
inp = channel.open2();
var properties2 = Components.classes["@mozilla.org/persistent-properties;1"].
createInstance(Components.interfaces.nsIPersistentProperties);
try {
properties2.load(inp);
do_throw("load() didn't fail");
- }
- catch (e) {
+ } catch (e) {
}
}
--- a/xpcom/tests/unit/test_bug333505.js
+++ b/xpcom/tests/unit/test_bug333505.js
@@ -1,10 +1,9 @@
-function run_test()
-{
+function run_test() {
var dirEntries = do_get_cwd().directoryEntries;
while (dirEntries.hasMoreElements())
dirEntries.getNext();
// We ensure there is no crash
dirEntries.hasMoreElements();
}
--- a/xpcom/tests/unit/test_bug364285-1.js
+++ b/xpcom/tests/unit/test_bug364285-1.js
@@ -6,46 +6,42 @@ var nameArray = [
"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()
-{
+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);
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();
do_check_eq(outFile.leafName.substr(0, fileName.length), 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]);
}
}
--- a/xpcom/tests/unit/test_bug374754.js
+++ b/xpcom/tests/unit/test_bug374754.js
@@ -1,30 +1,30 @@
var Cc = Components.classes;
var Ci = Components.interfaces;
var addedTopic = "xpcom-category-entry-added";
var removedTopic = "xpcom-category-entry-removed";
var testCategory = "bug-test-category";
var testEntry = "@mozilla.org/bug-test-entry;1";
-var testValue= "check validity";
+var 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);
var observerService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
observerService.removeObserver(this, addedTopic);
observerService.removeObserver(this, removedTopic);
do_test_finished();
--- a/xpcom/tests/unit/test_bug656331.js
+++ b/xpcom/tests/unit/test_bug656331.js
@@ -7,29 +7,29 @@ function info(s) {
dump("TEST-INFO | test_bug656331.js | " + s + "\n");
}
var gMessageExpected = /Native module.*has version 3.*expected/;
var gFound = false;
const kConsoleListener = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIConsoleListener]),
-
+
observe: function listener_observe(message) {
if (gMessageExpected.test(message.message))
gFound = true;
}
};
function run_test() {
let cs = Components.classes["@mozilla.org/consoleservice;1"].
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);
do_test_pending();
Components.classes["@mozilla.org/thread-manager;1"].
getService(Ci.nsIThreadManager).dispatchToMainThread(function() {
cs.unregisterListener(kConsoleListener);
--- a/xpcom/tests/unit/test_bug725015.js
+++ b/xpcom/tests/unit/test_bug725015.js
@@ -2,36 +2,35 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
var Cc = Components.classes;
var Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/Services.jsm");
-const manifest = do_get_file('bug725015.manifest');
+const manifest = do_get_file("bug725015.manifest");
const contract = "@bug725015.test.contract";
const observerTopic = "xpcom-category-entry-added";
const category = "bug725015-test-category";
const entry = "bug725015-category-entry";
const cid = Components.ID("{05070380-6e6e-42ba-aaa5-3289fc55ca5a}");
function observe_category(subj, topic, data) {
try {
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();
}
function run_test() {
do_test_pending();
Services.obs.addObserver(observe_category, observerTopic);
--- 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", [])));
}
--- a/xpcom/tests/unit/test_debugger_malloc_size_of.js
+++ b/xpcom/tests/unit/test_debugger_malloc_size_of.js
@@ -7,21 +7,20 @@
// This is just a sanity test that Gecko is giving SpiderMonkey a MallocSizeOf
// function for new JSRuntimes. There is more extensive testing around the
// expected byte sizes within SpiderMonkey's jit-tests, we just want to make
// sure that Gecko is providing SpiderMonkey with the callback it needs.
var Cu = Components.utils;
const { byteSize } = Cu.getJSTestingFunctions();
-function run_test()
-{
+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"),
new Date(),
new Uint8Array(64),
Promise.resolve(1),
function f() {},
Object
--- a/xpcom/tests/unit/test_file_createUnique.js
+++ b/xpcom/tests/unit/test_file_createUnique.js
@@ -2,31 +2,29 @@
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
-function run_test()
-{
+function run_test() {
// Generate a leaf name that is 255 characters long.
var longLeafName = new Array(256).join("T");
// Generate the path for a file located in a directory with a long name.
var tempFile = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
tempFile.append(longLeafName);
tempFile.append("test.txt");
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;
}
// We expect the function not to crash but to raise this exception.
}
}
--- a/xpcom/tests/unit/test_file_equality.js
+++ b/xpcom/tests/unit/test_file_equality.js
@@ -5,23 +5,21 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Cr = Components.results;
var Ci = Components.interfaces;
var CC = Components.Constructor;
var LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
-function run_test()
-{
+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);
var exists = tmp1.exists();
do_check_true(exists);
if (!exists)
return;
--- a/xpcom/tests/unit/test_file_renameTo.js
+++ b/xpcom/tests/unit/test_file_renameTo.js
@@ -1,60 +1,59 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Cc = Components.classes;
var Ci = Components.interfaces;
-function run_test()
-{
+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);
}
function exists(parent, filename) {
let file = parent.clone();
file.append(filename);
return file.exists();
--- a/xpcom/tests/unit/test_iniProcessor.js
+++ b/xpcom/tests/unit/test_iniProcessor.js
@@ -7,22 +7,22 @@ var factory;
function parserForFile(filename) {
let parser = null;
try {
let file = do_get_file(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) {
// If the expected output is null, we expect the parser to have
// failed (and vice-versa).
if (!parser || !expected) {
do_check_eq(parser, null);
do_check_eq(expected, null);
@@ -79,23 +79,23 @@ var testdata = [
{ filename: "data/iniparser06.ini", reference: {} },
{ filename: "data/iniparser07.ini", reference: {} },
{ filename: "data/iniparser08.ini", reference: { section1: { name1: "" }} },
{ filename: "data/iniparser09.ini", reference: { section1: { name1: "value1" } } },
{ filename: "data/iniparser10.ini", reference: { section1: { name1: "value1" } } },
{ 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:
{ "☺♫": { "♫": "☻", "♪": "♥" },
"☼": { "♣": "♠", "♦": "♥" }} },
];
testdata.push( { filename: "data/iniparser01-utf8BOM.ini",
reference: testdata[0].reference } );
testdata.push( { filename: "data/iniparser02-utf8BOM.ini",
@@ -126,17 +126,17 @@ var testdata = [
reference: testdata[13].reference } );
testdata.push( { filename: "data/iniparser15-utf8BOM.ini",
reference: testdata[14].reference } );
testdata.push( { filename: "data/iniparser16-utf8BOM.ini",
reference: testdata[15].reference } );
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",
reference: testdata[1].reference } );
testdata.push( { filename: "data/iniparser03-utf16leBOM.ini",
reference: testdata[2].reference } );
testdata.push( { filename: "data/iniparser04-utf16leBOM.ini",
reference: testdata[3].reference } );
@@ -170,17 +170,17 @@ var testdata = [
factory = Cc["@mozilla.org/xpcom/ini-processor-factory;1"].
getService(Ci.nsIINIParserFactory);
do_check_true(!!factory);
// Test reading from a variety of files. While we're at it, write out each one
// 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);
if (!parser)
continue;
do_check_true(parser instanceof Ci.nsIINIParserWriter);
// write contents out to a new file
let newfilename = filename + ".new";
@@ -277,12 +277,12 @@ try { parser.SetString("ok", "ok", "bad\
do_check_true(caughtError);
caughtError = false;
try { parser.SetString("ok", "ok", "bad\n"); } catch (e) { caughtError = true; }
do_check_true(caughtError);
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;
}
}
--- a/xpcom/tests/unit/test_ioutil.js
+++ b/xpcom/tests/unit/test_ioutil.js
@@ -4,18 +4,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
const util = Cc["@mozilla.org/io-util;1"].getService(Ci.nsIIOUtil);
-function run_test()
-{
+function run_test() {
try {
util.inputStreamIsBuffered(null);
do_throw("inputStreamIsBuffered should have thrown");
} catch (e) {
do_check_eq(e.result, Cr.NS_ERROR_INVALID_POINTER);
}
try {
--- a/xpcom/tests/unit/test_localfile.js
+++ b/xpcom/tests/unit/test_localfile.js
@@ -8,63 +8,52 @@ var Cr = Components.results;
var CC = Components.Constructor;
var Ci = Components.interfaces;
const MAX_TIME_DIFFERENCE = 2500;
const MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
var LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
-function run_test()
-{
+function run_test() {
test_toplevel_parent_is_null();
test_normalize_crash_if_media_missing();
test_file_modification_time();
test_directory_modification_time();
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
// parent == null relies for correctness
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");
// Should never happen but get rid of it anyway
if (file.exists())
file.remove(true);
var now = Date.now();
@@ -92,19 +81,18 @@ function test_file_modification_time()
file.lastModifiedTime = bug377307;
diff = Math.abs(file.lastModifiedTime - bug377307);
do_check_true(diff < MAX_TIME_DIFFERENCE);
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");
// Should never happen but get rid of it anyway
if (dir.exists())
dir.remove(true);
var now = Date.now();
@@ -126,18 +114,17 @@ function test_directory_modification_tim
dir.lastModifiedTime = tomorrow;
diff = Math.abs(dir.lastModifiedTime - tomorrow);
do_check_true(diff < MAX_TIME_DIFFERENCE);
dir.remove(true);
}
-function test_diskSpaceAvailable()
-{
+function test_diskSpaceAvailable() {
let file = do_get_profile();
file.QueryInterface(Ci.nsIFile);
let bytes = file.diskSpaceAvailable;
do_check_true(bytes > 0);
file.append("testfile");
if (file.exists())
--- 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());
}
--- a/xpcom/tests/unit/test_notxpcom_scriptable.js
+++ b/xpcom/tests/unit/test_notxpcom_scriptable.js
@@ -8,50 +8,49 @@ var Ci = Components.interfaces;
var Cu = Components.utils;
var Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const kCID = Components.ID("{1f9f7181-e6c5-4f4c-8f71-08005cec8468}");
const kContract = "@testing/notxpcomtest";
-function run_test()
-{
+function run_test() {
let manifest = do_get_file("xpcomtest.manifest");
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.autoRegister(manifest);
ok(Ci.ScriptableWithNotXPCOM);
let method1Called = false;
let testObject = {
QueryInterface: XPCOMUtils.generateQI([Ci.ScriptableOK,
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!");
},
jsonly: true,
};
let factory = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]),
- createInstance: function(outer, iid) {
+ createInstance(outer, iid) {
if (outer) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return testObject.QueryInterface(iid);
},
};
registrar.registerFactory(kCID, null, kContract, factory);
@@ -63,24 +62,22 @@ function run_test()
xpcomObject.QueryInterface(Ci.ScriptableOK);
xpcomObject.method1();
ok(method1Called);
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);
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);
}
--- a/xpcom/tests/unit/test_nsIMutableArray.js
+++ b/xpcom/tests/unit/test_nsIMutableArray.js
@@ -5,66 +5,61 @@
var Ci = Components.interfaces;
var Cr = Components.results;
var Cc = Components.classes;
var CC = Components.Constructor;
var MutableArray = CC("@mozilla.org/array;1", "nsIMutableArray");
var SupportsString = CC("@mozilla.org/supports-string;1", "nsISupportsString");
-function create_n_element_array(n)
-{
+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);
}
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";
arr.appendElement(str);
do_check_eq(1, arr.length);
var obj = arr.queryElementAt(0, Ci.nsISupportsString);
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);
var str = new SupportsString();
str.data = "hello";
arr.insertElementAt(str, 0, false);
do_check_eq(6, arr.length);
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);
var str = new SupportsString();
str.data = "hello";
// replace first element
arr.replaceElementAt(str, 0, false);
do_check_eq(5, arr.length);
@@ -78,27 +73,25 @@ function test_replace_element()
// replace after last element, should insert empty elements
arr.replaceElementAt(str, 9, false);
do_check_eq(10, arr.length);
obj = arr.queryElementAt(9, Ci.nsISupportsString);
do_check_eq(str, obj);
// 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);
arr.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();
var i = 0;
while (en.hasMoreElements()) {
let str = en.getNext();
do_check_true(str instanceof Ci.nsISupportsString);
do_check_eq(str.data, "element " + i);
--- a/xpcom/tests/unit/test_nsIProcess.js
+++ b/xpcom/tests/unit/test_nsIProcess.js
@@ -7,168 +7,156 @@ const TEST_ARGS = ["mozilla", "firefox",
const TEST_UNICODE_ARGS = ["M\u00F8z\u00EEll\u00E5",
"\u041C\u043E\u0437\u0438\u043B\u043B\u0430",
"\u09AE\u09CB\u099C\u09BF\u09B2\u09BE",
"\uD808\uDE2C\uD808\uDF63\uD808\uDDB7"];
// 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);
do_check_false(process.isRunning);
try {
process.kill();
do_throw("Attempting to kill a not-running process should throw");
- }
- catch (e) { }
+ } catch (e) { }
process.run(false, [], 0);
do_check_true(process.isRunning);
process.kill();
do_check_false(process.isRunning);
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);
asciiFile.moveTo(null, unicodeLeaf);
var unicodeFile = get_test_program(unicodeName);
test_args(unicodeFile, args, argsAreASCII);
unicodeFile.moveTo(null, asciiLeaf);
}
// 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",
TEST_ARGS, true);
rename_and_test("TestUnicodeArguments",
// "Unicode" in Thai
"\u0E22\u0E39\u0E19\u0E34\u0E42\u0E04\u0E14",
TEST_UNICODE_ARGS, false);
}
// 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"]
.createInstance(Components.interfaces.nsIProcess);
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);
test_notify_nonblocking();
}
});
}
// 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"]
.createInstance(Components.interfaces.nsIProcess);
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);
test_notify_killed();
}
});
}
// 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"]
.createInstance(Components.interfaces.nsIProcess);
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();
}
});
process.kill();
}
--- a/xpcom/tests/unit/test_nsIProcess_stress.js
+++ b/xpcom/tests/unit/test_nsIProcess_stress.js
@@ -9,18 +9,17 @@ function run_test() {
var process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
process.init(file);
process.run(false, [], 0);
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
// errors during the test.
tm.spinEventLoopUntilEmpty();
}
}
--- a/xpcom/tests/unit/test_pipe.js
+++ b/xpcom/tests/unit/test_pipe.js
@@ -6,40 +6,34 @@
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
var CC = Components.Constructor;
var Pipe = CC("@mozilla.org/pipe;1", "nsIPipe", "init");
-function run_test()
-{
+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);
is = p.inputStream.QueryInterface(Ci.nsIClassInfo);
os = p.outputStream.QueryInterface(Ci.nsIClassInfo);
do_check_true(Boolean(is.flags & Ci.nsIClassInfo.THREADSAFE));
do_check_true(Boolean(os.flags & Ci.nsIClassInfo.THREADSAFE));
--- a/xpcom/tests/unit/test_process_directives.js
+++ b/xpcom/tests/unit/test_process_directives.js
@@ -1,15 +1,14 @@
var Ci = Components.interfaces;
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;
if (isChild) {
do_check_false("@mozilla.org/xpcom/tests/MainProcessDirectiveTest;1" in Cc);
} else {
let svc = Cc["@mozilla.org/xpcom/tests/MainProcessDirectiveTest;1"].createInstance(Ci.nsISupportsString);
--- a/xpcom/tests/unit/test_seek_multiplex.js
+++ b/xpcom/tests/unit/test_seek_multiplex.js
@@ -106,17 +106,17 @@ function test_multiplex_streams() {
do_check_eq(readData, data.slice(5) + data);
do_check_eq(seekable.tell(), data.length * count);
// -- Try to do various edge cases
// Forward seek from the end, should throw.
var caught = false;
try {
seekable.seek(Ci.nsISeekableStream.NS_SEEK_END, 15);
- } catch(e) {
+ } catch (e) {
caught = true;
}
do_check_eq(caught, true);
do_check_eq(seekable.tell(), data.length * count);
// Backward seek from the beginning, should be clamped.
seekable.seek(Ci.nsISeekableStream.NS_SEEK_SET, 0);
do_check_eq(seekable.tell(), 0);
seekable.seek(Ci.nsISeekableStream.NS_SEEK_CUR, -15);
--- a/xpcom/tests/unit/test_storagestream.js
+++ b/xpcom/tests/unit/test_storagestream.js
@@ -3,30 +3,28 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
-function run_test()
-{
+function run_test() {
test1();
test2();
test3();
test4();
}
/**
* 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);
var out = ss.getOutputStream(0);
var inp2 = ss.newInputStream(0);
do_check_eq(inp2.available(), 0);
do_check_true(inp2.isNonBlocking());
@@ -48,79 +46,67 @@ function test1()
}
do_check_true(threw);
}
/**
* 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");
}
}
/**
* 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;
}
do_check_true(threw,
"should have thrown (nsStorageInputStream is nonblocking)");
}
/**
* 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"]
.createInstance(Ci.nsIStorageStream);
ss.init(1024, 1024, null);
var outStream = ss.getOutputStream(0);
@@ -130,37 +116,32 @@ function test4()
bos.writeByteArray(bytes, bytes.length);
bos.close();
var inp = ss.newInputStream(0);
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;
}
if (!threw)
do_throw("should have thrown but instead returned: '" + data + "'");
}
-function BIS(input)
-{
+function BIS(input) {
var bis = Cc["@mozilla.org/binaryinputstream;1"]
.createInstance(Ci.nsIBinaryInputStream);
bis.setInputStream(input);
return bis;
}
--- a/xpcom/tests/unit/test_streams.js
+++ b/xpcom/tests/unit/test_streams.js
@@ -24,17 +24,17 @@ function test_binary_streams() {
p = new Pipe(false, false, 1024, 1, null);
is = new BinaryInput(p.inputStream);
os = new BinaryOutput(p.outputStream);
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);
// Test reading immediately after writing.
os.writeBoolean(true);
do_check_eq(is.readBoolean(), true);
os.write8(4);
@@ -117,17 +117,17 @@ function test_binary_streams() {
do_check_eq(msg, HelloStr);
msg = null;
countObj.value = -1;
do_check_eq(is.available(), HelloStr.length);
msg = is.readByteArray(HelloStr.length)
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();
try {
os.writeBoolean(false);
do_throw("Not reached!");
} catch (e) {
--- a/xpcom/tests/unit/test_stringstream.js
+++ b/xpcom/tests/unit/test_stringstream.js
@@ -2,18 +2,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
-function run_test()
-{
+function run_test() {
var s = Cc["@mozilla.org/io/string-input-stream;1"]
.createInstance(Ci.nsIStringInputStream);
var body = "This is a test";
s.setData(body, body.length);
do_check_eq(s.available(), body.length);
var sis = Cc["@mozilla.org/scriptableinputstream;1"]
.createInstance(Ci.nsIScriptableInputStream);
--- a/xpcom/tests/unit/test_symlinks.js
+++ b/xpcom/tests/unit/test_symlinks.js
@@ -31,34 +31,32 @@ function createSymLink(from, to) {
}
function makeSymLink(from, toName, relative) {
var to = from.parent;
to.append(toName);
if (relative) {
createSymLink(from.leafName, to.path);
- }
- else {
+ } else {
createSymLink(from.path, to.path);
}
do_check_true(to.isSymlink());
print("---");
print(from.path);
print(to.path);
print(to.target);
if (from.leafName != DOES_NOT_EXIST && from.isSymlink()) {
// 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);
}
return to;
}
function setupTestDir(testDir, relative) {
var targetDir = testDir.clone();
@@ -89,18 +87,17 @@ function setupTestDir(testDir, relative)
makeSymLink(dirLink, DIR_LINK_LINK, relative);
makeSymLink(fileLink, FILE_LINK_LINK, relative);
makeSymLink(imaginary, DANGLING_LINK, relative);
try {
makeSymLink(loop, LOOP_LINK, relative);
do_check_true(false);
- }
- catch (e) {
+ } catch (e) {
}
}
function createSpaces(dirs, files, links) {
function longest(a, b) {
return a.length > b.length ? a : b;
}
return dirs.concat(files, links).reduce(longest, "").replace(/./g, " ");
--- a/xpcom/tests/unit/test_versioncomparator.js
+++ b/xpcom/tests/unit/test_versioncomparator.js
@@ -23,33 +23,30 @@ var comparisons = [
// Every version in this list means the same version number
var equality = [
"1.1pre",
"1.1pre0",
"1.0+"
];
-function run_test()
-{
+function run_test() {
var vc = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
.getService(Components.interfaces.nsIVersionComparator);
for (var i = 0; i < comparisons.length; i++) {
for (var j = 0; j < comparisons.length; j++) {
var result = vc.compare(comparisons[i], comparisons[j]);
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]);
}
}
}
for (i = 0; i < equality.length; i++) {
for (j = 0; j < equality.length; j++) {
if (vc.compare(equality[i], equality[j]) != 0)
--- a/xpcom/tests/unit/test_windows_registry.js
+++ b/xpcom/tests/unit/test_windows_registry.js
@@ -9,107 +9,100 @@ const Cr = Components.results;
const Ci = Components.interfaces;
const Cc = Components.classes;
const Cu = Components.utils;
const CC = Components.Constructor;
const nsIWindowsRegKey = Ci.nsIWindowsRegKey;
let regKeyComponent = Cc["@mozilla.org/windows-registry-key;1"];
-function run_test()
-{
- //* create a key structure in a spot that's normally writable (somewhere under HKCU).
+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.
let keyName = BASE_PATH + "\\" + TESTDATA_KEYNAME;
setup_test_run(testKey, keyName);
//* test that the write* functions write stuff
test_writing_functions(testKey);
//* 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);
//* check that creating/enumerating/deleting child keys works
test_childkey_functions(testKey);
test_watching_functions(testKey);
//* clean up
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;
}
}
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);
testKey.writeStringValue(TESTDATA_STRNAME, TESTDATA_STRVALUE);
strictEqual(testKey.hasValue(TESTDATA_STRNAME), true);
strictEqual(testKey.hasValue(TESTDATA_INTNAME), false);
testKey.writeIntValue(TESTDATA_INTNAME, TESTDATA_INTVALUE);
strictEqual(testKey.hasValue(TESTDATA_INT64NAME), false);
testKey.writeInt64Value(TESTDATA_INT64NAME, TESTDATA_INT64VALUE);
strictEqual(testKey.hasValue(TESTDATA_BINARYNAME), false);
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);
strictEqual(testKey.getValueName(2), TESTDATA_INT64NAME);
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.");
} catch (e) {
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
throw e;
}
}
@@ -138,65 +131,62 @@ function test_invalidread_functions(test
} catch (e) {
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
throw e;
}
}
}
-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();
strictEqual(testKey.childCount, 1);
strictEqual(testKey.hasChild(TESTDATA_CHILD_KEY), true);
strictEqual(testKey.getChildName(0), TESTDATA_CHILD_KEY);
childKey = testKey.openChild(TESTDATA_CHILD_KEY, nsIWindowsRegKey.ACCESS_ALL);
testKey.removeChild(TESTDATA_CHILD_KEY);
strictEqual(testKey.childCount, 0);
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);
// Create a child key, and update a value
let childKey = testKey.createChild(TESTDATA_CHILD_KEY, nsIWindowsRegKey.ACCESS_ALL);
childKey.writeIntValue(TESTDATA_INTNAME, TESTDATA_INTVALUE);
// Start a recursive watch, and update the child's value
testKey.startWatching(true);
strictEqual(testKey.isWatching(), true);
childKey.writeIntValue(TESTDATA_INTNAME, 0);
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++) {
testKey.removeChild(testKey.getChildName(i));
}
testKey.close();
let baseKey = regKeyComponent.createInstance(nsIWindowsRegKey);
--- a/xpcom/tests/unit/test_windows_shortcut.js
+++ b/xpcom/tests/unit/test_windows_shortcut.js
@@ -10,18 +10,17 @@ var Ci = Components.interfaces;
var Cc = Components.classes;
var Cu = Components.utils;
var CC = Components.Constructor;
const LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
Cu.import("resource://gre/modules/Services.jsm");
-function run_test()
-{
+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) {
let tempDir = Services.dirsvc.get("TmpD", Ci.nsIFile);
tempDir.append("shortcutTesting");
tempDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o666);
@@ -34,81 +33,73 @@ function run_test()
test_update_noargs(tempDir);
test_update_notarget(tempDir);
test_update_targetonly(tempDir);
test_update_normal(tempDir);
test_update_unicode(tempDir);
}
}
-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;
}
}
}
-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;
}
}
}
-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);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
win.setShortcut(targetFile);
let shortcutTarget = LocalFile(shortcutFile.target);
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);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@@ -118,18 +109,17 @@ function test_create_normal(tempDir)
do_get_cwd(),
"arg1 arg2",
"Ordinary shortcut");
let shortcutTarget = LocalFile(shortcutFile.target);
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);
let targetFile = tempDir.clone();
targetFile.append("ṩhогТϾừ†Target.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@@ -139,18 +129,17 @@ function test_create_unicode(tempDir)
do_get_cwd(), // XXX: This should probably be a unicode dir
"ᾶṟǵ1 ᾶṟǵ2",
"ῧṋіḉѻₑ");
let shortcutTarget = LocalFile(shortcutFile.target);
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);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@@ -162,18 +151,17 @@ function test_update_noargs(tempDir)
"A sample shortcut");
win.setShortcut();
let shortcutTarget = LocalFile(shortcutFile.target);
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);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@@ -188,18 +176,17 @@ function test_update_notarget(tempDir)
do_get_profile(),
"arg3 arg4",
"An UPDATED shortcut");
let shortcutTarget = LocalFile(shortcutFile.target);
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);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@@ -215,18 +202,17 @@ function test_update_targetonly(tempDir)
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
win.setShortcut(newTargetFile);
let shortcutTarget = LocalFile(shortcutFile.target);
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);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
@@ -245,18 +231,17 @@ function test_update_normal(tempDir)
do_get_profile(),
"arg3 arg4",
"An UPDATED shortcut");
let shortcutTarget = LocalFile(shortcutFile.target);
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);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);