summaryrefslogtreecommitdiffstats
path: root/browser/components/pocket/test/browser_pocket_library_menu_action.js
blob: 03599c414dbea827fce826abd5f82083aa17a81e (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

add_task(async function test_setup() {
  await SpecialPowers.pushPrefEnv({
    set: [
      [
        "extensions.pocket.site",
        "example.com/browser/browser/components/pocket/test/pocket_actions_test.html",
      ],
    ],
  });
});

add_task(async function() {
  let tab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    "https://example.com/browser/browser/components/pocket/test/test.html"
  );

  let libraryButton = document.getElementById("library-button");

  info("opening library menu");
  libraryButton.click();
  let libraryView = document.getElementById("appMenu-libraryView");
  let libraryPromise = BrowserTestUtils.waitForEvent(libraryView, "ViewShown");
  await libraryPromise;

  let pocketLibraryButton = document.getElementById(
    "appMenu-library-pocket-button"
  );
  ok(pocketLibraryButton, "library menu should have pocket button");
  is(
    pocketLibraryButton.disabled,
    false,
    "element appMenu-library-pocket-button is not disabled"
  );

  info("clicking on pocket library button");
  let pocketPagePromise = BrowserTestUtils.waitForNewTab(
    gBrowser,
    "https://example.com/browser/browser/components/pocket/test/pocket_actions_test.html/firefox_learnmore?src=ff_library"
  );
  pocketLibraryButton.click();
  await pocketPagePromise;

  is(
    gBrowser.currentURI.spec,
    "https://example.com/browser/browser/components/pocket/test/pocket_actions_test.html/firefox_learnmore?src=ff_library",
    "pocket button in library menu button opens correct page"
  );

  BrowserTestUtils.removeTab(tab);
  BrowserTestUtils.removeTab(gBrowser.selectedTab);
});