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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function bookmarks_toolbar_shown_on_newtab() {
let url =
getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",
"https://example.com"
) + "slow_loading_page.sjs";
for (let featureEnabled of [true, false]) {
for (let newTabEnabled of [true, false]) {
info(
`Testing with the feature ${
featureEnabled ? "enabled" : "disabled"
} and newtab ${newTabEnabled ? "enabled" : "disabled"}`
);
await SpecialPowers.pushPrefEnv({
set: [
["browser.toolbars.bookmarks.2h2020", featureEnabled],
["browser.newtabpage.enabled", newTabEnabled],
],
});
let newWindowOpened = BrowserTestUtils.domWindowOpened();
let triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
openUILinkIn(url, "window", { triggeringPrincipal });
let newWin = await newWindowOpened;
let exitConditions = {
visible: true,
};
let slowSiteLoaded = BrowserTestUtils.firstBrowserLoaded(newWin, false);
slowSiteLoaded.then(result => {
exitConditions.earlyExit = result;
});
let result = await waitForBookmarksToolbarVisibilityWithExitConditions({
win: newWin,
exitConditions,
message: "Toolbar should not become visible when loading slow site",
});
// The visibility promise will resolve to a Boolean whereas the browser
// load promise will resolve to an Event object.
ok(
typeof result != "boolean",
"The bookmarks toolbar should not become visible before the site is loaded"
);
ok(!isBookmarksToolbarVisible(newWin), "Toolbar hidden on slow site");
await BrowserTestUtils.closeWindow(newWin);
}
}
});
|