Bug 1185579 - UITour: Make the "accountStatus" target use the FxA avatar when logged in. r=markh

--HG--
extra : commitid : HoUXeCQssgu
This commit is contained in:
Matthew Noorenberghe 2015-08-04 22:55:21 -07:00
parent 4cb2a5ef13
commit 6cf549763e
4 changed files with 85 additions and 0 deletions

View File

@ -98,11 +98,20 @@ this.UITour = {
targets: new Map([
["accountStatus", {
query: (aDocument) => {
// If the user is logged in, use the avatar element.
let fxAFooter = aDocument.getElementById("PanelUI-footer-fxa");
if (fxAFooter.getAttribute("fxastatus")) {
return aDocument.getElementById("PanelUI-fxa-avatar");
}
// Otherwise use the sync setup icon.
let statusButton = aDocument.getElementById("PanelUI-fxa-label");
return aDocument.getAnonymousElementByAttribute(statusButton,
"class",
"toolbarbutton-icon");
},
// This is a fake widgetName starting with the "PanelUI-" prefix so we know
// to automatically open the appMenu when annotating this target.
widgetName: "PanelUI-fxa-label",
}],
["addons", {query: "#add-ons-button"}],

View File

@ -7,6 +7,8 @@ support-files =
[browser_backgroundTab.js]
skip-if = e10s # Bug 941428 - UITour.jsm not e10s friendly
[browser_fxa.js]
skip-if = e10s || debug || asan # Bug 1073247 - UITour tests not e10s friendly # updateAppMenuItem leaks
[browser_no_tabs.js]
[browser_openPreferences.js]
skip-if = e10s # Bug 1073247 - UITour tests not e10s friendly

View File

@ -0,0 +1,68 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
XPCOMUtils.defineLazyModuleGetter(this, "fxAccounts",
"resource://gre/modules/FxAccounts.jsm");
let gTestTab;
let gContentAPI;
let gContentWindow;
function test() {
UITourTest();
}
registerCleanupFunction(function*() {
yield signOut();
gFxAccounts.updateAppMenuItem();
});
let tests = [
taskify(function* test_highlight_accountStatus_loggedOut() {
let userData = yield fxAccounts.getSignedInUser();
is(userData, null, "Not logged in initially");
yield showMenuPromise("appMenu");
yield showHighlightPromise("accountStatus");
let highlight = document.getElementById("UITourHighlightContainer");
is(highlight.getAttribute("targetName"), "accountStatus", "Correct highlight target");
}),
taskify(function* test_highlight_accountStatus_loggedIn() {
yield setSignedInUser();
let userData = yield fxAccounts.getSignedInUser();
isnot(userData, null, "Logged in now");
// gFxAccounts.updateAppMenuItem(); // Causes a leak.
yield showMenuPromise("appMenu");
yield showHighlightPromise("accountStatus");
let highlight = document.getElementById("UITourHighlightContainer");
todo_is(highlight.popupBoxObject.anchorNode.id, "PanelUI-fxa-avatar", "Anchored on avatar");
is(highlight.getAttribute("targetName"), "accountStatus", "Correct highlight target");
}),
];
// Helpers copied from browser_aboutAccounts.js
// watch out - these will fire observers which if you aren't careful, may
// interfere with the tests.
function setSignedInUser(data) {
if (!data) {
data = {
email: "foo@example.com",
uid: "1234@lcip.org",
assertion: "foobar",
sessionToken: "dead",
kA: "beef",
kB: "cafe",
verified: true
};
}
return fxAccounts.setSignedInUser(data);
}
function signOut() {
// we always want a "localOnly" signout here...
return fxAccounts.signOut(true);
}

View File

@ -139,6 +139,12 @@ function showInfoPromise(...args) {
return promisePanelElementShown(window, popup);
}
function showHighlightPromise(...args) {
let popup = document.getElementById("UITourHighlightContainer");
gContentAPI.showHighlight.apply(gContentAPI, args);
return promisePanelElementShown(window, popup);
}
function showMenuPromise(name) {
return new Promise(resolve => {
gContentAPI.showMenu(name, () => resolve());