Bug 1810141 - fix loadURI callers that already have an nsIURI reference or where creating one is clearly safe, r=mossop,geckoview-reviewers,extension-reviewers,settings-reviewers,mconley,m_kato

There are 3 types of changes in this commit:

- from `loadURI(foo.spec)` to `loadURI(foo)`, as there's already a URI
- from `loadURI("string")` to `loadURI(Services.io.newURI("string"))` as the URL is hardcoded
- one or two where there is perhaps an intermediate variable but the patch
  context should still make it trivial to ascertain the change is correct.

Depends on D168393

Differential Revision: https://phabricator.services.mozilla.com/D168394
This commit is contained in:
Gijs Kruitbosch 2023-02-13 12:55:24 +00:00
Родитель 55af443c42
Коммит 6add9ed34d
19 изменённых файлов: 42 добавлений и 24 удалений

Просмотреть файл

@ -234,7 +234,7 @@ export let ContentSearch = {
// Since we're going to load the search in the same browser, blur the search
// UI to prevent further interaction before we start loading.
this._reply(actor, "Blur");
browser.loadURI(submission.uri.spec, {
browser.loadURI(submission.uri, {
postData: submission.postData,
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal(
{

Просмотреть файл

@ -553,7 +553,7 @@ var gIdentityHandler = {
// If we're on the error-page, we have to redirect the user
// from HTTPS to HTTP. Otherwise we can just reload the page.
if (this._isAboutHttpsOnlyErrorPage) {
gBrowser.loadURI(newURI.spec, {
gBrowser.loadURI(newURI, {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY,
});

Просмотреть файл

@ -46,7 +46,7 @@ var gFxaPairDeviceDialog = {
// When the modal closes we want to remove any query params
// To prevent refreshes/restores from reopening the dialog
const browser = window.docShell.chromeEventHandler;
browser.loadURI("about:preferences#sync", {
browser.loadURI(Services.io.newURI("about:preferences#sync"), {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});

Просмотреть файл

@ -437,7 +437,7 @@ var gSyncPane = {
// Get the <browser> element hosting us.
let browser = window.docShell.chromeEventHandler;
// And tell it to load our URL.
browser.loadURI(url, {
browser.loadURI(Services.io.newURI(url), {
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal(
{}
),

Просмотреть файл

@ -216,7 +216,10 @@ ContentRestoreInternal.prototype = {
// restore.
remoteTypeOverride: Services.appinfo.remoteType,
};
webNavigation.loadURI("about:blank", loadURIOptions);
webNavigation.loadURI(
Services.io.newURI("about:blank"),
loadURIOptions
);
}
return true;
@ -368,7 +371,7 @@ HistoryListener.prototype = {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
loadFlags,
};
this.webNavigation.loadURI(newURI.spec, loadURIOptions);
this.webNavigation.loadURI(newURI, loadURIOptions);
},
OnHistoryReload() {

Просмотреть файл

@ -210,7 +210,7 @@ function restoreSession() {
function startNewSession() {
if (Services.prefs.getIntPref("browser.startup.page") == 0) {
getBrowserWindow().gBrowser.loadURI("about:blank", {
getBrowserWindow().gBrowser.loadURI(Services.io.newURI("about:blank"), {
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal(
{}
),

Просмотреть файл

@ -58,7 +58,7 @@ function loadContentWindow(browser, url) {
oa
),
};
browser.loadURI(uri.spec, loadURIOptions);
browser.loadURI(uri, loadURIOptions);
let { webProgress } = browser;
let progressListener = {

Просмотреть файл

@ -489,7 +489,7 @@ var UITour = {
return;
}
// We want to replace the current tab.
browser.loadURI(url.href, {
browser.loadURI(url.URI, {
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal(
{}
),
@ -512,7 +512,7 @@ var UITour = {
}
// We want to replace the current tab.
browser.loadURI(url.href, {
browser.loadURI(url.URI, {
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal(
{}
),

Просмотреть файл

@ -147,7 +147,7 @@ let NewTabPagePreloading = {
}
let browser = this._createBrowser(window);
browser.loadURI(window.BROWSER_NEW_TAB_URL, {
browser.loadURI(Services.io.newURI(window.BROWSER_NEW_TAB_URL), {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
browser.docShellIsActive = false;

Просмотреть файл

@ -505,7 +505,7 @@ class GeckoViewNavigation extends GeckoViewModule {
}
// 3) We have a new session and a browser element, load the requested URI.
browser.loadURI(uri.spec, {
browser.loadURI(uri, {
triggeringPrincipal,
csp,
referrerInfo,

Просмотреть файл

@ -674,7 +674,7 @@ FxAccountsWebChannelHelpers.prototype = {
}
uri += "#sync";
browser.loadURI(uri, {
browser.loadURI(Services.io.newURI(uri), {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
},

Просмотреть файл

@ -81,9 +81,12 @@ async function createWindowlessBrowser({ isPrivate = false } = {}) {
const system = Services.scriptSecurityManager.getSystemPrincipal();
chromeShell.createAboutBlankContentViewer(system, system);
windowlessBrowser.browsingContext.useGlobalHistory = false;
chromeShell.loadURI("chrome://extensions/content/dummy.xhtml", {
triggeringPrincipal: system,
});
chromeShell.loadURI(
Services.io.newURI("chrome://extensions/content/dummy.xhtml"),
{
triggeringPrincipal: system,
}
);
await promiseObserved(
"chrome-document-global-created",

Просмотреть файл

@ -77,7 +77,7 @@ export class AboutHttpsOnlyErrorChild extends RemotePageChild {
.setHost("www." + oldURI.host)
.finalize();
webNav.loadURI(newWWWURI.spec, {
webNav.loadURI(newWWWURI, {
triggeringPrincipal,
loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY,
});

Просмотреть файл

@ -79,7 +79,10 @@ class BackgroundThumbnailsChild extends JSWindowActorChild {
loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_STOP_CONTENT,
};
try {
docShell.loadURI(message.data.url, loadURIOptions);
docShell.loadURI(
Services.io.newURI(message.data.url),
loadURIOptions
);
} catch (ex) {
return false;
}

Просмотреть файл

@ -244,7 +244,9 @@ export class NetErrorParent extends JSWindowActorParent {
let offlinePagePath = `chrome://global/content/neterror/supportpages/${supportPageSlug}.html`;
let triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
this.browser.loadURI(offlinePagePath, { triggeringPrincipal });
this.browser.loadURI(Services.io.newURI(offlinePagePath), {
triggeringPrincipal,
});
}
receiveMessage(message) {

Просмотреть файл

@ -65,6 +65,10 @@ const { ExtensionUtils } = ChromeUtils.import(
"resource://gre/modules/ExtensionUtils.jsm"
);
const DUMMY_PAGE_URI = Services.io.newURI(
"chrome://extensions/content/dummy.xhtml"
);
var {
BaseContext,
CanOfAPIs,
@ -1367,7 +1371,7 @@ class HiddenXULWindow {
}
windowlessBrowser.browsingContext.useGlobalHistory = false;
chromeShell.loadURI("chrome://extensions/content/dummy.xhtml", {
chromeShell.loadURI(DUMMY_PAGE_URI, {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});

Просмотреть файл

@ -23,7 +23,7 @@ const gfxFrameScript = {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
};
webNav.loadURI(
"chrome://gfxsanity/content/sanitytest.html",
Services.io.newURI("chrome://gfxsanity/content/sanitytest.html"),
loadURIOptions
);
},

Просмотреть файл

@ -243,7 +243,7 @@ const BackgroundPageThumbs = {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
};
wlBrowser.loadURI(
"chrome://global/content/backgroundPageThumbs.xhtml",
Services.io.newURI("chrome://global/content/backgroundPageThumbs.xhtml"),
loadURIOptions
);
this._windowlessContainer = wlBrowser;
@ -444,7 +444,10 @@ const BackgroundPageThumbs = {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_STOP_CONTENT,
};
this._thumbBrowser.loadURI("about:blank", loadURIOptions);
this._thumbBrowser.loadURI(
Services.io.newURI("about:blank"),
loadURIOptions
);
},
/**

Просмотреть файл

@ -4,7 +4,7 @@
import { PromiseUtils } from "resource://gre/modules/PromiseUtils.sys.mjs";
const XUL_PAGE = "chrome://global/content/win.xhtml";
const XUL_PAGE = Services.io.newURI("chrome://global/content/win.xhtml");
const gAllHiddenFrames = new Set();