summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/urlbar/tests')
-rw-r--r--browser/components/urlbar/tests/UrlbarTestUtils.sys.mjs16
-rw-r--r--browser/components/urlbar/tests/browser/browser.toml9
-rw-r--r--browser/components/urlbar/tests/browser/browser_UrlbarInput_untrimOnUserInteraction.js124
-rw-r--r--browser/components/urlbar/tests/browser/browser_autocomplete_edit_completed.js1
-rw-r--r--browser/components/urlbar/tests/browser/browser_contextualsearch.js73
-rw-r--r--browser/components/urlbar/tests/browser/browser_decode.js2
-rw-r--r--browser/components/urlbar/tests/browser/browser_keepStateAcrossTabSwitches.js195
-rw-r--r--browser/components/urlbar/tests/browser/browser_less_common_selection_manipulations.js48
-rw-r--r--browser/components/urlbar/tests/browser/browser_oneOffs.js6
-rw-r--r--browser/components/urlbar/tests/browser/browser_quickactions.js530
-rw-r--r--browser/components/urlbar/tests/browser/browser_quickactions_commands.js154
-rw-r--r--browser/components/urlbar/tests/browser/browser_quickactions_devtools.js23
-rw-r--r--browser/components/urlbar/tests/browser/browser_quickactions_screenshot.js68
-rw-r--r--browser/components/urlbar/tests/browser/browser_quickactions_tab_refocus.js10
-rw-r--r--browser/components/urlbar/tests/browser/browser_secondaryActions.js141
-rw-r--r--browser/components/urlbar/tests/browser/browser_strip_on_share.js28
-rw-r--r--browser/components/urlbar/tests/browser/browser_urlbar_telemetry_quickactions.js133
-rw-r--r--browser/components/urlbar/tests/browser/browser_view_selectionByMouse.js58
-rw-r--r--browser/components/urlbar/tests/browser/head.js71
-rw-r--r--browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_abandonment_groups.js24
-rw-r--r--browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_abandonment_search_mode.js7
-rw-r--r--browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_edge_cases.js5
-rw-r--r--browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_groups.js26
-rw-r--r--browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_interaction.js2
-rw-r--r--browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_search_mode.js12
-rw-r--r--browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_selected_result.js75
-rw-r--r--browser/components/urlbar/tests/engagementTelemetry/browser/head-interaction.js3
-rw-r--r--browser/components/urlbar/tests/engagementTelemetry/browser/head-search_mode.js13
-rw-r--r--browser/components/urlbar/tests/engagementTelemetry/browser/head.js4
-rw-r--r--browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest.js84
-rw-r--r--browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_dynamicWikipedia.js18
-rw-r--r--browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_weather.js18
-rw-r--r--browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_dynamicWikipedia.js5
-rw-r--r--browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_merino.js5
-rw-r--r--browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_scoreMap.js5
-rw-r--r--browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_topPicks.js5
-rw-r--r--browser/components/urlbar/tests/unit/test_autofill_origins.js65
-rw-r--r--browser/components/urlbar/tests/unit/test_quickactions.js109
-rw-r--r--browser/components/urlbar/tests/unit/test_tokenizer.js6
39 files changed, 952 insertions, 1229 deletions
diff --git a/browser/components/urlbar/tests/UrlbarTestUtils.sys.mjs b/browser/components/urlbar/tests/UrlbarTestUtils.sys.mjs
index f576f4ca19..793af24b41 100644
--- a/browser/components/urlbar/tests/UrlbarTestUtils.sys.mjs
+++ b/browser/components/urlbar/tests/UrlbarTestUtils.sys.mjs
@@ -1043,9 +1043,11 @@ export var UrlbarTestUtils = {
* Removes the scheme from an url according to user prefs.
*
* @param {string} url
- * The url that is supposed to be sanitizied.
- * @param {{removeSingleTrailingSlash: (boolean)}} options
- * removeSingleTrailingSlash: Remove trailing slash, when trimming enabled.
+ * The url that is supposed to be trimmed.
+ * @param {object} [options]
+ * Options for the trimming.
+ * @param {boolean} [options.removeSingleTrailingSlash]
+ * Remove trailing slash, when trimming enabled.
* @returns {string}
* The sanitized URL.
*/
@@ -1060,15 +1062,13 @@ export var UrlbarTestUtils = {
lazy.BrowserUIUtils.removeSingleTrailingSlashFromURL(sanitizedURL);
}
+ // Also remove emphasis markers if present.
if (lazy.UrlbarPrefs.get("trimHttps")) {
- sanitizedURL = sanitizedURL.replace("https://", "");
+ sanitizedURL = sanitizedURL.replace(/^<?https:\/\/>?/, "");
} else {
- sanitizedURL = sanitizedURL.replace("http://", "");
+ sanitizedURL = sanitizedURL.replace(/^<?http:\/\/>?/, "");
}
- // Remove empty emphasis markers in case the protocol was trimmed.
- sanitizedURL = sanitizedURL.replace("<>", "");
-
return sanitizedURL;
},
diff --git a/browser/components/urlbar/tests/browser/browser.toml b/browser/components/urlbar/tests/browser/browser.toml
index 44b964e5ca..38046aa26b 100644
--- a/browser/components/urlbar/tests/browser/browser.toml
+++ b/browser/components/urlbar/tests/browser/browser.toml
@@ -68,6 +68,8 @@ skip-if = ["apple_catalina && debug"] # Bug 1773790
["browser_UrlbarInput_trimURLs.js"]
https_first_disabled = true
+["browser_UrlbarInput_untrimOnUserInteraction.js"]
+
["browser_aboutHomeLoading.js"]
skip-if = [
"tsan", # Intermittently times out, see 1622698 (frequent on TSan).
@@ -365,6 +367,8 @@ support-files = [
["browser_quickactions.js"]
+["browser_quickactions_commands.js"]
+
["browser_quickactions_devtools.js"]
["browser_quickactions_screenshot.js"]
@@ -498,6 +502,8 @@ support-files = ["search-engines", "../../../search/test/browser/trendingSuggest
["browser_search_history_from_history_panel.js"]
+["browser_secondaryActions.js"]
+
["browser_selectStaleResults.js"]
support-files = [
"searchSuggestionEngineSlow.xml",
@@ -645,9 +651,6 @@ tags = "search-telemetry"
https_first_disabled = true
tags = "search-telemetry"
-["browser_urlbar_telemetry_quickactions.js"]
-tags = "search-telemetry"
-
["browser_urlbar_telemetry_remotetab.js"]
tags = "search-telemetry"
diff --git a/browser/components/urlbar/tests/browser/browser_UrlbarInput_untrimOnUserInteraction.js b/browser/components/urlbar/tests/browser/browser_UrlbarInput_untrimOnUserInteraction.js
new file mode 100644
index 0000000000..a6714df360
--- /dev/null
+++ b/browser/components/urlbar/tests/browser/browser_UrlbarInput_untrimOnUserInteraction.js
@@ -0,0 +1,124 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+let tests = [
+ {
+ description: "Test single click doesn't untrim",
+ untrimmedValue: BrowserUIUtils.trimURLProtocol + "www.example.com/",
+ execute() {
+ EventUtils.synthesizeMouseAtCenter(gURLBar.inputField, {});
+ Assert.equal(gURLBar.selectionStart, 0, "Selection start is 0.");
+ Assert.equal(
+ gURLBar.selectionEnd,
+ gURLBar.value.length,
+ "Selection end is at and of text."
+ );
+ },
+ shouldUntrim: false,
+ },
+ {
+ description: "Test CTRL+L doesn't untrim",
+ untrimmedValue: BrowserUIUtils.trimURLProtocol + "www.example.com/",
+ execute() {
+ EventUtils.synthesizeKey("l", { accelKey: true });
+ Assert.equal(gURLBar.selectionStart, 0, "Selection start is 0.");
+ Assert.equal(
+ gURLBar.selectionEnd,
+ gURLBar.value.length,
+ "Selection end is at and of text."
+ );
+ },
+ shouldUntrim: false,
+ },
+ {
+ description: "Test drag selection untrims",
+ untrimmedValue: BrowserUIUtils.trimURLProtocol + "www.example.com/",
+ execute() {
+ selectWithMouseDrag(100, 200);
+ Assert.greater(gURLBar.selectionStart, 0, "Selection start is positive.");
+ Assert.greater(
+ gURLBar.selectionEnd,
+ gURLBar.selectionStart,
+ "Selection is not empty."
+ );
+ },
+ shouldUntrim: true,
+ },
+ {
+ description: "Test double click selection untrims",
+ untrimmedValue: BrowserUIUtils.trimURLProtocol + "www.example.com/",
+ execute() {
+ selectWithDoubleClick(200);
+ Assert.greater(gURLBar.selectionStart, 0, "Selection start is positive.");
+ Assert.greater(
+ gURLBar.selectionEnd,
+ gURLBar.selectionStart,
+ "Selection is not empty."
+ );
+ },
+ shouldUntrim: true,
+ },
+ {
+ description: "Test click, LEFT untrims",
+ untrimmedValue: BrowserUIUtils.trimURLProtocol + "www.example.com/",
+ execute() {
+ EventUtils.synthesizeMouseAtCenter(gURLBar.inputField, {});
+ EventUtils.synthesizeKey("KEY_ArrowLeft");
+ },
+ shouldUntrim: true,
+ },
+ {
+ description: "Test CTRL+L, HOME untrims",
+ untrimmedValue: BrowserUIUtils.trimURLProtocol + "www.example.com/",
+ execute() {
+ EventUtils.synthesizeKey("l", { accelKey: true });
+ if (AppConstants.platform == "macosx") {
+ EventUtils.synthesizeKey("KEY_ArrowLeft", { metaKey: true });
+ } else {
+ EventUtils.synthesizeKey("KEY_Home");
+ }
+ },
+ shouldUntrim: true,
+ },
+ {
+ description: "Test SHIFT+LEFT untrims",
+ untrimmedValue: BrowserUIUtils.trimURLProtocol + "www.example.com/",
+ async execute() {
+ EventUtils.synthesizeKey("l", { accelKey: true });
+ EventUtils.synthesizeKey("KEY_ArrowLeft", { shiftKey: true });
+ Assert.equal(gURLBar.selectionStart, 0, "Selection start is 0.");
+ Assert.less(
+ gURLBar.selectionEnd,
+ gURLBar.value.length,
+ "Selection skips last characters."
+ );
+ },
+ shouldUntrim: true,
+ },
+];
+
+add_task(async function test_untrim() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.urlbar.untrimOnUserInteraction.featureGate", true]],
+ });
+
+ for (let test of tests) {
+ info(test.description);
+ let trimmedValue = UrlbarTestUtils.trimURL(test.untrimmedValue);
+ gURLBar._setValue(test.untrimmedValue, {
+ allowTrim: true,
+ valueIsTyped: false,
+ });
+ gURLBar.blur();
+ Assert.equal(gURLBar.value, trimmedValue, "Value has been trimmed");
+ await test.execute();
+ Assert.equal(
+ gURLBar.value,
+ test.shouldUntrim ? test.untrimmedValue : trimmedValue,
+ "Value has been untrimmed"
+ );
+ gURLBar.handleRevert();
+ }
+});
diff --git a/browser/components/urlbar/tests/browser/browser_autocomplete_edit_completed.js b/browser/components/urlbar/tests/browser/browser_autocomplete_edit_completed.js
index 4fa60f6bf3..220634eb2c 100644
--- a/browser/components/urlbar/tests/browser/browser_autocomplete_edit_completed.js
+++ b/browser/components/urlbar/tests/browser/browser_autocomplete_edit_completed.js
@@ -51,6 +51,7 @@ add_task(async function () {
info("Press backspace");
EventUtils.synthesizeKey("KEY_Backspace");
+ info("Backspaced value is " + gURLBar.value);
await UrlbarTestUtils.promiseSearchComplete(window);
let editedValue = gURLBar.value;
diff --git a/browser/components/urlbar/tests/browser/browser_contextualsearch.js b/browser/components/urlbar/tests/browser/browser_contextualsearch.js
index 60e489a542..449d1864c2 100644
--- a/browser/components/urlbar/tests/browser/browser_contextualsearch.js
+++ b/browser/components/urlbar/tests/browser/browser_contextualsearch.js
@@ -3,22 +3,54 @@
"use strict";
-const { UrlbarProviderContextualSearch } = ChromeUtils.importESModule(
- "resource:///modules/UrlbarProviderContextualSearch.sys.mjs"
+const { ActionsProviderContextualSearch } = ChromeUtils.importESModule(
+ "resource:///modules/ActionsProviderContextualSearch.sys.mjs"
+);
+
+const { AddonTestUtils } = ChromeUtils.importESModule(
+ "resource://testing-common/AddonTestUtils.sys.mjs"
);
add_setup(async function setup() {
await SpecialPowers.pushPrefEnv({
- set: [["browser.urlbar.contextualSearch.enabled", true]],
+ set: [
+ ["browser.urlbar.contextualSearch.enabled", true],
+ ["browser.urlbar.secondaryActions.featureGate", true],
+ ],
});
-});
-add_task(async function test_selectContextualSearchResult_already_installed() {
- await SearchTestUtils.installSearchExtension({
+ let ext = await SearchTestUtils.installSearchExtension({
name: "Contextual",
search_url: "https://example.com/browser",
});
+ await AddonTestUtils.waitForSearchProviderStartup(ext);
+});
+
+add_task(async function test_no_engine() {
+ const ENGINE_TEST_URL = "https://example.org/";
+ let onLoaded = BrowserTestUtils.browserLoaded(
+ gBrowser.selectedBrowser,
+ false,
+ ENGINE_TEST_URL
+ );
+ BrowserTestUtils.startLoadingURIString(
+ gBrowser.selectedBrowser,
+ ENGINE_TEST_URL
+ );
+ await onLoaded;
+
+ await UrlbarTestUtils.promiseAutocompleteResultPopup({
+ window,
+ value: "test",
+ });
+ Assert.ok(
+ UrlbarTestUtils.getResultCount(window) > 0,
+ "At least one result is shown"
+ );
+});
+
+add_task(async function test_selectContextualSearchResult_already_installed() {
const ENGINE_TEST_URL = "https://example.com/";
let onLoaded = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
@@ -44,25 +76,15 @@ add_task(async function test_selectContextualSearchResult_already_installed() {
window,
value: query,
});
- const resultIndex = UrlbarTestUtils.getResultCount(window) - 1;
- const result = await UrlbarTestUtils.getDetailsOfResultAt(
- window,
- resultIndex
- );
-
- is(
- result.dynamicType,
- "contextualSearch",
- "Second last result is a contextual search result"
- );
info("Focus and select the contextual search result");
- UrlbarTestUtils.setSelectedRowIndex(window, resultIndex);
let onLoad = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
expectedUrl
);
+
+ EventUtils.synthesizeKey("KEY_Tab");
EventUtils.synthesizeKey("KEY_Enter");
await onLoad;
@@ -95,25 +117,14 @@ add_task(async function test_selectContextualSearchResult_not_installed() {
window,
value: query,
});
- const resultIndex = UrlbarTestUtils.getResultCount(window) - 1;
- const result = await UrlbarTestUtils.getDetailsOfResultAt(
- window,
- resultIndex
- );
-
- Assert.equal(
- result.dynamicType,
- "contextualSearch",
- "Second last result is a contextual search result"
- );
info("Focus and select the contextual search result");
- UrlbarTestUtils.setSelectedRowIndex(window, resultIndex);
let onLoad = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
EXPECTED_URL
);
+ EventUtils.synthesizeKey("KEY_Tab");
EventUtils.synthesizeKey("KEY_Enter");
await onLoad;
@@ -122,4 +133,6 @@ add_task(async function test_selectContextualSearchResult_not_installed() {
EXPECTED_URL,
"Selecting the contextual search result opens the search URL"
);
+
+ ActionsProviderContextualSearch.resetForTesting();
});
diff --git a/browser/components/urlbar/tests/browser/browser_decode.js b/browser/components/urlbar/tests/browser/browser_decode.js
index 577d39b587..ee7831eea6 100644
--- a/browser/components/urlbar/tests/browser/browser_decode.js
+++ b/browser/components/urlbar/tests/browser/browser_decode.js
@@ -72,7 +72,7 @@ add_task(async function actionURILosslessDecode() {
Assert.equal(
gURLBar.value,
- UrlbarTestUtils.trimURL(urlNoScheme),
+ urlNoScheme,
"The string displayed in the textbox should not be escaped"
);
diff --git a/browser/components/urlbar/tests/browser/browser_keepStateAcrossTabSwitches.js b/browser/components/urlbar/tests/browser/browser_keepStateAcrossTabSwitches.js
index 6ad6ce43e6..abe12846ab 100644
--- a/browser/components/urlbar/tests/browser/browser_keepStateAcrossTabSwitches.js
+++ b/browser/components/urlbar/tests/browser/browser_keepStateAcrossTabSwitches.js
@@ -3,6 +3,10 @@
"use strict";
+add_setup(async function setup() {
+ registerCleanupFunction(PlacesUtils.history.clear);
+});
+
/**
* Verify user typed text remains in the URL bar when tab switching, even when
* loads fail.
@@ -78,94 +82,94 @@ add_task(async function invalidURL() {
* Test the urlbar status of text selection and focusing by tab switching.
*/
add_task(async function selectAndFocus() {
- // Create a tab with normal web page. Use a test-url that uses a protocol that
- // is not trimmed.
- const webpageTabURL =
- UrlbarTestUtils.getTrimmedProtocolWithSlashes() == "https://"
- ? "http://example.com"
- : "https://example.com";
- const webpageTab = await BrowserTestUtils.openNewForegroundTab({
- gBrowser,
- url: webpageTabURL,
- });
+ // Test both protocols to ensure we're testing any trimming case.
+ for (let protocol of ["http://", "https://"]) {
+ const webpageTabURL = protocol + "example.com";
+ const webpageTab = await BrowserTestUtils.openNewForegroundTab({
+ gBrowser,
+ url: webpageTabURL,
+ });
- // Create a tab with userTypedValue.
- const userTypedTabText = "test";
- const userTypedTab = await BrowserTestUtils.openNewForegroundTab({
- gBrowser,
- });
- await UrlbarTestUtils.inputIntoURLBar(window, userTypedTabText);
+ // Create a tab with userTypedValue.
+ const userTypedTabText = "test";
+ const userTypedTab = await BrowserTestUtils.openNewForegroundTab({
+ gBrowser,
+ });
+ await UrlbarTestUtils.inputIntoURLBar(window, userTypedTabText);
- // Create an empty tab.
- const emptyTab = await BrowserTestUtils.openNewForegroundTab({ gBrowser });
+ // Create an empty tab.
+ const emptyTab = await BrowserTestUtils.openNewForegroundTab({ gBrowser });
- registerCleanupFunction(async () => {
- await PlacesUtils.history.clear();
- BrowserTestUtils.removeTab(webpageTab);
- BrowserTestUtils.removeTab(userTypedTab);
- BrowserTestUtils.removeTab(emptyTab);
- });
+ async function cleanup() {
+ await PlacesUtils.history.clear();
+ BrowserTestUtils.removeTab(webpageTab);
+ BrowserTestUtils.removeTab(userTypedTab);
+ BrowserTestUtils.removeTab(emptyTab);
+ }
- await doSelectAndFocusTest({
- targetTab: webpageTab,
- targetSelectionStart: 0,
- targetSelectionEnd: 0,
- anotherTab: userTypedTab,
- });
- await doSelectAndFocusTest({
- targetTab: webpageTab,
- targetSelectionStart: 2,
- targetSelectionEnd: 5,
- anotherTab: userTypedTab,
- });
- await doSelectAndFocusTest({
- targetTab: webpageTab,
- targetSelectionStart: webpageTabURL.length,
- targetSelectionEnd: webpageTabURL.length,
- anotherTab: userTypedTab,
- });
- await doSelectAndFocusTest({
- targetTab: webpageTab,
- targetSelectionStart: 0,
- targetSelectionEnd: 0,
- anotherTab: emptyTab,
- });
- await doSelectAndFocusTest({
- targetTab: userTypedTab,
- targetSelectionStart: 0,
- targetSelectionEnd: 0,
- anotherTab: webpageTab,
- });
- await doSelectAndFocusTest({
- targetTab: userTypedTab,
- targetSelectionStart: 0,
- targetSelectionEnd: 0,
- anotherTab: emptyTab,
- });
- await doSelectAndFocusTest({
- targetTab: userTypedTab,
- targetSelectionStart: 1,
- targetSelectionEnd: 2,
- anotherTab: emptyTab,
- });
- await doSelectAndFocusTest({
- targetTab: userTypedTab,
- targetSelectionStart: userTypedTabText.length,
- targetSelectionEnd: userTypedTabText.length,
- anotherTab: emptyTab,
- });
- await doSelectAndFocusTest({
- targetTab: emptyTab,
- targetSelectionStart: 0,
- targetSelectionEnd: 0,
- anotherTab: webpageTab,
- });
- await doSelectAndFocusTest({
- targetTab: emptyTab,
- targetSelectionStart: 0,
- targetSelectionEnd: 0,
- anotherTab: userTypedTab,
- });
+ await doSelectAndFocusTest({
+ targetTab: webpageTab,
+ targetSelectionStart: 0,
+ targetSelectionEnd: 0,
+ anotherTab: userTypedTab,
+ });
+ await doSelectAndFocusTest({
+ targetTab: webpageTab,
+ targetSelectionStart: 2,
+ targetSelectionEnd: 5,
+ anotherTab: userTypedTab,
+ });
+ await doSelectAndFocusTest({
+ targetTab: webpageTab,
+ targetSelectionStart: webpageTabURL.length,
+ targetSelectionEnd: webpageTabURL.length,
+ anotherTab: userTypedTab,
+ });
+ await doSelectAndFocusTest({
+ targetTab: webpageTab,
+ targetSelectionStart: 0,
+ targetSelectionEnd: 0,
+ anotherTab: emptyTab,
+ });
+ await doSelectAndFocusTest({
+ targetTab: userTypedTab,
+ targetSelectionStart: 0,
+ targetSelectionEnd: 0,
+ anotherTab: webpageTab,
+ });
+ await doSelectAndFocusTest({
+ targetTab: userTypedTab,
+ targetSelectionStart: 0,
+ targetSelectionEnd: 0,
+ anotherTab: emptyTab,
+ });
+ await doSelectAndFocusTest({
+ targetTab: userTypedTab,
+ targetSelectionStart: 1,
+ targetSelectionEnd: 2,
+ anotherTab: emptyTab,
+ });
+ await doSelectAndFocusTest({
+ targetTab: userTypedTab,
+ targetSelectionStart: userTypedTabText.length,
+ targetSelectionEnd: userTypedTabText.length,
+ anotherTab: emptyTab,
+ });
+ await doSelectAndFocusTest({
+ targetTab: emptyTab,
+ targetSelectionStart: 0,
+ targetSelectionEnd: 0,
+ anotherTab: webpageTab,
+ });
+ await doSelectAndFocusTest({
+ targetTab: emptyTab,
+ targetSelectionStart: 0,
+ targetSelectionEnd: 0,
+ anotherTab: userTypedTab,
+ });
+
+ await cleanup();
+ }
});
async function doSelectAndFocusTest({
@@ -197,6 +201,13 @@ async function doSelectAndFocusTest({
targetSelectionStart,
targetSelectionEnd
);
+ const targetSelectedText = getSelectedText();
+ if (gURLBar.selectionStart != gURLBar.selectionEnd) {
+ Assert.ok(
+ targetSelectedText,
+ `Some text is selected: "${targetSelectedText}"`
+ );
+ }
const targetValue = gURLBar.value;
// Switch to another tab.
@@ -210,8 +221,9 @@ async function doSelectAndFocusTest({
Assert.equal(gURLBar.value, targetValue);
Assert.equal(gURLBar.focused, targetFocus);
if (gURLBar.focused) {
- Assert.equal(gURLBar.selectionStart, targetSelectionStart);
- Assert.equal(gURLBar.selectionEnd, targetSelectionEnd);
+ // Check the selected text rather than the selection indices, to keep
+ // untrimming into account.
+ Assert.equal(targetSelectedText, getSelectedText());
} else {
Assert.equal(gURLBar.selectionStart, gURLBar.value.length);
Assert.equal(gURLBar.selectionEnd, gURLBar.value.length);
@@ -221,12 +233,21 @@ async function doSelectAndFocusTest({
function setURLBarFocus(focus) {
if (focus) {
- gURLBar.focus();
+ // Simulate a user interaction, to eventually cause untrimming.
+ EventUtils.synthesizeMouseAtCenter(gURLBar.inputField, {});
} else {
gURLBar.blur();
}
}
+function getSelectedText() {
+ return gURLBar.inputField.editor.selection.toStringWithFormat(
+ "text/plain",
+ Ci.nsIDocumentEncoder.OutputPreformatted | Ci.nsIDocumentEncoder.OutputRaw,
+ 0
+ );
+}
+
async function switchTab(tab) {
if (gBrowser.selectedTab !== tab) {
EventUtils.synthesizeMouseAtCenter(tab, {});
diff --git a/browser/components/urlbar/tests/browser/browser_less_common_selection_manipulations.js b/browser/components/urlbar/tests/browser/browser_less_common_selection_manipulations.js
index 2ad6ee0e07..44a7ea64b2 100644
--- a/browser/components/urlbar/tests/browser/browser_less_common_selection_manipulations.js
+++ b/browser/components/urlbar/tests/browser/browser_less_common_selection_manipulations.js
@@ -238,51 +238,3 @@ function getTextWidth(inputText) {
.getPropertyValue("font");
return context.measureText(inputText).width;
}
-
-function selectWithMouseDrag(fromX, toX) {
- let target = gURLBar.inputField;
- let rect = target.getBoundingClientRect();
- let promise = BrowserTestUtils.waitForEvent(target, "mouseup");
- EventUtils.synthesizeMouse(
- target,
- fromX,
- rect.height / 2,
- { type: "mousemove" },
- target.ownerGlobal
- );
- EventUtils.synthesizeMouse(
- target,
- fromX,
- rect.height / 2,
- { type: "mousedown" },
- target.ownerGlobal
- );
- EventUtils.synthesizeMouse(
- target,
- toX,
- rect.height / 2,
- { type: "mousemove" },
- target.ownerGlobal
- );
- EventUtils.synthesizeMouse(
- target,
- toX,
- rect.height / 2,
- { type: "mouseup" },
- target.ownerGlobal
- );
- return promise;
-}
-
-function selectWithDoubleClick(offsetX) {
- let target = gURLBar.inputField;
- let rect = target.getBoundingClientRect();
- let promise = BrowserTestUtils.waitForEvent(target, "dblclick");
- EventUtils.synthesizeMouse(target, offsetX, rect.height / 2, {
- clickCount: 1,
- });
- EventUtils.synthesizeMouse(target, offsetX, rect.height / 2, {
- clickCount: 2,
- });
- return promise;
-}
diff --git a/browser/components/urlbar/tests/browser/browser_oneOffs.js b/browser/components/urlbar/tests/browser/browser_oneOffs.js
index 0c04f1e321..e517ea0a9a 100644
--- a/browser/components/urlbar/tests/browser/browser_oneOffs.js
+++ b/browser/components/urlbar/tests/browser/browser_oneOffs.js
@@ -30,7 +30,6 @@ add_setup(async function () {
set: [
["browser.search.separatePrivateDefault.ui.enabled", false],
["browser.urlbar.suggest.quickactions", false],
- ["browser.urlbar.shortcuts.quickactions", true],
],
});
@@ -943,7 +942,7 @@ async function doLocalShortcutsShownTest() {
await rebuildPromise;
let buttons = oneOffSearchButtons.localButtons;
- Assert.equal(buttons.length, 4, "Expected number of local shortcuts");
+ Assert.equal(buttons.length, 3, "Expected number of local shortcuts");
let expectedSource;
let seenIDs = new Set();
@@ -963,9 +962,6 @@ async function doLocalShortcutsShownTest() {
case "urlbar-engine-one-off-item-history":
expectedSource = UrlbarUtils.RESULT_SOURCE.HISTORY;
break;
- case "urlbar-engine-one-off-item-actions":
- expectedSource = UrlbarUtils.RESULT_SOURCE.ACTIONS;
- break;
default:
Assert.ok(false, `Unexpected local shortcut ID: ${button.id}`);
break;
diff --git a/browser/components/urlbar/tests/browser/browser_quickactions.js b/browser/components/urlbar/tests/browser/browser_quickactions.js
index ccf045d9e8..1fc4ef7cd6 100644
--- a/browser/components/urlbar/tests/browser/browser_quickactions.js
+++ b/browser/components/urlbar/tests/browser/browser_quickactions.js
@@ -10,32 +10,41 @@
ChromeUtils.defineESModuleGetters(this, {
AppConstants: "resource://gre/modules/AppConstants.sys.mjs",
UpdateService: "resource://gre/modules/UpdateService.sys.mjs",
- UrlbarProviderQuickActions:
- "resource:///modules/UrlbarProviderQuickActions.sys.mjs",
+ ActionsProviderQuickActions:
+ "resource:///modules/ActionsProviderQuickActions.sys.mjs",
});
const DUMMY_PAGE =
- "http://example.com/browser/browser/base/content/test/general/dummy_page.html";
+ "https://example.com/browser/browser/base/content/test/general/dummy_page.html";
let testActionCalled = 0;
+const assertAction = async name => {
+ await BrowserTestUtils.waitForCondition(() =>
+ window.document.querySelector(`.urlbarView-action-btn[data-action=${name}]`)
+ );
+ Assert.ok(true, `We found action "${name}`);
+};
+
+const hasQuickActions = win =>
+ !!win.document.querySelector(".urlbarView-action-btn");
+
add_setup(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.quickactions.enabled", true],
- ["browser.urlbar.suggest.quickactions", true],
- ["browser.urlbar.shortcuts.quickactions", true],
+ ["browser.urlbar.secondaryActions.featureGate", true],
],
});
- UrlbarProviderQuickActions.addAction("testaction", {
+ ActionsProviderQuickActions.addAction("testaction", {
commands: ["testaction"],
label: "quickactions-downloads2",
onPick: () => testActionCalled++,
});
registerCleanupFunction(() => {
- UrlbarProviderQuickActions.removeAction("testaction");
+ ActionsProviderQuickActions.removeAction("testaction");
});
});
@@ -57,183 +66,16 @@ add_task(async function basic() {
value: "testact",
});
- Assert.equal(
- UrlbarTestUtils.getResultCount(window),
- 2,
- "We matched the action"
- );
+ await assertAction("testaction");
info("The callback of the action is fired when selected");
- EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
+ EventUtils.synthesizeKey("KEY_Tab", {}, window);
EventUtils.synthesizeKey("KEY_Enter", {}, window);
- Assert.equal(testActionCalled, 1, "Test actionwas called");
-});
-
-add_task(async function test_label_command() {
- info("A prefix of the label matches");
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "View Dow",
- });
- Assert.equal(
- UrlbarTestUtils.getResultCount(window),
- 2,
- "We matched the action"
- );
-
- let { result } = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
- Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.DYNAMIC);
- Assert.equal(result.providerName, "quickactions");
- await UrlbarTestUtils.promisePopupClose(window, () => {
- EventUtils.synthesizeKey("KEY_Escape");
- });
-});
-
-add_task(async function enter_search_mode_button() {
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "test",
- });
-
- await clickQuickActionOneoffButton();
-
- await UrlbarTestUtils.waitForAutocompleteResultAt(window, 0);
- Assert.ok(true, "Actions are shown when we enter actions search mode.");
-
- await UrlbarTestUtils.exitSearchMode(window);
- await UrlbarTestUtils.promisePopupClose(window);
- EventUtils.synthesizeKey("KEY_Escape");
-});
-
-add_task(async function enter_search_mode_oneoff_by_key() {
- // Select actions oneoff button by keyboard.
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "",
- });
- await UrlbarTestUtils.enterSearchMode(window);
- const oneOffButtons = UrlbarTestUtils.getOneOffSearchButtons(window);
- for (;;) {
- EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true });
- if (
- oneOffButtons.selectedButton.source === UrlbarUtils.RESULT_SOURCE.ACTIONS
- ) {
- break;
- }
- }
-
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: " ",
- });
- await UrlbarTestUtils.assertSearchMode(window, {
- source: UrlbarUtils.RESULT_SOURCE.ACTIONS,
- entry: "oneoff",
- });
-
- await UrlbarTestUtils.exitSearchMode(window);
- await UrlbarTestUtils.promisePopupClose(window);
- EventUtils.synthesizeKey("KEY_Escape");
-});
-
-add_task(async function enter_search_mode_key() {
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "> ",
- });
- await UrlbarTestUtils.assertSearchMode(window, {
- source: UrlbarUtils.RESULT_SOURCE.ACTIONS,
- entry: "typed",
- });
- Assert.equal(
- await hasQuickActions(window),
- true,
- "Actions are shown in search mode"
- );
- await UrlbarTestUtils.exitSearchMode(window);
- await UrlbarTestUtils.promisePopupClose(window);
- EventUtils.synthesizeKey("KEY_Escape");
-});
-
-add_task(async function test_disabled() {
- UrlbarProviderQuickActions.addAction("disabledaction", {
- commands: ["disabledaction"],
- isActive: () => false,
- label: "quickactions-restart",
- });
-
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "disabled",
- });
-
- Assert.equal(
- await hasQuickActions(window),
- false,
- "Result for quick actions is hidden"
- );
-
- await UrlbarTestUtils.promisePopupClose(window);
- UrlbarProviderQuickActions.removeAction("disabledaction");
-});
-
-/**
- * The first part of this test confirms that when the screenshots component is enabled
- * the screenshot quick action button will be enabled on about: pages.
- * The second part confirms that when the screenshots extension is enabled the
- * screenshot quick action button will be disbaled on about: pages.
- */
-add_task(async function test_screenshot_enabled_or_disabled() {
- let onLoaded = BrowserTestUtils.browserLoaded(
- gBrowser.selectedBrowser,
- false,
- "about:blank"
- );
- BrowserTestUtils.startLoadingURIString(
- gBrowser.selectedBrowser,
- "about:blank"
- );
- await onLoaded;
-
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "screenshot",
- });
- Assert.equal(
- UrlbarTestUtils.getResultCount(window),
- 2,
- "The action is displayed"
- );
- let screenshotButton = window.document.querySelector(
- ".urlbarView-row[dynamicType=quickactions] .urlbarView-quickaction-button"
- );
- Assert.ok(
- !screenshotButton.hasAttribute("disabled"),
- "Screenshot button is enabled on about pages"
- );
-
- await UrlbarTestUtils.promisePopupClose(window);
- EventUtils.synthesizeKey("KEY_Escape");
-
- await SpecialPowers.pushPrefEnv({
- set: [["screenshots.browser.component.enabled", false]],
- });
-
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "screenshot",
- });
- Assert.equal(
- await hasQuickActions(window),
- false,
- "Result for quick actions is hidden"
- );
-
- await UrlbarTestUtils.promisePopupClose(window);
+ Assert.equal(testActionCalled, 1, "Test action was called");
});
add_task(async function match_in_phrase() {
- UrlbarProviderQuickActions.addAction("newtestaction", {
+ ActionsProviderQuickActions.addAction("newtestaction", {
commands: ["matchingstring"],
label: "quickactions-downloads2",
});
@@ -243,304 +85,31 @@ add_task(async function match_in_phrase() {
window,
value: "Test we match at end of matchingstring",
});
- Assert.equal(
- UrlbarTestUtils.getResultCount(window),
- 2,
- "We matched the action"
- );
- await UrlbarTestUtils.promisePopupClose(window);
- EventUtils.synthesizeKey("KEY_Escape");
- UrlbarProviderQuickActions.removeAction("newtestaction");
-});
-
-add_task(async function test_other_search_mode() {
- let defaultEngine = await SearchTestUtils.promiseNewSearchEngine({
- url: getRootDirectory(gTestPath) + "searchSuggestionEngine.xml",
- });
- defaultEngine.alias = "testalias";
- let oldDefaultEngine = await Services.search.getDefault();
- Services.search.setDefault(
- defaultEngine,
- Ci.nsISearchService.CHANGE_REASON_UNKNOWN
- );
-
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: defaultEngine.alias + " ",
- });
- Assert.equal(
- UrlbarTestUtils.getResultCount(window),
- 0,
- "The results should be empty as no actions are displayed in other search modes"
- );
- await UrlbarTestUtils.assertSearchMode(window, {
- engineName: defaultEngine.name,
- entry: "typed",
- });
- await UrlbarTestUtils.promisePopupClose(window, () => {
- EventUtils.synthesizeKey("KEY_Escape");
- });
- Services.search.setDefault(
- oldDefaultEngine,
- Ci.nsISearchService.CHANGE_REASON_UNKNOWN
- );
-});
-
-add_task(async function test_no_quickactions_suggestions() {
- await SpecialPowers.pushPrefEnv({
- set: [
- ["browser.urlbar.suggest.quickactions", false],
- ["screenshots.browser.component.enabled", true],
- ],
- });
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "screenshot",
- });
- Assert.ok(
- !window.document.querySelector(
- ".urlbarView-row[dynamicType=quickactions] .urlbarView-quickaction-button"
- ),
- "Screenshot button is not suggested"
- );
-
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "> screenshot",
- });
- Assert.ok(
- window.document.querySelector(
- ".urlbarView-row[dynamicType=quickactions] .urlbarView-quickaction-button"
- ),
- "Screenshot button is suggested"
- );
-
- await UrlbarTestUtils.promisePopupClose(window);
- EventUtils.synthesizeKey("KEY_Escape");
-
- await SpecialPowers.popPrefEnv();
-});
-
-add_task(async function test_quickactions_disabled() {
- await SpecialPowers.pushPrefEnv({
- set: [
- ["browser.urlbar.quickactions.enabled", false],
- ["browser.urlbar.suggest.quickactions", true],
- ],
- });
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "screenshot",
- });
-
- Assert.ok(
- !window.document.querySelector(
- ".urlbarView-row[dynamicType=quickactions] .urlbarView-quickaction-button"
- ),
- "Screenshot button is not suggested"
- );
-
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "> screenshot",
- });
- Assert.ok(
- !window.document.querySelector(
- ".urlbarView-row[dynamicType=quickactions] .urlbarView-quickaction-button"
- ),
- "Screenshot button is not suggested"
- );
-
+ await assertAction("newtestaction");
await UrlbarTestUtils.promisePopupClose(window);
EventUtils.synthesizeKey("KEY_Escape");
-
- await SpecialPowers.popPrefEnv();
-});
-
-let COMMANDS_TESTS = [
- {
- cmd: "add-ons",
- uri: "about:addons",
- testFun: async () => isSelected("button[name=discover]"),
- },
- {
- cmd: "plugins",
- uri: "about:addons",
- testFun: async () => isSelected("button[name=plugin]"),
- },
- {
- cmd: "extensions",
- uri: "about:addons",
- testFun: async () => isSelected("button[name=extension]"),
- },
- {
- cmd: "themes",
- uri: "about:addons",
- testFun: async () => isSelected("button[name=theme]"),
- },
- {
- cmd: "add-ons",
- setup: async () => {
- const onLoad = BrowserTestUtils.browserLoaded(
- gBrowser.selectedBrowser,
- false,
- "http://example.com/"
- );
- BrowserTestUtils.startLoadingURIString(
- gBrowser.selectedBrowser,
- "http://example.com/"
- );
- await onLoad;
- },
- uri: "about:addons",
- isNewTab: true,
- testFun: async () => isSelected("button[name=discover]"),
- },
- {
- cmd: "plugins",
- setup: async () => {
- const onLoad = BrowserTestUtils.browserLoaded(
- gBrowser.selectedBrowser,
- false,
- "http://example.com/"
- );
- BrowserTestUtils.startLoadingURIString(
- gBrowser.selectedBrowser,
- "http://example.com/"
- );
- await onLoad;
- },
- uri: "about:addons",
- isNewTab: true,
- testFun: async () => isSelected("button[name=plugin]"),
- },
- {
- cmd: "extensions",
- setup: async () => {
- const onLoad = BrowserTestUtils.browserLoaded(
- gBrowser.selectedBrowser,
- false,
- "http://example.com/"
- );
- BrowserTestUtils.startLoadingURIString(
- gBrowser.selectedBrowser,
- "http://example.com/"
- );
- await onLoad;
- },
- uri: "about:addons",
- isNewTab: true,
- testFun: async () => isSelected("button[name=extension]"),
- },
- {
- cmd: "themes",
- setup: async () => {
- const onLoad = BrowserTestUtils.browserLoaded(
- gBrowser.selectedBrowser,
- false,
- "http://example.com/"
- );
- BrowserTestUtils.startLoadingURIString(
- gBrowser.selectedBrowser,
- "http://example.com/"
- );
- await onLoad;
- },
- uri: "about:addons",
- isNewTab: true,
- testFun: async () => isSelected("button[name=theme]"),
- },
-];
-
-let isSelected = async selector =>
- SpecialPowers.spawn(gBrowser.selectedBrowser, [selector], arg => {
- return ContentTaskUtils.waitForCondition(() =>
- content.document.querySelector(arg)?.hasAttribute("selected")
- );
- });
-
-add_task(async function test_pages() {
- for (const { cmd, uri, setup, isNewTab, testFun } of COMMANDS_TESTS) {
- info(`Testing ${cmd} command is triggered`);
- let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
-
- if (setup) {
- info("Setup");
- await setup();
- }
-
- let onLoad = isNewTab
- ? BrowserTestUtils.waitForNewTab(gBrowser, uri, true)
- : BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, uri);
-
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: cmd,
- });
- EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
- EventUtils.synthesizeKey("KEY_Enter", {}, window);
-
- const newTab = await onLoad;
-
- Assert.ok(
- await testFun(),
- `The command "${cmd}" passed completed its test`
- );
-
- if (isNewTab) {
- await BrowserTestUtils.removeTab(newTab);
- }
- await BrowserTestUtils.removeTab(tab);
- }
+ ActionsProviderQuickActions.removeAction("newtestaction");
});
-const assertActionButtonStatus = async (name, expectedEnabled, description) => {
- await BrowserTestUtils.waitForCondition(() =>
- window.document.querySelector(`[data-key=${name}]`)
- );
- const target = window.document.querySelector(`[data-key=${name}]`);
- Assert.equal(!target.hasAttribute("disabled"), expectedEnabled, description);
-};
-
add_task(async function test_viewsource() {
info("Check the button status of when the page is not web content");
const tab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
- opening: "about:home",
+ opening: "https://example.com",
waitForLoad: true,
});
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "viewsource",
- });
- await assertActionButtonStatus(
- "viewsource",
- true,
- "Should be enabled even if the page is not web content"
- );
- info("Check the button status of when the page is web content");
- BrowserTestUtils.startLoadingURIString(
- gBrowser.selectedBrowser,
- "http://example.com"
- );
- await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "viewsource",
});
- await assertActionButtonStatus(
- "viewsource",
- true,
- "Should be enabled on web content as well"
- );
info("Do view source action");
const onLoad = BrowserTestUtils.waitForNewTab(
gBrowser,
- "view-source:http://example.com/"
+ "view-source:https://example.com/"
);
- EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
+ EventUtils.synthesizeKey("KEY_Tab", {}, window);
EventUtils.synthesizeKey("KEY_Enter", {}, window);
const viewSourceTab = await onLoad;
@@ -551,7 +120,7 @@ add_task(async function test_viewsource() {
});
Assert.equal(
- await hasQuickActions(window),
+ hasQuickActions(window),
false,
"Result for quick actions is hidden"
);
@@ -575,7 +144,7 @@ async function doAlertDialogTest({ input, dialogContentURI }) {
},
});
- EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
+ EventUtils.synthesizeKey("KEY_Tab", {}, window);
EventUtils.synthesizeKey("KEY_Enter", {}, window);
await onDialog;
@@ -601,16 +170,16 @@ add_task(async function test_clear() {
});
});
-async function doUpdateActionTest(isActiveExpected, description) {
+async function doUpdateActionTest(isActiveExpected) {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "update",
});
if (isActiveExpected) {
- await assertActionButtonStatus("update", isActiveExpected, description);
+ await assertAction("update");
} else {
- Assert.equal(await hasQuickActions(window), false, description);
+ Assert.equal(hasQuickActions(window), false, "No QuickActions were shown");
}
}
@@ -644,43 +213,6 @@ add_task(async function test_update() {
}
});
-async function hasQuickActions(win) {
- for (let i = 0, count = UrlbarTestUtils.getResultCount(win); i < count; i++) {
- const { result } = await UrlbarTestUtils.getDetailsOfResultAt(win, i);
- if (result.providerName === "quickactions") {
- return true;
- }
- }
- return false;
-}
-
-add_task(async function test_show_in_zero_prefix() {
- for (const minimumSearchString of [0, 3]) {
- info(
- `Test when quickactions.minimumSearchString pref is ${minimumSearchString}`
- );
- await SpecialPowers.pushPrefEnv({
- set: [
- [
- "browser.urlbar.quickactions.minimumSearchString",
- minimumSearchString,
- ],
- ],
- });
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "",
- });
-
- Assert.equal(
- await hasQuickActions(window),
- !minimumSearchString,
- "Result for quick actions is as expected"
- );
- await SpecialPowers.popPrefEnv();
- }
-});
-
add_task(async function test_whitespace() {
info("Test with quickactions.showInZeroPrefix pref is false");
await SpecialPowers.pushPrefEnv({
@@ -691,7 +223,7 @@ add_task(async function test_whitespace() {
value: " ",
});
Assert.equal(
- await hasQuickActions(window),
+ hasQuickActions(window),
false,
"Result for quick actions is not shown"
);
diff --git a/browser/components/urlbar/tests/browser/browser_quickactions_commands.js b/browser/components/urlbar/tests/browser/browser_quickactions_commands.js
new file mode 100644
index 0000000000..19b8d31ada
--- /dev/null
+++ b/browser/components/urlbar/tests/browser/browser_quickactions_commands.js
@@ -0,0 +1,154 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Test QuickActions.
+ */
+
+"use strict";
+
+add_setup(async function setup() {
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["browser.urlbar.quickactions.enabled", true],
+ ["browser.urlbar.secondaryActions.featureGate", true],
+ ],
+ });
+});
+
+let COMMANDS_TESTS = [
+ {
+ cmd: "add-ons",
+ uri: "about:addons",
+ testFun: async () => isSelected("button[name=discover]"),
+ },
+ {
+ cmd: "plugins",
+ uri: "about:addons",
+ testFun: async () => isSelected("button[name=plugin]"),
+ },
+ {
+ cmd: "extensions",
+ uri: "about:addons",
+ testFun: async () => isSelected("button[name=extension]"),
+ },
+ {
+ cmd: "themes",
+ uri: "about:addons",
+ testFun: async () => isSelected("button[name=theme]"),
+ },
+ {
+ cmd: "add-ons",
+ setup: async () => {
+ const onLoad = BrowserTestUtils.browserLoaded(
+ gBrowser.selectedBrowser,
+ false,
+ "https://example.com/"
+ );
+ BrowserTestUtils.startLoadingURIString(
+ gBrowser.selectedBrowser,
+ "https://example.com/"
+ );
+ await onLoad;
+ },
+ uri: "about:addons",
+ isNewTab: true,
+ testFun: async () => isSelected("button[name=discover]"),
+ },
+ {
+ cmd: "plugins",
+ setup: async () => {
+ const onLoad = BrowserTestUtils.browserLoaded(
+ gBrowser.selectedBrowser,
+ false,
+ "https://example.com/"
+ );
+ BrowserTestUtils.startLoadingURIString(
+ gBrowser.selectedBrowser,
+ "https://example.com/"
+ );
+ await onLoad;
+ },
+ uri: "about:addons",
+ isNewTab: true,
+ testFun: async () => isSelected("button[name=plugin]"),
+ },
+ {
+ cmd: "extensions",
+ setup: async () => {
+ const onLoad = BrowserTestUtils.browserLoaded(
+ gBrowser.selectedBrowser,
+ false,
+ "https://example.com/"
+ );
+ BrowserTestUtils.startLoadingURIString(
+ gBrowser.selectedBrowser,
+ "https://example.com/"
+ );
+ await onLoad;
+ },
+ uri: "about:addons",
+ isNewTab: true,
+ testFun: async () => isSelected("button[name=extension]"),
+ },
+ {
+ cmd: "themes",
+ setup: async () => {
+ const onLoad = BrowserTestUtils.browserLoaded(
+ gBrowser.selectedBrowser,
+ false,
+ "https://example.com/"
+ );
+ BrowserTestUtils.startLoadingURIString(
+ gBrowser.selectedBrowser,
+ "https://example.com/"
+ );
+ await onLoad;
+ },
+ uri: "about:addons",
+ isNewTab: true,
+ testFun: async () => isSelected("button[name=theme]"),
+ },
+];
+
+let isSelected = async selector =>
+ SpecialPowers.spawn(gBrowser.selectedBrowser, [selector], arg => {
+ return ContentTaskUtils.waitForCondition(() =>
+ content.document.querySelector(arg)?.hasAttribute("selected")
+ );
+ });
+
+add_task(async function test_pages() {
+ for (const { cmd, uri, setup, isNewTab, testFun } of COMMANDS_TESTS) {
+ info(`Testing ${cmd} command is triggered`);
+ let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
+
+ if (setup) {
+ info("Setup");
+ await setup();
+ }
+
+ let onLoad = isNewTab
+ ? BrowserTestUtils.waitForNewTab(gBrowser, uri, true)
+ : BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, uri);
+
+ await UrlbarTestUtils.promiseAutocompleteResultPopup({
+ window,
+ value: cmd,
+ });
+ EventUtils.synthesizeKey("KEY_Tab", {}, window);
+ EventUtils.synthesizeKey("KEY_Enter", {}, window);
+
+ const newTab = await onLoad;
+
+ Assert.ok(
+ await testFun(),
+ `The command "${cmd}" passed completed its test`
+ );
+
+ if (isNewTab) {
+ await BrowserTestUtils.removeTab(newTab);
+ }
+ await BrowserTestUtils.removeTab(tab);
+ }
+});
diff --git a/browser/components/urlbar/tests/browser/browser_quickactions_devtools.js b/browser/components/urlbar/tests/browser/browser_quickactions_devtools.js
index 1e1e92fb31..bee98d42af 100644
--- a/browser/components/urlbar/tests/browser/browser_quickactions_devtools.js
+++ b/browser/components/urlbar/tests/browser/browser_quickactions_devtools.js
@@ -17,7 +17,7 @@ add_setup(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.quickactions.enabled", true],
- ["browser.urlbar.suggest.quickactions", true],
+ ["browser.urlbar.secondaryActions.featureGate", true],
["browser.urlbar.shortcuts.quickactions", true],
],
});
@@ -25,21 +25,14 @@ add_setup(async function setup() {
const assertActionButtonStatus = async (name, expectedEnabled, description) => {
await BrowserTestUtils.waitForCondition(() =>
- window.document.querySelector(`[data-key=${name}]`)
+ window.document.querySelector(`[data-action=${name}]`)
);
- const target = window.document.querySelector(`[data-key=${name}]`);
+ const target = window.document.querySelector(`[data-action=${name}]`);
Assert.equal(!target.hasAttribute("disabled"), expectedEnabled, description);
};
-async function hasQuickActions(win) {
- for (let i = 0, count = UrlbarTestUtils.getResultCount(win); i < count; i++) {
- const { result } = await UrlbarTestUtils.getDetailsOfResultAt(win, i);
- if (result.providerName === "quickactions") {
- return true;
- }
- }
- return false;
-}
+const hasQuickActions = win =>
+ !!win.document.querySelector(".urlbarView-action-btn");
add_task(async function test_inspector() {
const testData = [
@@ -129,7 +122,7 @@ add_task(async function test_inspector() {
);
} else {
Assert.equal(
- await hasQuickActions(window),
+ hasQuickActions(window),
false,
"Result for quick actions is not shown since the inspector tool is disabled"
);
@@ -142,7 +135,7 @@ add_task(async function test_inspector() {
}
info("Do inspect action");
- EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
+ EventUtils.synthesizeKey("KEY_Tab", {}, window);
EventUtils.synthesizeKey("KEY_Enter", {}, window);
await BrowserTestUtils.waitForCondition(
() => DevToolsShim.hasToolboxForTab(gBrowser.selectedTab),
@@ -160,7 +153,7 @@ add_task(async function test_inspector() {
value: "inspector",
});
Assert.equal(
- await hasQuickActions(window),
+ hasQuickActions(window),
false,
"Result for quick actions is not shown since the inspector is already opening"
);
diff --git a/browser/components/urlbar/tests/browser/browser_quickactions_screenshot.js b/browser/components/urlbar/tests/browser/browser_quickactions_screenshot.js
index c81442f0f5..c83fdff441 100644
--- a/browser/components/urlbar/tests/browser/browser_quickactions_screenshot.js
+++ b/browser/components/urlbar/tests/browser/browser_quickactions_screenshot.js
@@ -34,11 +34,18 @@ async function clickQuickActionOneoffButton() {
});
}
+const assertAction = async name => {
+ await BrowserTestUtils.waitForCondition(() =>
+ window.document.querySelector(`.urlbarView-action-btn[data-action=${name}]`)
+ );
+ Assert.ok(true, `We found action "${name}`);
+};
+
add_setup(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.quickactions.enabled", true],
- ["browser.urlbar.suggest.quickactions", true],
+ ["browser.urlbar.secondaryActions.featureGate", true],
["browser.urlbar.shortcuts.quickactions", true],
],
});
@@ -61,17 +68,10 @@ add_task(async function test_screenshot() {
window,
value: "screenshot",
});
- Assert.equal(
- UrlbarTestUtils.getResultCount(window),
- 2,
- "We matched the action"
- );
- let { result } = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
- Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.DYNAMIC);
- Assert.equal(result.providerName, "quickactions");
+ await assertAction("screenshot");
info("Trigger the screenshot mode");
- EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
+ EventUtils.synthesizeKey("KEY_Tab", {}, window);
EventUtils.synthesizeKey("KEY_Enter", {}, window);
await TestUtils.waitForCondition(
isScreenshotInitialized,
@@ -104,38 +104,6 @@ add_task(async function search_mode_on_webpage() {
});
await UrlbarTestUtils.promiseSearchComplete(window);
- info("Enter quick action search mode");
- await clickQuickActionOneoffButton();
- await UrlbarTestUtils.waitForAutocompleteResultAt(window, 0);
- Assert.ok(true, "Actions are shown when we enter actions search mode.");
-
- info("Trigger the screenshot mode");
- const initialActionButtons = window.document.querySelectorAll(
- ".urlbarView-row[dynamicType=quickactions] .urlbarView-quickaction-button"
- );
- let screenshotButton;
- for (let i = 0; i < initialActionButtons.length; i++) {
- const item = initialActionButtons.item(i);
- if (item.dataset.key === "screenshot") {
- screenshotButton = item;
- break;
- }
- }
- EventUtils.synthesizeMouseAtCenter(screenshotButton, {}, window);
- await TestUtils.waitForCondition(
- isScreenshotInitialized,
- "Screenshot component is active",
- 200,
- 100
- );
-
- info("Press Escape to exit screenshot mode");
- EventUtils.synthesizeKey("KEY_Escape", {}, window);
- await TestUtils.waitForCondition(
- async () => !(await isScreenshotInitialized()),
- "Screenshot component has been dismissed"
- );
-
info("Check the urlbar state");
Assert.equal(gURLBar.value, UrlbarTestUtils.trimURL("https://example.com"));
Assert.equal(gURLBar.getAttribute("pageproxystate"), "valid");
@@ -146,23 +114,7 @@ add_task(async function search_mode_on_webpage() {
});
await UrlbarTestUtils.promiseSearchComplete(window);
- info("Enter quick action search mode again");
- await clickQuickActionOneoffButton();
- await UrlbarTestUtils.waitForAutocompleteResultAt(window, 0);
- const finalActionButtons = window.document.querySelectorAll(
- ".urlbarView-row[dynamicType=quickactions] .urlbarView-quickaction-button"
- );
-
- info("Check the action buttons and the urlbar");
- Assert.equal(
- finalActionButtons.length,
- initialActionButtons.length,
- "The same buttons as initially displayed will display"
- );
- Assert.equal(gURLBar.value, "");
-
info("Clean up");
- await UrlbarTestUtils.exitSearchMode(window);
await UrlbarTestUtils.promisePopupClose(window);
EventUtils.synthesizeKey("KEY_Escape");
BrowserTestUtils.removeTab(tab);
diff --git a/browser/components/urlbar/tests/browser/browser_quickactions_tab_refocus.js b/browser/components/urlbar/tests/browser/browser_quickactions_tab_refocus.js
index abac861931..ee1f3cab62 100644
--- a/browser/components/urlbar/tests/browser/browser_quickactions_tab_refocus.js
+++ b/browser/components/urlbar/tests/browser/browser_quickactions_tab_refocus.js
@@ -13,7 +13,7 @@ add_setup(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.quickactions.enabled", true],
- ["browser.urlbar.suggest.quickactions", true],
+ ["browser.urlbar.secondaryActions.featureGate", true],
["browser.urlbar.shortcuts.quickactions", true],
],
});
@@ -90,7 +90,7 @@ add_task(async function test_about_pages() {
window,
value: firstInput,
});
- EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
+ EventUtils.synthesizeKey("KEY_Tab", {}, window);
EventUtils.synthesizeKey("KEY_Enter", {}, window);
}
await onLoad;
@@ -106,7 +106,7 @@ add_task(async function test_about_pages() {
window,
value: secondInput || firstInput,
});
- EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
+ EventUtils.synthesizeKey("KEY_Tab", {}, window);
EventUtils.synthesizeKey("KEY_Enter", {}, window);
Assert.equal(
gBrowser.selectedTab,
@@ -158,7 +158,7 @@ add_task(async function test_about_addons_pages() {
window,
value: cmd,
});
- EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
+ EventUtils.synthesizeKey("KEY_Tab", {}, window);
EventUtils.synthesizeKey("KEY_Enter", {}, window);
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
Assert.ok(await testFun(), "The page content is correct");
@@ -175,7 +175,7 @@ add_task(async function test_about_addons_pages() {
window,
value: cmd,
});
- EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
+ EventUtils.synthesizeKey("KEY_Tab", {}, window);
EventUtils.synthesizeKey("KEY_Enter", {}, window);
await BrowserTestUtils.waitForCondition(() => testFun());
Assert.ok(true, "The tab correspondent action is selected");
diff --git a/browser/components/urlbar/tests/browser/browser_secondaryActions.js b/browser/components/urlbar/tests/browser/browser_secondaryActions.js
new file mode 100644
index 0000000000..7e03ae036c
--- /dev/null
+++ b/browser/components/urlbar/tests/browser/browser_secondaryActions.js
@@ -0,0 +1,141 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Basic tests for secondary Actions.
+ */
+
+"use strict";
+
+ChromeUtils.defineESModuleGetters(this, {
+ ActionsProviderQuickActions:
+ "resource:///modules/ActionsProviderQuickActions.sys.mjs",
+});
+
+let testActionCalled = 0;
+
+let loadURI = async (browser, uri) => {
+ let onLoaded = BrowserTestUtils.browserLoaded(browser, false, uri);
+ BrowserTestUtils.startLoadingURIString(browser, uri);
+ return onLoaded;
+};
+
+add_setup(async function setup() {
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["browser.urlbar.quickactions.enabled", true],
+ ["browser.urlbar.secondaryActions.featureGate", true],
+ ["browser.urlbar.contextualSearch.enabled", true],
+ ],
+ });
+
+ ActionsProviderQuickActions.addAction("testaction", {
+ commands: ["testaction"],
+ actionKey: "testaction",
+ label: "quickactions-downloads2",
+ onPick: () => testActionCalled++,
+ });
+
+ registerCleanupFunction(() => {
+ ActionsProviderQuickActions.removeAction("testaction");
+ });
+});
+
+add_task(async function test_quickaction() {
+ info("Match an installed quickaction and trigger it via tab");
+ await UrlbarTestUtils.promiseAutocompleteResultPopup({
+ window,
+ value: "testact",
+ });
+
+ Assert.equal(
+ UrlbarTestUtils.getResultCount(window),
+ 1,
+ "We matched the action"
+ );
+
+ info("The callback of the action is fired when selected");
+ EventUtils.synthesizeKey("KEY_Tab", {}, window);
+ EventUtils.synthesizeKey("KEY_Enter", {}, window);
+ Assert.equal(testActionCalled, 1, "Test action was called");
+});
+
+add_task(async function test_switchtab() {
+ let win = await BrowserTestUtils.openNewBrowserWindow();
+ await loadURI(win.gBrowser, "https://example.com/");
+
+ info("Open a new tab, type in the urlbar and switch to previous tab");
+ await BrowserTestUtils.openNewForegroundTab(win.gBrowser);
+ await UrlbarTestUtils.promiseAutocompleteResultPopup({
+ window: win,
+ value: "example",
+ });
+
+ EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
+ EventUtils.synthesizeKey("KEY_Tab", {}, win);
+ EventUtils.synthesizeKey("KEY_Enter", {}, win);
+
+ is(win.gBrowser.tabs.length, 1, "We switched to previous tab");
+ is(
+ win.gBrowser.currentURI.spec,
+ "https://example.com/",
+ "We switched to previous tab"
+ );
+
+ info(
+ "Open a new tab, type in the urlbar, select result and open url in current tab"
+ );
+ await BrowserTestUtils.openNewForegroundTab(win.gBrowser);
+ await UrlbarTestUtils.promiseAutocompleteResultPopup({
+ window: win,
+ value: "example",
+ });
+
+ EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
+ EventUtils.synthesizeKey("KEY_Enter", {}, win);
+ await BrowserTestUtils.browserLoaded(win.gBrowser);
+ is(win.gBrowser.tabs.length, 2, "We switched to previous tab");
+ is(
+ win.gBrowser.currentURI.spec,
+ "https://example.com/",
+ "We opened in current tab"
+ );
+
+ BrowserTestUtils.closeWindow(win);
+});
+
+add_task(async function test_sitesearch() {
+ await SearchTestUtils.installSearchExtension({
+ name: "Contextual",
+ search_url: "https://example.com/browser",
+ });
+
+ let ENGINE_TEST_URL = "https://example.com/";
+ await loadURI(gBrowser.selectedBrowser, ENGINE_TEST_URL);
+
+ const query = "search";
+ let engine = Services.search.getEngineByName("Contextual");
+ const [expectedUrl] = UrlbarUtils.getSearchQueryUrl(engine, query);
+
+ await UrlbarTestUtils.promiseAutocompleteResultPopup({
+ window,
+ value: "sea",
+ });
+
+ let onLoad = BrowserTestUtils.browserLoaded(
+ gBrowser.selectedBrowser,
+ false,
+ expectedUrl
+ );
+ gURLBar.value = query;
+ UrlbarTestUtils.fireInputEvent(window);
+ EventUtils.synthesizeKey("KEY_Tab");
+ EventUtils.synthesizeKey("KEY_Enter");
+ await onLoad;
+
+ Assert.equal(
+ gBrowser.selectedBrowser.currentURI.spec,
+ expectedUrl,
+ "Selecting the contextual search result opens the search URL"
+ );
+});
diff --git a/browser/components/urlbar/tests/browser/browser_strip_on_share.js b/browser/components/urlbar/tests/browser/browser_strip_on_share.js
index 9e045cee9c..ec3f96425a 100644
--- a/browser/components/urlbar/tests/browser/browser_strip_on_share.js
+++ b/browser/components/urlbar/tests/browser/browser_strip_on_share.js
@@ -101,6 +101,32 @@ add_task(async function testQueryParamIsNotStrippedForWrongSiteSpecific() {
});
});
+// Ensuring site specific parameters are stripped regardless
+// of capitalization in the URI
+add_task(async function testQueryParamIsStrippedWhenParamIsCapitalized() {
+ let originalUrl = "https://www.example.com/?TEST_1=1234";
+ let shortenedUrl = "https://www.example.com/";
+ await testMenuItemEnabled({
+ selectWholeUrl: true,
+ validUrl: originalUrl,
+ strippedUrl: shortenedUrl,
+ useTestList: true,
+ });
+});
+
+// Ensuring site specific parameters are stripped regardless
+// of capitalization in the URI
+add_task(async function testQueryParamIsStrippedWhenParamIsCapitalized() {
+ let originalUrl = "https://www.example.com/?test_5=1234";
+ let shortenedUrl = "https://www.example.com/";
+ await testMenuItemEnabled({
+ selectWholeUrl: true,
+ validUrl: originalUrl,
+ strippedUrl: shortenedUrl,
+ useTestList: true,
+ });
+});
+
/**
* Opens a new tab, opens the ulr bar context menu and checks that the strip-on-share menu item is not visible
*
@@ -163,7 +189,7 @@ async function testMenuItemEnabled({
topLevelSites: ["*"],
},
example: {
- queryParams: ["test_2", "test_1"],
+ queryParams: ["test_2", "test_1", "TEST_5"],
topLevelSites: ["www.example.com"],
},
exampleNet: {
diff --git a/browser/components/urlbar/tests/browser/browser_urlbar_telemetry_quickactions.js b/browser/components/urlbar/tests/browser/browser_urlbar_telemetry_quickactions.js
deleted file mode 100644
index b29807900b..0000000000
--- a/browser/components/urlbar/tests/browser/browser_urlbar_telemetry_quickactions.js
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-/**
- * This file tests urlbar telemetry for quickactions.
- */
-
-"use strict";
-
-ChromeUtils.defineESModuleGetters(this, {
- UrlbarProviderQuickActions:
- "resource:///modules/UrlbarProviderQuickActions.sys.mjs",
-});
-
-let testActionCalled = 0;
-
-add_setup(async function setup() {
- await SpecialPowers.pushPrefEnv({
- set: [
- ["browser.urlbar.suggest.quickactions", true],
- ["browser.urlbar.quickactions.enabled", true],
- ],
- });
-
- UrlbarProviderQuickActions.addAction("testaction", {
- commands: ["testaction"],
- label: "quickactions-downloads2",
- onPick: () => testActionCalled++,
- });
-
- registerCleanupFunction(() => {
- UrlbarProviderQuickActions.removeAction("testaction");
- });
-});
-
-add_task(async function test() {
- const histograms = snapshotHistograms();
-
- // Do a search to show the quickaction.
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "testaction",
- waitForFocus,
- fireInputEvent: true,
- });
-
- await UrlbarTestUtils.promisePopupClose(window, () => {
- EventUtils.synthesizeKey("KEY_ArrowDown");
- EventUtils.synthesizeKey("KEY_Enter");
- });
-
- Assert.equal(testActionCalled, 1, "Test action was called");
-
- TelemetryTestUtils.assertHistogram(
- histograms.resultMethodHist,
- UrlbarTestUtils.SELECTED_RESULT_METHODS.arrowEnterSelection,
- 1
- );
-
- let scalars = TelemetryTestUtils.getProcessScalars("parent", true, true);
- TelemetryTestUtils.assertKeyedScalar(
- scalars,
- `urlbar.picked.quickaction`,
- 1,
- 1
- );
-
- TelemetryTestUtils.assertKeyedScalar(
- scalars,
- "quickaction.picked",
- "testaction-10",
- 1
- );
-
- TelemetryTestUtils.assertKeyedScalar(
- scalars,
- "quickaction.impression",
- "testaction-10",
- 1
- );
-
- // Clean up for subsequent tests.
- gURLBar.handleRevert();
-});
-
-add_task(async function test_impressions() {
- UrlbarProviderQuickActions.addAction("testaction2", {
- commands: ["testaction2"],
- label: "quickactions-downloads2",
- onPick: () => {},
- });
-
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "testaction",
- waitForFocus,
- fireInputEvent: true,
- });
-
- await UrlbarTestUtils.promisePopupClose(window, () => {
- EventUtils.synthesizeKey("KEY_ArrowDown");
- EventUtils.synthesizeKey("KEY_Enter");
- });
-
- let scalars = TelemetryTestUtils.getProcessScalars("parent", true, true);
-
- TelemetryTestUtils.assertKeyedScalar(
- scalars,
- "quickaction.impression",
- `testaction-10`,
- 1
- );
- TelemetryTestUtils.assertKeyedScalar(
- scalars,
- "quickaction.impression",
- `testaction2-10`,
- 1
- );
-
- UrlbarProviderQuickActions.removeAction("testaction2");
- gURLBar.handleRevert();
-});
-
-function snapshotHistograms() {
- Services.telemetry.clearScalars();
- Services.telemetry.clearEvents();
- return {
- resultMethodHist: TelemetryTestUtils.getAndClearHistogram(
- "FX_URLBAR_SELECTED_RESULT_METHOD"
- ),
- };
-}
diff --git a/browser/components/urlbar/tests/browser/browser_view_selectionByMouse.js b/browser/components/urlbar/tests/browser/browser_view_selectionByMouse.js
index 10110a8928..0625a3397f 100644
--- a/browser/components/urlbar/tests/browser/browser_view_selectionByMouse.js
+++ b/browser/components/urlbar/tests/browser/browser_view_selectionByMouse.js
@@ -6,16 +6,16 @@
// Test selection on result view by mouse.
ChromeUtils.defineESModuleGetters(this, {
- UrlbarProviderQuickActions:
- "resource:///modules/UrlbarProviderQuickActions.sys.mjs",
+ ActionsProviderQuickActions:
+ "resource:///modules/ActionsProviderQuickActions.sys.mjs",
});
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [
+ ["browser.urlbar.secondaryActions.featureGate", true],
["browser.urlbar.quickactions.enabled", true],
["browser.urlbar.suggest.quickactions", true],
- ["browser.urlbar.shortcuts.quickactions", true],
],
});
@@ -23,7 +23,7 @@ add_setup(async function () {
await SearchTestUtils.installSearchExtension({}, { setAsDefault: true });
- UrlbarProviderQuickActions.addAction("test-addons", {
+ ActionsProviderQuickActions.addAction("test-addons", {
commands: ["test-addons"],
label: "quickactions-addons",
onPick: () =>
@@ -32,7 +32,7 @@ add_setup(async function () {
"about:about"
),
});
- UrlbarProviderQuickActions.addAction("test-downloads", {
+ ActionsProviderQuickActions.addAction("test-downloads", {
commands: ["test-downloads"],
label: "quickactions-downloads2",
onPick: () =>
@@ -43,40 +43,22 @@ add_setup(async function () {
});
registerCleanupFunction(function () {
- UrlbarProviderQuickActions.removeAction("test-addons");
- UrlbarProviderQuickActions.removeAction("test-downloads");
+ ActionsProviderQuickActions.removeAction("test-addons");
+ ActionsProviderQuickActions.removeAction("test-downloads");
});
});
add_task(async function basic() {
const testData = [
{
- description: "Normal result to quick action button",
- mousedown: ".urlbarView-row:nth-child(1) > .urlbarView-row-inner",
- mouseup: ".urlbarView-quickaction-button[data-key=test-downloads]",
- expected: "about:downloads",
- },
- {
- description: "Normal result to out of result",
- mousedown: ".urlbarView-row:nth-child(1) > .urlbarView-row-inner",
- mouseup: "body",
- expected: false,
- },
- {
description: "Quick action button to normal result",
- mousedown: ".urlbarView-quickaction-button[data-key=test-addons]",
+ mousedown: ".urlbarView-action-btn[data-action=test-addons]",
mouseup: ".urlbarView-row:nth-child(1)",
expected: "https://example.com/?q=test",
},
{
- description: "Quick action button to quick action button",
- mousedown: ".urlbarView-quickaction-button[data-key=test-addons]",
- mouseup: ".urlbarView-quickaction-button[data-key=test-downloads]",
- expected: "about:downloads",
- },
- {
description: "Quick action button to out of result",
- mousedown: ".urlbarView-quickaction-button[data-key=test-downloads]",
+ mousedown: ".urlbarView-action-btn[data-action=test-addons]",
mouseup: "body",
expected: false,
},
@@ -148,7 +130,7 @@ add_task(async function outOfBrowser() {
},
{
description: "Quick action button to out of browser",
- mousedown: ".urlbarView-quickaction-button[data-key=test-addons]",
+ mousedown: ".urlbarView-action-btn[data-action=test-addons]",
},
];
@@ -204,22 +186,22 @@ add_task(async function withSelectionByKeyboard() {
mouseup: "body",
expected: {
selectedElementByKey:
- "#urlbar-results .urlbarView-quickaction-button[selected]",
+ "#urlbar-results .urlbarView-action-btn[selected]",
selectedElementAfterMouseDown:
- "#urlbar-results .urlbarView-quickaction-button[selected]",
+ "#urlbar-results .urlbarView-action-btn[selected]",
actionedPage: false,
},
},
{
- description: "Select normal result, then click on about:downloads",
- mousedown: ".urlbarView-quickaction-button[data-key=test-downloads]",
- mouseup: ".urlbarView-quickaction-button[data-key=test-downloads]",
+ description: "Select normal result, then click on about:addons",
+ mousedown: ".urlbarView-action-btn[data-action=test-addons]",
+ mouseup: ".urlbarView-action-btn[data-action=test-addons]",
expected: {
selectedElementByKey:
"#urlbar-results .urlbarView-row > .urlbarView-row-inner[selected]",
selectedElementAfterMouseDown:
- ".urlbarView-quickaction-button[data-key=test-downloads]",
- actionedPage: "about:downloads",
+ ".urlbarView-action-btn[data-action=test-addons]",
+ actionedPage: "about:about",
},
},
];
@@ -244,11 +226,7 @@ add_task(async function withSelectionByKeyboard() {
]);
if (arrowDown) {
- EventUtils.synthesizeKey(
- "KEY_ArrowDown",
- { repeat: arrowDown },
- window
- );
+ EventUtils.synthesizeKey("KEY_Tab", { repeat: arrowDown }, window);
}
let [selectedElementByKey] = await waitForElements([
diff --git a/browser/components/urlbar/tests/browser/head.js b/browser/components/urlbar/tests/browser/head.js
index f78624e68e..73f9fda3a9 100644
--- a/browser/components/urlbar/tests/browser/head.js
+++ b/browser/components/urlbar/tests/browser/head.js
@@ -161,7 +161,7 @@ async function search({
// Set the input value and move the caret to the end to simulate the user
// typing. It's important the caret is at the end because otherwise autofill
// won't happen.
- gURLBar.value = searchString;
+ gURLBar._setValue(searchString, { allowTrim: false });
gURLBar.inputField.setSelectionRange(
searchString.length,
searchString.length
@@ -173,28 +173,21 @@ async function search({
// autofill before the search completes.
UrlbarTestUtils.fireInputEvent(window);
- // Subtract the protocol length, when the searchString contains the https://
- // protocol and trimHttps is enabled.
- let trimmedProtocolWSlashes = UrlbarTestUtils.getTrimmedProtocolWithSlashes();
- let selectionOffset = searchString.includes(trimmedProtocolWSlashes)
- ? trimmedProtocolWSlashes.length
- : 0;
-
// Check the input value and selection immediately, before waiting on the
// search to complete.
Assert.equal(
gURLBar.value,
- UrlbarTestUtils.trimURL(valueBefore),
+ valueBefore,
"gURLBar.value before the search completes"
);
Assert.equal(
gURLBar.selectionStart,
- searchString.length - selectionOffset,
+ searchString.length,
"gURLBar.selectionStart before the search completes"
);
Assert.equal(
gURLBar.selectionEnd,
- valueBefore.length - selectionOffset,
+ valueBefore.length,
"gURLBar.selectionEnd before the search completes"
);
@@ -205,17 +198,17 @@ async function search({
// Check the final value after the results arrived.
Assert.equal(
gURLBar.value,
- UrlbarTestUtils.trimURL(valueAfter),
+ valueAfter,
"gURLBar.value after the search completes"
);
Assert.equal(
gURLBar.selectionStart,
- searchString.length - selectionOffset,
+ searchString.length,
"gURLBar.selectionStart after the search completes"
);
Assert.equal(
gURLBar.selectionEnd,
- valueAfter.length - selectionOffset,
+ valueAfter.length,
"gURLBar.selectionEnd after the search completes"
);
@@ -227,7 +220,7 @@ async function search({
);
Assert.strictEqual(
gURLBar._autofillPlaceholder.value,
- UrlbarTestUtils.trimURL(placeholderAfter),
+ placeholderAfter,
"gURLBar._autofillPlaceholder.value after the search completes"
);
} else {
@@ -246,3 +239,51 @@ async function search({
"First result is an autofill result iff a placeholder is expected"
);
}
+
+function selectWithMouseDrag(fromX, toX, win = window) {
+ let target = win.gURLBar.inputField;
+ let rect = target.getBoundingClientRect();
+ let promise = BrowserTestUtils.waitForEvent(target, "mouseup");
+ EventUtils.synthesizeMouse(
+ target,
+ fromX,
+ rect.height / 2,
+ { type: "mousemove" },
+ target.ownerGlobal
+ );
+ EventUtils.synthesizeMouse(
+ target,
+ fromX,
+ rect.height / 2,
+ { type: "mousedown" },
+ target.ownerGlobal
+ );
+ EventUtils.synthesizeMouse(
+ target,
+ toX,
+ rect.height / 2,
+ { type: "mousemove" },
+ target.ownerGlobal
+ );
+ EventUtils.synthesizeMouse(
+ target,
+ toX,
+ rect.height / 2,
+ { type: "mouseup" },
+ target.ownerGlobal
+ );
+ return promise;
+}
+
+function selectWithDoubleClick(offsetX, win = window) {
+ let target = win.gURLBar.inputField;
+ let rect = target.getBoundingClientRect();
+ let promise = BrowserTestUtils.waitForEvent(target, "dblclick");
+ EventUtils.synthesizeMouse(target, offsetX, rect.height / 2, {
+ clickCount: 1,
+ });
+ EventUtils.synthesizeMouse(target, offsetX, rect.height / 2, {
+ clickCount: 2,
+ });
+ return promise;
+}
diff --git a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_abandonment_groups.js b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_abandonment_groups.js
index ce69d30517..f930b28f59 100644
--- a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_abandonment_groups.js
+++ b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_abandonment_groups.js
@@ -59,9 +59,9 @@ add_task(async function recent_search() {
assert: () =>
assertAbandonmentTelemetry([
{
- groups: "recent_search,suggested_index",
- results: "recent_search,action",
- n_results: 2,
+ groups: "recent_search",
+ results: "recent_search",
+ n_results: 1,
},
]),
});
@@ -114,9 +114,9 @@ add_task(async function top_site() {
assert: () =>
assertAbandonmentTelemetry([
{
- groups: "top_site,suggested_index",
- results: "top_site,action",
- n_results: 2,
+ groups: "top_site",
+ results: "top_site",
+ n_results: 1,
},
]),
});
@@ -128,9 +128,9 @@ add_task(async function clipboard() {
assert: () =>
assertAbandonmentTelemetry([
{
- groups: "general,suggested_index",
- results: "clipboard,action",
- n_results: 2,
+ groups: "general",
+ results: "clipboard",
+ n_results: 1,
},
]),
});
@@ -170,9 +170,9 @@ add_task(async function general() {
assert: () =>
assertAbandonmentTelemetry([
{
- groups: "heuristic,suggested_index,general",
- results: "search_engine,action,bookmark",
- n_results: 3,
+ groups: "heuristic,general",
+ results: "search_engine,bookmark",
+ n_results: 2,
},
]),
});
diff --git a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_abandonment_search_mode.js b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_abandonment_search_mode.js
index 7edcc47a30..45f4b79e7c 100644
--- a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_abandonment_search_mode.js
+++ b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_abandonment_search_mode.js
@@ -45,10 +45,3 @@ add_task(async function tabs() {
assert: () => assertAbandonmentTelemetry([{ search_mode: "tabs" }]),
});
});
-
-add_task(async function actions() {
- await doActionsTest({
- trigger: () => doBlur(),
- assert: () => assertAbandonmentTelemetry([{ search_mode: "actions" }]),
- });
-});
diff --git a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_edge_cases.js b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_edge_cases.js
index 04ef7e9757..1668470714 100644
--- a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_edge_cases.js
+++ b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_edge_cases.js
@@ -196,7 +196,6 @@ add_task(async function enter_to_reload_current_url() {
await BrowserTestUtils.waitForCondition(
() => window.document.activeElement === gURLBar.inputField
);
- await UrlbarTestUtils.promiseSearchComplete(window);
// Press Enter key to reload the page without selecting any suggestions.
await doEnter();
@@ -213,8 +212,8 @@ add_task(async function enter_to_reload_current_url() {
selected_result: "input_field",
selected_result_subtype: "",
provider: undefined,
- results: "action",
- groups: "suggested_index",
+ results: "",
+ groups: "",
},
]);
});
diff --git a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_groups.js b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_groups.js
index d46c874403..a0ef61dd19 100644
--- a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_groups.js
+++ b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_groups.js
@@ -59,9 +59,9 @@ add_task(async function recent_search() {
assert: () =>
assertEngagementTelemetry([
{
- groups: "recent_search,suggested_index",
- results: "recent_search,action",
- n_results: 2,
+ groups: "recent_search",
+ results: "recent_search",
+ n_results: 1,
},
]),
});
@@ -114,9 +114,9 @@ add_task(async function top_site() {
assert: () =>
assertEngagementTelemetry([
{
- groups: "top_site,suggested_index",
- results: "top_site,action",
- n_results: 2,
+ groups: "top_site",
+ results: "top_site",
+ n_results: 1,
},
]),
});
@@ -128,9 +128,9 @@ add_task(async function clipboard() {
assert: () =>
assertEngagementTelemetry([
{
- groups: "general,suggested_index",
- results: "clipboard,action",
- n_results: 2,
+ groups: "general",
+ results: "clipboard",
+ n_results: 1,
},
]),
});
@@ -170,9 +170,9 @@ add_task(async function general() {
assert: () =>
assertEngagementTelemetry([
{
- groups: "heuristic,suggested_index,general",
- results: "search_engine,action,bookmark",
- n_results: 3,
+ groups: "heuristic,general",
+ results: "search_engine,bookmark",
+ n_results: 2,
},
]),
});
@@ -255,6 +255,7 @@ add_task(async function always_empty_if_drop_go() {
await doTest(async () => {
// Open the results view once.
+ await addTopSites("https://example.com/");
await showResultByArrowDown();
await UrlbarTestUtils.promisePopupClose(window);
@@ -282,6 +283,7 @@ add_task(async function always_empty_if_paste_go() {
await doTest(async () => {
// Open the results view once.
+ await addTopSites("https://example.com/");
await showResultByArrowDown();
await UrlbarTestUtils.promisePopupClose(window);
diff --git a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_interaction.js b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_interaction.js
index 2866186c30..d2deacf597 100644
--- a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_interaction.js
+++ b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_interaction.js
@@ -42,6 +42,7 @@ add_task(async function dropped() {
});
await doTest(async () => {
+ await addTopSites("https://example.com/");
await showResultByArrowDown();
await doDropAndGo("example.com");
@@ -67,6 +68,7 @@ add_task(async function pasted() {
});
await doTest(async () => {
+ await addTopSites("https://example.com/");
await showResultByArrowDown();
await doPasteAndGo("www.example.com");
diff --git a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_search_mode.js b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_search_mode.js
index 013bef1904..9227b81fd0 100644
--- a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_search_mode.js
+++ b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_search_mode.js
@@ -42,6 +42,7 @@ add_task(async function tabs() {
await doTabTest({
trigger: async () => {
const currentTab = gBrowser.selectedTab;
+ EventUtils.synthesizeKey("KEY_Tab");
EventUtils.synthesizeKey("KEY_Enter");
await BrowserTestUtils.waitForCondition(
() => gBrowser.selectedTab !== currentTab
@@ -50,14 +51,3 @@ add_task(async function tabs() {
assert: () => assertEngagementTelemetry([{ search_mode: "tabs" }]),
});
});
-
-add_task(async function actions() {
- await doActionsTest({
- trigger: async () => {
- const onLoad = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
- doClickSubButton(".urlbarView-quickaction-button[data-key=addons]");
- await onLoad;
- },
- assert: () => assertEngagementTelemetry([{ search_mode: "actions" }]),
- });
-});
diff --git a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_selected_result.js b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_selected_result.js
index bea266dbf4..34083e4369 100644
--- a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_selected_result.js
+++ b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_engagement_selected_result.js
@@ -119,9 +119,9 @@ add_task(async function selected_result_bookmark() {
{
selected_result: "bookmark",
selected_result_subtype: "",
- selected_position: 3,
+ selected_position: 2,
provider: "Places",
- results: "search_engine,action,bookmark",
+ results: "search_engine,bookmark",
},
]);
});
@@ -267,27 +267,11 @@ add_task(async function selected_result_url() {
});
});
-add_task(async function selected_result_action() {
- await doTest(async () => {
- await showResultByArrowDown();
- await selectRowByProvider("quickactions");
- const onLoad = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
- doClickSubButton(".urlbarView-quickaction-button[data-key=addons]");
- await onLoad;
-
- assertEngagementTelemetry([
- {
- selected_result: "action",
- selected_result_subtype: "addons",
- selected_position: 1,
- provider: "quickactions",
- results: "action",
- },
- ]);
+add_task(async function selected_result_tab() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.urlbar.secondaryActions.featureGate", false]],
});
-});
-add_task(async function selected_result_tab() {
const tab = BrowserTestUtils.addTab(gBrowser, "https://example.com/");
await doTest(async () => {
@@ -307,6 +291,7 @@ add_task(async function selected_result_tab() {
]);
});
+ await SpecialPowers.popPrefEnv();
BrowserTestUtils.removeTab(tab);
});
@@ -402,7 +387,7 @@ add_task(async function selected_result_top_site() {
selected_result_subtype: "",
selected_position: 1,
provider: "UrlbarProviderTopSites",
- results: "top_site,action",
+ results: "top_site",
},
]);
});
@@ -456,7 +441,7 @@ add_task(async function selected_result_clipboard() {
selected_result_subtype: "",
selected_position: 1,
provider: "UrlbarProviderClipboard",
- results: "clipboard,action",
+ results: "clipboard",
},
]);
});
@@ -492,50 +477,6 @@ add_task(async function selected_result_unit() {
await SpecialPowers.popPrefEnv();
});
-add_task(async function selected_result_site_specific_contextual_search() {
- await SpecialPowers.pushPrefEnv({
- set: [["browser.urlbar.contextualSearch.enabled", true]],
- });
-
- await doTest(async () => {
- const extension = await SearchTestUtils.installSearchExtension(
- {
- name: "Contextual",
- search_url: "https://example.com/browser",
- },
- { skipUnload: true }
- );
- const onLoaded = BrowserTestUtils.browserLoaded(
- gBrowser.selectedBrowser,
- false,
- "https://example.com/"
- );
- BrowserTestUtils.startLoadingURIString(
- gBrowser.selectedBrowser,
- "https://example.com/"
- );
- await onLoaded;
-
- await openPopup("search");
- await selectRowByProvider("UrlbarProviderContextualSearch");
- await doEnter();
-
- assertEngagementTelemetry([
- {
- selected_result: "site_specific_contextual_search",
- selected_result_subtype: "",
- selected_position: 2,
- provider: "UrlbarProviderContextualSearch",
- results: "search_engine,site_specific_contextual_search",
- },
- ]);
-
- await extension.unload();
- });
-
- await SpecialPowers.popPrefEnv();
-});
-
add_task(async function selected_result_rs_adm_sponsored() {
const cleanupQuickSuggest = await ensureQuickSuggestInit({
prefs: [["quicksuggest.rustEnabled", false]],
diff --git a/browser/components/urlbar/tests/engagementTelemetry/browser/head-interaction.js b/browser/components/urlbar/tests/engagementTelemetry/browser/head-interaction.js
index 58c55b416f..dffdebad97 100644
--- a/browser/components/urlbar/tests/engagementTelemetry/browser/head-interaction.js
+++ b/browser/components/urlbar/tests/engagementTelemetry/browser/head-interaction.js
@@ -130,6 +130,7 @@ async function doTypedTest({ trigger, assert }) {
async function doTypedWithResultsPopupTest({ trigger, assert }) {
await doTest(async () => {
+ await addTopSites("https://example.org/");
await showResultByArrowDown();
EventUtils.synthesizeKey("x");
await UrlbarTestUtils.promiseSearchComplete(window);
@@ -150,6 +151,7 @@ async function doPastedTest({ trigger, assert }) {
async function doPastedWithResultsPopupTest({ trigger, assert }) {
await doTest(async () => {
+ await addTopSites("https://example.org/");
await showResultByArrowDown();
await doPaste("x");
@@ -257,6 +259,7 @@ async function doPersistedSearchTermsRestartedRefinedTest({
for (const { firstInput, secondInput, expected } of testData) {
await doTest(async () => {
+ await addTopSites("https://example.com/");
await openPopup(firstInput);
await doEnter();
diff --git a/browser/components/urlbar/tests/engagementTelemetry/browser/head-search_mode.js b/browser/components/urlbar/tests/engagementTelemetry/browser/head-search_mode.js
index 86151e1ba3..25a6504109 100644
--- a/browser/components/urlbar/tests/engagementTelemetry/browser/head-search_mode.js
+++ b/browser/components/urlbar/tests/engagementTelemetry/browser/head-search_mode.js
@@ -78,16 +78,3 @@ async function doTabTest({ trigger, assert }) {
BrowserTestUtils.removeTab(tab);
}
-
-async function doActionsTest({ trigger, assert }) {
- await doTest(async () => {
- await openPopup("add");
- await UrlbarTestUtils.enterSearchMode(window, {
- source: UrlbarUtils.RESULT_SOURCE.ACTIONS,
- });
- await selectRowByProvider("quickactions");
-
- await trigger();
- await assert();
- });
-}
diff --git a/browser/components/urlbar/tests/engagementTelemetry/browser/head.js b/browser/components/urlbar/tests/engagementTelemetry/browser/head.js
index 1373cc7e27..a3b2b020c0 100644
--- a/browser/components/urlbar/tests/engagementTelemetry/browser/head.js
+++ b/browser/components/urlbar/tests/engagementTelemetry/browser/head.js
@@ -406,9 +406,7 @@ async function setup() {
set: [
["browser.urlbar.searchEngagementTelemetry.enabled", true],
["browser.urlbar.quickactions.enabled", true],
- ["browser.urlbar.quickactions.minimumSearchString", 0],
- ["browser.urlbar.suggest.quickactions", true],
- ["browser.urlbar.shortcuts.quickactions", true],
+ ["browser.urlbar.secondaryActions.featureGate", true],
],
});
diff --git a/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest.js b/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest.js
index 98f6ba6117..87f94a641b 100644
--- a/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest.js
+++ b/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest.js
@@ -34,6 +34,27 @@ const REMOTE_SETTINGS_RESULTS = [
},
];
+const MERINO_NAVIGATIONAL_SUGGESTION = {
+ url: "https://example.com/navigational-suggestion",
+ title: "Navigational suggestion",
+ provider: "top_picks",
+ is_sponsored: false,
+ score: 0.25,
+ block_id: 0,
+ is_top_pick: true,
+};
+
+const MERINO_DYNAMIC_WIKIPEDIA_SUGGESTION = {
+ url: "https://example.com/dynamic-wikipedia",
+ title: "Dynamic Wikipedia suggestion",
+ click_url: "https://example.com/click",
+ impression_url: "https://example.com/impression",
+ advertiser: "dynamic-wikipedia",
+ provider: "wikipedia",
+ iab_category: "5 - Education",
+ block_id: 1,
+};
+
add_setup(async function () {
await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything();
@@ -46,7 +67,11 @@ add_setup(async function () {
attachment: REMOTE_SETTINGS_RESULTS,
},
],
+ merinoSuggestions: [],
});
+
+ // Disable Merino so we trigger only remote settings suggestions.
+ UrlbarPrefs.set("quicksuggest.dataCollection.enabled", false);
});
// Tests a sponsored result and keyword highlighting.
@@ -167,30 +192,9 @@ add_tasks_with_rust(
// Tests the "Manage" result menu for sponsored suggestion.
add_tasks_with_rust(async function resultMenu_manage_sponsored() {
- await BrowserTestUtils.withNewTab({ gBrowser }, async browser => {
- await UrlbarTestUtils.promiseAutocompleteResultPopup({
- window,
- value: "fra",
- });
-
- const managePage = "about:preferences#search";
- let onManagePageLoaded = BrowserTestUtils.browserLoaded(
- browser,
- false,
- managePage
- );
- // Click the command.
- await UrlbarTestUtils.openResultMenuAndClickItem(window, "manage", {
- resultIndex: 1,
- });
- await onManagePageLoaded;
- Assert.equal(
- browser.currentURI.spec,
- managePage,
- "The manage page is loaded"
- );
-
- await UrlbarTestUtils.promisePopupClose(window);
+ await doManageTest({
+ input: "fra",
+ index: 1,
});
});
@@ -201,3 +205,35 @@ add_tasks_with_rust(async function resultMenu_manage_nonSponsored() {
index: 1,
});
});
+
+// Tests the "Manage" result menu for Navigational suggestion.
+add_tasks_with_rust(async function resultMenu_manage_navigational() {
+ // Enable Merino.
+ UrlbarPrefs.set("quicksuggest.dataCollection.enabled", true);
+ MerinoTestUtils.server.response.body.suggestions = [
+ MERINO_NAVIGATIONAL_SUGGESTION,
+ ];
+
+ await doManageTest({
+ input: "test",
+ index: 1,
+ });
+
+ UrlbarPrefs.clear("quicksuggest.dataCollection.enabled");
+});
+
+// Tests the "Manage" result menu for Dynamic Wikipedia suggestion.
+add_tasks_with_rust(async function resultMenu_manage_dynamicWikipedia() {
+ // Enable Merino.
+ UrlbarPrefs.set("quicksuggest.dataCollection.enabled", true);
+ MerinoTestUtils.server.response.body.suggestions = [
+ MERINO_DYNAMIC_WIKIPEDIA_SUGGESTION,
+ ];
+
+ await doManageTest({
+ input: "test",
+ index: 1,
+ });
+
+ UrlbarPrefs.clear("quicksuggest.dataCollection.enabled");
+});
diff --git a/browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_dynamicWikipedia.js b/browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_dynamicWikipedia.js
index 71c289e0ef..c659eee268 100644
--- a/browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_dynamicWikipedia.js
+++ b/browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_dynamicWikipedia.js
@@ -88,24 +88,6 @@ add_task(async function () {
},
},
},
- // help
- {
- command: "help",
- scalars: {
- [TELEMETRY_SCALARS.IMPRESSION_DYNAMIC_WIKIPEDIA]: position,
- [TELEMETRY_SCALARS.HELP_DYNAMIC_WIKIPEDIA]: position,
- },
- event: {
- category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
- method: "engagement",
- object: "help",
- extra: {
- suggestion_type,
- match_type,
- position: position.toString(),
- },
- },
- },
],
});
});
diff --git a/browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_weather.js b/browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_weather.js
index e87c64740f..90044a95bd 100644
--- a/browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_weather.js
+++ b/browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_weather.js
@@ -121,24 +121,6 @@ add_task(async function () {
},
},
},
- // help
- {
- command: "help",
- scalars: {
- [WEATHER_SCALARS.IMPRESSION]: position,
- [WEATHER_SCALARS.HELP]: position,
- },
- event: {
- category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
- method: "engagement",
- object: "help",
- extra: {
- suggestion_type,
- match_type,
- position: position.toString(),
- },
- },
- },
],
});
});
diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_dynamicWikipedia.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_dynamicWikipedia.js
index a9f339c324..7fc687d3df 100644
--- a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_dynamicWikipedia.js
+++ b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_dynamicWikipedia.js
@@ -90,14 +90,11 @@ function makeExpectedResult() {
qsSuggestion: "full_keyword",
source: "merino",
provider: "wikipedia",
- helpUrl: QuickSuggest.HELP_URL,
- helpL10n: {
- id: "urlbar-result-menu-learn-more-about-firefox-suggest",
- },
isBlockable: true,
blockL10n: {
id: "urlbar-result-menu-dismiss-firefox-suggest",
},
+ isManageable: true,
},
};
}
diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_merino.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_merino.js
index 64f4991236..b88e14e0e0 100644
--- a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_merino.js
+++ b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_merino.js
@@ -549,14 +549,11 @@ add_task(async function bestMatch() {
url: "url",
icon: null,
qsSuggestion: "full_keyword",
- helpUrl: QuickSuggest.HELP_URL,
- helpL10n: {
- id: "urlbar-result-menu-learn-more-about-firefox-suggest",
- },
isBlockable: true,
blockL10n: {
id: "urlbar-result-menu-dismiss-firefox-suggest",
},
+ isManageable: true,
displayUrl: "url",
source: "merino",
provider: "some_top_pick_provider",
diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_scoreMap.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_scoreMap.js
index 224dd6cb22..89fefd3163 100644
--- a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_scoreMap.js
+++ b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_scoreMap.js
@@ -657,14 +657,11 @@ function makeExpectedDefaultResult({ suggestion }) {
? { id: "urlbar-result-action-sponsored" }
: undefined,
shouldShowUrl: true,
- helpUrl: QuickSuggest.HELP_URL,
- helpL10n: {
- id: "urlbar-result-menu-learn-more-about-firefox-suggest",
- },
isBlockable: true,
blockL10n: {
id: "urlbar-result-menu-dismiss-firefox-suggest",
},
+ isManageable: true,
},
};
}
diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_topPicks.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_topPicks.js
index 1b8da54920..468cedbe0b 100644
--- a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_topPicks.js
+++ b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_topPicks.js
@@ -175,14 +175,11 @@ function makeExpectedResult({
shouldShowUrl: true,
source: "merino",
provider: telemetryType,
- helpUrl: QuickSuggest.HELP_URL,
- helpL10n: {
- id: "urlbar-result-menu-learn-more-about-firefox-suggest",
- },
isBlockable: true,
blockL10n: {
id: "urlbar-result-menu-dismiss-firefox-suggest",
},
+ isManageable: true,
},
};
if (typeof dupedHeuristic == "boolean") {
diff --git a/browser/components/urlbar/tests/unit/test_autofill_origins.js b/browser/components/urlbar/tests/unit/test_autofill_origins.js
index 33e462a8af..454881b933 100644
--- a/browser/components/urlbar/tests/unit/test_autofill_origins.js
+++ b/browser/components/urlbar/tests/unit/test_autofill_origins.js
@@ -1039,3 +1039,68 @@ async function doTitleTest({ visits, input, expected }) {
await cleanup();
}
+
+/* Tests sorting order when only unvisited bookmarks are available (e.g. in
+ permanent private browsing mode), then the only information we have is the
+ number of bookmarks per origin, and we're going to use that. */
+add_task(async function just_multiple_unvisited_bookmarks() {
+ // These are sorted to avoid confusion with natural sorting, so the one with
+ // the highest score is added in the middle.
+ let filledUrl = "https://www.tld2.com/";
+ let urls = [
+ {
+ url: "https://tld1.com/",
+ count: 1,
+ },
+ {
+ url: "https://tld2.com/",
+ count: 2,
+ },
+ {
+ url: filledUrl,
+ count: 2,
+ },
+ {
+ url: "https://tld3.com/",
+ count: 3,
+ },
+ ];
+
+ await PlacesUtils.history.clear();
+ for (let { url, count } of urls) {
+ while (count--) {
+ await PlacesTestUtils.addBookmarkWithDetails({
+ uri: url,
+ });
+ }
+ }
+ await PlacesFrecencyRecalculator.recalculateAnyOutdatedFrecencies();
+
+ let context = createContext("tld", { isPrivate: false });
+ await check_results({
+ context,
+ autofilled: "tld2.com/",
+ completed: filledUrl,
+ matches: [
+ makeVisitResult(context, {
+ uri: filledUrl,
+ title: "A bookmark",
+ heuristic: true,
+ }),
+ makeBookmarkResult(context, {
+ uri: "https://tld3.com/",
+ title: "A bookmark",
+ }),
+ makeBookmarkResult(context, {
+ uri: "https://tld2.com/",
+ title: "A bookmark",
+ }),
+ makeBookmarkResult(context, {
+ uri: "https://tld1.com/",
+ title: "A bookmark",
+ }),
+ ],
+ });
+
+ await cleanup();
+});
diff --git a/browser/components/urlbar/tests/unit/test_quickactions.js b/browser/components/urlbar/tests/unit/test_quickactions.js
index 00206c77b2..30e3fbdd95 100644
--- a/browser/components/urlbar/tests/unit/test_quickactions.js
+++ b/browser/components/urlbar/tests/unit/test_quickactions.js
@@ -5,108 +5,58 @@
"use strict";
ChromeUtils.defineESModuleGetters(this, {
- UrlbarProviderQuickActions:
- "resource:///modules/UrlbarProviderQuickActions.sys.mjs",
+ ActionsProviderQuickActions:
+ "resource:///modules/ActionsProviderQuickActions.sys.mjs",
});
-let expectedMatch = (key, inputLength) => ({
- type: UrlbarUtils.RESULT_TYPE.DYNAMIC,
- source: UrlbarUtils.RESULT_SOURCE.ACTIONS,
- heuristic: false,
- payload: {
- results: [{ key }],
- dynamicType: "quickactions",
- inQuickActionsSearchMode: false,
- helpUrl: UrlbarProviderQuickActions.helpUrl,
- inputLength,
- },
-});
-
-testEngine_setup();
-
add_setup(async () => {
UrlbarPrefs.set("quickactions.enabled", true);
- UrlbarPrefs.set("suggest.quickactions", true);
- UrlbarProviderQuickActions.addAction("newaction", {
+ ActionsProviderQuickActions.addAction("newaction", {
commands: ["newaction"],
});
registerCleanupFunction(async () => {
UrlbarPrefs.clear("quickactions.enabled");
- UrlbarPrefs.clear("suggest.quickactions");
- UrlbarProviderQuickActions.removeAction("newaction");
+ ActionsProviderQuickActions.removeAction("newaction");
});
});
add_task(async function nomatch() {
- let context = createContext("this doesnt match", {
- providers: [UrlbarProviderQuickActions.name],
- isPrivate: false,
- });
- await check_results({
- context,
- matches: [],
- });
-});
-
-add_task(async function quickactions_disabled() {
- UrlbarPrefs.set("suggest.quickactions", false);
- let context = createContext("new", {
- providers: [UrlbarProviderQuickActions.name],
- isPrivate: false,
- });
- await check_results({
- context,
- matches: [],
- });
+ let context = createContext("this doesnt match", {});
+ let result = await ActionsProviderQuickActions.queryAction(context);
+ Assert.ok(result === null, "there were no matches");
});
add_task(async function quickactions_match() {
- UrlbarPrefs.set("suggest.quickactions", true);
- let context = createContext("new", {
- providers: [UrlbarProviderQuickActions.name],
- isPrivate: false,
- });
- await check_results({
- context,
- matches: [expectedMatch("newaction", 3)],
- });
+ let context = createContext("new", {});
+ let result = await ActionsProviderQuickActions.queryAction(context);
+ Assert.ok(result.key == "newaction", "Matched the new action");
});
add_task(async function duplicate_matches() {
- UrlbarProviderQuickActions.addAction("testaction", {
+ ActionsProviderQuickActions.addAction("testaction", {
commands: ["testaction", "test"],
});
- let context = createContext("testaction", {
- providers: [UrlbarProviderQuickActions.name],
- isPrivate: false,
- });
+ let context = createContext("test", {});
+ let result = await ActionsProviderQuickActions.queryAction(context);
- await check_results({
- context,
- matches: [expectedMatch("testaction", 10)],
- });
+ Assert.ok(result.key == "testaction", "Matched the test action");
- UrlbarProviderQuickActions.removeAction("testaction");
+ ActionsProviderQuickActions.removeAction("testaction");
});
add_task(async function remove_action() {
- UrlbarProviderQuickActions.addAction("testaction", {
+ ActionsProviderQuickActions.addAction("testaction", {
commands: ["testaction"],
});
- UrlbarProviderQuickActions.removeAction("testaction");
+ ActionsProviderQuickActions.removeAction("testaction");
- let context = createContext("test", {
- providers: [UrlbarProviderQuickActions.name],
- isPrivate: false,
- });
+ let context = createContext("test", {});
+ let result = await ActionsProviderQuickActions.queryAction(context);
- await check_results({
- context,
- matches: [],
- });
+ Assert.ok(result === null, "there were no matches");
});
add_task(async function minimum_search_string() {
@@ -114,13 +64,18 @@ add_task(async function minimum_search_string() {
for (let minimumSearchString of [0, 3]) {
UrlbarPrefs.set("quickactions.minimumSearchString", minimumSearchString);
for (let i = 1; i < 4; i++) {
- let context = createContext(searchString.substring(0, i), {
- providers: [UrlbarProviderQuickActions.name],
- isPrivate: false,
- });
- let matches =
- i >= minimumSearchString ? [expectedMatch("newaction", i)] : [];
- await check_results({ context, matches });
+ let context = createContext(searchString.substring(0, i), {});
+ let result = await ActionsProviderQuickActions.queryAction(context);
+
+ if (i >= minimumSearchString) {
+ Assert.ok(result.key == "newaction", "Matched the new action");
+ } else {
+ Assert.equal(
+ ActionsProviderQuickActions.isActive(context),
+ false,
+ "QuickActions Provider is not active"
+ );
+ }
}
}
UrlbarPrefs.clear("quickactions.minimumSearchString");
diff --git a/browser/components/urlbar/tests/unit/test_tokenizer.js b/browser/components/urlbar/tests/unit/test_tokenizer.js
index 835d1a5909..76b2c31ac2 100644
--- a/browser/components/urlbar/tests/unit/test_tokenizer.js
+++ b/browser/components/urlbar/tests/unit/test_tokenizer.js
@@ -32,6 +32,12 @@ add_task(async function test_tokenizer() {
],
},
{
+ desc: "do not separate restriction char at beginning in search mode",
+ searchMode: { engineName: "testEngine" },
+ searchString: `${UrlbarTokenizer.RESTRICT.SEARCH}test`,
+ expectedTokens: [{ value: "?test", type: UrlbarTokenizer.TYPE.TEXT }],
+ },
+ {
desc: "separate restriction char at end",
searchString: `test ${UrlbarTokenizer.RESTRICT.BOOKMARK}`,
expectedTokens: [