summaryrefslogtreecommitdiffstats
path: root/toolkit/modules/tests
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/modules/tests')
-rw-r--r--toolkit/modules/tests/browser/browser.toml2
-rw-r--r--toolkit/modules/tests/browser/browser_Deprecated.js140
-rw-r--r--toolkit/modules/tests/marionette/manifest.toml4
-rw-r--r--toolkit/modules/tests/marionette/test_first_startup.py54
-rw-r--r--toolkit/modules/tests/xpcshell/test_GMPInstallManager.js2
-rw-r--r--toolkit/modules/tests/xpcshell/test_Services.js1
-rw-r--r--toolkit/modules/tests/xpcshell/test_firstStartup.js25
-rw-r--r--toolkit/modules/tests/xpcshell/test_sqlite.js5
8 files changed, 84 insertions, 149 deletions
diff --git a/toolkit/modules/tests/browser/browser.toml b/toolkit/modules/tests/browser/browser.toml
index 932b06d19e..b3c2b9cfda 100644
--- a/toolkit/modules/tests/browser/browser.toml
+++ b/toolkit/modules/tests/browser/browser.toml
@@ -13,8 +13,6 @@ support-files = [
["browser_CreditCard.js"]
skip-if = ["apple_silicon"] # Disabled due to bleedover with other tests when run in regular suites; passes in "failures" jobs
-["browser_Deprecated.js"]
-
["browser_Finder.js"]
["browser_FinderHighlighter.js"]
diff --git a/toolkit/modules/tests/browser/browser_Deprecated.js b/toolkit/modules/tests/browser/browser_Deprecated.js
deleted file mode 100644
index b718ba37e7..0000000000
--- a/toolkit/modules/tests/browser/browser_Deprecated.js
+++ /dev/null
@@ -1,140 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-const PREF_DEPRECATION_WARNINGS = "devtools.errorconsole.deprecation_warnings";
-
-// Using this named functions to test deprecation and the properly logged
-// callstacks.
-function basicDeprecatedFunction() {
- Deprecated.warning("this method is deprecated.", "https://example.com");
- return true;
-}
-
-function deprecationFunctionBogusCallstack() {
- Deprecated.warning("this method is deprecated.", "https://example.com", {
- caller: {},
- });
- return true;
-}
-
-function deprecationFunctionCustomCallstack() {
- // Get the nsIStackFrame that will contain the name of this function.
- function getStack() {
- return Components.stack;
- }
- Deprecated.warning(
- "this method is deprecated.",
- "https://example.com",
- getStack()
- );
- return true;
-}
-
-var tests = [
- // Test deprecation warning without passing the callstack.
- {
- deprecatedFunction: basicDeprecatedFunction,
- expectedObservation(aMessage) {
- testAMessage(aMessage);
- Assert.greater(
- aMessage.indexOf("basicDeprecatedFunction"),
- 0,
- "Callstack is correctly logged."
- );
- },
- },
- // Test a reported error when URL to documentation is not passed.
- {
- deprecatedFunction() {
- Deprecated.warning("this method is deprecated.");
- return true;
- },
- expectedObservation(aMessage) {
- Assert.greater(
- aMessage.indexOf("must provide a URL"),
- 0,
- "Deprecation warning logged an empty URL argument."
- );
- },
- },
- // Test deprecation with a bogus callstack passed as an argument (it will be
- // replaced with the current call stack).
- {
- deprecatedFunction: deprecationFunctionBogusCallstack,
- expectedObservation(aMessage) {
- testAMessage(aMessage);
- Assert.greater(
- aMessage.indexOf("deprecationFunctionBogusCallstack"),
- 0,
- "Callstack is correctly logged."
- );
- },
- },
- // Test deprecation with a valid custom callstack passed as an argument.
- {
- deprecatedFunction: deprecationFunctionCustomCallstack,
- expectedObservation(aMessage) {
- testAMessage(aMessage);
- Assert.greater(
- aMessage.indexOf("deprecationFunctionCustomCallstack"),
- 0,
- "Callstack is correctly logged."
- );
- },
- // Set pref to true.
- logWarnings: true,
- },
-];
-
-// Test Console Message attributes.
-function testAMessage(aMessage) {
- Assert.strictEqual(
- aMessage.indexOf("DEPRECATION WARNING: this method is deprecated."),
- 0,
- "Deprecation is correctly logged."
- );
- Assert.greater(
- aMessage.indexOf("https://example.com"),
- 0,
- "URL is correctly logged."
- );
-}
-
-add_task(async function test_setup() {
- Services.prefs.setBoolPref(PREF_DEPRECATION_WARNINGS, true);
-
- // Check if Deprecated is loaded.
- ok(Deprecated, "Deprecated object exists");
-});
-
-add_task(async function test_pref_enabled() {
- for (let [idx, test] of tests.entries()) {
- info("Running test #" + idx);
-
- let promiseObserved = TestUtils.consoleMessageObserved(subject => {
- let msg = subject.wrappedJSObject.arguments?.[0];
- return (
- msg.includes("DEPRECATION WARNING: ") ||
- msg.includes("must provide a URL")
- );
- });
-
- test.deprecatedFunction();
-
- let msg = await promiseObserved;
-
- test.expectedObservation(msg.wrappedJSObject.arguments?.[0]);
- }
-});
-
-add_task(async function test_pref_disabled() {
- // Deprecation warnings will be logged only when the preference is set.
- Services.prefs.setBoolPref(PREF_DEPRECATION_WARNINGS, false);
-
- let endFn = TestUtils.listenForConsoleMessages();
- basicDeprecatedFunction();
-
- let messages = await endFn();
- Assert.equal(messages.length, 0, "Should not have received any messages");
-});
diff --git a/toolkit/modules/tests/marionette/manifest.toml b/toolkit/modules/tests/marionette/manifest.toml
new file mode 100644
index 0000000000..08a103c289
--- /dev/null
+++ b/toolkit/modules/tests/marionette/manifest.toml
@@ -0,0 +1,4 @@
+[DEFAULT]
+run-if = ["buildapp == 'browser'"]
+
+["test_first_startup.py"]
diff --git a/toolkit/modules/tests/marionette/test_first_startup.py b/toolkit/modules/tests/marionette/test_first_startup.py
new file mode 100644
index 0000000000..6d8bbce02d
--- /dev/null
+++ b/toolkit/modules/tests/marionette/test_first_startup.py
@@ -0,0 +1,54 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from marionette_harness import MarionetteTestCase
+
+
+class TestFirstStartup(MarionetteTestCase):
+ def setUp(self):
+ MarionetteTestCase.setUp(self)
+ self.marionette.quit()
+ self.marionette.instance.prefs = {
+ "browser.startup.homepage_override.mstone": ""
+ }
+ self.marionette.instance.app_args = ["-first-startup"]
+
+ def test_new_profile(self):
+ """Test launching with --first-startup when a new profile was created.
+
+ Launches the browser with --first-startup on a freshly created profile
+ and then ensures that FirstStartup.init ran successfully.
+ """
+
+ self.marionette.instance.switch_profile()
+ self.marionette.start_session()
+ self.marionette.set_context("chrome")
+ firstStartupInittedSuccessfully = self.marionette.execute_script(
+ """
+ const { FirstStartup } = ChromeUtils.importESModule("resource://gre/modules/FirstStartup.sys.mjs");
+ return FirstStartup.state == FirstStartup.SUCCESS
+ """
+ )
+
+ self.assertTrue(
+ firstStartupInittedSuccessfully, "FirstStartup initted successfully"
+ )
+
+ def test_existing_profile(self):
+ """Test launching with --first-startup with a pre-existing profile.
+
+ Launches the browser with --first-startup on a profile that has been
+ run before. Ensures that FirstStartup.init was never run.
+ """
+
+ self.marionette.start_session()
+ self.marionette.set_context("chrome")
+ firstStartupSkipped = self.marionette.execute_script(
+ """
+ const { FirstStartup } = ChromeUtils.importESModule("resource://gre/modules/FirstStartup.sys.mjs");
+ return FirstStartup.state == FirstStartup.NOT_STARTED
+ """
+ )
+
+ self.assertTrue(firstStartupSkipped, "FirstStartup init skipped")
diff --git a/toolkit/modules/tests/xpcshell/test_GMPInstallManager.js b/toolkit/modules/tests/xpcshell/test_GMPInstallManager.js
index 8f725fc78d..a0d12b8a6a 100644
--- a/toolkit/modules/tests/xpcshell/test_GMPInstallManager.js
+++ b/toolkit/modules/tests/xpcshell/test_GMPInstallManager.js
@@ -1257,7 +1257,7 @@ add_task(async function test_GMPExtractor_paths() {
if (AppConstants.platform == "macosx") {
await Assert.rejects(
IOUtils.getMacXAttr(extractedFile, "com.apple.quarantine"),
- /NotFoundError: The file `.+' does not have an extended attribute `com.apple.quarantine'/,
+ /NotFoundError: Could not get extended attribute `com.apple.quarantine' from `.+': the file does not have the attribute/,
"The 'com.apple.quarantine' attribute should not be present"
);
}
diff --git a/toolkit/modules/tests/xpcshell/test_Services.js b/toolkit/modules/tests/xpcshell/test_Services.js
index 55c762fdad..8169a23bbd 100644
--- a/toolkit/modules/tests/xpcshell/test_Services.js
+++ b/toolkit/modules/tests/xpcshell/test_Services.js
@@ -28,7 +28,6 @@ function run_test() {
checkService("cookies", Ci.nsICookieManager);
checkService("dirsvc", Ci.nsIDirectoryService);
checkService("dirsvc", Ci.nsIProperties);
- checkService("DOMRequest", Ci.nsIDOMRequestService);
checkService("domStorageManager", Ci.nsIDOMStorageManager);
checkService("droppedLinkHandler", Ci.nsIDroppedLinkHandler);
checkService("eTLD", Ci.nsIEffectiveTLDService);
diff --git a/toolkit/modules/tests/xpcshell/test_firstStartup.js b/toolkit/modules/tests/xpcshell/test_firstStartup.js
index 02f126d66f..445d3a0c72 100644
--- a/toolkit/modules/tests/xpcshell/test_firstStartup.js
+++ b/toolkit/modules/tests/xpcshell/test_firstStartup.js
@@ -24,11 +24,13 @@ add_task(async function test_success() {
updateAppInfo();
let submissionPromise;
+ FirstStartup.resetForTesting();
if (AppConstants.MOZ_NORMANDY || AppConstants.MOZ_UPDATE_AGENT) {
submissionPromise = new Promise(resolve => {
GleanPings.firstStartup.testBeforeNextSubmit(() => {
Assert.equal(FirstStartup.state, FirstStartup.SUCCESS);
+ Assert.ok(Glean.firstStartup.newProfile.testGetValue());
Assert.equal(
Glean.firstStartup.statusCode.testGetValue(),
FirstStartup.SUCCESS
@@ -49,6 +51,7 @@ add_task(async function test_success() {
submissionPromise = new Promise(resolve => {
GleanPings.firstStartup.testBeforeNextSubmit(() => {
Assert.equal(FirstStartup.state, FirstStartup.UNSUPPORTED);
+ Assert.ok(Glean.firstStartup.newProfile.testGetValue());
Assert.equal(
Glean.firstStartup.statusCode.testGetValue(),
FirstStartup.UNSUPPORTED
@@ -58,13 +61,14 @@ add_task(async function test_success() {
});
}
- FirstStartup.init();
+ FirstStartup.init(true /* newProfile */);
await submissionPromise;
});
add_task(async function test_timeout() {
updateAppInfo();
Services.prefs.setIntPref(PREF_TIMEOUT, 0);
+ FirstStartup.resetForTesting();
let submissionPromise;
@@ -73,6 +77,7 @@ add_task(async function test_timeout() {
GleanPings.firstStartup.testBeforeNextSubmit(() => {
Assert.equal(FirstStartup.state, FirstStartup.TIMED_OUT);
Assert.ok(Glean.firstStartup.elapsed.testGetValue() > 0);
+ Assert.ok(Glean.firstStartup.newProfile.testGetValue());
if (AppConstants.MOZ_NORMANDY) {
Assert.ok(Glean.firstStartup.normandyInitTime.testGetValue() > 0);
@@ -90,11 +95,27 @@ add_task(async function test_timeout() {
GleanPings.firstStartup.testBeforeNextSubmit(() => {
Assert.equal(FirstStartup.state, FirstStartup.UNSUPPORTED);
Assert.equal(Glean.firstStartup.elapsed.testGetValue(), 0);
+ Assert.ok(Glean.firstStartup.newProfile.testGetValue());
resolve();
});
});
}
- FirstStartup.init();
+ FirstStartup.init(true /* newProfile */);
+ await submissionPromise;
+});
+
+add_task(async function test_existing_profile() {
+ FirstStartup.resetForTesting();
+
+ let submissionPromise = new Promise(resolve => {
+ GleanPings.firstStartup.testBeforeNextSubmit(() => {
+ Assert.equal(FirstStartup.state, FirstStartup.NOT_STARTED);
+ Assert.ok(!Glean.firstStartup.newProfile.testGetValue());
+ resolve();
+ });
+ });
+
+ FirstStartup.init(false /* newProfile */);
await submissionPromise;
});
diff --git a/toolkit/modules/tests/xpcshell/test_sqlite.js b/toolkit/modules/tests/xpcshell/test_sqlite.js
index 2c3ede46d6..e0a79e137d 100644
--- a/toolkit/modules/tests/xpcshell/test_sqlite.js
+++ b/toolkit/modules/tests/xpcshell/test_sqlite.js
@@ -118,9 +118,8 @@ add_task(async function test_open_normal_error() {
// Ensure that our database doesn't already exist.
let path = PathUtils.join(PROFILE_DIR, "corrupt.sqlite");
- await Assert.rejects(
- IOUtils.stat(path),
- /Could not stat file\(.*\) because it does not exist/,
+ Assert.ok(
+ !(await IOUtils.exists(path)),
"Database file should not exist yet"
);