Bug 1783049 - about:welcome should open FxView in its pinned tab, r=Mardak

Differential Revision: https://phabricator.services.mozilla.com/D154478
This commit is contained in:
Dan Mosedale 2022-08-17 16:36:39 +00:00
Родитель 6b7edc6cf9
Коммит 4cbfcb0b8b
7 изменённых файлов: 99 добавлений и 4 удалений

Просмотреть файл

@ -531,8 +531,7 @@ const MR_ABOUT_WELCOME_DEFAULT = {
primary_button: { primary_button: {
label: "See whats new", label: "See whats new",
action: { action: {
type: "OPEN_ABOUT_PAGE", type: "OPEN_FIREFOX_VIEW",
data: { args: "firefoxview", where: "current" },
navigate: true, navigate: true,
}, },
}, },

Просмотреть файл

@ -332,8 +332,7 @@ const ONBOARDING_MESSAGES = () => [
primary_button: { primary_button: {
label: "See whats new", label: "See whats new",
action: { action: {
type: "OPEN_ABOUT_PAGE", type: "OPEN_FIREFOX_VIEW",
data: { args: "firefoxview", where: "current" },
navigate: true, navigate: true,
}, },
}, },

Просмотреть файл

@ -258,6 +258,9 @@ const SpecialMessageActions = {
action.data.where || "tab" action.data.where || "tab"
); );
break; break;
case "OPEN_FIREFOX_VIEW":
window.FirefoxViewHandler.openTab();
break;
case "OPEN_PREFERENCES_PAGE": case "OPEN_PREFERENCES_PAGE":
window.openPreferences( window.openPreferences(
action.data.category || action.data.args, action.data.category || action.data.args,

Просмотреть файл

@ -97,6 +97,18 @@
"additionalProperties": false, "additionalProperties": false,
"description": "Opens an about: page in Firefox" "description": "Opens an about: page in Firefox"
}, },
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["OPEN_FIREFOX_VIEW"]
}
},
"required": ["type"],
"additionalProperties": false,
"description": "Opens the Firefox View pseudo-pinned-tab"
},
{ {
"type": "object", "type": "object",
"properties": { "properties": {

Просмотреть файл

@ -21,6 +21,12 @@ For snippets, you should add the action type in `button_action` and any addition
Opens the applications menu. Opens the applications menu.
### `OPEN_FIREFOX_VIEW`
* args: (none)
Opens the Firefox View pseudo-tab.
### `OPEN_PRIVATE_BROWSER_WINDOW` ### `OPEN_PRIVATE_BROWSER_WINDOW`
* args: (none) * args: (none)

Просмотреть файл

@ -8,6 +8,7 @@ support-files =
[browser_sma_block_message.js] [browser_sma_block_message.js]
[browser_sma_open_about_page.js] [browser_sma_open_about_page.js]
[browser_sma_open_awesome_bar.js] [browser_sma_open_awesome_bar.js]
[browser_sma_open_firefox_view.js]
[browser_sma_open_private_browser_window.js] [browser_sma_open_private_browser_window.js]
[browser_sma_open_protection_panel.js] [browser_sma_open_protection_panel.js]
[browser_sma_open_protection_report.js] [browser_sma_open_protection_report.js]

Просмотреть файл

@ -0,0 +1,75 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* The setup code and the utility funcitons here are cribbed from (mostly)
* browser/components/firefoxview/test/browser/head.js
*
* https://bugzilla.mozilla.org/show_bug.cgi?id=1784979 has been filed to move
* these to some place publically accessible, after which we will be able to
* a bunch of code from this file.
*/
add_setup(async () => {
await SpecialPowers.pushPrefEnv({
set: [["browser.tabs.firefox-view", true]],
});
CustomizableUI.addWidgetToArea(
"firefox-view-button",
CustomizableUI.AREA_TABSTRIP,
0
);
registerCleanupFunction(async () => {
// If you're running mochitest with --keep-open=true, and need to
// easily tell whether the button really appeared, comment out the below
// line so that the button hangs around after the test finishes.
CustomizableUI.removeWidgetFromArea("firefox-view-button");
await SpecialPowers.popPrefEnv();
});
});
function assertFirefoxViewTab(w = window) {
ok(w.FirefoxViewHandler.tab, "Firefox View tab exists");
ok(w.FirefoxViewHandler.tab?.hidden, "Firefox View tab is hidden");
is(
w.gBrowser.tabs.indexOf(w.FirefoxViewHandler.tab),
0,
"Firefox View tab is the first tab"
);
is(
w.gBrowser.visibleTabs.indexOf(w.FirefoxViewHandler.tab),
-1,
"Firefox View tab is not in the list of visible tabs"
);
}
function closeFirefoxViewTab(w = window) {
w.gBrowser.removeTab(w.FirefoxViewHandler.tab);
ok(
!w.FirefoxViewHandler.tab,
"Reference to Firefox View tab got removed when closing the tab"
);
}
add_task(async function test_open_firefox_view() {
// setup
let newTabOpened = BrowserTestUtils.waitForEvent(
gBrowser.tabContainer,
"TabOpen"
);
// execute
await SMATestUtils.executeAndValidateAction({
type: "OPEN_FIREFOX_VIEW",
});
// verify
await newTabOpened;
assertFirefoxViewTab();
// cleanup
closeFirefoxViewTab();
});