forked from mirrors/gecko-dev
Bug 1501932 - Enable ESLint for modules/ (manual changes). r=aklotz,njn
Differential Revision: https://phabricator.services.mozilla.com/D14647 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
531ae2db82
commit
5886d1854f
48 changed files with 336 additions and 398 deletions
|
|
@ -22,7 +22,6 @@ extensions/spellcheck/**
|
|||
extensions/universalchardet/**
|
||||
image/**
|
||||
layout/**
|
||||
modules/**
|
||||
netwerk/cookie/test/browser/**
|
||||
netwerk/test/browser/**
|
||||
netwerk/test/mochitests/**
|
||||
|
|
|
|||
|
|
@ -23,16 +23,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1173171
|
|||
// Returns a promise with the response.
|
||||
let xhr = function(method, url, responseType) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open(method, url, true);
|
||||
xhr.onload = function() {
|
||||
resolve(xhr.response);
|
||||
let xhrInstance = new XMLHttpRequest();
|
||||
xhrInstance.open(method, url, true);
|
||||
xhrInstance.onload = function() {
|
||||
resolve(xhrInstance.response);
|
||||
};
|
||||
xhr.onerror = function() {
|
||||
xhrInstance.onerror = function() {
|
||||
resolve(null);
|
||||
};
|
||||
xhr.responseType = responseType;
|
||||
xhr.send();
|
||||
xhrInstance.responseType = responseType;
|
||||
xhrInstance.send();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -40,7 +40,6 @@ let jarURL = "jar:http://mochi.test:8888/tests/modules/libjar/test/mochitest/bug
|
|||
|
||||
// Test behavior when blocking is deactivated and activated.
|
||||
add_task(async function() {
|
||||
let shouldBlock = true;
|
||||
let response = await xhr("GET", jarURL, "document");
|
||||
is(response, null, "Remote jars should be blocked.");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,15 +4,14 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
// Check that reading non existant inner jars results in the right error
|
||||
|
||||
add_task(async function() {
|
||||
var file = do_get_file("data/test_bug597702.zip");
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
|
||||
var outerJarBase = "jar:" + Services.io.newFileURI(file).spec + "!/";
|
||||
var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello#!/ignore%20this%20part";
|
||||
var goodChannel = NetUtil.newChannel({uri: goodSpec, loadUsingSystemPrincipal: true});
|
||||
var instr = goodChannel.open();
|
||||
|
|
@ -22,9 +21,7 @@ add_task(async function() {
|
|||
|
||||
add_task(async function() {
|
||||
var file = do_get_file("data/test_bug597702.zip");
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
|
||||
var outerJarBase = "jar:" + Services.io.newFileURI(file).spec + "!/";
|
||||
var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello?ignore%20this%20part!/";
|
||||
var goodChannel = NetUtil.newChannel({uri: goodSpec, loadUsingSystemPrincipal: true});
|
||||
var instr = goodChannel.open();
|
||||
|
|
@ -34,9 +31,7 @@ add_task(async function() {
|
|||
|
||||
add_task(async function() {
|
||||
var file = do_get_file("data/test_bug597702.zip");
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
|
||||
var outerJarBase = "jar:" + Services.io.newFileURI(file).spec + "!/";
|
||||
var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello?ignore#this!/part";
|
||||
var goodChannel = NetUtil.newChannel({uri: goodSpec, loadUsingSystemPrincipal: true});
|
||||
var instr = goodChannel.open();
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
// Regression test for bug 278262 - JAR URIs should resolve relative URIs in the base section.
|
||||
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const path = "data/test_bug333423.zip";
|
||||
|
||||
function test_relative_sub() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
|
||||
var ios = Services.io;
|
||||
var spec = "jar:" + ios.newFileURI(do_get_file(path)).spec + "!/";
|
||||
var base = ios.newURI(spec);
|
||||
var uri = ios.newURI("../modules/libjar", null, base);
|
||||
|
|
@ -18,9 +18,7 @@ function test_relative_sub() {
|
|||
}
|
||||
|
||||
function test_relative_base() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
|
||||
var ios = Services.io;
|
||||
var base = ios.newFileURI(do_get_file("data/empty"));
|
||||
var uri = ios.newURI("jar:../" + path + "!/", null, base);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
// Regression test for bug 370103 - crash when passing a null listener to
|
||||
// nsIChannel.asyncOpen
|
||||
function run_test() {
|
||||
// Compose the jar: url
|
||||
var ioService = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var file = do_get_file("data/test_bug370103.jar");
|
||||
var url = ioService.newFileURI(file).spec;
|
||||
var url = Services.io.newFileURI(file).spec;
|
||||
url = "jar:" + url + "!/test_bug370103";
|
||||
|
||||
// Try opening channel with null listener
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
// Make sure we behave appropriately when asking for content-disposition
|
||||
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
const path = "data/test_bug589292.zip";
|
||||
|
||||
function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var spec = "jar:" + ios.newFileURI(do_get_file(path)).spec + "!/foo.txt";
|
||||
var spec = "jar:" + Services.io.newFileURI(do_get_file(path)).spec + "!/foo.txt";
|
||||
var channel = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true});
|
||||
instr = channel.open();
|
||||
var val;
|
||||
channel.open();
|
||||
try {
|
||||
val = channel.contentDisposition;
|
||||
channel.contentDisposition;
|
||||
Assert.ok(false, "The channel has content disposition?!");
|
||||
} catch (e) {
|
||||
// This is what we want to happen - there's no underlying channel, so no
|
||||
|
|
|
|||
|
|
@ -2,31 +2,29 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
// Check that reading non existant inner jars results in the right error
|
||||
|
||||
function run_test() {
|
||||
var file = do_get_file("data/test_bug597702.zip");
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
|
||||
var outerJarBase = "jar:" + Services.io.newFileURI(file).spec + "!/";
|
||||
var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello";
|
||||
var badSpec = "jar:" + outerJarBase + "jar_that_isnt_in_the.jar!/hello";
|
||||
var goodChannel = NetUtil.newChannel({uri: goodSpec, loadUsingSystemPrincipal: true});
|
||||
var badChannel = NetUtil.newChannel({uri: badSpec, loadUsingSystemPrincipal: true});
|
||||
|
||||
try {
|
||||
instr = goodChannel.open();
|
||||
goodChannel.open();
|
||||
} catch (e) {
|
||||
do_throw("Failed to open file in inner jar");
|
||||
}
|
||||
|
||||
try {
|
||||
instr = badChannel.open();
|
||||
badChannel.open();
|
||||
do_throw("Failed to report that file doesn't exist");
|
||||
} catch (e) {
|
||||
Assert.ok(e.name == "NS_ERROR_FILE_NOT_FOUND");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,25 +2,23 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
// Check that the zip cache can expire entries from nested jars
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
|
||||
function open_inner_zip(base, idx) {
|
||||
var spec = "jar:" + base + "inner" + idx + ".zip!/foo";
|
||||
var channel = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true});
|
||||
var stream = channel.open();
|
||||
channel.open();
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
var file = do_get_file("data/test_bug637286.zip");
|
||||
var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
|
||||
var outerJarBase = "jar:" + Services.io.newFileURI(file).spec + "!/";
|
||||
|
||||
for (var i = 0; i < 40; i++) {
|
||||
open_inner_zip(outerJarBase, i);
|
||||
gc();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,19 +2,18 @@
|
|||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
// Check that we don't crash on reading a directory entry signature
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
|
||||
function run_test() {
|
||||
var file = do_get_file("data/test_bug658093.zip");
|
||||
var spec = "jar:" + ios.newFileURI(file).spec + "!/0000";
|
||||
var spec = "jar:" + Services.io.newFileURI(file).spec + "!/0000";
|
||||
var channel = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true});
|
||||
var failed = false;
|
||||
try {
|
||||
var stream = channel.open();
|
||||
channel.open();
|
||||
} catch (e) {
|
||||
failed = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ function run_test() {
|
|||
let entry = zipreader.getEntry(entryPath);
|
||||
if (!entry.isDirectory) {
|
||||
try {
|
||||
let inputStream = zipreader.getInputStream(entryPath);
|
||||
zipreader.getInputStream(entryPath);
|
||||
} catch (e) {
|
||||
failed = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ function run_test() {
|
|||
return true;
|
||||
}
|
||||
Assert.ok(check_archive_crc());
|
||||
let entries = zipreader.findEntries(null);
|
||||
zipreader.findEntries(null);
|
||||
let stream = wrapInputStream(zipreader.getInputStream("modules/libjar/test/Makefile.in"));
|
||||
let dirstream = wrapInputStream(zipreader.getInputStream("modules/libjar/test/"));
|
||||
zipreader.close();
|
||||
|
|
|
|||
|
|
@ -7,21 +7,14 @@
|
|||
*/
|
||||
|
||||
|
||||
const {classes: Cc,
|
||||
interfaces: Ci,
|
||||
results: Cr,
|
||||
utils: Cu,
|
||||
Constructor: ctor,
|
||||
} = Components;
|
||||
const {Constructor: ctor} = Components;
|
||||
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
const ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
const dirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
const obs = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
const ios = Services.io;
|
||||
const dirSvc = Services.dirsvc;
|
||||
const obs = Services.obs;
|
||||
|
||||
const nsIBinaryInputStream = ctor("@mozilla.org/binaryinputstream;1",
|
||||
"nsIBinaryInputStream",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ function run_test() {
|
|||
return true;
|
||||
}
|
||||
Assert.ok(check_archive_crc());
|
||||
var entries = zipreader.findEntries(null);
|
||||
zipreader.findEntries(null);
|
||||
var stream = wrapInputStream(zipreader.getInputStream("modules/libjar/test/Makefile.in"));
|
||||
var dirstream = wrapInputStream(zipreader.getInputStream("modules/libjar/test/"));
|
||||
zipreader.close();
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
// Should report file not found on non-existent files
|
||||
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
const path = "data/test_bug333423.zip";
|
||||
|
||||
function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var spec = "jar:" + ios.newFileURI(do_get_file(path)).spec + "!/";
|
||||
var spec = "jar:" + Services.io.newFileURI(do_get_file(path)).spec + "!/";
|
||||
var channel = NetUtil.newChannel({
|
||||
uri: spec + "file_that_isnt_in.archive",
|
||||
loadUsingSystemPrincipal: true,
|
||||
});
|
||||
try {
|
||||
instr = channel.open();
|
||||
channel.open();
|
||||
do_throw("Failed to report that file doesn't exist");
|
||||
} catch (e) {
|
||||
Assert.ok(e.name == "NS_ERROR_FILE_NOT_FOUND");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function run_test() {
|
||||
var dirService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
|
||||
var tmpDir = dirService.get("TmpD", Ci.nsIFile);
|
||||
var tmpDir = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
|
||||
var zipfile = do_get_file("data/test_umlaute.zip");
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ const PR_MSEC_PER_SEC = 1000;
|
|||
|
||||
const DATA_DIR = "data/";
|
||||
|
||||
var ioSvc = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService);
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var ioSvc = Services.io;
|
||||
|
||||
var ZipWriter = Components.Constructor("@mozilla.org/zipwriter;1",
|
||||
"nsIZipWriter");
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ function move_to_data(bis, offset) {
|
|||
bis.readBytes(4);
|
||||
var file_len = swap16(bis.read16());
|
||||
var extra_len = swap16(bis.read16());
|
||||
var file = bis.readBytes(file_len);
|
||||
bis.readBytes(file_len);
|
||||
bis.readBytes(extra_len);
|
||||
offset += ZIP_FILE_HEADER_SIZE + file_len + extra_len;
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ function test_alignment(align_size) {
|
|||
|
||||
// Check data can be decompressed.
|
||||
var zipR = new ZipReader(tmpFile);
|
||||
var stream = Cc["@mozilla.org/scriptableinputstream;1"]
|
||||
stream = Cc["@mozilla.org/scriptableinputstream;1"]
|
||||
.createInstance(Ci.nsIScriptableInputStream);
|
||||
stream.init(zipR.getInputStream(FILENAME));
|
||||
var result = stream.read(DATA.length);
|
||||
|
|
@ -91,7 +91,7 @@ function test_alignment(align_size) {
|
|||
|
||||
ret = move_to_data(bis, offset); // "test_data.txt"
|
||||
offset = ret.offset;
|
||||
var result = bis.readBytes(DATA.length);
|
||||
result = bis.readBytes(DATA.length);
|
||||
Assert.equal(result, DATA);
|
||||
Assert.equal(offset % align_size, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ function run_test() {
|
|||
var zipR = new ZipReader(tmpFile);
|
||||
testpass(zipR);
|
||||
zipR.test(FILENAME);
|
||||
var stream = Cc["@mozilla.org/scriptableinputstream;1"]
|
||||
stream = Cc["@mozilla.org/scriptableinputstream;1"]
|
||||
.createInstance(Ci.nsIScriptableInputStream);
|
||||
stream.init(zipR.getInputStream(FILENAME));
|
||||
var result = stream.read(DATA.length);
|
||||
|
|
|
|||
|
|
@ -4,17 +4,16 @@
|
|||
*/
|
||||
|
||||
function run_test() {
|
||||
var test;
|
||||
// zipW is an uninitialised zipwriter at this point.
|
||||
try {
|
||||
test = zipW.file;
|
||||
zipW.file;
|
||||
do_throw("Should have thrown uninitialized error.");
|
||||
} catch (e) {
|
||||
Assert.equal(e.result, Cr.NS_ERROR_NOT_INITIALIZED);
|
||||
}
|
||||
|
||||
try {
|
||||
test = zipW.comment;
|
||||
zipW.comment;
|
||||
do_throw("Should have thrown uninitialized error.");
|
||||
} catch (e) {
|
||||
Assert.equal(e.result, Cr.NS_ERROR_NOT_INITIALIZED);
|
||||
|
|
|
|||
|
|
@ -44,17 +44,18 @@ BinaryComparer.prototype = {
|
|||
try {
|
||||
actual = stream.read8();
|
||||
} catch (e) {
|
||||
do_throw("Unable to read from converted stream at offset " + this.offset + " " + e);
|
||||
do_throw("Unable to read from converted stream at offset " +
|
||||
this.offset + " " + e);
|
||||
}
|
||||
// The byte at offset 9 is the OS byte (see RFC 1952, section 2.3), which
|
||||
// can legitimately differ when the source is compressed on different
|
||||
// operating systems. The actual .gz for this test was created on a Unix
|
||||
// system, but we want the test to work correctly everywhere. So ignore
|
||||
// the byte at offset 9.
|
||||
if (this.offset == 9)
|
||||
;
|
||||
else if (source != actual)
|
||||
do_throw("Invalid value " + actual + " at offset " + this.offset + ", should have been " + source);
|
||||
if (this.offset != 9 && source != actual) {
|
||||
do_throw("Invalid value " + actual + " at offset " +
|
||||
this.offset + ", should have been " + source);
|
||||
}
|
||||
this.offset++;
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function run_test() {
|
|||
|
||||
zipR.test(FILENAME);
|
||||
|
||||
var stream = Cc["@mozilla.org/scriptableinputstream;1"]
|
||||
stream = Cc["@mozilla.org/scriptableinputstream;1"]
|
||||
.createInstance(Ci.nsIScriptableInputStream);
|
||||
stream.init(zipR.getInputStream(FILENAME));
|
||||
var result = stream.read(DATA.length);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ function run_test() {
|
|||
|
||||
zipW.open(tmpFile, PR_RDWR);
|
||||
|
||||
for (var i = 0; i < TESTS.length; i++) {
|
||||
for (let i = 0; i < TESTS.length; i++) {
|
||||
Assert.ok(zipW.hasEntry(TESTS[i].name));
|
||||
var entry = zipW.getEntry(TESTS[i].name);
|
||||
Assert.ok(entry != null);
|
||||
|
|
@ -46,7 +46,7 @@ function run_test() {
|
|||
Assert.equal(e.result, Cr.NS_ERROR_FILE_NOT_FOUND);
|
||||
}
|
||||
|
||||
for (var i = 0; i < TESTS.length; i++) {
|
||||
for (let i = 0; i < TESTS.length; i++) {
|
||||
zipW.removeEntry(TESTS[i].name, false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ function run_test() {
|
|||
var zipR = new ZipReader(tmpFile);
|
||||
testpass(zipR);
|
||||
zipR.test(FILENAME);
|
||||
var stream = Cc["@mozilla.org/scriptableinputstream;1"]
|
||||
stream = Cc["@mozilla.org/scriptableinputstream;1"]
|
||||
.createInstance(Ci.nsIScriptableInputStream);
|
||||
stream.init(zipR.getInputStream(FILENAME));
|
||||
var result = stream.read(DATA.length);
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ function run_test() {
|
|||
zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
|
||||
|
||||
var size = 0;
|
||||
for (var i = 0; i < TESTS.length; i++) {
|
||||
var source = do_get_file(DATA_DIR + TESTS[i].name);
|
||||
for (let i = 0; i < TESTS.length; i++) {
|
||||
let source = do_get_file(DATA_DIR + TESTS[i].name);
|
||||
zipW.addEntryFile(TESTS[i].name, Ci.nsIZipWriter.COMPRESSION_NONE, source,
|
||||
false);
|
||||
size += ZIP_FILE_HEADER_SIZE + ZIP_CDS_HEADER_SIZE +
|
||||
|
|
@ -38,8 +38,8 @@ function run_test() {
|
|||
// Test the stored data with the zipreader
|
||||
var zipR = new ZipReader(tmpFile);
|
||||
|
||||
for (var i = 0; i < TESTS.length; i++) {
|
||||
var source = do_get_file(DATA_DIR + TESTS[i].name);
|
||||
for (let i = 0; i < TESTS.length; i++) {
|
||||
let source = do_get_file(DATA_DIR + TESTS[i].name);
|
||||
Assert.ok(zipR.hasEntry(TESTS[i].name));
|
||||
|
||||
var entry = zipR.getEntry(TESTS[i].name);
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ var TESTS = [
|
|||
function run_test() {
|
||||
zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
|
||||
|
||||
for (var i = 0; i < TESTS.length; i++) {
|
||||
var source = do_get_file(DATA_DIR + TESTS[i]);
|
||||
for (let i = 0; i < TESTS.length; i++) {
|
||||
let source = do_get_file(DATA_DIR + TESTS[i]);
|
||||
zipW.addEntryFile(TESTS[i], Ci.nsIZipWriter.COMPRESSION_NONE, source,
|
||||
false);
|
||||
}
|
||||
|
||||
try {
|
||||
var source = do_get_file(DATA_DIR + TESTS[0]);
|
||||
let source = do_get_file(DATA_DIR + TESTS[0]);
|
||||
zipW.addEntryFile(TESTS[0], Ci.nsIZipWriter.COMPRESSION_NONE, source,
|
||||
false);
|
||||
do_throw("Should not be able to add the same file twice");
|
||||
|
|
@ -28,7 +28,7 @@ function run_test() {
|
|||
}
|
||||
|
||||
// Remove all the tests and see if we are left with an empty zip
|
||||
for (var i = 0; i < TESTS.length; i++) {
|
||||
for (let i = 0; i < TESTS.length; i++) {
|
||||
zipW.removeEntry(TESTS[i], false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,16 +17,16 @@ function do_check_throws(f, result, stack) {
|
|||
ok(false, "expected result " + result + ", none thrown");
|
||||
}
|
||||
|
||||
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// Register current test directory as provider for the profile directory.
|
||||
var provider = {
|
||||
getFile(prop, persistent) {
|
||||
persistent.value = true;
|
||||
if (prop == NS_APP_USER_PROFILE_50_DIR)
|
||||
return dirSvc.get("CurProcD", Ci.nsIFile);
|
||||
return Services.dirsvc.get("CurProcD", Ci.nsIFile);
|
||||
throw Components.Exception("Tried to get test directory '" + prop + "'", Cr.NS_ERROR_FAILURE);
|
||||
},
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIDirectoryServiceProvider"]),
|
||||
};
|
||||
dirSvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);
|
||||
Services.dirsvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);
|
||||
|
|
|
|||
|
|
@ -9,13 +9,11 @@ function run_test() {
|
|||
const FLOAT = 9.674;
|
||||
const FUDGE = 0.001;
|
||||
|
||||
let ps = Cc["@mozilla.org/preferences-service;1"]
|
||||
.getService(Ci.nsIPrefService);
|
||||
let prefs = ps.getDefaultBranch(null);
|
||||
let prefs = Services.prefs.getDefaultBranch(null);
|
||||
|
||||
/* Test with a non-default branch */
|
||||
prefs.setCharPref(FULL_PREF_NAME, FLOAT);
|
||||
let pb = ps.getBranch(BRANCH);
|
||||
let pb = Services.prefs.getBranch(BRANCH);
|
||||
|
||||
let floatPref = pb.getFloatPref(PREF_NAME);
|
||||
Assert.ok(FLOAT + FUDGE >= floatPref);
|
||||
|
|
|
|||
|
|
@ -6,22 +6,20 @@
|
|||
function run_test() {
|
||||
const PREF_NAME = "testPref";
|
||||
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"]
|
||||
.getService(Ci.nsIPrefBranch);
|
||||
var observer = {
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
|
||||
|
||||
observe: function observe(aSubject, aTopic, aState) {
|
||||
prefs.removeObserver(PREF_NAME, observer);
|
||||
Services.prefs.removeObserver(PREF_NAME, observer);
|
||||
},
|
||||
};
|
||||
prefs.addObserver(PREF_NAME, observer);
|
||||
Services.prefs.addObserver(PREF_NAME, observer);
|
||||
|
||||
prefs.setCharPref(PREF_NAME, "test0");
|
||||
Services.prefs.setCharPref(PREF_NAME, "test0");
|
||||
// This second call isn't needed on a clean profile: it makes sure
|
||||
// the observer gets called even if the pref already had the value
|
||||
// "test0" before this test.
|
||||
prefs.setCharPref(PREF_NAME, "test1");
|
||||
Services.prefs.setCharPref(PREF_NAME, "test1");
|
||||
|
||||
Assert.ok(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@
|
|||
function run_test() {
|
||||
const PREF_NAME = "testPref";
|
||||
|
||||
var ps = Cc["@mozilla.org/preferences-service;1"]
|
||||
.getService(Ci.nsIPrefService);
|
||||
var prefs = ps.getDefaultBranch(null);
|
||||
var userprefs = ps.getBranch(null);
|
||||
var prefs = Services.prefs.getDefaultBranch(null);
|
||||
var userprefs = Services.prefs.getBranch(null);
|
||||
|
||||
prefs.setCharPref(PREF_NAME, "test0");
|
||||
prefs.lockPref(PREF_NAME);
|
||||
|
|
@ -16,11 +14,11 @@ function run_test() {
|
|||
|
||||
var file = do_get_profile();
|
||||
file.append("prefs.js");
|
||||
ps.savePrefFile(file);
|
||||
Services.prefs.savePrefFile(file);
|
||||
|
||||
prefs.unlockPref(PREF_NAME);
|
||||
prefs.setCharPref(PREF_NAME, "test1");
|
||||
ps.readUserPrefsFromFile(file);
|
||||
Services.prefs.readUserPrefsFromFile(file);
|
||||
|
||||
Assert.equal("test1", userprefs.getCharPref(PREF_NAME));
|
||||
Assert.equal(false, userprefs.prefHasUserValue(PREF_NAME));
|
||||
|
|
|
|||
|
|
@ -3,12 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
function run_test() {
|
||||
var ps = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefService);
|
||||
|
||||
var pb = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
|
||||
var observer = {
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
|
||||
|
||||
|
|
@ -18,6 +12,6 @@ function run_test() {
|
|||
};
|
||||
|
||||
/* Set the same pref twice. This shouldn't leak. */
|
||||
pb.addObserver("UserPref.nonexistent.setIntPref", observer);
|
||||
pb.addObserver("UserPref.nonexistent.setIntPref", observer);
|
||||
Services.prefs.addObserver("UserPref.nonexistent.setIntPref", observer);
|
||||
Services.prefs.addObserver("UserPref.nonexistent.setIntPref", observer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@
|
|||
function run_test() {
|
||||
const PREF_NAME = "testPref";
|
||||
|
||||
var ps = Cc["@mozilla.org/preferences-service;1"]
|
||||
.getService(Ci.nsIPrefService);
|
||||
var prefs = ps.getDefaultBranch(null);
|
||||
var userprefs = ps.getBranch(null);
|
||||
var prefs = Services.prefs.getDefaultBranch(null);
|
||||
var userprefs = Services.prefs.getBranch(null);
|
||||
|
||||
/* First, test to make sure we can parse a float from a string properly. */
|
||||
prefs.setCharPref(PREF_NAME, "9.674");
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ const PREF_INT = 64;
|
|||
const PREF_STRING = 32;
|
||||
|
||||
function run_test() {
|
||||
var ps = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefService);
|
||||
var ps = Services.prefs;
|
||||
|
||||
let defaultBranch = ps.getDefaultBranch("");
|
||||
let userBranch = ps.getBranch("");
|
||||
|
|
|
|||
|
|
@ -5,10 +5,7 @@
|
|||
/* Tests for providing a default value to get{Bool,Char,Float,Int}Pref */
|
||||
|
||||
function run_test() {
|
||||
var ps = Cc["@mozilla.org/preferences-service;1"]
|
||||
.getService(Ci.nsIPrefService)
|
||||
.QueryInterface(Ci.nsIPrefBranch);
|
||||
|
||||
const ps = Services.prefs;
|
||||
let prefName = "test.default.values.bool";
|
||||
do_check_throws(function() { ps.getBoolPref(prefName); },
|
||||
Cr.NS_ERROR_UNEXPECTED);
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ const PREF_INT = 64;
|
|||
const PREF_STRING = 32;
|
||||
|
||||
function run_test() {
|
||||
var ps = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefService);
|
||||
const ps = Services.prefs;
|
||||
|
||||
let defaultBranch = ps.getDefaultBranch("");
|
||||
let userBranch = ps.getBranch("");
|
||||
|
|
|
|||
|
|
@ -18,153 +18,146 @@ function makeList(a) {
|
|||
}
|
||||
|
||||
function run_test() {
|
||||
var ps = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefService);
|
||||
|
||||
var pb2 = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
|
||||
var pb = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
const ps = Services.prefs;
|
||||
|
||||
//* *************************************************************************//
|
||||
// Nullsafety
|
||||
|
||||
do_check_throws(function() {
|
||||
pb.getPrefType(null);
|
||||
ps.getPrefType(null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.getBoolPref(null);
|
||||
ps.getBoolPref(null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.setBoolPref(null, false);
|
||||
ps.setBoolPref(null, false);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.getIntPref(null);
|
||||
ps.getIntPref(null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.setIntPref(null, 0);
|
||||
ps.setIntPref(null, 0);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.getCharPref(null);
|
||||
ps.getCharPref(null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.setCharPref(null, null);
|
||||
ps.setCharPref(null, null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.getStringPref(null);
|
||||
ps.getStringPref(null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.setStringPref(null, null);
|
||||
ps.setStringPref(null, null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.clearUserPref(null);
|
||||
ps.clearUserPref(null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.prefHasUserValue(null);
|
||||
ps.prefHasUserValue(null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.lockPref(null);
|
||||
ps.lockPref(null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.prefIsLocked(null);
|
||||
ps.prefIsLocked(null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.unlockPref(null);
|
||||
ps.unlockPref(null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.deleteBranch(null);
|
||||
ps.deleteBranch(null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
do_check_throws(function() {
|
||||
pb.getChildList(null);
|
||||
ps.getChildList(null);
|
||||
}, Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
//* *************************************************************************//
|
||||
// Nonexisting user preferences
|
||||
|
||||
Assert.equal(pb.prefHasUserValue("UserPref.nonexistent.hasUserValue"), false);
|
||||
pb.clearUserPref("UserPref.nonexistent.clearUserPref"); // shouldn't throw
|
||||
Assert.equal(pb.getPrefType("UserPref.nonexistent.getPrefType"), PREF_INVALID);
|
||||
Assert.equal(pb.root, "");
|
||||
Assert.equal(ps.prefHasUserValue("UserPref.nonexistent.hasUserValue"), false);
|
||||
ps.clearUserPref("UserPref.nonexistent.clearUserPref"); // shouldn't throw
|
||||
Assert.equal(ps.getPrefType("UserPref.nonexistent.getPrefType"), PREF_INVALID);
|
||||
Assert.equal(ps.root, "");
|
||||
|
||||
// bool...
|
||||
do_check_throws(function() {
|
||||
pb.getBoolPref("UserPref.nonexistent.getBoolPref");
|
||||
ps.getBoolPref("UserPref.nonexistent.getBoolPref");
|
||||
}, Cr.NS_ERROR_UNEXPECTED);
|
||||
pb.setBoolPref("UserPref.nonexistent.setBoolPref", false);
|
||||
Assert.equal(pb.getBoolPref("UserPref.nonexistent.setBoolPref"), false);
|
||||
ps.setBoolPref("UserPref.nonexistent.setBoolPref", false);
|
||||
Assert.equal(ps.getBoolPref("UserPref.nonexistent.setBoolPref"), false);
|
||||
|
||||
// int...
|
||||
do_check_throws(function() {
|
||||
pb.getIntPref("UserPref.nonexistent.getIntPref");
|
||||
ps.getIntPref("UserPref.nonexistent.getIntPref");
|
||||
}, Cr.NS_ERROR_UNEXPECTED);
|
||||
pb.setIntPref("UserPref.nonexistent.setIntPref", 5);
|
||||
Assert.equal(pb.getIntPref("UserPref.nonexistent.setIntPref"), 5);
|
||||
ps.setIntPref("UserPref.nonexistent.setIntPref", 5);
|
||||
Assert.equal(ps.getIntPref("UserPref.nonexistent.setIntPref"), 5);
|
||||
|
||||
// char
|
||||
do_check_throws(function() {
|
||||
pb.getCharPref("UserPref.nonexistent.getCharPref");
|
||||
ps.getCharPref("UserPref.nonexistent.getCharPref");
|
||||
}, Cr.NS_ERROR_UNEXPECTED);
|
||||
pb.setCharPref("UserPref.nonexistent.setCharPref", "_test");
|
||||
Assert.equal(pb.getCharPref("UserPref.nonexistent.setCharPref"), "_test");
|
||||
ps.setCharPref("UserPref.nonexistent.setCharPref", "_test");
|
||||
Assert.equal(ps.getCharPref("UserPref.nonexistent.setCharPref"), "_test");
|
||||
|
||||
//* *************************************************************************//
|
||||
// Existing user Prefs and data integrity test (round-trip match)
|
||||
|
||||
pb.setBoolPref("UserPref.existing.bool", true);
|
||||
pb.setIntPref("UserPref.existing.int", 23);
|
||||
pb.setCharPref("UserPref.existing.char", "hey");
|
||||
ps.setBoolPref("UserPref.existing.bool", true);
|
||||
ps.setIntPref("UserPref.existing.int", 23);
|
||||
ps.setCharPref("UserPref.existing.char", "hey");
|
||||
|
||||
// getPref should return the pref value
|
||||
Assert.equal(pb.getBoolPref("UserPref.existing.bool"), true);
|
||||
Assert.equal(pb.getIntPref("UserPref.existing.int"), 23);
|
||||
Assert.equal(pb.getCharPref("UserPref.existing.char"), "hey");
|
||||
Assert.equal(ps.getBoolPref("UserPref.existing.bool"), true);
|
||||
Assert.equal(ps.getIntPref("UserPref.existing.int"), 23);
|
||||
Assert.equal(ps.getCharPref("UserPref.existing.char"), "hey");
|
||||
|
||||
// setPref should not complain and should change the value of the pref
|
||||
pb.setBoolPref("UserPref.existing.bool", false);
|
||||
Assert.equal(pb.getBoolPref("UserPref.existing.bool"), false);
|
||||
pb.setIntPref("UserPref.existing.int", 24);
|
||||
Assert.equal(pb.getIntPref("UserPref.existing.int"), 24);
|
||||
pb.setCharPref("UserPref.existing.char", "hej då!");
|
||||
Assert.equal(pb.getCharPref("UserPref.existing.char"), "hej då!");
|
||||
ps.setBoolPref("UserPref.existing.bool", false);
|
||||
Assert.equal(ps.getBoolPref("UserPref.existing.bool"), false);
|
||||
ps.setIntPref("UserPref.existing.int", 24);
|
||||
Assert.equal(ps.getIntPref("UserPref.existing.int"), 24);
|
||||
ps.setCharPref("UserPref.existing.char", "hej då!");
|
||||
Assert.equal(ps.getCharPref("UserPref.existing.char"), "hej då!");
|
||||
|
||||
// prefHasUserValue should return true now
|
||||
Assert.ok(pb.prefHasUserValue("UserPref.existing.bool"));
|
||||
Assert.ok(pb.prefHasUserValue("UserPref.existing.int"));
|
||||
Assert.ok(pb.prefHasUserValue("UserPref.existing.char"));
|
||||
Assert.ok(ps.prefHasUserValue("UserPref.existing.bool"));
|
||||
Assert.ok(ps.prefHasUserValue("UserPref.existing.int"));
|
||||
Assert.ok(ps.prefHasUserValue("UserPref.existing.char"));
|
||||
|
||||
// clearUserPref should remove the pref
|
||||
pb.clearUserPref("UserPref.existing.bool");
|
||||
Assert.ok(!pb.prefHasUserValue("UserPref.existing.bool"));
|
||||
pb.clearUserPref("UserPref.existing.int");
|
||||
Assert.ok(!pb.prefHasUserValue("UserPref.existing.int"));
|
||||
pb.clearUserPref("UserPref.existing.char");
|
||||
Assert.ok(!pb.prefHasUserValue("UserPref.existing.char"));
|
||||
ps.clearUserPref("UserPref.existing.bool");
|
||||
Assert.ok(!ps.prefHasUserValue("UserPref.existing.bool"));
|
||||
ps.clearUserPref("UserPref.existing.int");
|
||||
Assert.ok(!ps.prefHasUserValue("UserPref.existing.int"));
|
||||
ps.clearUserPref("UserPref.existing.char");
|
||||
Assert.ok(!ps.prefHasUserValue("UserPref.existing.char"));
|
||||
|
||||
//* *************************************************************************//
|
||||
// Large value test
|
||||
|
||||
let largeStr = new Array(MAX_PREF_LENGTH + 1).join("x");
|
||||
pb.setCharPref("UserPref.large.char", largeStr);
|
||||
ps.setCharPref("UserPref.large.char", largeStr);
|
||||
largeStr += "x";
|
||||
do_check_throws(function() {
|
||||
pb.setCharPref("UserPref.large.char", largeStr);
|
||||
ps.setCharPref("UserPref.large.char", largeStr);
|
||||
}, Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
|
||||
//* *************************************************************************//
|
||||
// getPrefType test
|
||||
|
||||
// bool...
|
||||
pb.setBoolPref("UserPref.getPrefType.bool", true);
|
||||
Assert.equal(pb.getPrefType("UserPref.getPrefType.bool"), PREF_BOOL);
|
||||
ps.setBoolPref("UserPref.getPrefType.bool", true);
|
||||
Assert.equal(ps.getPrefType("UserPref.getPrefType.bool"), PREF_BOOL);
|
||||
|
||||
// int...
|
||||
pb.setIntPref("UserPref.getPrefType.int", -234);
|
||||
Assert.equal(pb.getPrefType("UserPref.getPrefType.int"), PREF_INT);
|
||||
ps.setIntPref("UserPref.getPrefType.int", -234);
|
||||
Assert.equal(ps.getPrefType("UserPref.getPrefType.int"), PREF_INT);
|
||||
|
||||
// char...
|
||||
pb.setCharPref("UserPref.getPrefType.char", "testing1..2");
|
||||
Assert.equal(pb.getPrefType("UserPref.getPrefType.char"), PREF_STRING);
|
||||
ps.setCharPref("UserPref.getPrefType.char", "testing1..2");
|
||||
Assert.equal(ps.getPrefType("UserPref.getPrefType.char"), PREF_STRING);
|
||||
|
||||
//* *************************************************************************//
|
||||
// getBranch tests
|
||||
|
|
@ -172,7 +165,7 @@ function run_test() {
|
|||
Assert.equal(ps.root, "");
|
||||
|
||||
// bool ...
|
||||
pb.setBoolPref("UserPref.root.boolPref", true);
|
||||
ps.setBoolPref("UserPref.root.boolPref", true);
|
||||
let pb_1 = ps.getBranch("UserPref.root.");
|
||||
Assert.equal(pb_1.getBoolPref("boolPref"), true);
|
||||
let pb_2 = ps.getBranch("UserPref.root.boolPref");
|
||||
|
|
@ -182,7 +175,7 @@ function run_test() {
|
|||
Assert.equal(pb_3.getBoolPref("f.anotherPref"), false);
|
||||
|
||||
// int ...
|
||||
pb.setIntPref("UserPref.root.intPref", 23);
|
||||
ps.setIntPref("UserPref.root.intPref", 23);
|
||||
pb_1 = ps.getBranch("UserPref.root.");
|
||||
Assert.equal(pb_1.getIntPref("intPref"), 23);
|
||||
pb_2 = ps.getBranch("UserPref.root.intPref");
|
||||
|
|
@ -192,7 +185,7 @@ function run_test() {
|
|||
Assert.equal(pb_3.getIntPref("f.anotherPref"), 69);
|
||||
|
||||
// char...
|
||||
pb.setCharPref("UserPref.root.charPref", "_char");
|
||||
ps.setCharPref("UserPref.root.charPref", "_char");
|
||||
pb_1 = ps.getBranch("UserPref.root.");
|
||||
Assert.equal(pb_1.getCharPref("charPref"), "_char");
|
||||
pb_2 = ps.getBranch("UserPref.root.charPref");
|
||||
|
|
@ -205,7 +198,7 @@ function run_test() {
|
|||
// getChildlist tests
|
||||
|
||||
// get an already set prefBranch
|
||||
pb1 = ps.getBranch("UserPref.root.");
|
||||
let pb1 = ps.getBranch("UserPref.root.");
|
||||
let prefList = pb1.getChildList("");
|
||||
Assert.equal(prefList.length, 6);
|
||||
|
||||
|
|
@ -297,7 +290,7 @@ function run_test() {
|
|||
// ps.deleteBranch("UserPref.nonexistent.deleteBranch");}, Cr.NS_ERROR_UNEXPECTED);
|
||||
|
||||
ps.deleteBranch("DefaultPref");
|
||||
pb = ps.getBranch("DefaultPref");
|
||||
let pb = ps.getBranch("DefaultPref");
|
||||
pb1 = ps.getDefaultBranch("DefaultPref");
|
||||
|
||||
// getting prefs on deleted user branches should throw
|
||||
|
|
@ -426,15 +419,15 @@ function run_test() {
|
|||
do_test_pending();
|
||||
do_test_pending();
|
||||
|
||||
let observer = new PrefObserver(pb2, "ReadPref.int", 76);
|
||||
let observer = new PrefObserver(ps, "ReadPref.int", 76);
|
||||
ps.setIntPref("ReadPref.int", 76);
|
||||
|
||||
// removed observer should not fire
|
||||
pb2.removeObserver("ReadPref.int", observer);
|
||||
ps.removeObserver("ReadPref.int", observer);
|
||||
ps.setIntPref("ReadPref.int", 32);
|
||||
|
||||
// let's test observers once more with a non-root prefbranch
|
||||
pb = pb2.getBranch("ReadPref.");
|
||||
pb = ps.getBranch("ReadPref.");
|
||||
observer = new PrefObserver(pb, "int", 76);
|
||||
ps.setIntPref("ReadPref.int", 76);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,6 @@
|
|||
|
||||
// This file tests the `locked` attribute in default pref files.
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const ps = Services.prefs;
|
||||
|
||||
add_test(function notChangedFromAPI() {
|
||||
|
|
|
|||
|
|
@ -2,12 +2,7 @@
|
|||
* http://creativecommons.org/licenses/publicdomain/ */
|
||||
|
||||
function run_test() {
|
||||
const PREF_NAME = "testPref";
|
||||
|
||||
var ps = Cc["@mozilla.org/preferences-service;1"]
|
||||
.getService(Ci.nsIPrefService);
|
||||
var defaultPrefs = ps.getDefaultBranch(null);
|
||||
var prefs = ps.getBranch(null);
|
||||
const ps = Services.prefs;
|
||||
|
||||
ps.resetPrefs();
|
||||
ps.readDefaultPrefsFromFile(do_get_file("data/testParser.js"));
|
||||
|
|
@ -35,7 +30,7 @@ function run_test() {
|
|||
Assert.equal(ps.getIntPref("int.+ 345"), 345);
|
||||
Assert.equal(ps.getIntPref("int.-0"), -0);
|
||||
Assert.equal(ps.getIntPref("int.-1"), -1);
|
||||
Assert.equal(ps.getIntPref("int.- /* hmm */ 456"), -456);
|
||||
Assert.equal(ps.getIntPref("int.- /* hmm */\t456"), -456);
|
||||
Assert.equal(ps.getIntPref("int.-\n567"), -567);
|
||||
Assert.equal(ps.getIntPref("int.INT_MAX-1"), 2147483646);
|
||||
Assert.equal(ps.getIntPref("int.INT_MAX"), 2147483647);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/ */
|
||||
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const ps = Services.prefs;
|
||||
|
||||
// A little helper to reset the service and load one pref file.
|
||||
|
|
|
|||
|
|
@ -2,12 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
var cs = Cc["@mozilla.org/consoleservice;1"].
|
||||
getService(Ci.nsIConsoleService);
|
||||
var ps = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefService);
|
||||
|
||||
function makeBuffer(length) {
|
||||
return new Array(length + 1).join("x");
|
||||
}
|
||||
|
|
@ -31,7 +25,7 @@ function checkWarning(pref, buffer) {
|
|||
}
|
||||
complete = true;
|
||||
info("Warning while setting " + pref);
|
||||
cs.unregisterListener(listener);
|
||||
Services.console.unregisterListener(listener);
|
||||
resolve(true);
|
||||
},
|
||||
};
|
||||
|
|
@ -41,11 +35,11 @@ function checkWarning(pref, buffer) {
|
|||
}
|
||||
complete = true;
|
||||
info("No warning while setting " + pref);
|
||||
cs.unregisterListener(listener);
|
||||
Services.console.unregisterListener(listener);
|
||||
resolve(false);
|
||||
});
|
||||
cs.registerListener(listener);
|
||||
ps.setCharPref(pref, buffer);
|
||||
Services.console.registerListener(listener);
|
||||
Services.prefs.setCharPref(pref, buffer);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function isParentProcess() {
|
||||
let appInfo = Cc["@mozilla.org/xre/app-info;1"];
|
||||
return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
||||
return (!appInfo || Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
if (isParentProcess() == false) {
|
||||
if (!isParentProcess()) {
|
||||
do_load_child_test_harness();
|
||||
|
||||
var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
var pb = Services.prefs;
|
||||
pb.setBoolPref("Test.IPC.bool.new", true);
|
||||
pb.setIntPref("Test.IPC.int.new", 23);
|
||||
pb.setCharPref("Test.IPC.char.new", "hey");
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function isParentProcess() {
|
||||
let appInfo = Cc["@mozilla.org/xre/app-info;1"];
|
||||
return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
||||
return (Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
if (isParentProcess() == false) {
|
||||
var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
if (!isParentProcess()) {
|
||||
const pb = Services.prefs;
|
||||
pb.setBoolPref("Test.IPC.bool", true);
|
||||
pb.setIntPref("Test.IPC.int", 23);
|
||||
pb.setCharPref("Test.IPC.char", "hey");
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@
|
|||
// Large preferences should not be set in the child process.
|
||||
// Non-string preferences are not tested here, because their behavior
|
||||
// should not be affected by this filtering.
|
||||
//
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function isParentProcess() {
|
||||
let appInfo = Cc["@mozilla.org/xre/app-info;1"];
|
||||
return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
||||
return (Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
function makeBuffer(length) {
|
||||
|
|
@ -46,9 +47,8 @@ function expectedPrefValue(def, user) {
|
|||
}
|
||||
|
||||
function run_test() {
|
||||
let pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
let ps = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
|
||||
let defaultBranch = ps.getDefaultBranch("");
|
||||
const pb = Services.prefs;
|
||||
let defaultBranch = pb.getDefaultBranch("");
|
||||
|
||||
let isParent = isParentProcess();
|
||||
if (isParent) {
|
||||
|
|
|
|||
|
|
@ -4,13 +4,14 @@
|
|||
|
||||
// Locked status should be communicated to children.
|
||||
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function isParentProcess() {
|
||||
let appInfo = Cc["@mozilla.org/xre/app-info;1"];
|
||||
return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
||||
return (Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
let pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
const pb = Services.prefs;
|
||||
|
||||
let bprefname = "Test.IPC.locked.bool";
|
||||
let iprefname = "Test.IPC.locked.int";
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function isParentProcess() {
|
||||
let appInfo = Cc["@mozilla.org/xre/app-info;1"];
|
||||
return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
||||
return (Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
if (isParentProcess() == false) {
|
||||
var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
if (!isParentProcess()) {
|
||||
const pb = Services.prefs;
|
||||
Assert.equal(pb.getBoolPref("Test.IPC.bool.new"), true);
|
||||
Assert.equal(pb.getIntPref("Test.IPC.int.new"), 23);
|
||||
Assert.equal(pb.getCharPref("Test.IPC.char.new"), "hey");
|
||||
|
|
|
|||
|
|
@ -152,7 +152,6 @@ const PREFS = [
|
|||
|
||||
for (let {type, values} of PREFS) {
|
||||
let set = `set${type}Pref`;
|
||||
let get = `get${type}Pref`;
|
||||
|
||||
function prefTest(opts) {
|
||||
function check(pref, proc, val, {expectedVal, defaultVal = undefined, expectedDefault = defaultVal, expectedFlags = {}}) {
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ const {ExtensionTestUtils} = ChromeUtils.import("resource://testing-common/Exten
|
|||
|
||||
ExtensionTestUtils.init(this);
|
||||
|
||||
let contentPage;
|
||||
|
||||
const {prefs} = Services;
|
||||
const defaultPrefs = prefs.getDefaultBranch("");
|
||||
|
||||
|
|
@ -52,14 +50,15 @@ add_task(async function test_sharedMap_var_caches() {
|
|||
let contentPage = await ExtensionTestUtils.loadContentPage("about:blank", {remote: true});
|
||||
registerCleanupFunction(() => contentPage.close());
|
||||
|
||||
/* eslint-disable no-shadow */
|
||||
let values = await contentPage.spawn([PREF1_NAME, PREF2_NAME], (prefs) => {
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
return prefs.map(pref => Services.prefs.getBoolPref(pref));
|
||||
});
|
||||
/* eslint-enable no-shadow */
|
||||
|
||||
equal(values[0], !PREF1_VALUE,
|
||||
`Expected content value for ${PREF1_NAME}`);
|
||||
equal(values[1], !PREF2_VALUE,
|
||||
`Expected content value for ${PREF2_NAME}`);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function isParentProcess() {
|
||||
let appInfo = Cc["@mozilla.org/xre/app-info;1"];
|
||||
return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
||||
return Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
if (isParentProcess()) {
|
||||
do_load_child_test_harness();
|
||||
|
||||
var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
var pb = Services.prefs;
|
||||
|
||||
// these prefs are set after the child has been created.
|
||||
pb.setBoolPref("Test.IPC.bool.new", true);
|
||||
|
|
@ -19,7 +20,7 @@ function run_test() {
|
|||
}
|
||||
|
||||
function testPrefClear() {
|
||||
var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
var pb = Services.prefs;
|
||||
pb.clearUserPref("Test.IPC.bool.new");
|
||||
|
||||
sendCommand(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const pb = Services.prefs;
|
||||
|
||||
// This pref is chosen somewhat arbitrarily --- we just need one
|
||||
// that's guaranteed to have a default value.
|
||||
|
|
|
|||
Loading…
Reference in a new issue