Bug 1810141 - fix replaceUrlInTab webextension utility to deal with loadURI changes, r=rpl
Depends on D168392 Differential Revision: https://phabricator.services.mozilla.com/D168393
This commit is contained in:
@@ -127,9 +127,9 @@ global.waitForTabLoaded = (tab, url) => {
|
||||
});
|
||||
};
|
||||
|
||||
global.replaceUrlInTab = (gBrowser, tab, url) => {
|
||||
let loaded = waitForTabLoaded(tab, url);
|
||||
gBrowser.loadURI(url, {
|
||||
global.replaceUrlInTab = (gBrowser, tab, uri) => {
|
||||
let loaded = waitForTabLoaded(tab, uri.spec);
|
||||
gBrowser.loadURI(uri, {
|
||||
flags: Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY,
|
||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), // This is safe from this functions usage however it would be preferred not to dot his.
|
||||
});
|
||||
|
||||
@@ -66,7 +66,7 @@ XPCOMUtils.defineLazyGetter(this, "homepagePopup", () => {
|
||||
// 3. Trigger the browser's homepage method
|
||||
let gBrowser = win.gBrowser;
|
||||
let tab = gBrowser.selectedTab;
|
||||
await replaceUrlInTab(gBrowser, tab, "about:blank");
|
||||
await replaceUrlInTab(gBrowser, tab, Services.io.newURI("about:blank"));
|
||||
Services.prefs.addObserver(HOMEPAGE_PREF, async function prefObserver() {
|
||||
Services.prefs.removeObserver(HOMEPAGE_PREF, prefObserver);
|
||||
let loaded = waitForTabLoaded(tab);
|
||||
|
||||
@@ -58,11 +58,15 @@ XPCOMUtils.defineLazyGetter(this, "newTabPopup", () => {
|
||||
// 3. Once the New Tab URL has changed, replace the tab's URL with the new New Tab URL
|
||||
let gBrowser = win.gBrowser;
|
||||
let tab = gBrowser.selectedTab;
|
||||
await replaceUrlInTab(gBrowser, tab, "about:blank");
|
||||
await replaceUrlInTab(gBrowser, tab, Services.io.newURI("about:blank"));
|
||||
Services.obs.addObserver(
|
||||
{
|
||||
async observe() {
|
||||
await replaceUrlInTab(gBrowser, tab, AboutNewTab.newTabURL);
|
||||
await replaceUrlInTab(
|
||||
gBrowser,
|
||||
tab,
|
||||
Services.io.newURI(AboutNewTab.newTabURL)
|
||||
);
|
||||
// Now that the New Tab is loading, try to open the popup again. This
|
||||
// will only open the popup if a new extension is controlling the New Tab.
|
||||
popup.open();
|
||||
|
||||
Reference in New Issue
Block a user