Skip to content

Commit

Permalink
Fix createTab incognito and createTab window commands with no URLs on…
Browse files Browse the repository at this point in the history
… Firefox

Fixes #3675.
  • Loading branch information
philc committed Sep 17, 2023
1 parent b2c53be commit 31f1332
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions background_scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,26 +177,29 @@ const BackgroundCommands = {
request.urls = urlList;
} else {
// Otherwise, just create a new tab.
const newTabUrl = Settings.get("newTabUrl");
if (newTabUrl === "pages/blank.html") {
let newTabUrl = Settings.get("newTabUrl");
if (newTabUrl == "pages/blank.html") {
// "pages/blank.html" does not work in incognito mode, so fall back to "chrome://newtab"
// instead.
request.urls = [
request.tab.incognito ? "chrome://newtab" : chrome.runtime.getURL(newTabUrl),
];
} else {
request.urls = [newTabUrl];
newTabUrl =
request.tab.incognito
? Settings.defaultOptions.newTabUrl
: chrome.runtime.getURL(newTabUrl);
}
request.urls = [newTabUrl];
}
}
}
if (request.registryEntry.options.incognito || request.registryEntry.options.window) {
// Firefox does not allow an incognito window to be created with the URL about:newtab. It
// throws this error: "Illegal URL: about:newtab".
const urls = request.urls.filter((u) => u != Settings.defaultOptions.newTabUrl);
const windowConfig = {
url: request.urls,
url: urls,
incognito: request.registryEntry.options.incognito || false,
};
const result = await chrome.windows.create(windowConfig);
callback(request);
await chrome.windows.create(windowConfig);
callback(request)
} else {
let openNextUrl;
const urls = request.urls.slice().reverse();
Expand Down

0 comments on commit 31f1332

Please sign in to comment.