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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_setup(async function () {
let toolbar = document.getElementById("PersonalToolbar");
let wasCollapsed = toolbar.collapsed;
// Uncollapse the personal toolbar if needed.
if (wasCollapsed) {
await promiseSetToolbarVisibility(toolbar, true);
}
// Clean before and after so we don't have anything in the folders.
await PlacesUtils.bookmarks.eraseEverything();
registerCleanupFunction(async function () {
// Collapse the personal toolbar if needed.
if (wasCollapsed) {
await promiseSetToolbarVisibility(toolbar, false);
}
await PlacesUtils.bookmarks.eraseEverything();
});
});
const TEST_FOLDER_NAME = "Test folder";
add_task(async function test_change_location_from_Toolbar() {
let newTabButton = document.getElementById("tabs-newtab-button");
let children = [
{
title: "first",
url: "http://www.mochi.test/first",
},
{
title: "second",
url: "http://www.mochi.test/second",
},
{
type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
},
{
title: "third",
url: "http://www.mochi.test/third",
},
];
let guid = PlacesUtils.history.makeGuid();
await PlacesUtils.bookmarks.insertTree({
guid: PlacesUtils.bookmarks.toolbarGuid,
children: [
{
guid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
title: TEST_FOLDER_NAME,
children,
},
],
});
let folder = getToolbarNodeForItemGuid(guid);
let loadedPromises = children
.filter(item => "url" in item)
.map(item =>
BrowserTestUtils.waitForNewTab(gBrowser, item.url, false, true)
);
let srcX = 10,
srcY = 10;
// We should drag upwards, since dragging downwards opens menu instead.
let stepX = 0,
stepY = -5;
// We need to dispatch mousemove before dragging, to populate
// PlacesToolbar._cachedMouseMoveEvent, with the cursor position after the
// first step, so that the places code detects it as dragging upward.
EventUtils.synthesizeMouse(folder, srcX + stepX, srcY + stepY, {
type: "mousemove",
});
await EventUtils.synthesizePlainDragAndDrop({
srcElement: folder,
destElement: newTabButton,
srcX,
srcY,
stepX,
stepY,
});
let tabs = await Promise.all(loadedPromises);
for (let tab of tabs) {
BrowserTestUtils.removeTab(tab);
}
ok(true);
});
|