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
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
const TEST_FILE = "file_with_link_to_http.html";
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
const TEST_HTTP = "http://example.org/";
// Test for bug 1338375.
add_task(async function () {
// Open file:// page.
let dir = getChromeDir(getResolvedURI(gTestPath));
dir.append(TEST_FILE);
const uriString = Services.io.newFileURI(dir).spec;
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, uriString);
registerCleanupFunction(async function () {
BrowserTestUtils.removeTab(tab);
});
let browser = tab.linkedBrowser;
// Set pref to open in new window.
Services.prefs.setIntPref("browser.link.open_newwindow", 2);
registerCleanupFunction(function () {
Services.prefs.clearUserPref("browser.link.open_newwindow");
});
// Open new http window from JavaScript in file:// page and check that we get
// a new window with the correct page and features.
let promiseNewWindow = BrowserTestUtils.waitForNewWindow({ url: TEST_HTTP });
await SpecialPowers.spawn(browser, [TEST_HTTP], uri => {
content.open(uri, "_blank");
});
let win = await promiseNewWindow;
registerCleanupFunction(async function () {
await BrowserTestUtils.closeWindow(win);
});
ok(win, "Check that an http window loaded when using window.open.");
ok(
win.menubar.visible,
"Check that the menu bar on the new window is visible."
);
ok(
win.toolbar.visible,
"Check that the tool bar on the new window is visible."
);
// Open new http window from a link in file:// page and check that we get a
// new window with the correct page and features.
promiseNewWindow = BrowserTestUtils.waitForNewWindow({ url: TEST_HTTP });
await BrowserTestUtils.synthesizeMouseAtCenter("#linkToExample", {}, browser);
let win2 = await promiseNewWindow;
registerCleanupFunction(async function () {
await BrowserTestUtils.closeWindow(win2);
});
ok(win2, "Check that an http window loaded when using link.");
ok(
win2.menubar.visible,
"Check that the menu bar on the new window is visible."
);
ok(
win2.toolbar.visible,
"Check that the tool bar on the new window is visible."
);
});
|