-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathbrowser_sidebar_move.js
76 lines (68 loc) · 1.99 KB
/
browser_sidebar_move.js
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
registerCleanupFunction(() => {
Services.prefs.clearUserPref("sidebar.position_start");
SidebarController.hide();
});
const EXPECTED_START_ORDINALS = [
["sidebar-main", 1],
["sidebar-launcher-splitter", 2],
["sidebar-box", 3],
["sidebar-splitter", 4],
["tabbrowser-tabbox", 5],
];
const EXPECTED_END_ORDINALS = [
["sidebar-main", 5],
["sidebar-launcher-splitter", 4],
["sidebar-box", 3],
["sidebar-splitter", 2],
["tabbrowser-tabbox", 1],
];
function getBrowserChildrenWithOrdinals() {
let browser = document.getElementById("browser");
return [...browser.children].map(node => {
return [node.id, node.style.order];
});
}
add_task(async function () {
await SidebarController.show("viewBookmarksSidebar");
SidebarController.showSwitcherPanel();
let reversePositionButton = document.getElementById(
"sidebar-reverse-position"
);
let originalLabel = reversePositionButton.getAttribute("label");
let box = document.getElementById("sidebar-box");
// Default (position: left)
Assert.deepEqual(
getBrowserChildrenWithOrdinals(),
EXPECTED_START_ORDINALS,
"Correct browser ordinal (start)"
);
ok(!box.hasAttribute("sidebar-positionend"), "Positioned start");
// Moved to right
SidebarController.reversePosition();
SidebarController.showSwitcherPanel();
Assert.deepEqual(
getBrowserChildrenWithOrdinals(),
EXPECTED_END_ORDINALS,
"Correct browser ordinal (end)"
);
isnot(
reversePositionButton.getAttribute("label"),
originalLabel,
"Label changed"
);
ok(box.hasAttribute("sidebar-positionend"), "Positioned end");
// Moved to back to left
SidebarController.reversePosition();
SidebarController.showSwitcherPanel();
Assert.deepEqual(
getBrowserChildrenWithOrdinals(),
EXPECTED_START_ORDINALS,
"Correct browser ordinal (start)"
);
ok(!box.hasAttribute("sidebar-positionend"), "Positioned start");
is(
reversePositionButton.getAttribute("label"),
originalLabel,
"Label is back to normal"
);
});