summaryrefslogtreecommitdiffstats
path: root/browser/components/places/tests/browser/browser_library_open_bookmark.js
blob: 7532d7c1c9b634ada3fd740d6efec3302861e481 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

/**
 * Test that the a bookmark can be opened from the Library by mouse double click.
 */
"use strict";

const TEST_URL = "about:buildconfig";

add_task(async function test_open_bookmark_from_library() {
  let bm = await PlacesUtils.bookmarks.insert({
    parentGuid: PlacesUtils.bookmarks.unfiledGuid,
    url: TEST_URL,
    title: TEST_URL,
  });

  let tab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    "about:blank"
  );

  let gLibrary = await promiseLibrary("UnfiledBookmarks");

  registerCleanupFunction(async function () {
    await promiseLibraryClosed(gLibrary);
    await PlacesUtils.bookmarks.eraseEverything();
    await BrowserTestUtils.removeTab(tab);
  });

  let bmLibrary = gLibrary.ContentTree.view.view.nodeForTreeIndex(0);
  Assert.equal(bmLibrary.title, bm.title, "Found bookmark in the right pane");

  gLibrary.ContentTree.view.selectNode(bmLibrary);
  synthesizeClickOnSelectedTreeCell(gLibrary.ContentTree.view, {
    clickCount: 2,
  });

  await BrowserTestUtils.browserLoaded(
    gBrowser.selectedBrowser,
    false,
    TEST_URL
  );
  Assert.ok(true, "Expected tab was loaded");
});