summaryrefslogtreecommitdiffstats
path: root/toolkit/modules/tests/xpcshell
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/modules/tests/xpcshell')
-rw-r--r--toolkit/modules/tests/xpcshell/test_DeferredTask.js2
-rw-r--r--toolkit/modules/tests/xpcshell/test_FinderIterator.js28
-rw-r--r--toolkit/modules/tests/xpcshell/test_GMPInstallManager.js67
-rw-r--r--toolkit/modules/tests/xpcshell/test_Integration.js2
-rw-r--r--toolkit/modules/tests/xpcshell/test_Log.js3
-rw-r--r--toolkit/modules/tests/xpcshell/test_PermissionsUtils.js2
-rw-r--r--toolkit/modules/tests/xpcshell/test_UpdateUtils_updatechannel.js1
-rw-r--r--toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js1
-rw-r--r--toolkit/modules/tests/xpcshell/test_sqlite.js37
-rw-r--r--toolkit/modules/tests/xpcshell/test_web_channel.js4
-rw-r--r--toolkit/modules/tests/xpcshell/test_web_channel_broker.js2
11 files changed, 97 insertions, 52 deletions
diff --git a/toolkit/modules/tests/xpcshell/test_DeferredTask.js b/toolkit/modules/tests/xpcshell/test_DeferredTask.js
index e6c58e03db..cb1cc2d600 100644
--- a/toolkit/modules/tests/xpcshell/test_DeferredTask.js
+++ b/toolkit/modules/tests/xpcshell/test_DeferredTask.js
@@ -389,7 +389,7 @@ add_test(function test_finalize() {
let finalized = false;
// Let idleDispatch take longer.
- replaceIdleDispatch((callback, timeout) => {
+ replaceIdleDispatch(callback => {
Assert.ok(!idleStarted);
idleStarted = true;
do_timeout(T, callback);
diff --git a/toolkit/modules/tests/xpcshell/test_FinderIterator.js b/toolkit/modules/tests/xpcshell/test_FinderIterator.js
index fcbe97ba5f..5125740c55 100644
--- a/toolkit/modules/tests/xpcshell/test_FinderIterator.js
+++ b/toolkit/modules/tests/xpcshell/test_FinderIterator.js
@@ -7,7 +7,7 @@ let finderIterator = new FinderIterator();
var gFindResults = [];
// Stub the method that instantiates nsIFind and does all the interaction with
// the docShell to be searched through.
-finderIterator._iterateDocument = function* (word, window, finder) {
+finderIterator._iterateDocument = function* () {
for (let range of gFindResults) {
yield range;
}
@@ -117,7 +117,7 @@ add_task(async function test_valid_arguments() {
entireWord: false,
finder: gMockFinder,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count;
},
},
@@ -136,7 +136,7 @@ add_task(async function test_valid_arguments() {
finderIterator.start({
entireWord: false,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count;
},
},
@@ -154,7 +154,7 @@ add_task(async function test_valid_arguments() {
caseSensitive: false,
entireWord: false,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count;
},
},
@@ -170,7 +170,7 @@ add_task(async function test_valid_arguments() {
finderIterator.start({
caseSensitive: false,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count;
},
},
@@ -188,7 +188,7 @@ add_task(async function test_valid_arguments() {
caseSensitive: false,
entireWord: false,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count;
},
},
@@ -221,7 +221,7 @@ add_task(async function test_valid_arguments() {
entireWord: true,
finder: gMockFinder,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count;
},
},
@@ -246,7 +246,7 @@ add_task(async function test_stop() {
entireWord: false,
finder: gMockFinder,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count;
},
},
@@ -274,7 +274,7 @@ add_task(async function test_reset() {
entireWord: false,
finder: gMockFinder,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count;
},
},
@@ -317,7 +317,7 @@ add_task(async function test_parallel_starts() {
entireWord: false,
finder: gMockFinder,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count;
},
},
@@ -334,7 +334,7 @@ add_task(async function test_parallel_starts() {
entireWord: false,
finder: gMockFinder,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count2;
},
},
@@ -385,7 +385,7 @@ add_task(async function test_allowDistance() {
entireWord: false,
finder: gMockFinder,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count;
},
},
@@ -399,7 +399,7 @@ add_task(async function test_allowDistance() {
entireWord: false,
finder: gMockFinder,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count2;
},
},
@@ -414,7 +414,7 @@ add_task(async function test_allowDistance() {
entireWord: false,
finder: gMockFinder,
listener: {
- onIteratorRangeFound(range) {
+ onIteratorRangeFound() {
++count3;
},
},
diff --git a/toolkit/modules/tests/xpcshell/test_GMPInstallManager.js b/toolkit/modules/tests/xpcshell/test_GMPInstallManager.js
index a0d12b8a6a..be1be93968 100644
--- a/toolkit/modules/tests/xpcshell/test_GMPInstallManager.js
+++ b/toolkit/modules/tests/xpcshell/test_GMPInstallManager.js
@@ -837,6 +837,60 @@ add_task(async function test_checkForAddons_contentSignatureFailure() {
});
/**
+ * Tests that the signature verification URL is as expected.
+ */
+add_task(async function test_checkForAddons_get_verifier_url() {
+ const previousUrlOverride = setupContentSigTestPrefs();
+
+ let installManager = new GMPInstallManager();
+ // checkForAddons() calls _getContentSignatureRootForURL() with the return
+ // value of _getURL(), which is effectively KEY_URL_OVERRIDE or KEY_URL
+ // followed by some normalization.
+ const rootForUrl = async () => {
+ const url = await installManager._getURL();
+ return installManager._getContentSignatureRootForURL(url);
+ };
+
+ Assert.equal(
+ await rootForUrl(),
+ Ci.nsIX509CertDB.AppXPCShellRoot,
+ "XPCShell root used by default in xpcshell test"
+ );
+
+ const defaultPrefs = Services.prefs.getDefaultBranch("");
+ const defaultUrl = defaultPrefs.getStringPref(GMPPrefs.KEY_URL);
+ Preferences.set(GMPPrefs.KEY_URL_OVERRIDE, defaultUrl);
+ Assert.equal(
+ await rootForUrl(),
+ Ci.nsIContentSignatureVerifier.ContentSignatureProdRoot,
+ "Production cert should be used for the default Balrog URL: " + defaultUrl
+ );
+
+ // The current Balrog endpoint is at aus5.mozilla.org. Confirm that the prod
+ // cert is used even if we bump the version (e.g. aus6):
+ const potentialProdUrl = "https://aus1337.mozilla.org/potential/prod/URL";
+ Preferences.set(GMPPrefs.KEY_URL_OVERRIDE, potentialProdUrl);
+ Assert.equal(
+ await rootForUrl(),
+ Ci.nsIContentSignatureVerifier.ContentSignatureProdRoot,
+ "Production cert should be used for: " + potentialProdUrl
+ );
+
+ // Stage URL documented at https://mozilla-balrog.readthedocs.io/en/latest/infrastructure.html
+ const stageUrl = "https://stage.balrog.nonprod.cloudops.mozgcp.net/etc.";
+ Preferences.set(GMPPrefs.KEY_URL_OVERRIDE, stageUrl);
+ Assert.equal(
+ await rootForUrl(),
+ Ci.nsIContentSignatureVerifier.ContentSignatureStageRoot,
+ "Stage cert should be used with the stage URL: " + stageUrl
+ );
+
+ installManager.uninit();
+
+ revertContentSigTestPrefs(previousUrlOverride);
+});
+
+/**
* Tests that checkForAddons() works as expected when certificate pinning
* checking is enabled. We plan to move away from cert pinning in favor of
* content signature checks, but part of doing this is comparing the telemetry
@@ -1175,7 +1229,7 @@ add_test(function test_installAddon_noServer() {
GMPInstallManager.overrideLeaveDownloadedZip = true;
let installPromise = installManager.installAddon(gmpAddon);
installPromise.then(
- extractedPaths => {
+ () => {
do_throw("No server for install should reject");
},
err => {
@@ -1324,8 +1378,8 @@ function mockRequest(inputStatus, inputResponse, options) {
this._options = options || {};
}
mockRequest.prototype = {
- overrideMimeType(aMimetype) {},
- setRequestHeader(aHeader, aValue) {},
+ overrideMimeType() {},
+ setRequestHeader() {},
status: null,
channel: { set notificationCallbacks(aVal) {} },
open(aMethod, aUrl) {
@@ -1339,7 +1393,7 @@ mockRequest.prototype = {
},
responseXML: null,
responseText: null,
- send(aBody) {
+ send() {
executeSoon(() => {
try {
if (this._options.dropRequest) {
@@ -1427,9 +1481,8 @@ mockRequest.prototype = {
}
}
},
- addEventListener(aEvent, aValue, aCapturing) {
- // eslint-disable-next-line no-eval
- eval("this._on" + aEvent + " = aValue");
+ addEventListener(aEvent, aValue) {
+ this[`_on${aEvent}`] = aValue;
},
get wrappedJSObject() {
return this;
diff --git a/toolkit/modules/tests/xpcshell/test_Integration.js b/toolkit/modules/tests/xpcshell/test_Integration.js
index 8213e32592..d0f53cc22a 100644
--- a/toolkit/modules/tests/xpcshell/test_Integration.js
+++ b/toolkit/modules/tests/xpcshell/test_Integration.js
@@ -170,7 +170,7 @@ add_task(async function test_override_super_multiple() {
* ensures that this does not block other functions from being registered.
*/
add_task(async function test_override_error() {
- let errorOverrideFn = base => {
+ let errorOverrideFn = () => {
throw new Error("Expected error.");
};
diff --git a/toolkit/modules/tests/xpcshell/test_Log.js b/toolkit/modules/tests/xpcshell/test_Log.js
index c9fc367dc3..5989dbb78f 100644
--- a/toolkit/modules/tests/xpcshell/test_Log.js
+++ b/toolkit/modules/tests/xpcshell/test_Log.js
@@ -362,7 +362,6 @@ add_task(async function log_template_literal_message() {
/*
* Check that we format JS Errors reasonably.
- * This needs to stay a generator to exercise Task.jsm's stack rewriting.
*/
add_task(async function format_errors() {
let pFormat = new Log.ParameterFormatter();
@@ -386,8 +385,6 @@ add_task(async function format_errors() {
// lineNumber:columnNumber.
Assert.ok(str.includes(":1:12)"));
// Make sure that we use human-readable stack traces
- // Check that the error doesn't contain any reference to "Task.jsm"
- Assert.ok(!str.includes("Task.jsm"));
Assert.ok(str.includes("format_errors"));
}
});
diff --git a/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js b/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js
index a712044359..80154a0c67 100644
--- a/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js
+++ b/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js
@@ -2,7 +2,7 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// Tests that PerrmissionsUtils.jsm works as expected, including:
+// Tests that PerrmissionsUtils.sys.mjs works as expected, including:
// * PermissionsUtils.importfromPrefs()
// <ROOT>.[whitelist|blacklist].add preferences are emptied when
// converted into permissions on startup.
diff --git a/toolkit/modules/tests/xpcshell/test_UpdateUtils_updatechannel.js b/toolkit/modules/tests/xpcshell/test_UpdateUtils_updatechannel.js
index 81db867ba4..2dc4654492 100644
--- a/toolkit/modules/tests/xpcshell/test_UpdateUtils_updatechannel.js
+++ b/toolkit/modules/tests/xpcshell/test_UpdateUtils_updatechannel.js
@@ -25,6 +25,7 @@ add_task(async function test_updatechannel() {
Assert.equal(UpdateUtils.getUpdateChannel(true), currentChannel);
Assert.equal(UpdateUtils.getUpdateChannel(false), currentChannel);
+ defaultPrefs.unlock(PREF_APP_UPDATE_CHANNEL);
defaultPrefs.set(PREF_APP_UPDATE_CHANNEL, TEST_CHANNEL);
Assert.equal(UpdateUtils.UpdateChannel, TEST_CHANNEL);
Assert.equal(UpdateUtils.getUpdateChannel(true), TEST_CHANNEL);
diff --git a/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js b/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js
index 00176a5f3a..b8618291f8 100644
--- a/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js
+++ b/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js
@@ -34,6 +34,7 @@ const gAppInfo = getAppInfo();
const gDefaultPrefBranch = Services.prefs.getDefaultBranch(null);
function setUpdateChannel(aChannel) {
+ gDefaultPrefBranch.unlockPref(PREF_APP_UPDATE_CHANNEL);
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_CHANNEL, aChannel);
}
diff --git a/toolkit/modules/tests/xpcshell/test_sqlite.js b/toolkit/modules/tests/xpcshell/test_sqlite.js
index e0a79e137d..bea349ded4 100644
--- a/toolkit/modules/tests/xpcshell/test_sqlite.js
+++ b/toolkit/modules/tests/xpcshell/test_sqlite.js
@@ -334,12 +334,9 @@ add_task(async function test_execute_invalid_statement() {
await new Promise(resolve => {
Assert.equal(c._connectionData._anonymousStatements.size, 0);
- c.execute("SELECT invalid FROM unknown").then(
- do_throw,
- function onError(error) {
- resolve();
- }
- );
+ c.execute("SELECT invalid FROM unknown").then(do_throw, function onError() {
+ resolve();
+ });
});
// Ensure we don't leak the statement instance.
@@ -366,15 +363,11 @@ add_task(async function test_on_row_exception_ignored() {
}
let i = 0;
- let hasResult = await c.execute(
- "SELECT * FROM DIRS",
- null,
- function onRow(row) {
- i++;
+ let hasResult = await c.execute("SELECT * FROM DIRS", null, function onRow() {
+ i++;
- throw new Error("Some silly error.");
- }
- );
+ throw new Error("Some silly error.");
+ });
Assert.equal(hasResult, true);
Assert.equal(i, 10);
@@ -418,7 +411,7 @@ add_task(async function test_on_row_stop_iteration() {
let hasResult = await c.execute(
`SELECT * FROM dirs WHERE path="nonexistent"`,
null,
- function onRow(row) {
+ function onRow() {
i++;
}
);
@@ -473,7 +466,7 @@ add_task(async function test_execute_transaction_rollback() {
// We should never get here.
do_throw();
- }).then(do_throw, function onError(error) {
+ }).then(do_throw, function onError() {
deferred.resolve();
});
@@ -490,7 +483,7 @@ add_task(async function test_close_during_transaction() {
await c.execute("INSERT INTO dirs (path) VALUES ('foo')");
- let promise = c.executeTransaction(async function transaction(conn) {
+ let promise = c.executeTransaction(async function transaction() {
await c.execute("INSERT INTO dirs (path) VALUES ('bar')");
});
await c.close();
@@ -801,7 +794,7 @@ add_task(async function test_discard_while_active() {
let discarded = -1;
let first = true;
let sql = "SELECT * FROM dirs";
- await c.executeCached(sql, null, function onRow(row) {
+ await c.executeCached(sql, null, function onRow() {
if (!first) {
return;
}
@@ -1010,7 +1003,7 @@ add_task(async function test_direct() {
let deferred = Promise.withResolvers();
begin.executeAsync({
- handleCompletion(reason) {
+ handleCompletion() {
deferred.resolve();
},
});
@@ -1021,7 +1014,7 @@ add_task(async function test_direct() {
deferred = Promise.withResolvers();
print("Executing async.");
statement.executeAsync({
- handleResult(resultSet) {},
+ handleResult() {},
handleError(error) {
print(
@@ -1031,7 +1024,7 @@ add_task(async function test_direct() {
deferred.reject();
},
- handleCompletion(reason) {
+ handleCompletion() {
print("Completed.");
deferred.resolve();
},
@@ -1041,7 +1034,7 @@ add_task(async function test_direct() {
deferred = Promise.withResolvers();
end.executeAsync({
- handleCompletion(reason) {
+ handleCompletion() {
deferred.resolve();
},
});
diff --git a/toolkit/modules/tests/xpcshell/test_web_channel.js b/toolkit/modules/tests/xpcshell/test_web_channel.js
index 6d62762e97..a45f52efde 100644
--- a/toolkit/modules/tests/xpcshell/test_web_channel.js
+++ b/toolkit/modules/tests/xpcshell/test_web_channel.js
@@ -37,7 +37,7 @@ var MockWebChannelBroker = {
* Test channel listening with originOrPermission being an nsIURI.
*/
add_task(function test_web_channel_listen() {
- return new Promise((resolve, reject) => {
+ return new Promise(resolve => {
let channel = new WebChannel(
VALID_WEB_CHANNEL_ID,
VALID_WEB_CHANNEL_ORIGIN,
@@ -94,7 +94,7 @@ add_task(function test_web_channel_listen() {
* Test channel listening with originOrPermission being a permission string.
*/
add_task(function test_web_channel_listen_permission() {
- return new Promise((resolve, reject) => {
+ return new Promise(resolve => {
// add a new permission
PermissionTestUtils.add(
VALID_WEB_CHANNEL_ORIGIN,
diff --git a/toolkit/modules/tests/xpcshell/test_web_channel_broker.js b/toolkit/modules/tests/xpcshell/test_web_channel_broker.js
index 232e02e935..3e3d4efc0e 100644
--- a/toolkit/modules/tests/xpcshell/test_web_channel_broker.js
+++ b/toolkit/modules/tests/xpcshell/test_web_channel_broker.js
@@ -44,7 +44,7 @@ add_test(function test_web_channel_broker_channel_map() {
* Test WebChannelBroker _listener test
*/
add_task(function test_web_channel_broker_listener() {
- return new Promise((resolve, reject) => {
+ return new Promise(resolve => {
var channel = {
id: VALID_WEB_CHANNEL_ID,
_originCheckCallback: requestPrincipal => {