From d4835402f9d9c21afa217ab52f3ceb9d9d87f140 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Wed, 25 Oct 2017 21:43:02 -0700 Subject: [PATCH] Backed out changeset bae28f445fad (bug 1410763) for failing browser_onboarding_uitour.js on Win7 debug non-e10s MozReview-Commit-ID: 3HixjOyzjSg --- browser/components/uitour/UITour.jsm | 16 +++++++-- .../components/uitour/test/browser_UITour5.js | 36 +++++++++++++++++++ .../test/browser/browser_onboarding_uitour.js | 7 ++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/browser/components/uitour/UITour.jsm b/browser/components/uitour/UITour.jsm index 80ca51e96bfe..f4710a255304 100644 --- a/browser/components/uitour/UITour.jsm +++ b/browser/components/uitour/UITour.jsm @@ -115,7 +115,13 @@ this.UITour = { // to automatically open the appMenu when annotating this target. widgetName: "appMenu-fxa-label", }], - ["addons", {query: "#appMenu-addons-button"}], + ["addons", { + query: (aDocument) => { + // select toolbar icon if exist, fallback to appMenu item + let node = aDocument.getElementById("add-ons-button"); + return node ? node : aDocument.getElementById("appMenu-addons-button"); + }, + }], ["appMenu", { addTargetListener: (aDocument, aCallback) => { let panelPopup = aDocument.defaultView.PanelUI.panel; @@ -146,7 +152,13 @@ this.UITour = { }], ["help", {query: "#appMenu-help-button"}], ["home", {query: "#home-button"}], - ["library", {query: "#appMenu-library-button"}], + ["library", { + query: (aDocument) => { + // select toolbar icon if exist, fallback to appMenu item + let node = aDocument.getElementById("library-button"); + return node ? node : aDocument.getElementById("appMenu-library-button"); + }, + }], ["pocket", { allowAdd: true, query: (aDocument) => { diff --git a/browser/components/uitour/test/browser_UITour5.js b/browser/components/uitour/test/browser_UITour5.js index 97422da86819..be1962136475 100644 --- a/browser/components/uitour/test/browser_UITour5.js +++ b/browser/components/uitour/test/browser_UITour5.js @@ -6,7 +6,41 @@ var gContentWindow; add_task(setup_UITourTest); +add_UITour_task(async function test_highlight_library_icon_in_toolbar() { + let highlight = document.getElementById("UITourHighlight"); + is_element_hidden(highlight, "Highlight should initially be hidden"); + + // Test highlighting the library button + let highlightVisiblePromise = elementVisiblePromise(highlight, "Should show highlight"); + gContentAPI.showHighlight("library"); + await highlightVisiblePromise; + UITour.getTarget(window, "library").then((target) => { + is("library-button", target.node.id, "Should highlight the right target"); + }); +}); + +add_UITour_task(async function test_highlight_addons_icon_in_toolbar() { + CustomizableUI.addWidgetToArea("add-ons-button", CustomizableUI.AREA_NAVBAR, 0); + ok(!UITour.availableTargetsCache.has(window), + "Targets should be evicted from cache after widget change"); + let highlight = document.getElementById("UITourHighlight"); + is_element_hidden(highlight, "Highlight should initially be hidden"); + + // Test highlighting the addons button on toolbar + let highlightVisiblePromise = elementVisiblePromise(highlight, "Should show highlight"); + gContentAPI.showHighlight("addons"); + await highlightVisiblePromise; + UITour.getTarget(window, "addons").then((target) => { + is("add-ons-button", target.node.id, "Should highlight the right target"); + CustomizableUI.removeWidgetFromArea("add-ons-button"); + }); +}); + add_UITour_task(async function test_highlight_library_and_show_library_subview() { + CustomizableUI.removeWidgetFromArea("library-button"); + + ok(!UITour.availableTargetsCache.has(window), + "Targets should be evicted from cache after widget change"); let highlight = document.getElementById("UITourHighlight"); is_element_hidden(highlight, "Highlight should initially be hidden"); @@ -37,4 +71,6 @@ add_UITour_task(async function test_highlight_library_and_show_library_subview() gContentAPI.hideMenu("appMenu"); await appMenuHiddenPromise; is(appMenu.state, "closed", "Should close the app menu"); + CustomizableUI.addWidgetToArea("library", CustomizableUI.AREA_NAVBAR, 0); }); + diff --git a/browser/extensions/onboarding/test/browser/browser_onboarding_uitour.js b/browser/extensions/onboarding/test/browser/browser_onboarding_uitour.js index 6a71da041182..80c9317092a0 100644 --- a/browser/extensions/onboarding/test/browser/browser_onboarding_uitour.js +++ b/browser/extensions/onboarding/test/browser/browser_onboarding_uitour.js @@ -66,6 +66,13 @@ add_task(async function test_clean_up_uitour_after_closing_overlay() { await highlightOpenPromise; is(highlight.state, "open", "Should show UITour highlight"); is(highlight.getAttribute("targetName"), "library", "UITour should highlight library"); + + // Close the overlay by clicking the skip-tour button + highlightClosePromise = promisePopupChange(highlight, "closed"); + BrowserTestUtils.synthesizeMouseAtCenter("#onboarding-skip-tour-btn", {}, tab.linkedBrowser); + await promiseOnboardingOverlayClosed(tab.linkedBrowser); + await highlightClosePromise; + is(highlight.state, "closed", "Should close UITour highlight after closing the overlay by clicking the skip-tour button"); await BrowserTestUtils.removeTab(tab); });