Bug 1105523 - UITour: Provide a way for some Hello targets to have their info panel arrow on the side r=Unfocused

This commit is contained in:
Matthew Noorenberghe 2014-12-09 16:08:08 -08:00
parent a16cef4d14
commit 85c138330a
3 changed files with 38 additions and 3 deletions

View File

@ -121,15 +121,19 @@ this.UITour = {
}],
["loop", {query: "#loop-button"}],
["loop-newRoom", {
infoPanelPosition: "leftcenter topright",
query: (aDocument) => {
let loopBrowser = aDocument.querySelector("#loop-notification-panel > #loop");
if (!loopBrowser) {
return null;
}
return loopBrowser.contentDocument.querySelector(".new-room-button");
// Use the parentElement full-width container of the button so our arrow
// doesn't overlap the panel contents much.
return loopBrowser.contentDocument.querySelector(".new-room-button").parentElement;
},
}],
["loop-roomList", {
infoPanelPosition: "leftcenter topright",
query: (aDocument) => {
let loopBrowser = aDocument.querySelector("#loop-notification-panel > #loop");
if (!loopBrowser) {
@ -150,6 +154,7 @@ this.UITour = {
["privateWindow", {query: "#privatebrowsing-button"}],
["quit", {query: "#PanelUI-quit"}],
["search", {
infoPanelPosition: "after_start",
query: "#searchbar",
widgetName: "search-container",
}],
@ -877,6 +882,7 @@ this.UITour = {
deferred.resolve({
addTargetListener: targetObject.addTargetListener,
infoPanelPosition: targetObject.infoPanelPosition,
node: node,
removeTargetListener: targetObject.removeTargetListener,
targetName: aTargetName,
@ -1209,10 +1215,13 @@ this.UITour = {
tooltip.setAttribute("targetName", aAnchor.targetName);
tooltip.hidden = false;
let xOffset = 0, yOffset = 0;
let alignment = "bottomcenter topright";
if (aAnchor.infoPanelPosition) {
alignment = aAnchor.infoPanelPosition;
}
let xOffset = 0, yOffset = 0;
if (aAnchor.targetName == "search") {
alignment = "after_start";
xOffset = 18;
}
this._addAnnotationPanelMutationObserver(tooltip);

View File

@ -100,8 +100,28 @@ let tests = [
});
LoopRooms.open("fakeTourRoom");
},
taskify(function* test_arrow_panel_position() {
ise(loopButton.open, false, "Menu should initially be closed");
let popup = document.getElementById("UITourTooltip");
yield showMenuPromise("loop");
let currentTarget = "loop-newRoom";
yield showInfoPromise(currentTarget, "This is " + currentTarget, "My arrow should be on the side");
is(popup.popupBoxObject.alignmentPosition, "start_before", "Check " + currentTarget + " position");
currentTarget = "loop-roomList";
yield showInfoPromise(currentTarget, "This is " + currentTarget, "My arrow should be on the side");
is(popup.popupBoxObject.alignmentPosition, "start_before", "Check " + currentTarget + " position");
currentTarget = "loop-signInUpLink";
yield showInfoPromise(currentTarget, "This is " + currentTarget, "My arrow should be underneath");
is(popup.popupBoxObject.alignmentPosition, "after_end", "Check " + currentTarget + " position");
}),
];
// End tests
function checkLoopPanelIsHidden() {
ok(!loopPanel.hasAttribute("noautohide"), "@noautohide on the loop panel should have been cleaned up");
ok(!loopPanel.hasAttribute("panelopen"), "The panel shouldn't have @panelopen");

View File

@ -135,6 +135,12 @@ function showInfoPromise(...args) {
return promisePanelElementShown(window, popup);
}
function showMenuPromise(name) {
return new Promise(resolve => {
gContentAPI.showMenu(name, () => resolve());
});
}
function waitForCallbackResultPromise() {
return waitForConditionPromise(() => {
return gContentWindow.callbackResult;