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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
async function emptyToolbarMessageVisible(visible, win = window) {
info("Empty toolbar message should be " + (visible ? "visible" : "hidden"));
let emptyMessage = win.document.getElementById("personal-toolbar-empty");
await BrowserTestUtils.waitForMutationCondition(
emptyMessage,
{ attributes: true, attributeFilter: ["hidden"] },
() => emptyMessage.hidden != visible
);
}
add_task(async function empty_message_on_non_empty_bookmarks_toolbar() {
await resetCustomization();
ok(CustomizableUI.inDefaultState, "Default state to begin");
await SpecialPowers.pushPrefEnv({
set: [["browser.toolbars.bookmarks.visibility", "always"]],
});
CustomizableUI.removeWidgetFromArea("import-button");
CustomizableUI.removeWidgetFromArea("personal-bookmarks");
CustomizableUI.addWidgetToArea(
"bookmarks-menu-button",
CustomizableUI.AREA_BOOKMARKS,
0
);
let newWin = await BrowserTestUtils.openNewBrowserWindow();
let doc = newWin.document;
ok(
BrowserTestUtils.isVisible(doc.getElementById("PersonalToolbar")),
"Personal toolbar should be visible"
);
ok(
doc.getElementById("personal-toolbar-empty").hidden,
"Empty message should be hidden"
);
await BrowserTestUtils.closeWindow(newWin);
await resetCustomization();
});
add_task(async function empty_message_after_customization() {
// ensure There's something on the toolbar.
let bm = await PlacesUtils.bookmarks.insert({
url: "https://mozilla.org/",
title: "test",
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
});
registerCleanupFunction(() => PlacesUtils.bookmarks.remove(bm));
ok(CustomizableUI.inDefaultState, "Default state to begin");
// Open window with a visible toolbar.
await SpecialPowers.pushPrefEnv({
set: [["browser.toolbars.bookmarks.visibility", "always"]],
});
let newWin = await BrowserTestUtils.openNewBrowserWindow();
let doc = newWin.document;
let toolbar = doc.getElementById("PersonalToolbar");
ok(BrowserTestUtils.isVisible(toolbar), "Personal toolbar should be visible");
await emptyToolbarMessageVisible(false, newWin);
// Force a Places view uninit through customization.
CustomizableUI.removeWidgetFromArea("personal-bookmarks");
await resetCustomization();
// Show the toolbar again.
setToolbarVisibility(toolbar, true, false, false);
ok(BrowserTestUtils.isVisible(toolbar), "Personal toolbar should be visible");
// Wait for bookmarks to be visible.
let placesItems = doc.getElementById("PlacesToolbarItems");
await BrowserTestUtils.waitForMutationCondition(
placesItems,
{ childList: true },
() => placesItems.childNodes.length
);
await emptyToolbarMessageVisible(false, newWin);
await BrowserTestUtils.closeWindow(newWin);
});
|