forked from mirrors/gecko-dev
Bug 1561435 - Format xpcom/, a=automatic-formatting
# ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D35945 --HG-- extra : source : c64ace0e98b196a9a392d54800159e327921bf99
This commit is contained in:
parent
c03a3e486b
commit
1fcaa7d445
40 changed files with 978 additions and 647 deletions
|
|
@ -45,7 +45,6 @@ module.exports = {
|
||||||
"overrides": [{
|
"overrides": [{
|
||||||
"files": [
|
"files": [
|
||||||
"devtools/**",
|
"devtools/**",
|
||||||
"xpcom/**",
|
|
||||||
"xpfe/**",
|
"xpfe/**",
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ toolkit/components/telemetry/datareporting-prefs.js
|
||||||
toolkit/components/telemetry/healthreport-prefs.js
|
toolkit/components/telemetry/healthreport-prefs.js
|
||||||
|
|
||||||
# Ignore all top-level directories for now.
|
# Ignore all top-level directories for now.
|
||||||
xpcom/**
|
|
||||||
xpfe/**
|
xpfe/**
|
||||||
|
|
||||||
# Ignore all devtools directories for now, except the debugger.
|
# Ignore all devtools directories for now, except the debugger.
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@ const nsIWindowsRegKey = Ci.nsIWindowsRegKey;
|
||||||
const BASE_PATH = "SOFTWARE\\Mozilla\\Firefox";
|
const BASE_PATH = "SOFTWARE\\Mozilla\\Firefox";
|
||||||
|
|
||||||
function idump(indent, str) {
|
function idump(indent, str) {
|
||||||
for (var j = 0; j < indent; ++j)
|
for (var j = 0; j < indent; ++j) {
|
||||||
dump(" ");
|
dump(" ");
|
||||||
|
}
|
||||||
dump(str);
|
dump(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -24,10 +25,11 @@ function list_values(indent, key) {
|
||||||
if (key.getValueType(vn) == nsIWindowsRegKey.TYPE_STRING) {
|
if (key.getValueType(vn) == nsIWindowsRegKey.TYPE_STRING) {
|
||||||
val = key.readStringValue(vn);
|
val = key.readStringValue(vn);
|
||||||
}
|
}
|
||||||
if (vn == "")
|
if (vn == "") {
|
||||||
idump(indent + 1, "(Default): \"" + val + "\"\n");
|
idump(indent + 1, '(Default): "' + val + '"\n');
|
||||||
else
|
} else {
|
||||||
idump(indent + 1, vn + ": \"" + val + "\"\n");
|
idump(indent + 1, vn + ': "' + val + '"\n');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
idump(indent, "}\n");
|
idump(indent, "}\n");
|
||||||
}
|
}
|
||||||
|
|
@ -44,13 +46,20 @@ function list_children(indent, key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// enumerate everything under BASE_PATH
|
// enumerate everything under BASE_PATH
|
||||||
var key = Cc["@mozilla.org/windows-registry-key;1"].
|
var key = Cc["@mozilla.org/windows-registry-key;1"].createInstance(
|
||||||
createInstance(nsIWindowsRegKey);
|
nsIWindowsRegKey
|
||||||
key.open(nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE, BASE_PATH,
|
);
|
||||||
nsIWindowsRegKey.ACCESS_READ);
|
key.open(
|
||||||
|
nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
|
||||||
|
BASE_PATH,
|
||||||
|
nsIWindowsRegKey.ACCESS_READ
|
||||||
|
);
|
||||||
list_children(1, key);
|
list_children(1, key);
|
||||||
|
|
||||||
key.close();
|
key.close();
|
||||||
key.open(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, BASE_PATH,
|
key.open(
|
||||||
nsIWindowsRegKey.ACCESS_READ);
|
nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||||
|
BASE_PATH,
|
||||||
|
nsIWindowsRegKey.ACCESS_READ
|
||||||
|
);
|
||||||
list_children(1, key);
|
list_children(1, key);
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* 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
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
const { XPCOMUtils } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/XPCOMUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
function TestProcessDirective() {}
|
function TestProcessDirective() {}
|
||||||
TestProcessDirective.prototype = {
|
TestProcessDirective.prototype = {
|
||||||
|
|
||||||
/* Boilerplate */
|
/* Boilerplate */
|
||||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIProperty]),
|
QueryInterface: ChromeUtils.generateQI([Ci.nsIProperty]),
|
||||||
contractID: "@mozilla.org/xpcom/tests/ChildProcessDirectiveTest;1",
|
contractID: "@mozilla.org/xpcom/tests/ChildProcessDirectiveTest;1",
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* 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
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
const { XPCOMUtils } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/XPCOMUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
function TestProcessDirective() {}
|
function TestProcessDirective() {}
|
||||||
TestProcessDirective.prototype = {
|
TestProcessDirective.prototype = {
|
||||||
|
|
||||||
/* Boilerplate */
|
/* Boilerplate */
|
||||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIProperty]),
|
QueryInterface: ChromeUtils.generateQI([Ci.nsIProperty]),
|
||||||
contractID: "@mozilla.org/xpcom/tests/MainProcessDirectiveTest;1",
|
contractID: "@mozilla.org/xpcom/tests/MainProcessDirectiveTest;1",
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,14 @@ function get_test_program(prog) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_process_running_environment() {
|
function set_process_running_environment() {
|
||||||
var envSvc = Cc["@mozilla.org/process/environment;1"].
|
var envSvc = Cc["@mozilla.org/process/environment;1"].getService(
|
||||||
getService(Ci.nsIEnvironment);
|
Ci.nsIEnvironment
|
||||||
|
);
|
||||||
// Importing Services here messes up appInfo for some of the tests.
|
// Importing Services here messes up appInfo for some of the tests.
|
||||||
// eslint-disable-next-line mozilla/use-services
|
// eslint-disable-next-line mozilla/use-services
|
||||||
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(
|
||||||
getService(Ci.nsIProperties);
|
Ci.nsIProperties
|
||||||
|
);
|
||||||
var greBinDir = dirSvc.get("GreBinD", Ci.nsIFile);
|
var greBinDir = dirSvc.get("GreBinD", Ci.nsIFile);
|
||||||
envSvc.set("DYLD_LIBRARY_PATH", greBinDir.path);
|
envSvc.set("DYLD_LIBRARY_PATH", greBinDir.path);
|
||||||
// For Linux
|
// For Linux
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
var dataFile = do_get_file("data/bug121341.properties");
|
var dataFile = do_get_file("data/bug121341.properties");
|
||||||
|
|
@ -59,6 +59,5 @@ function run_test() {
|
||||||
try {
|
try {
|
||||||
properties2.load(inp);
|
properties2.load(inp);
|
||||||
do_throw("load() didn't fail");
|
do_throw("load() didn't fail");
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
* http://creativecommons.org/licenses/publicdomain/ */
|
* http://creativecommons.org/licenses/publicdomain/ */
|
||||||
|
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
let complete = false;
|
let complete = false;
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,16 @@ var observer1 = {
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
|
|
||||||
// Actual delay may not be exact, so convert to seconds and round.
|
// Actual delay may not be exact, so convert to seconds and round.
|
||||||
Assert.equal(Math.round((Date.now() - gStartTime1) / 1000),
|
Assert.equal(
|
||||||
kExpectedDelay1);
|
Math.round((Date.now() - gStartTime1) / 1000),
|
||||||
|
kExpectedDelay1
|
||||||
|
);
|
||||||
|
|
||||||
timer = null;
|
timer = null;
|
||||||
|
|
||||||
info("1st timer triggered (before being cancelled). Should not have happened!");
|
info(
|
||||||
|
"1st timer triggered (before being cancelled). Should not have happened!"
|
||||||
|
);
|
||||||
Assert.ok(false);
|
Assert.ok(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -32,8 +36,10 @@ var observer2 = {
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
|
|
||||||
// Actual delay may not be exact, so convert to seconds and round.
|
// Actual delay may not be exact, so convert to seconds and round.
|
||||||
Assert.equal(Math.round((Date.now() - gStartTime2) / 1000),
|
Assert.equal(
|
||||||
kExpectedDelay2);
|
Math.round((Date.now() - gStartTime2) / 1000),
|
||||||
|
kExpectedDelay2
|
||||||
|
);
|
||||||
|
|
||||||
timer = null;
|
timer = null;
|
||||||
|
|
||||||
|
|
@ -49,12 +55,18 @@ function run_test() {
|
||||||
|
|
||||||
// Initialize the timer (with some delay), then cancel it.
|
// Initialize the timer (with some delay), then cancel it.
|
||||||
gStartTime1 = Date.now();
|
gStartTime1 = Date.now();
|
||||||
timer.init(observer1, kExpectedDelay1 * 1000,
|
timer.init(
|
||||||
timer.TYPE_REPEATING_PRECISE_CAN_SKIP);
|
observer1,
|
||||||
|
kExpectedDelay1 * 1000,
|
||||||
|
timer.TYPE_REPEATING_PRECISE_CAN_SKIP
|
||||||
|
);
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
|
|
||||||
// Re-initialize the timer (with a different delay).
|
// Re-initialize the timer (with a different delay).
|
||||||
gStartTime2 = Date.now();
|
gStartTime2 = Date.now();
|
||||||
timer.init(observer2, kExpectedDelay2 * 1000,
|
timer.init(
|
||||||
timer.TYPE_REPEATING_PRECISE_CAN_SKIP);
|
observer2,
|
||||||
|
kExpectedDelay2 * 1000,
|
||||||
|
timer.TYPE_REPEATING_PRECISE_CAN_SKIP
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
var f = Services.dirsvc.get("CurProcD", Ci.nsIFile);
|
var f = Services.dirsvc.get("CurProcD", Ci.nsIFile);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
function run_test() {
|
function run_test() {
|
||||||
var dirEntries = do_get_cwd().directoryEntries;
|
var dirEntries = do_get_cwd().directoryEntries;
|
||||||
|
|
||||||
while (dirEntries.hasMoreElements())
|
while (dirEntries.hasMoreElements()) {
|
||||||
dirEntries.getNext();
|
dirEntries.getNext();
|
||||||
|
}
|
||||||
|
|
||||||
// We ensure there is no crash
|
// We ensure there is no crash
|
||||||
dirEntries.hasMoreElements();
|
dirEntries.hasMoreElements();
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,45 @@
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
var nameArray = [
|
var nameArray = [
|
||||||
"ascii", // ASCII
|
"ascii", // ASCII
|
||||||
"fran\u00E7ais", // Latin-1
|
"fran\u00E7ais", // Latin-1
|
||||||
"\u0420\u0443\u0441\u0441\u043A\u0438\u0439", // Cyrillic
|
"\u0420\u0443\u0441\u0441\u043A\u0438\u0439", // Cyrillic
|
||||||
"\u65E5\u672C\u8A9E", // Japanese
|
"\u65E5\u672C\u8A9E", // Japanese
|
||||||
"\u4E2D\u6587", // Chinese
|
"\u4E2D\u6587", // Chinese
|
||||||
"\uD55C\uAD6D\uC5B4", // Korean
|
"\uD55C\uAD6D\uC5B4", // Korean
|
||||||
"\uD801\uDC0F\uD801\uDC2D\uD801\uDC3B\uD801\uDC2B", // Deseret
|
"\uD801\uDC0F\uD801\uDC2D\uD801\uDC3B\uD801\uDC2B", // Deseret
|
||||||
];
|
];
|
||||||
|
|
||||||
function getTempDir() {
|
function getTempDir() {
|
||||||
return Services.dirsvc.get("TmpD", Ci.nsIFile);
|
return Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_file(fileName) {
|
function create_file(fileName) {
|
||||||
var outFile = getTempDir();
|
var outFile = getTempDir();
|
||||||
outFile.append(fileName);
|
outFile.append(fileName);
|
||||||
outFile.createUnique(outFile.NORMAL_FILE_TYPE, 0o600);
|
outFile.createUnique(outFile.NORMAL_FILE_TYPE, 0o600);
|
||||||
|
|
||||||
var stream = Cc["@mozilla.org/network/file-output-stream;1"]
|
var stream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIFileOutputStream);
|
Ci.nsIFileOutputStream
|
||||||
stream.init(outFile, 0x02 | 0x08 | 0x20, 0o600, 0);
|
);
|
||||||
stream.write("foo", 3);
|
stream.init(outFile, 0x02 | 0x08 | 0x20, 0o600, 0);
|
||||||
stream.close();
|
stream.write("foo", 3);
|
||||||
|
stream.close();
|
||||||
|
|
||||||
Assert.equal(outFile.leafName.substr(0, fileName.length), fileName);
|
Assert.equal(outFile.leafName.substr(0, fileName.length), fileName);
|
||||||
|
|
||||||
return outFile;
|
return outFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_create(fileName) {
|
function test_create(fileName) {
|
||||||
var file1 = create_file(fileName);
|
var file1 = create_file(fileName);
|
||||||
var file2 = create_file(fileName);
|
var file2 = create_file(fileName);
|
||||||
file1.remove(false);
|
file1.remove(false);
|
||||||
file2.remove(false);
|
file2.remove(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
for (var i = 0; i < nameArray.length; ++i) {
|
for (var i = 0; i < nameArray.length; ++i) {
|
||||||
test_create(nameArray[i]);
|
test_create(nameArray[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
var addedTopic = "xpcom-category-entry-added";
|
var addedTopic = "xpcom-category-entry-added";
|
||||||
var removedTopic = "xpcom-category-entry-removed";
|
var removedTopic = "xpcom-category-entry-removed";
|
||||||
|
|
@ -25,13 +25,18 @@ var observer = {
|
||||||
timer = null;
|
timer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subject.QueryInterface(Ci.nsISupportsCString).data != testEntry || data != testCategory)
|
if (
|
||||||
|
subject.QueryInterface(Ci.nsISupportsCString).data != testEntry ||
|
||||||
|
data != testCategory
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (topic == addedTopic)
|
if (topic == addedTopic) {
|
||||||
result += "add ";
|
result += "add ";
|
||||||
else if (topic == removedTopic)
|
} else if (topic == removedTopic) {
|
||||||
result += "remove ";
|
result += "remove ";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -41,8 +46,20 @@ function run_test() {
|
||||||
Services.obs.addObserver(observer, addedTopic);
|
Services.obs.addObserver(observer, addedTopic);
|
||||||
Services.obs.addObserver(observer, removedTopic);
|
Services.obs.addObserver(observer, removedTopic);
|
||||||
|
|
||||||
Services.catMan.addCategoryEntry(testCategory, testEntry, testValue, false, true);
|
Services.catMan.addCategoryEntry(
|
||||||
Services.catMan.addCategoryEntry(testCategory, testEntry, testValue, false, true);
|
testCategory,
|
||||||
|
testEntry,
|
||||||
|
testValue,
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
Services.catMan.addCategoryEntry(
|
||||||
|
testCategory,
|
||||||
|
testEntry,
|
||||||
|
testValue,
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
);
|
||||||
Services.catMan.deleteCategoryEntry(testCategory, testEntry, false);
|
Services.catMan.deleteCategoryEntry(testCategory, testEntry, false);
|
||||||
|
|
||||||
timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||||
|
|
|
||||||
|
|
@ -7,17 +7,21 @@ function run_test() {
|
||||||
// create a test file, then symlink it, then check that we think it's a symlink
|
// create a test file, then symlink it, then check that we think it's a symlink
|
||||||
var targetFile = testDir.clone();
|
var targetFile = testDir.clone();
|
||||||
targetFile.append("target.txt");
|
targetFile.append("target.txt");
|
||||||
if (!targetFile.exists())
|
if (!targetFile.exists()) {
|
||||||
targetFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
|
targetFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
|
||||||
|
}
|
||||||
|
|
||||||
var link = testDir.clone();
|
var link = testDir.clone();
|
||||||
link.append("link");
|
link.append("link");
|
||||||
if (link.exists())
|
if (link.exists()) {
|
||||||
link.remove(false);
|
link.remove(false);
|
||||||
|
}
|
||||||
|
|
||||||
var ln = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
var ln = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
||||||
ln.initWithPath("/bin/ln");
|
ln.initWithPath("/bin/ln");
|
||||||
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
|
var process = Cc["@mozilla.org/process/util;1"].createInstance(
|
||||||
|
Ci.nsIProcess
|
||||||
|
);
|
||||||
process.init(ln);
|
process.init(ln);
|
||||||
var args = ["-s", targetFile.path, link.path];
|
var args = ["-s", targetFile.path, link.path];
|
||||||
process.run(true, args, args.length);
|
process.run(true, args, args.length);
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
var nsIFile = Ci.nsIFile;
|
var nsIFile = Ci.nsIFile;
|
||||||
var root = Cc["@mozilla.org/file/local;1"].
|
var root = Cc["@mozilla.org/file/local;1"].createInstance(nsIFile);
|
||||||
createInstance(nsIFile);
|
|
||||||
|
|
||||||
// copied from http://mxr.mozilla.org/mozilla-central/source/image/test/unit/test_imgtools.js#135
|
// copied from http://mxr.mozilla.org/mozilla-central/source/image/test/unit/test_imgtools.js#135
|
||||||
// nsIXULRuntime.OS doesn't seem to be available in xpcshell, so we'll use
|
// nsIXULRuntime.OS doesn't seem to be available in xpcshell, so we'll use
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* 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/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.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 contract = "@bug725015.test.contract";
|
||||||
|
|
@ -14,8 +14,9 @@ const cid = Components.ID("{05070380-6e6e-42ba-aaa5-3289fc55ca5a}");
|
||||||
function observe_category(subj, topic, data) {
|
function observe_category(subj, topic, data) {
|
||||||
try {
|
try {
|
||||||
Assert.equal(topic, observerTopic);
|
Assert.equal(topic, observerTopic);
|
||||||
if (data != category)
|
if (data != category) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var thisentry = subj.QueryInterface(Ci.nsISupportsCString).data;
|
var thisentry = subj.QueryInterface(Ci.nsISupportsCString).data;
|
||||||
Assert.equal(thisentry, entry);
|
Assert.equal(thisentry, entry);
|
||||||
|
|
@ -31,5 +32,7 @@ function observe_category(subj, topic, data) {
|
||||||
function run_test() {
|
function run_test() {
|
||||||
do_test_pending();
|
do_test_pending();
|
||||||
Services.obs.addObserver(observe_category, observerTopic);
|
Services.obs.addObserver(observe_category, observerTopic);
|
||||||
Components.manager.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(manifest);
|
Components.manager
|
||||||
|
.QueryInterface(Ci.nsIComponentRegistrar)
|
||||||
|
.autoRegister(manifest);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
const {FileUtils} = ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
|
const { FileUtils } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/FileUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
Assert.ok(FileUtils.File("~").equals(FileUtils.getDir("Home", [])));
|
Assert.ok(FileUtils.File("~").equals(FileUtils.getDir("Home", [])));
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
// Generate a leaf name that is 255 characters long.
|
// Generate a leaf name that is 255 characters long.
|
||||||
|
|
@ -18,8 +18,12 @@ function run_test() {
|
||||||
tempFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
|
tempFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
|
||||||
do_throw("Creating an item in a folder with a very long name should throw");
|
do_throw("Creating an item in a folder with a very long name should throw");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!(e instanceof Ci.nsIException &&
|
if (
|
||||||
e.result == Cr.NS_ERROR_FILE_UNRECOGNIZED_PATH)) {
|
!(
|
||||||
|
e instanceof Ci.nsIException &&
|
||||||
|
e.result == Cr.NS_ERROR_FILE_UNRECOGNIZED_PATH
|
||||||
|
)
|
||||||
|
) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
// We expect the function not to crash but to raise this exception.
|
// We expect the function not to crash but to raise this exception.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
var LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
|
var LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
|
||||||
|
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
test_normalized_vs_non_normalized();
|
test_normalized_vs_non_normalized();
|
||||||
|
|
@ -17,8 +17,9 @@ function test_normalized_vs_non_normalized() {
|
||||||
var tmp1 = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
var tmp1 = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||||
var exists = tmp1.exists();
|
var exists = tmp1.exists();
|
||||||
Assert.ok(exists);
|
Assert.ok(exists);
|
||||||
if (!exists)
|
if (!exists) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// the test logic below assumes we're starting with a normalized path, but the
|
// the test logic below assumes we're starting with a normalized path, but the
|
||||||
// default location on macos is a symbolic link, so resolve it before starting
|
// default location on macos is a symbolic link, so resolve it before starting
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
// Create the base directory.
|
// Create the base directory.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const NS_OS_TEMP_DIR = "TmpD";
|
||||||
|
|
||||||
const CWD = do_get_cwd();
|
const CWD = do_get_cwd();
|
||||||
|
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
var hiddenUnixFile;
|
var hiddenUnixFile;
|
||||||
function createUNIXHiddenFile() {
|
function createUNIXHiddenFile() {
|
||||||
|
|
@ -11,15 +11,17 @@ function createUNIXHiddenFile() {
|
||||||
hiddenUnixFile.append(".foo");
|
hiddenUnixFile.append(".foo");
|
||||||
// we don't care if this already exists because we don't care
|
// we don't care if this already exists because we don't care
|
||||||
// about the file's contents (just the name)
|
// about the file's contents (just the name)
|
||||||
if (!hiddenUnixFile.exists())
|
if (!hiddenUnixFile.exists()) {
|
||||||
hiddenUnixFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
|
hiddenUnixFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
|
||||||
|
}
|
||||||
return hiddenUnixFile.exists();
|
return hiddenUnixFile.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
// Skip this test on Windows
|
// Skip this test on Windows
|
||||||
if (mozinfo.os == "win")
|
if (mozinfo.os == "win") {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Assert.ok(createUNIXHiddenFile());
|
Assert.ok(createUNIXHiddenFile());
|
||||||
Assert.ok(hiddenUnixFile.isHidden());
|
Assert.ok(hiddenUnixFile.isHidden());
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
const CWD = do_get_cwd();
|
const CWD = do_get_cwd();
|
||||||
function checkOS(os) {
|
function checkOS(os) {
|
||||||
const nsILocalFile_ = "nsILocalFile" + os;
|
const nsILocalFile_ = "nsILocalFile" + os;
|
||||||
return nsILocalFile_ in Ci &&
|
return nsILocalFile_ in Ci && CWD instanceof Ci[nsILocalFile_];
|
||||||
CWD instanceof Ci[nsILocalFile_];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const isWin = checkOS("Win");
|
const isWin = checkOS("Win");
|
||||||
|
|
@ -14,7 +13,9 @@ function run_test() {
|
||||||
|
|
||||||
var homeDir = Services.dirsvc.get("Home", Ci.nsIFile);
|
var homeDir = Services.dirsvc.get("Home", Ci.nsIFile);
|
||||||
|
|
||||||
var env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
|
var env = Cc["@mozilla.org/process/environment;1"].getService(
|
||||||
|
Ci.nsIEnvironment
|
||||||
|
);
|
||||||
var expected = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
var expected = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
||||||
expected.initWithPath(env.get(envVar));
|
expected.initWithPath(env.get(envVar));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,304 +2,466 @@ var testnum = 0;
|
||||||
var factory;
|
var factory;
|
||||||
|
|
||||||
function parserForFile(filename) {
|
function parserForFile(filename) {
|
||||||
let parser = null;
|
let parser = null;
|
||||||
try {
|
try {
|
||||||
let file = do_get_file(filename);
|
let file = do_get_file(filename);
|
||||||
Assert.ok(!!file);
|
Assert.ok(!!file);
|
||||||
parser = factory.createINIParser(file);
|
parser = factory.createINIParser(file);
|
||||||
Assert.ok(!!parser);
|
Assert.ok(!!parser);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
dump("INFO | caught error: " + e);
|
dump("INFO | caught error: " + e);
|
||||||
// checkParserOutput will handle a null parser when it's expected.
|
// checkParserOutput will handle a null parser when it's expected.
|
||||||
}
|
}
|
||||||
return parser;
|
return parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkParserOutput(parser, expected) {
|
function checkParserOutput(parser, expected) {
|
||||||
// If the expected output is null, we expect the parser to have
|
// If the expected output is null, we expect the parser to have
|
||||||
// failed (and vice-versa).
|
// failed (and vice-versa).
|
||||||
if (!parser || !expected) {
|
if (!parser || !expected) {
|
||||||
Assert.equal(parser, null);
|
Assert.equal(parser, null);
|
||||||
Assert.equal(expected, null);
|
Assert.equal(expected, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = getParserOutput(parser);
|
let output = getParserOutput(parser);
|
||||||
for (let section in expected) {
|
for (let section in expected) {
|
||||||
Assert.ok(section in output);
|
Assert.ok(section in output);
|
||||||
for (let key in expected[section]) {
|
for (let key in expected[section]) {
|
||||||
Assert.ok(key in output[section]);
|
Assert.ok(key in output[section]);
|
||||||
Assert.equal(output[section][key], expected[section][key]);
|
Assert.equal(output[section][key], expected[section][key]);
|
||||||
delete output[section][key];
|
delete output[section][key];
|
||||||
}
|
|
||||||
for (let key in output[section])
|
|
||||||
Assert.equal(key, "wasn't expecting this key!");
|
|
||||||
delete output[section];
|
|
||||||
}
|
}
|
||||||
for (let section in output)
|
for (let key in output[section]) {
|
||||||
Assert.equal(section, "wasn't expecting this section!");
|
Assert.equal(key, "wasn't expecting this key!");
|
||||||
|
}
|
||||||
|
delete output[section];
|
||||||
|
}
|
||||||
|
for (let section in output) {
|
||||||
|
Assert.equal(section, "wasn't expecting this section!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getParserOutput(parser) {
|
function getParserOutput(parser) {
|
||||||
let output = {};
|
let output = {};
|
||||||
|
|
||||||
for (let section of parser.getSections()) {
|
for (let section of parser.getSections()) {
|
||||||
Assert.equal(false, section in output); // catch dupes
|
Assert.equal(false, section in output); // catch dupes
|
||||||
output[section] = {};
|
output[section] = {};
|
||||||
|
|
||||||
for (let key of parser.getKeys(section)) {
|
for (let key of parser.getKeys(section)) {
|
||||||
Assert.equal(false, key in output[section]); // catch dupes
|
Assert.equal(false, key in output[section]); // catch dupes
|
||||||
let value = parser.getString(section, key);
|
let value = parser.getString(section, key);
|
||||||
output[section][key] = value;
|
output[section][key] = value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return output;
|
}
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
try {
|
try {
|
||||||
var testdata = [
|
var testdata = [
|
||||||
{ filename: "data/iniparser01.ini", reference: {} },
|
{ filename: "data/iniparser01.ini", reference: {} },
|
||||||
{ filename: "data/iniparser02.ini", reference: {} },
|
{ filename: "data/iniparser02.ini", reference: {} },
|
||||||
{ filename: "data/iniparser03.ini", reference: {} },
|
{ filename: "data/iniparser03.ini", reference: {} },
|
||||||
{ filename: "data/iniparser04.ini", reference: {} },
|
{ filename: "data/iniparser04.ini", reference: {} },
|
||||||
{ filename: "data/iniparser05.ini", reference: {} },
|
{ filename: "data/iniparser05.ini", reference: {} },
|
||||||
{ filename: "data/iniparser06.ini", reference: {} },
|
{ filename: "data/iniparser06.ini", reference: {} },
|
||||||
{ filename: "data/iniparser07.ini", reference: {} },
|
{ filename: "data/iniparser07.ini", reference: {} },
|
||||||
{ filename: "data/iniparser08.ini", reference: { section1: { name1: "" }} },
|
{
|
||||||
{ filename: "data/iniparser09.ini", reference: { section1: { name1: "value1" } } },
|
filename: "data/iniparser08.ini",
|
||||||
{ filename: "data/iniparser10.ini", reference: { section1: { name1: "value1" } } },
|
reference: { section1: { name1: "" } },
|
||||||
{ 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/iniparser09.ini",
|
||||||
{ filename: "data/iniparser14.ini", reference:
|
reference: { section1: { name1: "value1" } },
|
||||||
{ section1: { name1: "value1", name2: "value2" },
|
},
|
||||||
section2: { name1: "value1", name2: "foopy" }} },
|
{
|
||||||
{ filename: "data/iniparser15.ini", reference:
|
filename: "data/iniparser10.ini",
|
||||||
{ section1: { name1: "newValue1" },
|
reference: { section1: { name1: "value1" } },
|
||||||
section2: { name1: "foopy" }} },
|
},
|
||||||
{ filename: "data/iniparser16.ini", reference:
|
{
|
||||||
{ "☺♫": { "♫": "☻", "♪": "♥" },
|
filename: "data/iniparser11.ini",
|
||||||
"☼": { "♣": "♠", "♦": "♥" }} },
|
reference: { section1: { name1: "value1" } },
|
||||||
{ filename: "data/iniparser17.ini", reference: { section: { key: "" } } },
|
},
|
||||||
|
{
|
||||||
|
filename: "data/iniparser12.ini",
|
||||||
|
reference: { section1: { name1: "value1" } },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filename: "data/iniparser13.ini",
|
||||||
|
reference: { section1: { name1: "value1" } },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filename: "data/iniparser14.ini",
|
||||||
|
reference: {
|
||||||
|
section1: { name1: "value1", name2: "value2" },
|
||||||
|
section2: { name1: "value1", name2: "foopy" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filename: "data/iniparser15.ini",
|
||||||
|
reference: {
|
||||||
|
section1: { name1: "newValue1" },
|
||||||
|
section2: { name1: "foopy" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filename: "data/iniparser16.ini",
|
||||||
|
reference: {
|
||||||
|
"☺♫": { "♫": "☻", "♪": "♥" },
|
||||||
|
"☼": { "♣": "♠", "♦": "♥" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ filename: "data/iniparser17.ini", reference: { section: { key: "" } } },
|
||||||
];
|
];
|
||||||
|
|
||||||
testdata.push( { filename: "data/iniparser01-utf8BOM.ini",
|
testdata.push({
|
||||||
reference: testdata[0].reference } );
|
filename: "data/iniparser01-utf8BOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser02-utf8BOM.ini",
|
reference: testdata[0].reference,
|
||||||
reference: testdata[1].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser03-utf8BOM.ini",
|
testdata.push({
|
||||||
reference: testdata[2].reference } );
|
filename: "data/iniparser02-utf8BOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser04-utf8BOM.ini",
|
reference: testdata[1].reference,
|
||||||
reference: testdata[3].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser05-utf8BOM.ini",
|
testdata.push({
|
||||||
reference: testdata[4].reference } );
|
filename: "data/iniparser03-utf8BOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser06-utf8BOM.ini",
|
reference: testdata[2].reference,
|
||||||
reference: testdata[5].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser07-utf8BOM.ini",
|
testdata.push({
|
||||||
reference: testdata[6].reference } );
|
filename: "data/iniparser04-utf8BOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser08-utf8BOM.ini",
|
reference: testdata[3].reference,
|
||||||
reference: testdata[7].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser09-utf8BOM.ini",
|
testdata.push({
|
||||||
reference: testdata[8].reference } );
|
filename: "data/iniparser05-utf8BOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser10-utf8BOM.ini",
|
reference: testdata[4].reference,
|
||||||
reference: testdata[9].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser11-utf8BOM.ini",
|
testdata.push({
|
||||||
reference: testdata[10].reference } );
|
filename: "data/iniparser06-utf8BOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser12-utf8BOM.ini",
|
reference: testdata[5].reference,
|
||||||
reference: testdata[11].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser13-utf8BOM.ini",
|
testdata.push({
|
||||||
reference: testdata[12].reference } );
|
filename: "data/iniparser07-utf8BOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser14-utf8BOM.ini",
|
reference: testdata[6].reference,
|
||||||
reference: testdata[13].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser15-utf8BOM.ini",
|
testdata.push({
|
||||||
reference: testdata[14].reference } );
|
filename: "data/iniparser08-utf8BOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser16-utf8BOM.ini",
|
reference: testdata[7].reference,
|
||||||
reference: testdata[15].reference } );
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser09-utf8BOM.ini",
|
||||||
|
reference: testdata[8].reference,
|
||||||
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser10-utf8BOM.ini",
|
||||||
|
reference: testdata[9].reference,
|
||||||
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser11-utf8BOM.ini",
|
||||||
|
reference: testdata[10].reference,
|
||||||
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser12-utf8BOM.ini",
|
||||||
|
reference: testdata[11].reference,
|
||||||
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser13-utf8BOM.ini",
|
||||||
|
reference: testdata[12].reference,
|
||||||
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser14-utf8BOM.ini",
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
|
||||||
// Intentional test for appInfo that can't be preloaded.
|
// Intentional test for appInfo that can't be preloaded.
|
||||||
// eslint-disable-next-line mozilla/use-services
|
// eslint-disable-next-line mozilla/use-services
|
||||||
let os = Cc["@mozilla.org/xre/app-info;1"]
|
let os = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
|
||||||
.getService(Ci.nsIXULRuntime).OS;
|
|
||||||
if ("WINNT" === os) {
|
if ("WINNT" === os) {
|
||||||
testdata.push( { filename: "data/iniparser01-utf16leBOM.ini",
|
testdata.push({
|
||||||
reference: testdata[0].reference } );
|
filename: "data/iniparser01-utf16leBOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser02-utf16leBOM.ini",
|
reference: testdata[0].reference,
|
||||||
reference: testdata[1].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser03-utf16leBOM.ini",
|
testdata.push({
|
||||||
reference: testdata[2].reference } );
|
filename: "data/iniparser02-utf16leBOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser04-utf16leBOM.ini",
|
reference: testdata[1].reference,
|
||||||
reference: testdata[3].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser05-utf16leBOM.ini",
|
testdata.push({
|
||||||
reference: testdata[4].reference } );
|
filename: "data/iniparser03-utf16leBOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser06-utf16leBOM.ini",
|
reference: testdata[2].reference,
|
||||||
reference: testdata[5].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser07-utf16leBOM.ini",
|
testdata.push({
|
||||||
reference: testdata[6].reference } );
|
filename: "data/iniparser04-utf16leBOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser08-utf16leBOM.ini",
|
reference: testdata[3].reference,
|
||||||
reference: testdata[7].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser09-utf16leBOM.ini",
|
testdata.push({
|
||||||
reference: testdata[8].reference } );
|
filename: "data/iniparser05-utf16leBOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser10-utf16leBOM.ini",
|
reference: testdata[4].reference,
|
||||||
reference: testdata[9].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser11-utf16leBOM.ini",
|
testdata.push({
|
||||||
reference: testdata[10].reference } );
|
filename: "data/iniparser06-utf16leBOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser12-utf16leBOM.ini",
|
reference: testdata[5].reference,
|
||||||
reference: testdata[11].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser13-utf16leBOM.ini",
|
testdata.push({
|
||||||
reference: testdata[12].reference } );
|
filename: "data/iniparser07-utf16leBOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser14-utf16leBOM.ini",
|
reference: testdata[6].reference,
|
||||||
reference: testdata[13].reference } );
|
});
|
||||||
testdata.push( { filename: "data/iniparser15-utf16leBOM.ini",
|
testdata.push({
|
||||||
reference: testdata[14].reference } );
|
filename: "data/iniparser08-utf16leBOM.ini",
|
||||||
testdata.push( { filename: "data/iniparser16-utf16leBOM.ini",
|
reference: testdata[7].reference,
|
||||||
reference: testdata[15].reference } );
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser09-utf16leBOM.ini",
|
||||||
|
reference: testdata[8].reference,
|
||||||
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser10-utf16leBOM.ini",
|
||||||
|
reference: testdata[9].reference,
|
||||||
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser11-utf16leBOM.ini",
|
||||||
|
reference: testdata[10].reference,
|
||||||
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser12-utf16leBOM.ini",
|
||||||
|
reference: testdata[11].reference,
|
||||||
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser13-utf16leBOM.ini",
|
||||||
|
reference: testdata[12].reference,
|
||||||
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser14-utf16leBOM.ini",
|
||||||
|
reference: testdata[13].reference,
|
||||||
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser15-utf16leBOM.ini",
|
||||||
|
reference: testdata[14].reference,
|
||||||
|
});
|
||||||
|
testdata.push({
|
||||||
|
filename: "data/iniparser16-utf16leBOM.ini",
|
||||||
|
reference: testdata[15].reference,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========== 0 ========== */
|
/* ========== 0 ========== */
|
||||||
factory = Cc["@mozilla.org/xpcom/ini-parser-factory;1"].
|
factory = Cc["@mozilla.org/xpcom/ini-parser-factory;1"].getService(
|
||||||
getService(Ci.nsIINIParserFactory);
|
Ci.nsIINIParserFactory
|
||||||
Assert.ok(!!factory);
|
);
|
||||||
|
Assert.ok(!!factory);
|
||||||
|
|
||||||
// Test reading from a variety of files. While we're at it, write out each one
|
// 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.
|
// and read it back to ensure that nothing changed.
|
||||||
while (testnum < testdata.length) {
|
while (testnum < testdata.length) {
|
||||||
dump("\nINFO | test #" + ++testnum);
|
dump("\nINFO | test #" + ++testnum);
|
||||||
let filename = testdata[testnum - 1].filename;
|
let filename = testdata[testnum - 1].filename;
|
||||||
dump(", filename " + filename + "\n");
|
dump(", filename " + filename + "\n");
|
||||||
let parser = parserForFile(filename);
|
let parser = parserForFile(filename);
|
||||||
checkParserOutput(parser, testdata[testnum - 1].reference);
|
checkParserOutput(parser, testdata[testnum - 1].reference);
|
||||||
if (!parser)
|
if (!parser) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
Assert.ok(parser instanceof Ci.nsIINIParserWriter);
|
||||||
|
// write contents out to a new file
|
||||||
|
let newfilename = filename + ".new";
|
||||||
|
let newfile = do_get_file(filename);
|
||||||
|
newfile.leafName += ".new";
|
||||||
|
parser.writeFile(newfile);
|
||||||
|
// read new file and make sure the contents are the same.
|
||||||
|
parser = parserForFile(newfilename);
|
||||||
|
checkParserOutput(parser, testdata[testnum - 1].reference);
|
||||||
|
// cleanup after the test
|
||||||
|
newfile.remove(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
dump("INFO | test #" + ++testnum + "\n");
|
||||||
|
|
||||||
|
// test writing to a new file.
|
||||||
|
var newfile = do_get_file("data/");
|
||||||
|
newfile.append("nonexistent-file.ini");
|
||||||
|
if (newfile.exists()) {
|
||||||
|
newfile.remove(false);
|
||||||
|
}
|
||||||
|
Assert.ok(!newfile.exists());
|
||||||
|
|
||||||
|
try {
|
||||||
|
var parser = factory.createINIParser(newfile);
|
||||||
|
Assert.ok(false, "Should have thrown an exception");
|
||||||
|
} catch (e) {
|
||||||
|
Assert.equal(
|
||||||
|
e.result,
|
||||||
|
Cr.NS_ERROR_FILE_NOT_FOUND,
|
||||||
|
"Caught a file not found exception"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
parser = factory.createINIParser();
|
||||||
|
Assert.ok(!!parser);
|
||||||
Assert.ok(parser instanceof Ci.nsIINIParserWriter);
|
Assert.ok(parser instanceof Ci.nsIINIParserWriter);
|
||||||
// write contents out to a new file
|
checkParserOutput(parser, {});
|
||||||
let newfilename = filename + ".new";
|
|
||||||
let newfile = do_get_file(filename);
|
|
||||||
newfile.leafName += ".new";
|
|
||||||
parser.writeFile(newfile);
|
parser.writeFile(newfile);
|
||||||
// read new file and make sure the contents are the same.
|
Assert.ok(newfile.exists());
|
||||||
parser = parserForFile(newfilename);
|
|
||||||
checkParserOutput(parser, testdata[testnum - 1].reference);
|
// test adding a new section and new key
|
||||||
|
parser.setString("section", "key", "value");
|
||||||
|
parser.setString("section", "key2", "");
|
||||||
|
parser.writeFile(newfile);
|
||||||
|
Assert.ok(newfile.exists());
|
||||||
|
checkParserOutput(parser, { section: { key: "value", key2: "" } });
|
||||||
|
// read it in again, check for same data.
|
||||||
|
parser = parserForFile("data/nonexistent-file.ini");
|
||||||
|
checkParserOutput(parser, { section: { key: "value", key2: "" } });
|
||||||
// cleanup after the test
|
// cleanup after the test
|
||||||
newfile.remove(false);
|
newfile.remove(false);
|
||||||
}
|
|
||||||
|
|
||||||
dump("INFO | test #" + ++testnum + "\n");
|
dump("INFO | test #" + ++testnum + "\n");
|
||||||
|
|
||||||
// test writing to a new file.
|
// test modifying a existing key's value (in an existing section)
|
||||||
var newfile = do_get_file("data/");
|
parser = parserForFile("data/iniparser09.ini");
|
||||||
newfile.append("nonexistent-file.ini");
|
checkParserOutput(parser, { section1: { name1: "value1" } });
|
||||||
if (newfile.exists())
|
|
||||||
newfile.remove(false);
|
|
||||||
Assert.ok(!newfile.exists());
|
|
||||||
|
|
||||||
try {
|
Assert.ok(parser instanceof Ci.nsIINIParserWriter);
|
||||||
var parser = factory.createINIParser(newfile);
|
parser.setString("section1", "name1", "value2");
|
||||||
Assert.ok(false, "Should have thrown an exception");
|
checkParserOutput(parser, { section1: { name1: "value2" } });
|
||||||
} catch (e) {
|
|
||||||
Assert.equal(e.result, Cr.NS_ERROR_FILE_NOT_FOUND, "Caught a file not found exception");
|
|
||||||
}
|
|
||||||
parser = factory.createINIParser();
|
|
||||||
Assert.ok(!!parser);
|
|
||||||
Assert.ok(parser instanceof Ci.nsIINIParserWriter);
|
|
||||||
checkParserOutput(parser, {});
|
|
||||||
parser.writeFile(newfile);
|
|
||||||
Assert.ok(newfile.exists());
|
|
||||||
|
|
||||||
// test adding a new section and new key
|
dump("INFO | test #" + ++testnum + "\n");
|
||||||
parser.setString("section", "key", "value");
|
|
||||||
parser.setString("section", "key2", "");
|
|
||||||
parser.writeFile(newfile);
|
|
||||||
Assert.ok(newfile.exists());
|
|
||||||
checkParserOutput(parser, {section: {key: "value", key2: ""} });
|
|
||||||
// read it in again, check for same data.
|
|
||||||
parser = parserForFile("data/nonexistent-file.ini");
|
|
||||||
checkParserOutput(parser, {section: {key: "value", key2: ""} });
|
|
||||||
// cleanup after the test
|
|
||||||
newfile.remove(false);
|
|
||||||
|
|
||||||
dump("INFO | test #" + ++testnum + "\n");
|
// test trying to set illegal characters
|
||||||
|
var caughtError;
|
||||||
|
caughtError = null;
|
||||||
|
checkParserOutput(parser, { section1: { name1: "value2" } });
|
||||||
|
|
||||||
// test modifying a existing key's value (in an existing section)
|
// Bad characters in section name
|
||||||
parser = parserForFile("data/iniparser09.ini");
|
try {
|
||||||
checkParserOutput(parser, {section1: {name1: "value1"} });
|
parser.setString("bad\0", "ok", "ok");
|
||||||
|
} catch (e) {
|
||||||
|
caughtError = e;
|
||||||
|
}
|
||||||
|
Assert.ok(caughtError);
|
||||||
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
|
caughtError = null;
|
||||||
|
try {
|
||||||
|
parser.setString("bad\r", "ok", "ok");
|
||||||
|
} catch (e) {
|
||||||
|
caughtError = e;
|
||||||
|
}
|
||||||
|
Assert.ok(caughtError);
|
||||||
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
|
caughtError = null;
|
||||||
|
try {
|
||||||
|
parser.setString("bad\n", "ok", "ok");
|
||||||
|
} catch (e) {
|
||||||
|
caughtError = e;
|
||||||
|
}
|
||||||
|
Assert.ok(caughtError);
|
||||||
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
|
caughtError = null;
|
||||||
|
try {
|
||||||
|
parser.setString("bad[", "ok", "ok");
|
||||||
|
} catch (e) {
|
||||||
|
caughtError = e;
|
||||||
|
}
|
||||||
|
Assert.ok(caughtError);
|
||||||
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
|
caughtError = null;
|
||||||
|
try {
|
||||||
|
parser.setString("bad]", "ok", "ok");
|
||||||
|
} catch (e) {
|
||||||
|
caughtError = e;
|
||||||
|
}
|
||||||
|
Assert.ok(caughtError);
|
||||||
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
|
caughtError = null;
|
||||||
|
try {
|
||||||
|
parser.setString("", "ok", "ok");
|
||||||
|
} catch (e) {
|
||||||
|
caughtError = e;
|
||||||
|
}
|
||||||
|
Assert.ok(caughtError);
|
||||||
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
|
|
||||||
Assert.ok(parser instanceof Ci.nsIINIParserWriter);
|
// Bad characters in key name
|
||||||
parser.setString("section1", "name1", "value2");
|
caughtError = null;
|
||||||
checkParserOutput(parser, {section1: {name1: "value2"} });
|
try {
|
||||||
|
parser.setString("ok", "bad\0", "ok");
|
||||||
|
} catch (e) {
|
||||||
|
caughtError = e;
|
||||||
|
}
|
||||||
|
Assert.ok(caughtError);
|
||||||
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
|
caughtError = null;
|
||||||
|
try {
|
||||||
|
parser.setString("ok", "bad\r", "ok");
|
||||||
|
} catch (e) {
|
||||||
|
caughtError = e;
|
||||||
|
}
|
||||||
|
Assert.ok(caughtError);
|
||||||
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
|
caughtError = null;
|
||||||
|
try {
|
||||||
|
parser.setString("ok", "bad\n", "ok");
|
||||||
|
} catch (e) {
|
||||||
|
caughtError = e;
|
||||||
|
}
|
||||||
|
Assert.ok(caughtError);
|
||||||
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
|
caughtError = null;
|
||||||
|
try {
|
||||||
|
parser.setString("ok", "bad=", "ok");
|
||||||
|
} catch (e) {
|
||||||
|
caughtError = e;
|
||||||
|
}
|
||||||
|
Assert.ok(caughtError);
|
||||||
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
|
caughtError = null;
|
||||||
|
try {
|
||||||
|
parser.setString("ok", "", "ok");
|
||||||
|
} catch (e) {
|
||||||
|
caughtError = e;
|
||||||
|
}
|
||||||
|
Assert.ok(caughtError);
|
||||||
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
|
|
||||||
dump("INFO | test #" + ++testnum + "\n");
|
// Bad characters in value
|
||||||
|
caughtError = null;
|
||||||
// test trying to set illegal characters
|
try {
|
||||||
var caughtError;
|
parser.setString("ok", "ok", "bad\0");
|
||||||
caughtError = null;
|
} catch (e) {
|
||||||
checkParserOutput(parser, {section1: {name1: "value2"} });
|
caughtError = e;
|
||||||
|
}
|
||||||
// Bad characters in section name
|
Assert.ok(caughtError);
|
||||||
try { parser.setString("bad\0", "ok", "ok"); } catch (e) { caughtError = e; }
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
Assert.ok(caughtError);
|
caughtError = null;
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
try {
|
||||||
caughtError = null;
|
parser.setString("ok", "ok", "bad\r");
|
||||||
try { parser.setString("bad\r", "ok", "ok"); } catch (e) { caughtError = e; }
|
} catch (e) {
|
||||||
Assert.ok(caughtError);
|
caughtError = e;
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
}
|
||||||
caughtError = null;
|
Assert.ok(caughtError);
|
||||||
try { parser.setString("bad\n", "ok", "ok"); } catch (e) { caughtError = e; }
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
Assert.ok(caughtError);
|
caughtError = null;
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
try {
|
||||||
caughtError = null;
|
parser.setString("ok", "ok", "bad\n");
|
||||||
try { parser.setString("bad[", "ok", "ok"); } catch (e) { caughtError = e; }
|
} catch (e) {
|
||||||
Assert.ok(caughtError);
|
caughtError = e;
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
}
|
||||||
caughtError = null;
|
Assert.ok(caughtError);
|
||||||
try { parser.setString("bad]", "ok", "ok"); } catch (e) { caughtError = e; }
|
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
||||||
Assert.ok(caughtError);
|
caughtError = null;
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
try {
|
||||||
caughtError = null;
|
parser.setString("ok", "ok", "good=");
|
||||||
try { parser.setString("", "ok", "ok"); } catch (e) { caughtError = e; }
|
} catch (e) {
|
||||||
Assert.ok(caughtError);
|
caughtError = e;
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
}
|
||||||
|
Assert.ok(!caughtError);
|
||||||
// Bad characters in key name
|
caughtError = null;
|
||||||
caughtError = null;
|
} catch (e) {
|
||||||
try { parser.setString("ok", "bad\0", "ok"); } catch (e) { caughtError = e; }
|
|
||||||
Assert.ok(caughtError);
|
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
|
||||||
caughtError = null;
|
|
||||||
try { parser.setString("ok", "bad\r", "ok"); } catch (e) { caughtError = e; }
|
|
||||||
Assert.ok(caughtError);
|
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
|
||||||
caughtError = null;
|
|
||||||
try { parser.setString("ok", "bad\n", "ok"); } catch (e) { caughtError = e; }
|
|
||||||
Assert.ok(caughtError);
|
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
|
||||||
caughtError = null;
|
|
||||||
try { parser.setString("ok", "bad=", "ok"); } catch (e) { caughtError = e; }
|
|
||||||
Assert.ok(caughtError);
|
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
|
||||||
caughtError = null;
|
|
||||||
try { parser.setString("ok", "", "ok"); } catch (e) { caughtError = e; }
|
|
||||||
Assert.ok(caughtError);
|
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
|
||||||
|
|
||||||
// Bad characters in value
|
|
||||||
caughtError = null;
|
|
||||||
try { parser.setString("ok", "ok", "bad\0"); } catch (e) { caughtError = e; }
|
|
||||||
Assert.ok(caughtError);
|
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
|
||||||
caughtError = null;
|
|
||||||
try { parser.setString("ok", "ok", "bad\r"); } catch (e) { caughtError = e; }
|
|
||||||
Assert.ok(caughtError);
|
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
|
||||||
caughtError = null;
|
|
||||||
try { parser.setString("ok", "ok", "bad\n"); } catch (e) { caughtError = e; }
|
|
||||||
Assert.ok(caughtError);
|
|
||||||
Assert.equal(caughtError.result, Cr.NS_ERROR_INVALID_ARG);
|
|
||||||
caughtError = null;
|
|
||||||
try { parser.setString("ok", "ok", "good="); } catch (e) { caughtError = e; }
|
|
||||||
Assert.ok(!caughtError);
|
|
||||||
caughtError = null;
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error(`FAILED in test #${testnum} -- ${e}`);
|
throw new Error(`FAILED in test #${testnum} -- ${e}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,23 +6,24 @@
|
||||||
const util = Cc["@mozilla.org/io-util;1"].getService(Ci.nsIIOUtil);
|
const util = Cc["@mozilla.org/io-util;1"].getService(Ci.nsIIOUtil);
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
try {
|
try {
|
||||||
util.inputStreamIsBuffered(null);
|
util.inputStreamIsBuffered(null);
|
||||||
do_throw("inputStreamIsBuffered should have thrown");
|
do_throw("inputStreamIsBuffered should have thrown");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Assert.equal(e.result, Cr.NS_ERROR_INVALID_POINTER);
|
Assert.equal(e.result, Cr.NS_ERROR_INVALID_POINTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
util.outputStreamIsBuffered(null);
|
util.outputStreamIsBuffered(null);
|
||||||
do_throw("outputStreamIsBuffered should have thrown");
|
do_throw("outputStreamIsBuffered should have thrown");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Assert.equal(e.result, Cr.NS_ERROR_INVALID_POINTER);
|
Assert.equal(e.result, Cr.NS_ERROR_INVALID_POINTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
var s = Cc["@mozilla.org/io/string-input-stream;1"]
|
var s = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIStringInputStream);
|
Ci.nsIStringInputStream
|
||||||
var body = "This is a test";
|
);
|
||||||
s.setData(body, body.length);
|
var body = "This is a test";
|
||||||
Assert.equal(util.inputStreamIsBuffered(s), true);
|
s.setData(body, body.length);
|
||||||
|
Assert.equal(util.inputStreamIsBuffered(s), true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
const MAX_TIME_DIFFERENCE = 2500;
|
const MAX_TIME_DIFFERENCE = 2500;
|
||||||
const MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
|
const MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
|
||||||
|
|
||||||
var LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
|
var LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
|
||||||
|
|
||||||
|
|
@ -38,8 +38,7 @@ function test_normalize_crash_if_media_missing() {
|
||||||
for (var i = a; i <= z; ++i) {
|
for (var i = a; i <= z; ++i) {
|
||||||
try {
|
try {
|
||||||
LocalFile(String.fromCharCode(i) + ":.\\test").normalize();
|
LocalFile(String.fromCharCode(i) + ":.\\test").normalize();
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,8 +48,9 @@ function test_file_modification_time() {
|
||||||
file.append("testfile");
|
file.append("testfile");
|
||||||
|
|
||||||
// Should never happen but get rid of it anyway
|
// Should never happen but get rid of it anyway
|
||||||
if (file.exists())
|
if (file.exists()) {
|
||||||
file.remove(true);
|
file.remove(true);
|
||||||
|
}
|
||||||
|
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
file.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
|
file.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
|
||||||
|
|
@ -88,8 +88,9 @@ function test_directory_modification_time() {
|
||||||
dir.append("testdir");
|
dir.append("testdir");
|
||||||
|
|
||||||
// Should never happen but get rid of it anyway
|
// Should never happen but get rid of it anyway
|
||||||
if (dir.exists())
|
if (dir.exists()) {
|
||||||
dir.remove(true);
|
dir.remove(true);
|
||||||
|
}
|
||||||
|
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
dir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
|
dir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
|
||||||
|
|
@ -123,8 +124,9 @@ function test_diskSpaceAvailable() {
|
||||||
Assert.ok(bytes > 0);
|
Assert.ok(bytes > 0);
|
||||||
|
|
||||||
file.append("testfile");
|
file.append("testfile");
|
||||||
if (file.exists())
|
if (file.exists()) {
|
||||||
file.remove(true);
|
file.remove(true);
|
||||||
|
}
|
||||||
file.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
|
file.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
|
||||||
|
|
||||||
bytes = file.diskSpaceAvailable;
|
bytes = file.diskSpaceAvailable;
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,10 @@ function run_test() {
|
||||||
let method1Called = false;
|
let method1Called = false;
|
||||||
|
|
||||||
let testObject = {
|
let testObject = {
|
||||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIScriptableOK,
|
QueryInterface: ChromeUtils.generateQI([
|
||||||
Ci.nsIScriptableWithNotXPCOM]),
|
Ci.nsIScriptableOK,
|
||||||
|
Ci.nsIScriptableWithNotXPCOM,
|
||||||
|
]),
|
||||||
|
|
||||||
method1() {
|
method1() {
|
||||||
method1Called = true;
|
method1Called = true;
|
||||||
|
|
@ -58,7 +60,11 @@ function run_test() {
|
||||||
xpcomObject.QueryInterface(Ci.nsIScriptableWithNotXPCOM);
|
xpcomObject.QueryInterface(Ci.nsIScriptableWithNotXPCOM);
|
||||||
ok(false, "Should not have implemented nsIScriptableWithNotXPCOM");
|
ok(false, "Should not have implemented nsIScriptableWithNotXPCOM");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ok(true, "Should not have implemented nsIScriptableWithNotXPCOM. Correctly threw error: " + e);
|
ok(
|
||||||
|
true,
|
||||||
|
"Should not have implemented nsIScriptableWithNotXPCOM. Correctly threw error: " +
|
||||||
|
e
|
||||||
|
);
|
||||||
}
|
}
|
||||||
strictEqual(xpcomObject.method2, undefined);
|
strictEqual(xpcomObject.method2, undefined);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,7 @@ var tests = [
|
||||||
];
|
];
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
for (var i = 0; i < tests.length; i++)
|
for (var i = 0; i < tests.length; i++) {
|
||||||
tests[i]();
|
tests[i]();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,30 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
// nsIProcess unit test
|
// nsIProcess unit test
|
||||||
const TEST_ARGS = ["mozilla", "firefox", "thunderbird", "seamonkey", "foo",
|
const TEST_ARGS = [
|
||||||
"bar", "argument with spaces", "\"argument with quotes\""];
|
"mozilla",
|
||||||
|
"firefox",
|
||||||
|
"thunderbird",
|
||||||
|
"seamonkey",
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"argument with spaces",
|
||||||
|
'"argument with quotes"',
|
||||||
|
];
|
||||||
|
|
||||||
const TEST_UNICODE_ARGS = ["M\u00F8z\u00EEll\u00E5",
|
const TEST_UNICODE_ARGS = [
|
||||||
"\u041C\u043E\u0437\u0438\u043B\u043B\u0430",
|
"M\u00F8z\u00EEll\u00E5",
|
||||||
"\u09AE\u09CB\u099C\u09BF\u09B2\u09BE",
|
"\u041C\u043E\u0437\u0438\u043B\u043B\u0430",
|
||||||
"\uD808\uDE2C\uD808\uDF63\uD808\uDDB7"];
|
"\u09AE\u09CB\u099C\u09BF\u09B2\u09BE",
|
||||||
|
"\uD808\uDE2C\uD808\uDF63\uD808\uDDB7",
|
||||||
|
];
|
||||||
|
|
||||||
// test if a process can be started, polled for its running status
|
// test if a process can be started, polled for its running status
|
||||||
// and then killed
|
// and then killed
|
||||||
function test_kill() {
|
function test_kill() {
|
||||||
var file = get_test_program("TestBlockingProcess");
|
var file = get_test_program("TestBlockingProcess");
|
||||||
|
|
||||||
var process = Cc["@mozilla.org/process/util;1"]
|
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
|
||||||
.createInstance(Ci.nsIProcess);
|
|
||||||
process.init(file);
|
process.init(file);
|
||||||
|
|
||||||
Assert.ok(!process.isRunning);
|
Assert.ok(!process.isRunning);
|
||||||
|
|
@ -24,7 +33,7 @@ function test_kill() {
|
||||||
try {
|
try {
|
||||||
process.kill();
|
process.kill();
|
||||||
do_throw("Attempting to kill a not-running process should throw");
|
do_throw("Attempting to kill a not-running process should throw");
|
||||||
} catch (e) { }
|
} catch (e) {}
|
||||||
|
|
||||||
process.run(false, [], 0);
|
process.run(false, [], 0);
|
||||||
|
|
||||||
|
|
@ -37,7 +46,7 @@ function test_kill() {
|
||||||
try {
|
try {
|
||||||
process.kill();
|
process.kill();
|
||||||
do_throw("Attempting to kill a not-running process should throw");
|
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
|
// test if we can get an exit value from an application that is
|
||||||
|
|
@ -45,8 +54,7 @@ function test_kill() {
|
||||||
function test_quick() {
|
function test_quick() {
|
||||||
var file = get_test_program("TestQuickReturn");
|
var file = get_test_program("TestQuickReturn");
|
||||||
|
|
||||||
var process = Cc["@mozilla.org/process/util;1"]
|
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
|
||||||
.createInstance(Ci.nsIProcess);
|
|
||||||
process.init(file);
|
process.init(file);
|
||||||
|
|
||||||
// to get an exit value it must be a blocking process
|
// to get an exit value it must be a blocking process
|
||||||
|
|
@ -56,14 +64,14 @@ function test_quick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_args(file, args, argsAreASCII) {
|
function test_args(file, args, argsAreASCII) {
|
||||||
var process = Cc["@mozilla.org/process/util;1"]
|
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
|
||||||
.createInstance(Ci.nsIProcess);
|
|
||||||
process.init(file);
|
process.init(file);
|
||||||
|
|
||||||
if (argsAreASCII)
|
if (argsAreASCII) {
|
||||||
process.run(true, args, args.length);
|
process.run(true, args, args.length);
|
||||||
else
|
} else {
|
||||||
process.runw(true, args, args.length);
|
process.runw(true, args, args.length);
|
||||||
|
}
|
||||||
|
|
||||||
Assert.equal(process.exitValue, 0);
|
Assert.equal(process.exitValue, 0);
|
||||||
}
|
}
|
||||||
|
|
@ -95,23 +103,28 @@ function rename_and_test(asciiName, unicodeName, args, argsAreASCII) {
|
||||||
|
|
||||||
// test passing ASCII and Unicode arguments to an application with a Unicode name
|
// 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",
|
rename_and_test(
|
||||||
// "Unicode" in Tamil
|
"TestArguments",
|
||||||
"\u0BAF\u0BC1\u0BA9\u0BBF\u0B95\u0BCB\u0B9F\u0BCD",
|
// "Unicode" in Tamil
|
||||||
TEST_ARGS, true);
|
"\u0BAF\u0BC1\u0BA9\u0BBF\u0B95\u0BCB\u0B9F\u0BCD",
|
||||||
|
TEST_ARGS,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
rename_and_test("TestUnicodeArguments",
|
rename_and_test(
|
||||||
// "Unicode" in Thai
|
"TestUnicodeArguments",
|
||||||
"\u0E22\u0E39\u0E19\u0E34\u0E42\u0E04\u0E14",
|
// "Unicode" in Thai
|
||||||
TEST_UNICODE_ARGS, false);
|
"\u0E22\u0E39\u0E19\u0E34\u0E42\u0E04\u0E14",
|
||||||
|
TEST_UNICODE_ARGS,
|
||||||
|
false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test if we get notified about a blocking process
|
// test if we get notified about a blocking process
|
||||||
function test_notify_blocking() {
|
function test_notify_blocking() {
|
||||||
var file = get_test_program("TestQuickReturn");
|
var file = get_test_program("TestQuickReturn");
|
||||||
|
|
||||||
var process = Cc["@mozilla.org/process/util;1"]
|
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
|
||||||
.createInstance(Ci.nsIProcess);
|
|
||||||
process.init(file);
|
process.init(file);
|
||||||
|
|
||||||
process.runAsync([], 0, {
|
process.runAsync([], 0, {
|
||||||
|
|
@ -128,8 +141,7 @@ function test_notify_blocking() {
|
||||||
function test_notify_nonblocking() {
|
function test_notify_nonblocking() {
|
||||||
var file = get_test_program("TestArguments");
|
var file = get_test_program("TestArguments");
|
||||||
|
|
||||||
var process = Cc["@mozilla.org/process/util;1"]
|
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
|
||||||
.createInstance(Ci.nsIProcess);
|
|
||||||
process.init(file);
|
process.init(file);
|
||||||
|
|
||||||
process.runAsync(TEST_ARGS, TEST_ARGS.length, {
|
process.runAsync(TEST_ARGS, TEST_ARGS.length, {
|
||||||
|
|
@ -146,8 +158,7 @@ function test_notify_nonblocking() {
|
||||||
function test_notify_killed() {
|
function test_notify_killed() {
|
||||||
var file = get_test_program("TestBlockingProcess");
|
var file = get_test_program("TestBlockingProcess");
|
||||||
|
|
||||||
var process = Cc["@mozilla.org/process/util;1"]
|
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
|
||||||
.createInstance(Ci.nsIProcess);
|
|
||||||
process.init(file);
|
process.init(file);
|
||||||
|
|
||||||
process.runAsync([], 0, {
|
process.runAsync([], 0, {
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,19 @@ function run_test() {
|
||||||
set_process_running_environment();
|
set_process_running_environment();
|
||||||
|
|
||||||
var file = get_test_program("TestQuickReturn");
|
var file = get_test_program("TestQuickReturn");
|
||||||
var tm = Cc["@mozilla.org/thread-manager;1"]
|
var tm = Cc["@mozilla.org/thread-manager;1"].getService();
|
||||||
.getService();
|
|
||||||
|
|
||||||
for (var i = 0; i < 1000; i++) {
|
for (var i = 0; i < 1000; i++) {
|
||||||
var process = Cc["@mozilla.org/process/util;1"]
|
var process = Cc["@mozilla.org/process/util;1"].createInstance(
|
||||||
.createInstance(Ci.nsIProcess);
|
Ci.nsIProcess
|
||||||
|
);
|
||||||
process.init(file);
|
process.init(file);
|
||||||
|
|
||||||
process.run(false, [], 0);
|
process.run(false, [], 0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
process.kill();
|
process.kill();
|
||||||
} catch (e) { }
|
} catch (e) {}
|
||||||
|
|
||||||
// We need to ensure that we process any events on the main thread -
|
// 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
|
// this allow threads to clean up properly and avoid out of memory
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,17 @@ function run_test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_not_initialized() {
|
function test_not_initialized() {
|
||||||
var p = Cc["@mozilla.org/pipe;1"]
|
var p = Cc["@mozilla.org/pipe;1"].createInstance(Ci.nsIPipe);
|
||||||
.createInstance(Ci.nsIPipe);
|
|
||||||
try {
|
try {
|
||||||
var dummy = p.outputStream;
|
var dummy = p.outputStream;
|
||||||
dump("dummy: " + dummy + "\n");
|
dump("dummy: " + dummy + "\n");
|
||||||
throw Cr.NS_ERROR_FAILURE;
|
throw Cr.NS_ERROR_FAILURE;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.result != Cr.NS_ERROR_NOT_INITIALIZED)
|
if (e.result != Cr.NS_ERROR_NOT_INITIALIZED) {
|
||||||
do_throw("using a pipe before initializing it should throw NS_ERROR_NOT_INITIALIZED");
|
do_throw(
|
||||||
|
"using a pipe before initializing it should throw NS_ERROR_NOT_INITIALIZED"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,34 @@
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
Components.manager.autoRegister(do_get_file("data/process_directive.manifest"));
|
Components.manager.autoRegister(
|
||||||
|
do_get_file("data/process_directive.manifest")
|
||||||
|
);
|
||||||
|
|
||||||
let isChild = Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT;
|
let isChild =
|
||||||
|
Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT;
|
||||||
|
|
||||||
if (isChild) {
|
if (isChild) {
|
||||||
Assert.equal(false, "@mozilla.org/xpcom/tests/MainProcessDirectiveTest;1" in Cc);
|
Assert.equal(
|
||||||
|
false,
|
||||||
|
"@mozilla.org/xpcom/tests/MainProcessDirectiveTest;1" in Cc
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
let svc = Cc["@mozilla.org/xpcom/tests/MainProcessDirectiveTest;1"].createInstance(Ci.nsIProperty);
|
let svc = Cc[
|
||||||
|
"@mozilla.org/xpcom/tests/MainProcessDirectiveTest;1"
|
||||||
|
].createInstance(Ci.nsIProperty);
|
||||||
Assert.equal(svc.name, "main process");
|
Assert.equal(svc.name, "main process");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isChild) {
|
if (!isChild) {
|
||||||
Assert.equal(false, "@mozilla.org/xpcom/tests/ChildProcessDirectiveTest;1" in Cc);
|
Assert.equal(
|
||||||
|
false,
|
||||||
|
"@mozilla.org/xpcom/tests/ChildProcessDirectiveTest;1" in Cc
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
let svc = Cc["@mozilla.org/xpcom/tests/ChildProcessDirectiveTest;1"].createInstance(Ci.nsIProperty);
|
let svc = Cc[
|
||||||
|
"@mozilla.org/xpcom/tests/ChildProcessDirectiveTest;1"
|
||||||
|
].createInstance(Ci.nsIProperty);
|
||||||
Assert.equal(svc.name, "child process");
|
Assert.equal(svc.name, "child process");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,21 +8,25 @@ const data = "0123456789";
|
||||||
const count = 10;
|
const count = 10;
|
||||||
|
|
||||||
function test_multiplex_streams() {
|
function test_multiplex_streams() {
|
||||||
var MultiplexStream = CC("@mozilla.org/io/multiplex-input-stream;1",
|
var MultiplexStream = CC(
|
||||||
"nsIMultiplexInputStream");
|
"@mozilla.org/io/multiplex-input-stream;1",
|
||||||
|
"nsIMultiplexInputStream"
|
||||||
|
);
|
||||||
Assert.equal(1, 1);
|
Assert.equal(1, 1);
|
||||||
|
|
||||||
var multiplex = new MultiplexStream();
|
var multiplex = new MultiplexStream();
|
||||||
for (var i = 0; i < count; ++i) {
|
for (var i = 0; i < count; ++i) {
|
||||||
let s = Cc["@mozilla.org/io/string-input-stream;1"]
|
let s = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIStringInputStream);
|
Ci.nsIStringInputStream
|
||||||
|
);
|
||||||
s.setData(data, data.length);
|
s.setData(data, data.length);
|
||||||
|
|
||||||
multiplex.appendStream(s);
|
multiplex.appendStream(s);
|
||||||
}
|
}
|
||||||
var seekable = multiplex.QueryInterface(Ci.nsISeekableStream);
|
var seekable = multiplex.QueryInterface(Ci.nsISeekableStream);
|
||||||
var sis = Cc["@mozilla.org/scriptableinputstream;1"]
|
var sis = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIScriptableInputStream);
|
Ci.nsIScriptableInputStream
|
||||||
|
);
|
||||||
sis.init(seekable);
|
sis.init(seekable);
|
||||||
// Read some data.
|
// Read some data.
|
||||||
var readData = sis.read(20);
|
var readData = sis.read(20);
|
||||||
|
|
@ -125,20 +129,24 @@ function test_multiplex_streams() {
|
||||||
function test_multiplex_bug797871() {
|
function test_multiplex_bug797871() {
|
||||||
var data2 = "1234567890123456789012345678901234567890";
|
var data2 = "1234567890123456789012345678901234567890";
|
||||||
|
|
||||||
var MultiplexStream = CC("@mozilla.org/io/multiplex-input-stream;1",
|
var MultiplexStream = CC(
|
||||||
"nsIMultiplexInputStream");
|
"@mozilla.org/io/multiplex-input-stream;1",
|
||||||
|
"nsIMultiplexInputStream"
|
||||||
|
);
|
||||||
Assert.equal(1, 1);
|
Assert.equal(1, 1);
|
||||||
|
|
||||||
var multiplex = new MultiplexStream();
|
var multiplex = new MultiplexStream();
|
||||||
let s = Cc["@mozilla.org/io/string-input-stream;1"]
|
let s = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIStringInputStream);
|
Ci.nsIStringInputStream
|
||||||
|
);
|
||||||
s.setData(data2, data2.length);
|
s.setData(data2, data2.length);
|
||||||
|
|
||||||
multiplex.appendStream(s);
|
multiplex.appendStream(s);
|
||||||
|
|
||||||
var seekable = multiplex.QueryInterface(Ci.nsISeekableStream);
|
var seekable = multiplex.QueryInterface(Ci.nsISeekableStream);
|
||||||
var sis = Cc["@mozilla.org/scriptableinputstream;1"]
|
var sis = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIScriptableInputStream);
|
Ci.nsIScriptableInputStream
|
||||||
|
);
|
||||||
sis.init(seekable);
|
sis.init(seekable);
|
||||||
|
|
||||||
seekable.seek(Ci.nsISeekableStream.NS_SEEK_SET, 8);
|
seekable.seek(Ci.nsISeekableStream.NS_SEEK_SET, 8);
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,9 @@ function run_test() {
|
||||||
* anything written to it throws a not-initialized exception.
|
* anything written to it throws a not-initialized exception.
|
||||||
*/
|
*/
|
||||||
function test1() {
|
function test1() {
|
||||||
var ss = Cc["@mozilla.org/storagestream;1"]
|
var ss = Cc["@mozilla.org/storagestream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIStorageStream);
|
Ci.nsIStorageStream
|
||||||
|
);
|
||||||
ss.init(1024, 1024, null);
|
ss.init(1024, 1024, null);
|
||||||
|
|
||||||
var unusedVariable = ss.getOutputStream(0);
|
var unusedVariable = ss.getOutputStream(0);
|
||||||
|
|
@ -27,9 +28,9 @@ function test1() {
|
||||||
Assert.equal(inp2.available(), 0);
|
Assert.equal(inp2.available(), 0);
|
||||||
Assert.ok(inp2.isNonBlocking());
|
Assert.ok(inp2.isNonBlocking());
|
||||||
|
|
||||||
var sis =
|
var sis = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(
|
||||||
Cc["@mozilla.org/scriptableinputstream;1"]
|
Ci.nsIScriptableInputStream
|
||||||
.createInstance(Ci.nsIScriptableInputStream);
|
);
|
||||||
sis.init(inp2);
|
sis.init(inp2);
|
||||||
|
|
||||||
var threw = false;
|
var threw = false;
|
||||||
|
|
@ -50,8 +51,9 @@ function test1() {
|
||||||
* data have been explicitly written doesn't throw an exception.
|
* data have been explicitly written doesn't throw an exception.
|
||||||
*/
|
*/
|
||||||
function test2() {
|
function test2() {
|
||||||
var ss = Cc["@mozilla.org/storagestream;1"]
|
var ss = Cc["@mozilla.org/storagestream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIStorageStream);
|
Ci.nsIStorageStream
|
||||||
|
);
|
||||||
ss.init(1024, 1024, null);
|
ss.init(1024, 1024, null);
|
||||||
|
|
||||||
var out = ss.getOutputStream(0);
|
var out = ss.getOutputStream(0);
|
||||||
|
|
@ -68,8 +70,9 @@ function test2() {
|
||||||
* which has had 0 bytes written to it explicitly works correctly.
|
* which has had 0 bytes written to it explicitly works correctly.
|
||||||
*/
|
*/
|
||||||
function test3() {
|
function test3() {
|
||||||
var ss = Cc["@mozilla.org/storagestream;1"]
|
var ss = Cc["@mozilla.org/storagestream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIStorageStream);
|
Ci.nsIStorageStream
|
||||||
|
);
|
||||||
ss.init(1024, 1024, null);
|
ss.init(1024, 1024, null);
|
||||||
|
|
||||||
var out = ss.getOutputStream(0);
|
var out = ss.getOutputStream(0);
|
||||||
|
|
@ -87,12 +90,12 @@ function test3() {
|
||||||
var bis = BIS(inp);
|
var bis = BIS(inp);
|
||||||
bis.readByteArray(5);
|
bis.readByteArray(5);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.result != Cr.NS_BASE_STREAM_WOULD_BLOCK)
|
if (e.result != Cr.NS_BASE_STREAM_WOULD_BLOCK) {
|
||||||
do_throw("wrong error thrown: " + e);
|
do_throw("wrong error thrown: " + e);
|
||||||
|
}
|
||||||
threw = true;
|
threw = true;
|
||||||
}
|
}
|
||||||
Assert.ok(threw,
|
Assert.ok(threw, "should have thrown (nsStorageInputStream is nonblocking)");
|
||||||
"should have thrown (nsStorageInputStream is nonblocking)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -102,14 +105,16 @@ function test3() {
|
||||||
function test4() {
|
function test4() {
|
||||||
var bytes = [65, 66, 67, 68, 69, 70, 71, 72, 73, 74];
|
var bytes = [65, 66, 67, 68, 69, 70, 71, 72, 73, 74];
|
||||||
|
|
||||||
var ss = Cc["@mozilla.org/storagestream;1"]
|
var ss = Cc["@mozilla.org/storagestream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIStorageStream);
|
Ci.nsIStorageStream
|
||||||
|
);
|
||||||
ss.init(1024, 1024, null);
|
ss.init(1024, 1024, null);
|
||||||
|
|
||||||
var outStream = ss.getOutputStream(0);
|
var outStream = ss.getOutputStream(0);
|
||||||
|
|
||||||
var bos = Cc["@mozilla.org/binaryoutputstream;1"]
|
var bos = Cc["@mozilla.org/binaryoutputstream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIBinaryOutputStream);
|
Ci.nsIBinaryOutputStream
|
||||||
|
);
|
||||||
bos.setOutputStream(outStream);
|
bos.setOutputStream(outStream);
|
||||||
|
|
||||||
bos.writeByteArray(bytes, bytes.length);
|
bos.writeByteArray(bytes, bytes.length);
|
||||||
|
|
@ -128,18 +133,20 @@ function test4() {
|
||||||
try {
|
try {
|
||||||
data = bis.read8(1);
|
data = bis.read8(1);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.result != Cr.NS_ERROR_FAILURE)
|
if (e.result != Cr.NS_ERROR_FAILURE) {
|
||||||
do_throw("wrong error thrown: " + e);
|
do_throw("wrong error thrown: " + e);
|
||||||
|
}
|
||||||
threw = true;
|
threw = true;
|
||||||
}
|
}
|
||||||
if (!threw)
|
if (!threw) {
|
||||||
do_throw("should have thrown but instead returned: '" + data + "'");
|
do_throw("should have thrown but instead returned: '" + data + "'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function BIS(input) {
|
function BIS(input) {
|
||||||
var bis = Cc["@mozilla.org/binaryinputstream;1"]
|
var bis = Cc["@mozilla.org/binaryinputstream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIBinaryInputStream);
|
Ci.nsIBinaryInputStream
|
||||||
|
);
|
||||||
bis.setInputStream(input);
|
bis.setInputStream(input);
|
||||||
return bis;
|
return bis;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,17 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
var Pipe = CC("@mozilla.org/pipe;1",
|
var Pipe = CC("@mozilla.org/pipe;1", "nsIPipe", "init");
|
||||||
"nsIPipe",
|
var BinaryOutput = CC(
|
||||||
"init");
|
"@mozilla.org/binaryoutputstream;1",
|
||||||
var BinaryOutput = CC("@mozilla.org/binaryoutputstream;1",
|
"nsIBinaryOutputStream",
|
||||||
"nsIBinaryOutputStream",
|
"setOutputStream"
|
||||||
"setOutputStream");
|
);
|
||||||
var BinaryInput = CC("@mozilla.org/binaryinputstream;1",
|
var BinaryInput = CC(
|
||||||
"nsIBinaryInputStream",
|
"@mozilla.org/binaryinputstream;1",
|
||||||
"setInputStream");
|
"nsIBinaryInputStream",
|
||||||
|
"setInputStream"
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binary stream tests.
|
* Binary stream tests.
|
||||||
|
|
@ -25,7 +27,9 @@ function test_binary_streams() {
|
||||||
const LargeNum = Math.pow(2, 18) + Math.pow(2, 12) + 1;
|
const LargeNum = Math.pow(2, 18) + Math.pow(2, 12) + 1;
|
||||||
const HugeNum = Math.pow(2, 62);
|
const HugeNum = Math.pow(2, 62);
|
||||||
const HelloStr = "Hello World";
|
const HelloStr = "Hello World";
|
||||||
const HelloArray = Array.from(HelloStr, function(c) { return c.charCodeAt(0); });
|
const HelloArray = Array.from(HelloStr, function(c) {
|
||||||
|
return c.charCodeAt(0);
|
||||||
|
});
|
||||||
var countObj = {};
|
var countObj = {};
|
||||||
var msg = {};
|
var msg = {};
|
||||||
var buffer = new ArrayBuffer(HelloArray.length);
|
var buffer = new ArrayBuffer(HelloArray.length);
|
||||||
|
|
@ -51,8 +55,8 @@ function test_binary_streams() {
|
||||||
Assert.equal(is.read64(), HugeNum);
|
Assert.equal(is.read64(), HugeNum);
|
||||||
os.writeFloat(2.5);
|
os.writeFloat(2.5);
|
||||||
Assert.equal(is.readFloat(), 2.5);
|
Assert.equal(is.readFloat(), 2.5);
|
||||||
// os.writeDouble(Math.SQRT2);
|
// os.writeDouble(Math.SQRT2);
|
||||||
// do_check_eq(is.readDouble(), Math.SQRT2);
|
// do_check_eq(is.readDouble(), Math.SQRT2);
|
||||||
os.writeStringZ("Mozilla");
|
os.writeStringZ("Mozilla");
|
||||||
Assert.equal(is.readCString(), "Mozilla");
|
Assert.equal(is.readCString(), "Mozilla");
|
||||||
os.writeWStringZ("Gecko");
|
os.writeWStringZ("Gecko");
|
||||||
|
|
@ -70,8 +74,11 @@ function test_binary_streams() {
|
||||||
Assert.equal(msg.toSource(), HelloArray.toSource());
|
Assert.equal(msg.toSource(), HelloArray.toSource());
|
||||||
Assert.equal(is.available(), 0);
|
Assert.equal(is.available(), 0);
|
||||||
os.writeByteArray(HelloArray, HelloArray.length);
|
os.writeByteArray(HelloArray, HelloArray.length);
|
||||||
Assert.equal(is.readArrayBuffer(buffer.byteLength, buffer), HelloArray.length);
|
Assert.equal(
|
||||||
Assert.equal([...(new Uint8Array(buffer))].toSource(), HelloArray.toSource());
|
is.readArrayBuffer(buffer.byteLength, buffer),
|
||||||
|
HelloArray.length
|
||||||
|
);
|
||||||
|
Assert.equal([...new Uint8Array(buffer)].toSource(), HelloArray.toSource());
|
||||||
Assert.equal(is.available(), 0);
|
Assert.equal(is.available(), 0);
|
||||||
|
|
||||||
// Test writing in one big chunk.
|
// Test writing in one big chunk.
|
||||||
|
|
@ -85,7 +92,7 @@ function test_binary_streams() {
|
||||||
os.write64(1024);
|
os.write64(1024);
|
||||||
os.write64(HugeNum);
|
os.write64(HugeNum);
|
||||||
os.writeFloat(2.5);
|
os.writeFloat(2.5);
|
||||||
// os.writeDouble(Math.SQRT2);
|
// os.writeDouble(Math.SQRT2);
|
||||||
os.writeStringZ("Mozilla");
|
os.writeStringZ("Mozilla");
|
||||||
os.writeWStringZ("Gecko");
|
os.writeWStringZ("Gecko");
|
||||||
os.writeBytes(HelloStr, HelloStr.length);
|
os.writeBytes(HelloStr, HelloStr.length);
|
||||||
|
|
@ -104,7 +111,7 @@ function test_binary_streams() {
|
||||||
Assert.equal(is.read64(), 1024);
|
Assert.equal(is.read64(), 1024);
|
||||||
Assert.equal(is.read64(), HugeNum);
|
Assert.equal(is.read64(), HugeNum);
|
||||||
Assert.equal(is.readFloat(), 2.5);
|
Assert.equal(is.readFloat(), 2.5);
|
||||||
// do_check_eq(is.readDouble(), Math.SQRT2);
|
// do_check_eq(is.readDouble(), Math.SQRT2);
|
||||||
Assert.equal(is.readCString(), "Mozilla");
|
Assert.equal(is.readCString(), "Mozilla");
|
||||||
Assert.equal(is.readString(), "Gecko");
|
Assert.equal(is.readString(), "Gecko");
|
||||||
// Remember, we wrote HelloStr twice - once as a string, and then as an array.
|
// Remember, we wrote HelloStr twice - once as a string, and then as an array.
|
||||||
|
|
@ -127,8 +134,9 @@ function test_binary_streams() {
|
||||||
os.writeBoolean(false);
|
os.writeBoolean(false);
|
||||||
do_throw("Not reached!");
|
do_throw("Not reached!");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!(e instanceof Ci.nsIException &&
|
if (
|
||||||
e.result == Cr.NS_BASE_STREAM_CLOSED)) {
|
!(e instanceof Ci.nsIException && e.result == Cr.NS_BASE_STREAM_CLOSED)
|
||||||
|
) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
@ -138,8 +146,9 @@ function test_binary_streams() {
|
||||||
is.available();
|
is.available();
|
||||||
do_throw("Not reached!");
|
do_throw("Not reached!");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!(e instanceof Ci.nsIException &&
|
if (
|
||||||
e.result == Cr.NS_BASE_STREAM_CLOSED)) {
|
!(e instanceof Ci.nsIException && e.result == Cr.NS_BASE_STREAM_CLOSED)
|
||||||
|
) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
@ -149,8 +158,7 @@ function test_binary_streams() {
|
||||||
is.readBoolean();
|
is.readBoolean();
|
||||||
do_throw("Not reached!");
|
do_throw("Not reached!");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!(e instanceof Ci.nsIException &&
|
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
|
||||||
e.result == Cr.NS_ERROR_FAILURE)) {
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,17 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
var s = Cc["@mozilla.org/io/string-input-stream;1"]
|
var s = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIStringInputStream);
|
Ci.nsIStringInputStream
|
||||||
var body = "This is a test";
|
);
|
||||||
s.setData(body, body.length);
|
var body = "This is a test";
|
||||||
Assert.equal(s.available(), body.length);
|
s.setData(body, body.length);
|
||||||
|
Assert.equal(s.available(), body.length);
|
||||||
|
|
||||||
var sis = Cc["@mozilla.org/scriptableinputstream;1"]
|
var sis = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(
|
||||||
.createInstance(Ci.nsIScriptableInputStream);
|
Ci.nsIScriptableInputStream
|
||||||
sis.init(s);
|
);
|
||||||
|
sis.init(s);
|
||||||
|
|
||||||
Assert.equal(sis.read(body.length), body);
|
Assert.equal(sis.read(body.length), body);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,25 @@
|
||||||
const CWD = do_get_cwd();
|
const CWD = do_get_cwd();
|
||||||
|
|
||||||
const DIR_TARGET = "target";
|
const DIR_TARGET = "target";
|
||||||
const DIR_LINK = "link";
|
const DIR_LINK = "link";
|
||||||
const DIR_LINK_LINK = "link_link";
|
const DIR_LINK_LINK = "link_link";
|
||||||
const FILE_TARGET = "target.txt";
|
const FILE_TARGET = "target.txt";
|
||||||
const FILE_LINK = "link.txt";
|
const FILE_LINK = "link.txt";
|
||||||
const FILE_LINK_LINK = "link_link.txt";
|
const FILE_LINK_LINK = "link_link.txt";
|
||||||
|
|
||||||
const DOES_NOT_EXIST = "doesnotexist";
|
const DOES_NOT_EXIST = "doesnotexist";
|
||||||
const DANGLING_LINK = "dangling_link";
|
const DANGLING_LINK = "dangling_link";
|
||||||
const LOOP_LINK = "loop_link";
|
const LOOP_LINK = "loop_link";
|
||||||
|
|
||||||
const nsIFile = Ci.nsIFile;
|
const nsIFile = Ci.nsIFile;
|
||||||
|
|
||||||
var process;
|
var process;
|
||||||
function createSymLink(from, to) {
|
function createSymLink(from, to) {
|
||||||
if (!process) {
|
if (!process) {
|
||||||
var ln = Cc["@mozilla.org/file/local;1"]
|
var ln = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
||||||
.createInstance(Ci.nsIFile);
|
|
||||||
ln.initWithPath("/bin/ln");
|
ln.initWithPath("/bin/ln");
|
||||||
|
|
||||||
process = Cc["@mozilla.org/process/util;1"]
|
process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
|
||||||
.createInstance(Ci.nsIProcess);
|
|
||||||
process.init(ln);
|
process.init(ln);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +79,7 @@ function setupTestDir(testDir, relative) {
|
||||||
var loop = testDir.clone();
|
var loop = testDir.clone();
|
||||||
loop.append(LOOP_LINK);
|
loop.append(LOOP_LINK);
|
||||||
|
|
||||||
var dirLink = makeSymLink(targetDir, DIR_LINK, relative);
|
var dirLink = makeSymLink(targetDir, DIR_LINK, relative);
|
||||||
var fileLink = makeSymLink(targetFile, FILE_LINK, relative);
|
var fileLink = makeSymLink(targetFile, FILE_LINK, relative);
|
||||||
|
|
||||||
makeSymLink(dirLink, DIR_LINK_LINK, relative);
|
makeSymLink(dirLink, DIR_LINK_LINK, relative);
|
||||||
|
|
@ -92,36 +90,43 @@ function setupTestDir(testDir, relative) {
|
||||||
try {
|
try {
|
||||||
makeSymLink(loop, LOOP_LINK, relative);
|
makeSymLink(loop, LOOP_LINK, relative);
|
||||||
Assert.ok(false);
|
Assert.ok(false);
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSpaces(dirs, files, links) {
|
function createSpaces(dirs, files, links) {
|
||||||
function longest(a, b) {
|
function longest(a, b) {
|
||||||
return a.length > b.length ? a : b;
|
return a.length > b.length ? a : b;
|
||||||
}
|
}
|
||||||
return dirs.concat(files, links).reduce(longest, "").replace(/./g, " ");
|
return dirs
|
||||||
|
.concat(files, links)
|
||||||
|
.reduce(longest, "")
|
||||||
|
.replace(/./g, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSymLinks(testDir, relative) {
|
function testSymLinks(testDir, relative) {
|
||||||
setupTestDir(testDir, relative);
|
setupTestDir(testDir, relative);
|
||||||
|
|
||||||
const dirLinks = [DIR_LINK, DIR_LINK_LINK];
|
const dirLinks = [DIR_LINK, DIR_LINK_LINK];
|
||||||
const fileLinks = [FILE_LINK, FILE_LINK_LINK];
|
const fileLinks = [FILE_LINK, FILE_LINK_LINK];
|
||||||
const otherLinks = [DANGLING_LINK, LOOP_LINK];
|
const otherLinks = [DANGLING_LINK, LOOP_LINK];
|
||||||
const dirs = [DIR_TARGET].concat(dirLinks);
|
const dirs = [DIR_TARGET].concat(dirLinks);
|
||||||
const files = [FILE_TARGET].concat(fileLinks);
|
const files = [FILE_TARGET].concat(fileLinks);
|
||||||
const links = otherLinks.concat(dirLinks, fileLinks);
|
const links = otherLinks.concat(dirLinks, fileLinks);
|
||||||
|
|
||||||
const spaces = createSpaces(dirs, files, links);
|
const spaces = createSpaces(dirs, files, links);
|
||||||
const bools = {false: " false", true: " true "};
|
const bools = { false: " false", true: " true " };
|
||||||
print(spaces + " dir file symlink");
|
print(spaces + " dir file symlink");
|
||||||
var dirEntries = testDir.directoryEntries;
|
var dirEntries = testDir.directoryEntries;
|
||||||
while (dirEntries.hasMoreElements()) {
|
while (dirEntries.hasMoreElements()) {
|
||||||
const file = dirEntries.nextFile;
|
const file = dirEntries.nextFile;
|
||||||
const name = file.leafName;
|
const name = file.leafName;
|
||||||
print(name + spaces.substring(name.length) + bools[file.isDirectory()] +
|
print(
|
||||||
bools[file.isFile()] + bools[file.isSymlink()]);
|
name +
|
||||||
|
spaces.substring(name.length) +
|
||||||
|
bools[file.isDirectory()] +
|
||||||
|
bools[file.isFile()] +
|
||||||
|
bools[file.isSymlink()]
|
||||||
|
);
|
||||||
Assert.equal(file.isDirectory(), dirs.includes(name));
|
Assert.equal(file.isDirectory(), dirs.includes(name));
|
||||||
Assert.equal(file.isFile(), files.includes(name));
|
Assert.equal(file.isFile(), files.includes(name));
|
||||||
Assert.equal(file.isSymlink(), links.includes(name));
|
Assert.equal(file.isSymlink(), links.includes(name));
|
||||||
|
|
@ -130,8 +135,9 @@ function testSymLinks(testDir, relative) {
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
// Skip this test on Windows
|
// Skip this test on Windows
|
||||||
if (mozinfo.os == "win")
|
if (mozinfo.os == "win") {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var testDir = CWD;
|
var testDir = CWD;
|
||||||
testDir.append("test_symlinks");
|
testDir.append("test_symlinks");
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,17 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
const PROPERTIES = ["name", "arch", "version", "pagesize",
|
const PROPERTIES = [
|
||||||
"pageshift", "memmapalign", "cpucount", "memsize"];
|
"name",
|
||||||
let sysInfo = Cc["@mozilla.org/system-info;1"].
|
"arch",
|
||||||
getService(Ci.nsIPropertyBag2);
|
"version",
|
||||||
|
"pagesize",
|
||||||
|
"pageshift",
|
||||||
|
"memmapalign",
|
||||||
|
"cpucount",
|
||||||
|
"memsize",
|
||||||
|
];
|
||||||
|
let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
|
||||||
|
|
||||||
PROPERTIES.forEach(function(aPropertyName) {
|
PROPERTIES.forEach(function(aPropertyName) {
|
||||||
print("Testing property: " + aPropertyName);
|
print("Testing property: " + aPropertyName);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
// Versions to test listed in ascending order, none can be equal
|
// Versions to test listed in ascending order, none can be equal
|
||||||
var comparisons = [
|
var comparisons = [
|
||||||
"pre",
|
"pre",
|
||||||
// A number that is too large to be supported should be normalized to 0.
|
// A number that is too large to be supported should be normalized to 0.
|
||||||
String(0x1F0000000),
|
String(0x1f0000000),
|
||||||
"0.9",
|
"0.9",
|
||||||
"0.9.1",
|
"0.9.1",
|
||||||
"1.0pre1",
|
"1.0pre1",
|
||||||
|
|
@ -27,22 +27,20 @@ var comparisons = [
|
||||||
];
|
];
|
||||||
|
|
||||||
// Every version in this list means the same version number
|
// Every version in this list means the same version number
|
||||||
var equality = [
|
var equality = ["1.1pre", "1.1pre0", "1.0+"];
|
||||||
"1.1pre",
|
|
||||||
"1.1pre0",
|
|
||||||
"1.0+",
|
|
||||||
];
|
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
for (var i = 0; i < comparisons.length; i++) {
|
for (var i = 0; i < comparisons.length; i++) {
|
||||||
for (var j = 0; j < comparisons.length; j++) {
|
for (var j = 0; j < comparisons.length; j++) {
|
||||||
var result = Services.vc.compare(comparisons[i], comparisons[j]);
|
var result = Services.vc.compare(comparisons[i], comparisons[j]);
|
||||||
if (i == j) {
|
if (i == j) {
|
||||||
if (result != 0)
|
if (result != 0) {
|
||||||
do_throw(comparisons[i] + " should be the same as itself");
|
do_throw(comparisons[i] + " should be the same as itself");
|
||||||
|
}
|
||||||
} else if (i < j) {
|
} else if (i < j) {
|
||||||
if (!(result < 0))
|
if (!(result < 0)) {
|
||||||
do_throw(comparisons[i] + " should be less than " + comparisons[j]);
|
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]);
|
do_throw(comparisons[i] + " should be greater than " + comparisons[j]);
|
||||||
}
|
}
|
||||||
|
|
@ -51,8 +49,9 @@ function run_test() {
|
||||||
|
|
||||||
for (i = 0; i < equality.length; i++) {
|
for (i = 0; i < equality.length; i++) {
|
||||||
for (j = 0; j < equality.length; j++) {
|
for (j = 0; j < equality.length; j++) {
|
||||||
if (Services.vc.compare(equality[i], equality[j]) != 0)
|
if (Services.vc.compare(equality[i], equality[j]) != 0) {
|
||||||
do_throw(equality[i] + " should equal " + equality[j]);
|
do_throw(equality[i] + " should equal " + equality[j]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
let executableFile = Services.dirsvc.get("CurProcD", Ci.nsIFile);
|
let executableFile = Services.dirsvc.get("CurProcD", Ci.nsIFile);
|
||||||
executableFile.append("xpcshell.exe");
|
executableFile.append("xpcshell.exe");
|
||||||
|
|
@ -9,7 +9,11 @@ function run_test() {
|
||||||
info(`Testing with ${cmdline}`);
|
info(`Testing with ${cmdline}`);
|
||||||
let f = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFileWin);
|
let f = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFileWin);
|
||||||
f.initWithCommandLine(cmdline);
|
f.initWithCommandLine(cmdline);
|
||||||
Assert.equal(f.path, executableFile.path, "Should be able to recover executable path");
|
Assert.equal(
|
||||||
|
f.path,
|
||||||
|
executableFile.path,
|
||||||
|
"Should be able to recover executable path"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let f = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFileWin);
|
let f = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFileWin);
|
||||||
|
|
|
||||||
|
|
@ -9,183 +9,218 @@ const nsIWindowsRegKey = Ci.nsIWindowsRegKey;
|
||||||
let regKeyComponent = Cc["@mozilla.org/windows-registry-key;1"];
|
let regKeyComponent = Cc["@mozilla.org/windows-registry-key;1"];
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
//* create a key structure in a spot that's normally writable (somewhere under HKCU).
|
//* create a key structure in a spot that's normally writable (somewhere under HKCU).
|
||||||
let testKey = regKeyComponent.createInstance(nsIWindowsRegKey);
|
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.
|
// 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;
|
let keyName = BASE_PATH + "\\" + TESTDATA_KEYNAME;
|
||||||
setup_test_run(testKey, keyName);
|
setup_test_run(testKey, keyName);
|
||||||
|
|
||||||
//* test that the write* functions write stuff
|
//* test that the write* functions write stuff
|
||||||
test_writing_functions(testKey);
|
test_writing_functions(testKey);
|
||||||
|
|
||||||
//* check that the valueCount/getValueName functions work for the values we just wrote
|
//* check that the valueCount/getValueName functions work for the values we just wrote
|
||||||
test_value_functions(testKey);
|
test_value_functions(testKey);
|
||||||
|
|
||||||
//* check that the get* functions work for the values we just wrote.
|
//* check that the get* functions work for the values we just wrote.
|
||||||
test_reading_functions(testKey);
|
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
|
//* 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);
|
test_invalidread_functions(testKey);
|
||||||
|
|
||||||
//* check that creating/enumerating/deleting child keys works
|
//* check that creating/enumerating/deleting child keys works
|
||||||
test_childkey_functions(testKey);
|
test_childkey_functions(testKey);
|
||||||
|
|
||||||
test_watching_functions(testKey);
|
test_watching_functions(testKey);
|
||||||
|
|
||||||
//* clean up
|
//* clean up
|
||||||
cleanup_test_run(testKey, keyName);
|
cleanup_test_run(testKey, keyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_test_run(testKey, keyName) {
|
function setup_test_run(testKey, keyName) {
|
||||||
info("Setup test run");
|
info("Setup test run");
|
||||||
try {
|
try {
|
||||||
testKey.open(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, keyName, nsIWindowsRegKey.ACCESS_READ);
|
testKey.open(
|
||||||
info("Test key exists. Needs cleanup.");
|
nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||||
cleanup_test_run(testKey, keyName);
|
keyName,
|
||||||
} catch (e) {
|
nsIWindowsRegKey.ACCESS_READ
|
||||||
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
|
);
|
||||||
throw e;
|
info("Test key exists. Needs cleanup.");
|
||||||
}
|
cleanup_test_run(testKey, keyName);
|
||||||
|
} 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);
|
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.valueCount, 0);
|
||||||
|
|
||||||
strictEqual(testKey.hasValue(TESTDATA_STRNAME), false);
|
strictEqual(testKey.hasValue(TESTDATA_STRNAME), false);
|
||||||
testKey.writeStringValue(TESTDATA_STRNAME, TESTDATA_STRVALUE);
|
testKey.writeStringValue(TESTDATA_STRNAME, TESTDATA_STRVALUE);
|
||||||
strictEqual(testKey.hasValue(TESTDATA_STRNAME), true);
|
strictEqual(testKey.hasValue(TESTDATA_STRNAME), true);
|
||||||
|
|
||||||
strictEqual(testKey.hasValue(TESTDATA_INTNAME), false);
|
strictEqual(testKey.hasValue(TESTDATA_INTNAME), false);
|
||||||
testKey.writeIntValue(TESTDATA_INTNAME, TESTDATA_INTVALUE);
|
testKey.writeIntValue(TESTDATA_INTNAME, TESTDATA_INTVALUE);
|
||||||
|
|
||||||
strictEqual(testKey.hasValue(TESTDATA_INT64NAME), false);
|
strictEqual(testKey.hasValue(TESTDATA_INT64NAME), false);
|
||||||
testKey.writeInt64Value(TESTDATA_INT64NAME, TESTDATA_INT64VALUE);
|
testKey.writeInt64Value(TESTDATA_INT64NAME, TESTDATA_INT64VALUE);
|
||||||
|
|
||||||
strictEqual(testKey.hasValue(TESTDATA_BINARYNAME), false);
|
strictEqual(testKey.hasValue(TESTDATA_BINARYNAME), false);
|
||||||
testKey.writeBinaryValue(TESTDATA_BINARYNAME, TESTDATA_BINARYVALUE);
|
testKey.writeBinaryValue(TESTDATA_BINARYNAME, TESTDATA_BINARYVALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_value_functions(testKey) {
|
function test_value_functions(testKey) {
|
||||||
strictEqual(testKey.valueCount, 4);
|
strictEqual(testKey.valueCount, 4);
|
||||||
strictEqual(testKey.getValueName(0), TESTDATA_STRNAME);
|
strictEqual(testKey.getValueName(0), TESTDATA_STRNAME);
|
||||||
strictEqual(testKey.getValueName(1), TESTDATA_INTNAME);
|
strictEqual(testKey.getValueName(1), TESTDATA_INTNAME);
|
||||||
strictEqual(testKey.getValueName(2), TESTDATA_INT64NAME);
|
strictEqual(testKey.getValueName(2), TESTDATA_INT64NAME);
|
||||||
strictEqual(testKey.getValueName(3), TESTDATA_BINARYNAME);
|
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(
|
||||||
strictEqual(testKey.readStringValue(TESTDATA_STRNAME), TESTDATA_STRVALUE);
|
testKey.getValueType(TESTDATA_STRNAME),
|
||||||
|
nsIWindowsRegKey.TYPE_STRING
|
||||||
|
);
|
||||||
|
strictEqual(testKey.readStringValue(TESTDATA_STRNAME), TESTDATA_STRVALUE);
|
||||||
|
|
||||||
strictEqual(testKey.getValueType(TESTDATA_INTNAME), nsIWindowsRegKey.TYPE_INT);
|
strictEqual(
|
||||||
strictEqual(testKey.readIntValue(TESTDATA_INTNAME), TESTDATA_INTVALUE);
|
testKey.getValueType(TESTDATA_INTNAME),
|
||||||
|
nsIWindowsRegKey.TYPE_INT
|
||||||
|
);
|
||||||
|
strictEqual(testKey.readIntValue(TESTDATA_INTNAME), TESTDATA_INTVALUE);
|
||||||
|
|
||||||
strictEqual(testKey.getValueType(TESTDATA_INT64NAME), nsIWindowsRegKey.TYPE_INT64);
|
strictEqual(
|
||||||
strictEqual( testKey.readInt64Value(TESTDATA_INT64NAME), TESTDATA_INT64VALUE);
|
testKey.getValueType(TESTDATA_INT64NAME),
|
||||||
|
nsIWindowsRegKey.TYPE_INT64
|
||||||
|
);
|
||||||
|
strictEqual(testKey.readInt64Value(TESTDATA_INT64NAME), TESTDATA_INT64VALUE);
|
||||||
|
|
||||||
strictEqual(testKey.getValueType(TESTDATA_BINARYNAME), nsIWindowsRegKey.TYPE_BINARY);
|
strictEqual(
|
||||||
strictEqual( testKey.readBinaryValue(TESTDATA_BINARYNAME), TESTDATA_BINARYVALUE);
|
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 {
|
try {
|
||||||
testKey.readIntValue(TESTDATA_STRNAME);
|
testKey.readIntValue(TESTDATA_STRNAME);
|
||||||
do_throw("Reading an integer from a string registry value should throw.");
|
do_throw("Reading an integer from a string registry value should throw.");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
|
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let val = testKey.readStringValue(TESTDATA_INTNAME);
|
let val = testKey.readStringValue(TESTDATA_INTNAME);
|
||||||
do_throw("Reading an string from an Int registry value should throw." + val);
|
do_throw(
|
||||||
} catch (e) {
|
"Reading an string from an Int registry value should throw." + val
|
||||||
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
|
);
|
||||||
throw e;
|
} catch (e) {
|
||||||
}
|
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
testKey.readStringValue(TESTDATA_INT64NAME);
|
testKey.readStringValue(TESTDATA_INT64NAME);
|
||||||
do_throw("Reading an string from an Int64 registry value should throw.");
|
do_throw("Reading an string from an Int64 registry value should throw.");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
|
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
testKey.readStringValue(TESTDATA_BINARYNAME);
|
testKey.readStringValue(TESTDATA_BINARYNAME);
|
||||||
do_throw("Reading a string from an Binary registry value should throw.");
|
do_throw("Reading a string from an Binary registry value should throw.");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
|
if (!(e instanceof Ci.nsIException && e.result == Cr.NS_ERROR_FAILURE)) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_childkey_functions(testKey) {
|
function test_childkey_functions(testKey) {
|
||||||
strictEqual(testKey.childCount, 0);
|
strictEqual(testKey.childCount, 0);
|
||||||
strictEqual(testKey.hasChild(TESTDATA_CHILD_KEY), false);
|
strictEqual(testKey.hasChild(TESTDATA_CHILD_KEY), false);
|
||||||
|
|
||||||
let childKey = testKey.createChild(TESTDATA_CHILD_KEY, nsIWindowsRegKey.ACCESS_ALL);
|
let childKey = testKey.createChild(
|
||||||
childKey.close();
|
TESTDATA_CHILD_KEY,
|
||||||
|
nsIWindowsRegKey.ACCESS_ALL
|
||||||
|
);
|
||||||
|
childKey.close();
|
||||||
|
|
||||||
strictEqual(testKey.childCount, 1);
|
strictEqual(testKey.childCount, 1);
|
||||||
strictEqual(testKey.hasChild(TESTDATA_CHILD_KEY), true);
|
strictEqual(testKey.hasChild(TESTDATA_CHILD_KEY), true);
|
||||||
strictEqual(testKey.getChildName(0), TESTDATA_CHILD_KEY);
|
strictEqual(testKey.getChildName(0), TESTDATA_CHILD_KEY);
|
||||||
|
|
||||||
childKey = testKey.openChild(TESTDATA_CHILD_KEY, nsIWindowsRegKey.ACCESS_ALL);
|
childKey = testKey.openChild(TESTDATA_CHILD_KEY, nsIWindowsRegKey.ACCESS_ALL);
|
||||||
testKey.removeChild(TESTDATA_CHILD_KEY);
|
testKey.removeChild(TESTDATA_CHILD_KEY);
|
||||||
strictEqual(testKey.childCount, 0);
|
strictEqual(testKey.childCount, 0);
|
||||||
strictEqual(testKey.hasChild(TESTDATA_CHILD_KEY), false);
|
strictEqual(testKey.hasChild(TESTDATA_CHILD_KEY), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_watching_functions(testKey) {
|
function test_watching_functions(testKey) {
|
||||||
strictEqual(testKey.isWatching(), false);
|
strictEqual(testKey.isWatching(), false);
|
||||||
strictEqual(testKey.hasChanged(), false);
|
strictEqual(testKey.hasChanged(), false);
|
||||||
|
|
||||||
testKey.startWatching(true);
|
testKey.startWatching(true);
|
||||||
strictEqual(testKey.isWatching(), true);
|
strictEqual(testKey.isWatching(), true);
|
||||||
|
|
||||||
testKey.stopWatching();
|
testKey.stopWatching();
|
||||||
strictEqual(testKey.isWatching(), false);
|
strictEqual(testKey.isWatching(), false);
|
||||||
|
|
||||||
// Create a child key, and update a value
|
// Create a child key, and update a value
|
||||||
let childKey = testKey.createChild(TESTDATA_CHILD_KEY, nsIWindowsRegKey.ACCESS_ALL);
|
let childKey = testKey.createChild(
|
||||||
childKey.writeIntValue(TESTDATA_INTNAME, TESTDATA_INTVALUE);
|
TESTDATA_CHILD_KEY,
|
||||||
|
nsIWindowsRegKey.ACCESS_ALL
|
||||||
|
);
|
||||||
|
childKey.writeIntValue(TESTDATA_INTNAME, TESTDATA_INTVALUE);
|
||||||
|
|
||||||
// Start a recursive watch, and update the child's value
|
// Start a recursive watch, and update the child's value
|
||||||
testKey.startWatching(true);
|
testKey.startWatching(true);
|
||||||
strictEqual(testKey.isWatching(), true);
|
strictEqual(testKey.isWatching(), true);
|
||||||
|
|
||||||
childKey.writeIntValue(TESTDATA_INTNAME, 0);
|
childKey.writeIntValue(TESTDATA_INTNAME, 0);
|
||||||
strictEqual(testKey.hasChanged(), true);
|
strictEqual(testKey.hasChanged(), true);
|
||||||
testKey.stopWatching();
|
testKey.stopWatching();
|
||||||
strictEqual(testKey.isWatching(), false);
|
strictEqual(testKey.isWatching(), false);
|
||||||
|
|
||||||
childKey.removeValue(TESTDATA_INTNAME);
|
childKey.removeValue(TESTDATA_INTNAME);
|
||||||
childKey.close();
|
childKey.close();
|
||||||
testKey.removeChild(TESTDATA_CHILD_KEY);
|
testKey.removeChild(TESTDATA_CHILD_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_test_run(testKey, keyName) {
|
function cleanup_test_run(testKey, keyName) {
|
||||||
info("Cleaning up test.");
|
info("Cleaning up test.");
|
||||||
|
|
||||||
for (var i = 0; i < testKey.childCount; i++) {
|
for (var i = 0; i < testKey.childCount; i++) {
|
||||||
testKey.removeChild(testKey.getChildName(i));
|
testKey.removeChild(testKey.getChildName(i));
|
||||||
}
|
}
|
||||||
testKey.close();
|
testKey.close();
|
||||||
|
|
||||||
let baseKey = regKeyComponent.createInstance(nsIWindowsRegKey);
|
let baseKey = regKeyComponent.createInstance(nsIWindowsRegKey);
|
||||||
baseKey.open(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, BASE_PATH, nsIWindowsRegKey.ACCESS_ALL);
|
baseKey.open(
|
||||||
baseKey.removeChild(TESTDATA_KEYNAME);
|
nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||||
baseKey.close();
|
BASE_PATH,
|
||||||
|
nsIWindowsRegKey.ACCESS_ALL
|
||||||
|
);
|
||||||
|
baseKey.removeChild(TESTDATA_KEYNAME);
|
||||||
|
baseKey.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test data used above.
|
// Test data used above.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue