summaryrefslogtreecommitdiffstats
path: root/browser/components/uitour/test/browser_UITour5.js
blob: b6094b42fc02bdf15aa7f8724f69e2e2724274fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"use strict";

var gTestTab;
var gContentAPI;
var gContentWindow;

add_task(setup_UITourTest);

add_UITour_task(
  async function test_highlight_library_and_show_library_subview() {
    let highlight = document.getElementById("UITourHighlight");
    is_element_hidden(highlight, "Highlight should initially be hidden");

    // Test highlighting the library button
    let appMenu = PanelUI.panel;
    let appMenuShownPromise = promisePanelElementShown(window, appMenu);
    let highlightVisiblePromise = elementVisiblePromise(
      highlight,
      "Should show highlight"
    );
    gContentAPI.showHighlight("library");
    await appMenuShownPromise;
    await highlightVisiblePromise;
    is(
      appMenu.state,
      "open",
      "Should open the app menu to highlight the library button"
    );
    is(
      getShowHighlightTargetName(),
      "library",
      "Should highlight the library button on the app menu"
    );

    // Click the library button to show the subview
    let ViewShownPromise = new Promise(resolve => {
      appMenu.addEventListener("ViewShown", resolve, { once: true });
    });
    let highlightHiddenPromise = elementHiddenPromise(
      highlight,
      "Should hide highlight"
    );
    let libraryBtn = document.getElementById("appMenu-library-button");
    libraryBtn.dispatchEvent(new Event("command"));
    await highlightHiddenPromise;
    await ViewShownPromise;
    let libView = document.getElementById("appMenu-libraryView");
    ok(PanelView.forNode(libView).active, "Should show the library subview");
    is(
      appMenu.state,
      "open",
      "Should still open the app menu for the library subview"
    );

    // Clean up
    let appMenuHiddenPromise = promisePanelElementHidden(window, appMenu);
    gContentAPI.hideMenu("appMenu");
    await appMenuHiddenPromise;
    is(appMenu.state, "closed", "Should close the app menu");
  }
);