Bug 1703391 - Fix browser_UITour4.js for proton urlbar. r=harry

Differential Revision: https://phabricator.services.mozilla.com/D111184
This commit is contained in:
Marco Bonardo 2021-04-08 20:22:10 +00:00
Родитель 70c11d7795
Коммит d4ca45c776
3 изменённых файлов: 123 добавлений и 85 удалений

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

@ -282,7 +282,7 @@ var UITour = {
],
]),
nonProtonURLBarTargets: [
nonProtonTargets: [
[
"pageAction-copyURL",
{
@ -350,8 +350,8 @@ var UITour = {
);
// Add non-proton targets if necessary.
if (!Services.prefs.getBoolPref("browser.proton.urlbar.enabled", false)) {
for (let [id, target] of this.nonProtonURLBarTargets) {
if (!UITour.protonEnabled) {
for (let [id, target] of this.nonProtonTargets) {
this.targets.set(id, target);
}
}
@ -1170,7 +1170,10 @@ var UITour = {
let shouldOpenPageActionPanel = false;
if (this.targetIsInAppMenu(aTarget)) {
shouldOpenAppMenu = true;
} else if (this.targetIsInPageActionPanel(aTarget)) {
} else if (
this.targetIsInPageActionPanel(aTarget) &&
!UITour.protonEnabled
) {
shouldOpenPageActionPanel = true;
// Ensure the panel visibility so as to ensure the visibility of the target
// element inside the panel otherwise we would be rejected in the below
@ -1573,7 +1576,10 @@ var UITour = {
aMenuBtn.openMenu(true);
}
if (aMenuName == "appMenu" || aMenuName == "pageActionPanel") {
if (
aMenuName == "appMenu" ||
(aMenuName == "pageActionPanel" && !UITour.protonEnabled)
) {
let menu = {
onPanelHidden: this.onPanelHidden,
};
@ -1651,7 +1657,7 @@ var UITour = {
closeMenuButton(menuBtn);
} else if (aMenuName == "urlbar") {
aWindow.gURLBar.view.close();
} else if (aMenuName == "pageActionPanel") {
} else if (aMenuName == "pageActionPanel" && !UITour.protonEnabled) {
aWindow.BrowserPageActions.panelNode.hidePopup();
}
},

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

@ -37,6 +37,12 @@ add_UITour_task(
// Test switching the highlight to the copyURL button on the page action panel
let appMenuHiddenPromise = promisePanelElementHidden(window, appMenu);
// This doesn't exist in Proton.
if (!UITour.targets.has("pageAction-copyURL")) {
return;
}
let pageActionPanelShownPromise = promisePanelElementShown(
window,
pageActionPanel
@ -97,16 +103,18 @@ add_UITour_task(
let appMenu = window.PanelUI.panel;
let pageActionPanel = BrowserPageActions.panelNode;
let tooltipVisiblePromise = elementVisiblePromise(
tooltip,
"Should show info tooltip"
);
// This doesn't exist in Proton.
if (UITour.targets.has("pageAction-emailLink")) {
// Test showing info tooltip on the emailLink button on the page action panel
let pageActionPanelShownPromise = promisePanelElementShown(
window,
pageActionPanel
);
let tooltipVisiblePromise = elementVisiblePromise(
tooltip,
"Should show info tooltip"
);
await showInfoPromise("pageAction-emailLink", "title", "text");
await pageActionPanelShownPromise;
await tooltipVisiblePromise;
@ -128,6 +136,7 @@ add_UITour_task(
window,
pageActionPanel
);
tooltipVisiblePromise = elementVisiblePromise(
tooltip,
"Should show info tooltip"
@ -135,6 +144,11 @@ add_UITour_task(
await showInfoPromise("addons", "title", "text");
await appMenuShownPromise;
await pageActionPanelHiddenPromise;
} else {
let appMenuShownPromise = promisePanelElementShown(window, appMenu);
await showInfoPromise("addons", "title", "text");
await appMenuShownPromise;
}
await tooltipVisiblePromise;
is(
appMenu.state,
@ -179,7 +193,10 @@ add_UITour_task(
let appMenu = window.PanelUI.panel;
let pageActionPanel = BrowserPageActions.panelNode;
let pageActionPanelHiddenPromise = Promise.resolve();
// This doesn't exist in Proton.
if (UITour.targets.has("pageAction-sendToDevice")) {
// Test highlighting the sendToDevice button on the page action panel
let pageActionPanelShownPromise = promisePanelElementShown(
window,
@ -203,6 +220,11 @@ add_UITour_task(
"pageAction-sendToDevice",
"Should highlight the sendToDevice button on the page action panel"
);
pageActionPanelHiddenPromise = promisePanelElementHidden(
window,
pageActionPanel
);
}
// Test showing info tooltip on the privateWindow button on the app menu
let appMenuShownPromise = promisePanelElementShown(window, appMenu);
@ -210,10 +232,6 @@ add_UITour_task(
tooltip,
"Should show info tooltip"
);
let pageActionPanelHiddenPromise = promisePanelElementHidden(
window,
pageActionPanel
);
let highlightHiddenPromise = elementHiddenPromise(
highlight,
"Should hide highlight"
@ -283,6 +301,11 @@ add_UITour_task(
"Should show info tooltip on the privateWindow button on the app menu"
);
// This doesn't exist in Proton.
if (!UITour.targets.has("pageAction-sendToDevice")) {
return;
}
// Test highlighting the sendToDevice button on the page action panel
let pageActionPanelShownPromise = promisePanelElementShown(
window,
@ -336,6 +359,11 @@ add_UITour_task(
add_UITour_task(
async function test_show_appMenu_and_highligh_buttonOnPageActionPanel() {
// This doesn't exist in Proton.
if (!UITour.targets.has("pageAction-sendToDevice")) {
return;
}
let highlight = document.getElementById("UITourHighlight");
is_element_hidden(highlight, "Highlight should initially be hidden");
@ -419,6 +447,7 @@ add_UITour_task(
let appMenu = window.PanelUI.panel;
let pageActionPanel = BrowserPageActions.panelNode;
if (!gProton) {
// Test explicity asking for opening the page action panel
let pageActionPanelShownPromise = promisePanelElementShown(
window,
@ -428,6 +457,7 @@ add_UITour_task(
await pageActionPanelShownPromise;
is(appMenu.state, "closed", "Shouldn't open the app menu");
is(pageActionPanel.state, "open", "Should open the page action panel");
}
// Test showing info tooltip on the privateWindow button on the app menu
let appMenuShownPromise = promisePanelElementShown(window, appMenu);
@ -445,8 +475,8 @@ add_UITour_task(
);
is(
pageActionPanel.state,
"open",
"Shouldn't close the page action panel because it is opened explictly by api user."
gProton ? "closed" : "open",
"Check state of the page action panel if it was opened explictly by api user."
);
is(
getShowInfoTargetName(),
@ -454,6 +484,7 @@ add_UITour_task(
"Should show info tooltip on the privateWindow button on the app menu"
);
if (!gProton) {
// Test hiding the page action panel wouldn't affect the info tooltip on the app menu
let pageActionPanelHiddenPromise = promisePanelElementHidden(
window,
@ -461,6 +492,7 @@ add_UITour_task(
);
gContentAPI.hideMenu("pageActionPanel");
await pageActionPanelHiddenPromise;
}
is_element_visible(tooltip, "Tooltip should still be visible");
is(appMenu.state, "open", "Shouldn't close the app menu");
is(

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

@ -21,7 +21,7 @@ function getExpectedTargets() {
"library",
"logins",
"pageAction-bookmark",
...(UrlbarPrefs.get("browser.proton.urlbar.enabled")
...(gProton
? []
: [
"pageAction-copyURL",