summaryrefslogtreecommitdiffstats
path: root/browser/components/places/tests/browser/browser_bookmark_all_tabs.js
blob: 2852bf4019b428224483df4f54d3ef7383b5a8af (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
/**
 * Test for Bug 446171 - Name field of bookmarks saved via 'Bookmark All Tabs'
 * has '(null)' value if history is disabled or just in private browsing mode
 */
"use strict";

add_task(async function () {
  const BASE_URL =
    "http://example.org/browser/browser/components/places/tests/browser/";
  const TEST_PAGES = [
    BASE_URL + "bookmark_dummy_1.html",
    BASE_URL + "bookmark_dummy_2.html",
    BASE_URL + "bookmark_dummy_1.html",
  ];

  function promiseAddTab(url) {
    return BrowserTestUtils.openNewForegroundTab(gBrowser, url);
  }

  let tabs = await Promise.all(TEST_PAGES.map(promiseAddTab));

  let URIs = PlacesCommandHook.uniqueCurrentPages;
  is(URIs.length, 3, "Only unique pages are returned");

  Assert.deepEqual(
    URIs.map(URI => URI.uri.spec),
    [
      "about:blank",
      BASE_URL + "bookmark_dummy_1.html",
      BASE_URL + "bookmark_dummy_2.html",
    ],
    "Correct URIs are returned"
  );

  Assert.deepEqual(
    URIs.map(URI => URI.title),
    ["New Tab", "Bookmark Dummy 1", "Bookmark Dummy 2"],
    "Correct titles are returned"
  );

  registerCleanupFunction(async function () {
    for (let tab of tabs) {
      BrowserTestUtils.removeTab(tab);
    }
  });
});