summaryrefslogtreecommitdiffstats
path: root/browser/components/places/tests/browser/browser_bookmarkProperties_readOnlyRoot.js
blob: d98b7477ec9187a1429dd1a1151c242e707b9e51 (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
62
63
64
65
66
67
"use strict";

add_task(async function test_dialog() {
  info("Bug 479348 - Properties dialog on a root should be read-only.");
  await withSidebarTree("bookmarks", async function (tree) {
    tree.selectItems([PlacesUtils.bookmarks.unfiledGuid]);
    Assert.ok(
      !tree.controller.isCommandEnabled("placesCmd_show:info"),
      "'placesCmd_show:info' on current selected node is disabled"
    );

    await withBookmarksDialog(
      true,
      function openDialog() {
        // Even if the cmd is disabled, we can execute it regardless.
        tree.controller.doCommand("placesCmd_show:info");
      },
      async function test(dialogWin) {
        // Check that the dialog is read-only.
        Assert.ok(dialogWin.gEditItemOverlay.readOnly, "Dialog is read-only");
        // Check that accept button is disabled
        let acceptButton = dialogWin.document
          .getElementById("bookmarkpropertiesdialog")
          .getButton("accept");
        Assert.ok(acceptButton.disabled, "Accept button is disabled");

        // Check that name picker is read only
        let namepicker = dialogWin.document.getElementById(
          "editBMPanel_namePicker"
        );
        Assert.ok(namepicker.readOnly, "Name field is read-only");
        Assert.equal(
          namepicker.value,
          PlacesUtils.getString("OtherBookmarksFolderTitle"),
          "Node title is correct"
        );
      }
    );
  });
});

add_task(async function test_library() {
  info("Bug 479348 - Library info pane on a root should be read-only.");
  let library = await promiseLibrary("UnfiledBookmarks");
  registerCleanupFunction(async function () {
    await promiseLibraryClosed(library);
  });
  let PlacesOrganizer = library.PlacesOrganizer;
  let tree = PlacesOrganizer._places;
  tree.focus();
  Assert.ok(
    !tree.controller.isCommandEnabled("placesCmd_show:info"),
    "'placesCmd_show:info' on current selected node is disabled"
  );

  // Check that the pane is read-only.
  Assert.ok(library.gEditItemOverlay.readOnly, "Info pane is read-only");

  // Check that name picker is read only
  let namepicker = library.document.getElementById("editBMPanel_namePicker");
  Assert.ok(namepicker.readOnly, "Name field is read-only");
  Assert.equal(
    namepicker.value,
    PlacesUtils.getString("OtherBookmarksFolderTitle"),
    "Node title is correct"
  );
});