Skip to content

Commit 3e5d710

Browse files
committed
Bug 1817443 - move url loading method implementations from utilityOverlay.js into their own helper module, r=mossop
openLinkIn would really benefit from being split up a bit, and adding more globals to the browser window is icky. Also, the story for opening new tabs if you're not inside a window is a nightmare right now. Moving this code to a module is a first step to making that story nicer. I kept wrappers for all the functions I'm moving, and added the `window` as the first argument. In the future we can update these functions to support being called without a `window` ref. The one exception is getTopWin, where I updated the callers in this patch. I had to tweak the parameter detection of the different arguments supported by openUILinkIn because forwarding calls means arguments.length is always larger than 3... but then also removed it in the next commit. Differential Revision: https://phabricator.services.mozilla.com/D170210
1 parent 1c30e93 commit 3e5d710

File tree

6 files changed

+648
-555
lines changed

6 files changed

+648
-555
lines changed

browser/base/content/browser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,7 +2808,7 @@ function openLocation(event) {
28082808
}
28092809

28102810
// If there's an open browser window, redirect the command there.
2811-
let win = getTopWin();
2811+
let win = URILoadingHelper.getTargetWindow(window);
28122812
if (win) {
28132813
win.focus();
28142814
win.openLocation();
@@ -3947,7 +3947,7 @@ const BrowserSearch = {
39473947
window.location.href != AppConstants.BROWSER_CHROME_URL ||
39483948
gURLBar.readOnly
39493949
) {
3950-
let win = getTopWin({ skipPopups: true });
3950+
let win = URILoadingHelper.getTopWin(window, { skipPopups: true });
39513951
if (win) {
39523952
// If there's an open browser window, it should handle this command
39533953
win.focus();

browser/base/content/test/contextMenu/browser_utilityOverlay.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ add_task(async function test_eventMatchesKey() {
5151
}
5252
});
5353

54-
add_task(async function test_getTopWin() {
55-
is(getTopWin(), window, "got top window");
54+
add_task(async function test_getTargetWindow() {
55+
is(URILoadingHelper.getTargetWindow(window), window, "got top window");
5656
});
5757

5858
add_task(async function test_openUILink() {
59-
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
60-
const kURL = "http://example.org/";
59+
const kURL = "https://example.org/";
6160
let tab = await BrowserTestUtils.openNewForegroundTab(
6261
gBrowser,
6362
"about:blank"

0 commit comments

Comments
 (0)