summaryrefslogtreecommitdiffstats
path: root/browser/components
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--browser/components/aboutwelcome/content/aboutwelcome.css29
-rw-r--r--browser/components/asrouter/content-src/styles/_feature-callout.scss6
-rw-r--r--browser/components/asrouter/modules/FeatureCallout.sys.mjs8
-rw-r--r--browser/components/urlbar/UrlbarInput.sys.mjs16
-rw-r--r--browser/components/urlbar/tests/browser/browser_result_menu_general.js117
5 files changed, 134 insertions, 42 deletions
diff --git a/browser/components/aboutwelcome/content/aboutwelcome.css b/browser/components/aboutwelcome/content/aboutwelcome.css
index 411f6d4f9b..aa0445e0ef 100644
--- a/browser/components/aboutwelcome/content/aboutwelcome.css
+++ b/browser/components/aboutwelcome/content/aboutwelcome.css
@@ -167,6 +167,35 @@
--fc-link-color-active: var(--fc-link-color-hover-active, #AAF2FF);
}
}
+:root[lwt-newtab-brighttext] #feature-callout.simulateContent.lwtNewtab {
+ color-scheme: dark;
+ --fc-background: var(--fc-background-dark, rgb(43, 42, 51));
+ --fc-color: var(--fc-color-dark, rgb(251, 251, 254));
+ --fc-border: var(--fc-border-dark, #3A3944);
+ --fc-accent-color: var(--fc-accent-color-dark, rgb(0, 221, 255));
+ --fc-button-background: var(--fc-button-background-dark, #2B2A33);
+ --fc-button-color: var(--fc-button-color-dark, rgb(251, 251, 254));
+ --fc-button-border: var(--fc-button-border-dark, transparent);
+ --fc-button-background-hover: var(--fc-button-background-hover-dark, #52525E);
+ --fc-button-color-hover: var(--fc-button-color-hover-dark, rgb(251, 251, 254));
+ --fc-button-border-hover: var(--fc-button-border-hover-dark, transparent);
+ --fc-button-background-active: var(--fc-button-background-active-dark, #5B5B66);
+ --fc-button-color-active: var(--fc-button-color-active-dark, rgb(251, 251, 254));
+ --fc-button-border-active: var(--fc-button-border-active-dark, transparent);
+ --fc-primary-button-background: var(--fc-primary-button-background-dark, rgb(0,221,255));
+ --fc-primary-button-color: var(--fc-primary-button-color-dark, rgb(43,42,51));
+ --fc-primary-button-border: var(--fc-primary-button-border-dark, transparent);
+ --fc-primary-button-background-hover: var(--fc-primary-button-background-hover-dark, rgb(128,235,255));
+ --fc-primary-button-color-hover: var(--fc-primary-button-color-hover-dark, rgb(43,42,51));
+ --fc-primary-button-border-hover: var(--fc-primary-button-border-hover-dark, transparent);
+ --fc-primary-button-background-active: var(--fc-primary-button-background-active-dark, rgb(170,242,255));
+ --fc-primary-button-color-active: var(--fc-primary-button-color-active-dark, rgb(43,42,51));
+ --fc-primary-button-border-active: var(--fc-primary-button-border-active-dark, transparent);
+ --fc-link-color: var(--fc-link-color-dark, #00DDFF);
+ --fc-link-color-hover: var(--fc-link-color-hover-dark, #80EBFF);
+ --fc-link-color-active: var(--fc-link-color-hover-active, #AAF2FF);
+}
+
@media (prefers-contrast) {
#feature-callout.simulateContent {
--fc-background: var(--fc-background-hcm, -moz-dialog);
diff --git a/browser/components/asrouter/content-src/styles/_feature-callout.scss b/browser/components/asrouter/content-src/styles/_feature-callout.scss
index 66770c2238..40137fd29a 100644
--- a/browser/components/asrouter/content-src/styles/_feature-callout.scss
+++ b/browser/components/asrouter/content-src/styles/_feature-callout.scss
@@ -42,6 +42,12 @@
@include dark-theme;
}
+ @at-root :root[lwt-newtab-brighttext] #{&}.lwtNewtab {
+ color-scheme: dark;
+
+ @include dark-theme;
+ }
+
@media (prefers-contrast) {
@include hcm-theme;
}
diff --git a/browser/components/asrouter/modules/FeatureCallout.sys.mjs b/browser/components/asrouter/modules/FeatureCallout.sys.mjs
index 01998662f6..5f0e266a4e 100644
--- a/browser/components/asrouter/modules/FeatureCallout.sys.mjs
+++ b/browser/components/asrouter/modules/FeatureCallout.sys.mjs
@@ -1834,6 +1834,14 @@ export class FeatureCallout {
"simulateContent",
!!this.theme.simulateContent
);
+ this._container.classList.toggle(
+ "lwtNewtab",
+ !!(
+ this.theme.lwtNewtab !== false &&
+ this.theme.simulateContent &&
+ ["themed-content", "newtab"].includes(this.theme.preset)
+ )
+ );
for (const type of ["light", "dark", "hcm"]) {
const scheme = this.theme[type];
for (const name of FeatureCallout.themePropNames) {
diff --git a/browser/components/urlbar/UrlbarInput.sys.mjs b/browser/components/urlbar/UrlbarInput.sys.mjs
index 6aefd18f9c..96fc7b9301 100644
--- a/browser/components/urlbar/UrlbarInput.sys.mjs
+++ b/browser/components/urlbar/UrlbarInput.sys.mjs
@@ -2766,20 +2766,18 @@ export class UrlbarInput {
return;
}
- let url =
- element.dataset.command == "help"
- ? result.payload.helpUrl
- : element.dataset.url;
+ let url;
+ if (element.dataset.command == "help") {
+ url = result.payload.helpUrl;
+ }
+ url ||= element.dataset.url;
+
if (!url) {
return;
}
let where = this._whereToOpen(event);
- if (
- url &&
- result.type != lazy.UrlbarUtils.RESULT_TYPE.TIP &&
- where == "current"
- ) {
+ if (result.type != lazy.UrlbarUtils.RESULT_TYPE.TIP && where == "current") {
// Open non-tip help links in a new tab unless the user held a modifier.
// TODO (bug 1696232): Do this for tip help links, too.
where = "tab";
diff --git a/browser/components/urlbar/tests/browser/browser_result_menu_general.js b/browser/components/urlbar/tests/browser/browser_result_menu_general.js
index ece48de20a..397ffe0e94 100644
--- a/browser/components/urlbar/tests/browser/browser_result_menu_general.js
+++ b/browser/components/urlbar/tests/browser/browser_result_menu_general.js
@@ -9,6 +9,9 @@
const MAX_RESULTS = UrlbarPrefs.get("maxRichResults");
const RESULT_URL = "https://example.com/test";
const RESULT_HELP_URL = "https://example.com/help";
+const DEFAULT_HELP_URL =
+ Services.urlFormatter.formatURLPref("app.support.baseURL") +
+ "awesome-bar-result-menu";
add_setup(async function () {
// Add enough results to fill up the view.
@@ -21,25 +24,60 @@ add_setup(async function () {
});
});
-// Sets `helpUrl` on a result payload and makes sure the result menu ends up
-// with a help command.
-add_task(async function help() {
- let provider = registerTestProvider(1);
+// Creates a provider that sets `helpUrl` on its result payload. The specified
+// `helpUrl` should be loaded when the result's help menu item is clicked.
+add_task(async function help_resultHelpUrl() {
+ await doHelpTest({
+ provider: registerTestProvider({
+ resultHelpUrl: RESULT_HELP_URL,
+ }),
+ expectedHelpUrl: RESULT_HELP_URL,
+ expectedHelpL10n: { id: "urlbar-result-menu-tip-get-help", args: null },
+ });
+});
+
+// Creates a provider that does not set `helpUrl` on its result payload but
+// instead implements `getResultCommands()` and returns a "help" command. The
+// default help URL should be loaded when the result's help menu item is
+// clicked.
+add_task(async function help_getResultCommands() {
+ let provider = registerTestProvider({
+ resultHelpUrl: null,
+ });
+ let l10n = { id: "urlbar-result-menu-learn-more", args: null };
+ provider.getResultCommands = () => [{ l10n, name: "help" }];
+
+ await doHelpTest({
+ provider,
+ expectedHelpUrl: DEFAULT_HELP_URL,
+ expectedHelpL10n: l10n,
+ });
+});
+
+async function doHelpTest({
+ provider,
+ expectedHelpUrl,
+ expectedHelpL10n,
+ expectedResultIndex = 1,
+}) {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
value: "example",
window,
});
- await assertIsTestResult(1);
+ await assertIsTestResult(expectedResultIndex);
- let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
+ let result = await UrlbarTestUtils.getDetailsOfResultAt(
+ window,
+ expectedResultIndex
+ );
let menuButton = result.element.row._buttons.get("menu");
Assert.ok(menuButton, "Sanity check: menu button should exist");
let menuitem = await UrlbarTestUtils.openResultMenuAndGetItem({
window,
command: "help",
- resultIndex: 1,
+ resultIndex: expectedResultIndex,
openByMouse: true,
});
Assert.ok(menuitem, "Help menu item should exist");
@@ -47,7 +85,7 @@ add_task(async function help() {
let l10nAttrs = document.l10n.getAttributes(menuitem);
Assert.deepEqual(
l10nAttrs,
- { id: "urlbar-result-menu-tip-get-help", args: null },
+ expectedHelpL10n,
"The l10n ID attribute was correctly set"
);
@@ -60,7 +98,7 @@ add_task(async function help() {
let loadPromise = BrowserTestUtils.waitForNewTab(gBrowser);
await UrlbarTestUtils.openResultMenuAndClickItem(window, "help", {
- resultIndex: 1,
+ resultIndex: expectedResultIndex,
openByMouse: true,
});
@@ -69,18 +107,18 @@ add_task(async function help() {
await TestUtils.waitForTick();
Assert.equal(
gBrowser.currentURI.spec,
- RESULT_HELP_URL,
+ expectedHelpUrl,
"The load URL should be the help URL"
);
BrowserTestUtils.removeTab(gBrowser.selectedTab);
UrlbarProvidersManager.unregisterProvider(provider);
-});
+}
// (SHIFT+)TABs through a result with a menu button. The result is the second
// result and has other results after it.
add_task(async function keyboardSelection_secondResult() {
- let provider = registerTestProvider(1);
+ let provider = registerTestProvider();
await UrlbarTestUtils.promiseAutocompleteResultPopup({
value: "example",
window,
@@ -130,7 +168,7 @@ add_task(async function keyboardSelection_secondResult() {
// (SHIFT+)TABs through a result with a help button. The result is the
// last result.
add_task(async function keyboardSelection_lastResult() {
- let provider = registerTestProvider(MAX_RESULTS - 1);
+ let provider = registerTestProvider({ suggestedIndex: MAX_RESULTS - 1 });
await UrlbarTestUtils.promiseAutocompleteResultPopup({
value: "example",
window,
@@ -221,7 +259,7 @@ add_task(async function pick_help_mouse() {
async function doPickTest({ pickHelp, useKeyboard }) {
await BrowserTestUtils.withNewTab("about:blank", async () => {
let index = 1;
- let provider = registerTestProvider(index);
+ let provider = registerTestProvider({ suggestedIndex: index });
await UrlbarTestUtils.promiseAutocompleteResultPopup({
value: "example",
window,
@@ -281,31 +319,44 @@ async function doPickTest({ pickHelp, useKeyboard }) {
}
/**
- * Registers a provider that creates a result with a help URL.
+ * Registers a provider that creates a result optionally with a help URL.
*
- * @param {number} suggestedIndex
+ * @param {object} options
+ * Options object
+ * @param {number} options.suggestedIndex
* The result's suggestedIndex.
+ * @param {string} options.resultHelpUrl
+ * The result's helpUrl. Pass a falsey value to prevent setting a helpUrl.
* @returns {UrlbarProvider}
* The new provider.
*/
-function registerTestProvider(suggestedIndex) {
- let results = [
- Object.assign(
- new UrlbarResult(
- UrlbarUtils.RESULT_TYPE.URL,
- UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
- {
- url: RESULT_URL,
- helpUrl: RESULT_HELP_URL,
- helpL10n: {
- id: "urlbar-result-menu-tip-get-help",
- },
- }
+function registerTestProvider({
+ suggestedIndex = 1,
+ resultHelpUrl = RESULT_HELP_URL,
+} = {}) {
+ let payload = { url: RESULT_URL };
+ if (resultHelpUrl) {
+ payload = {
+ ...payload,
+ helpUrl: resultHelpUrl,
+ helpL10n: {
+ id: "urlbar-result-menu-tip-get-help",
+ },
+ };
+ }
+
+ let provider = new UrlbarTestUtils.TestProvider({
+ results: [
+ Object.assign(
+ new UrlbarResult(
+ UrlbarUtils.RESULT_TYPE.URL,
+ UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
+ payload
+ ),
+ { suggestedIndex }
),
- { suggestedIndex }
- ),
- ];
- let provider = new UrlbarTestUtils.TestProvider({ results });
+ ],
+ });
UrlbarProvidersManager.registerProvider(provider);
return provider;
}