mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1685801: Part 3 - Remove BrowserUtils.makeURI and makeFileURI. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D101483
This commit is contained in:
parent
59963809cd
commit
d7b8eeedcc
@ -42,8 +42,6 @@ const ICON_DATA =
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABH0lEQVRYw2P8////f4YBBEwMAwxGHcBCUMX/91DGOSj/BpT/DkpzQChGBSjfBErLQsVZhmoI/L8LpRdD6X1QietQGhYy7FB5aAgwmkLpBKi4BZTPMThDgBGjHIDF+f9mKD0fKvGBRKNdoF7sgPL1saaJwZgGDkJ9vpZMn8PAHqg5G9FyifBgD4H/W9HyOWrU/f+DIzHhkoeZxxgzZEIAVtJ9RxX+Q6DAxCmP3byhXxkxshAs5odqbcioAY3UC1CBLyTGOTqAmsfAOWRCwBvqxV0oIUB2OQAzDy3/D+a6wB7q8mCU2vD/nw94GziYIQOtDRn9oXz+IZMGBKGMbCjNh9Ii+v8HR4uIAUeLiEEbb9twELaIRlqrmHG0bzjiHQAA1LVfww8jwM4AAAAASUVORK5CYII=";
|
||||
|
||||
let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
|
||||
let makeURI = ChromeUtils.import("resource://gre/modules/BrowserUtils.jsm", {})
|
||||
.BrowserUtils.makeURI;
|
||||
|
||||
function clearAllImageCaches() {
|
||||
let tools = SpecialPowers.Cc["@mozilla.org/image/tools;1"].getService(
|
||||
@ -244,8 +242,8 @@ function assertIconIsData(item) {
|
||||
}
|
||||
|
||||
async function doTest(aTestPage, aExpectedCookies, aFaviconURL) {
|
||||
let firstPageURI = makeURI(TEST_SITE_ONE + aTestPage);
|
||||
let secondPageURI = makeURI(TEST_SITE_TWO + aTestPage);
|
||||
let firstPageURI = Services.io.newURI(TEST_SITE_ONE + aTestPage);
|
||||
let secondPageURI = Services.io.newURI(TEST_SITE_TWO + aTestPage);
|
||||
|
||||
// Start to observe the event of that favicon has been fully loaded.
|
||||
let promiseFaviconLoaded = waitOnFaviconLoaded(aFaviconURL);
|
||||
|
@ -15,8 +15,6 @@ const FAVICON_URI = TEST_SITE + TEST_DIRECTORY + "file_favicon.png";
|
||||
const FAVICON_CACHE_URI = TEST_CACHE_SITE + TEST_DIRECTORY + "file_favicon.png";
|
||||
|
||||
let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
|
||||
let makeURI = ChromeUtils.import("resource://gre/modules/BrowserUtils.jsm", {})
|
||||
.BrowserUtils.makeURI;
|
||||
|
||||
function clearAllImageCaches() {
|
||||
let tools = SpecialPowers.Cc["@mozilla.org/image/tools;1"].getService(
|
||||
@ -205,7 +203,7 @@ add_task(async function test_favicon_privateBrowsing() {
|
||||
let privateWindow = await BrowserTestUtils.openNewBrowserWindow({
|
||||
private: true,
|
||||
});
|
||||
let pageURI = makeURI(TEST_PAGE);
|
||||
let pageURI = Services.io.newURI(TEST_PAGE);
|
||||
|
||||
// Generate two random cookies for non-private window and private window
|
||||
// respectively.
|
||||
|
@ -254,7 +254,7 @@ function testURL(
|
||||
let threw = false;
|
||||
let targetURI;
|
||||
try {
|
||||
targetURI = makeURI(target);
|
||||
targetURI = Services.io.newURI(target);
|
||||
} catch (ex) {
|
||||
ok(
|
||||
!canCreate,
|
||||
@ -300,7 +300,7 @@ add_task(async function() {
|
||||
if (sourceString.startsWith("about:test-chrome-privs")) {
|
||||
source = ssm.getSystemPrincipal();
|
||||
} else {
|
||||
source = ssm.createContentPrincipal(makeURI(sourceString), {});
|
||||
source = ssm.createContentPrincipal(Services.io.newURI(sourceString), {});
|
||||
}
|
||||
for (let [
|
||||
target,
|
||||
@ -341,10 +341,6 @@ add_task(async function() {
|
||||
// eslint-disable-next-line no-shadow
|
||||
let baseFlags = ssm.STANDARD | ssm.DONT_REPORT_ERRORS;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
let makeURI = ChromeUtils.import(
|
||||
"resource://gre/modules/BrowserUtils.jsm",
|
||||
{}
|
||||
).BrowserUtils.makeURI;
|
||||
let b = new content.Blob(["I am a blob"]);
|
||||
let contentBlobURI = content.URL.createObjectURL(b);
|
||||
let contentPrincipal = content.document.nodePrincipal;
|
||||
|
@ -15,46 +15,41 @@
|
||||
|
||||
<script type="application/javascript"><![CDATA[
|
||||
SimpleTest.requestCompleteLog();
|
||||
let makeURI = ChromeUtils.import("resource://gre/modules/BrowserUtils.jsm", {}).BrowserUtils.makeURI;
|
||||
|
||||
const BASE_URI = "http://mochi.test:8888/chrome/dom/security/test/general/";
|
||||
const FAVICON_URI = BASE_URI + "favicon_bug1277803.ico";
|
||||
const LOADING_URI = BASE_URI + "bug1277803.html";
|
||||
let testWindow; //will be used to trigger favicon load
|
||||
|
||||
let securityManager = Cc["@mozilla.org/scriptsecuritymanager;1"].
|
||||
getService(Ci.nsIScriptSecurityManager);
|
||||
let expectedPrincipal = securityManager.createContentPrincipal(makeURI(LOADING_URI), {});
|
||||
let systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance();
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let expectedPrincipal = Services.scriptSecurityManager
|
||||
.createContentPrincipal(Services.io.newURI(LOADING_URI), {});
|
||||
let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
|
||||
|
||||
function runTest() {
|
||||
// Register our observer to intercept favicon requests.
|
||||
let os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData)
|
||||
{
|
||||
// Make sure this is a favicon request.
|
||||
let httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
|
||||
if (FAVICON_URI != httpChannel.URI.spec) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure the topic is the one we set an observer for.
|
||||
is(aTopic, "http-on-modify-request", "Expected observer topic");
|
||||
|
||||
// Check for the correct loadingPrincipal, triggeringPrincipal.
|
||||
let triggeringPrincipal = httpChannel.loadInfo.triggeringPrincipal;
|
||||
let loadingPrincipal = httpChannel.loadInfo.loadingPrincipal;
|
||||
|
||||
ok(loadingPrincipal.equals(expectedPrincipal), "Should be loading with the expected principal.");
|
||||
ok(triggeringPrincipal.equals(expectedPrincipal), "Should be triggered with the expected principal.");
|
||||
|
||||
os.removeObserver(this, "http-on-modify-request");
|
||||
SimpleTest.finish();
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
// Make sure this is a favicon request.
|
||||
let httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
|
||||
if (FAVICON_URI != httpChannel.URI.spec) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure the topic is the one we set an observer for.
|
||||
is(aTopic, "http-on-modify-request", "Expected observer topic");
|
||||
|
||||
// Check for the correct loadingPrincipal, triggeringPrincipal.
|
||||
let triggeringPrincipal = httpChannel.loadInfo.triggeringPrincipal;
|
||||
let loadingPrincipal = httpChannel.loadInfo.loadingPrincipal;
|
||||
|
||||
ok(loadingPrincipal.equals(expectedPrincipal), "Should be loading with the expected principal.");
|
||||
ok(triggeringPrincipal.equals(expectedPrincipal), "Should be triggered with the expected principal.");
|
||||
|
||||
Services.obs.removeObserver(this, "http-on-modify-request");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
os.addObserver(observer, "http-on-modify-request");
|
||||
Services.obs.addObserver(observer, "http-on-modify-request");
|
||||
|
||||
// Now that the observer is set up, trigger a favicon load with navigation
|
||||
testWindow = window.open(LOADING_URI);
|
||||
|
@ -193,26 +193,6 @@ var BrowserUtils = {
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructs a new URI, using nsIIOService.
|
||||
* @param aURL The URI spec.
|
||||
* @param aOriginCharset The charset of the URI.
|
||||
* @param aBaseURI Base URI to resolve aURL, or null.
|
||||
* @return an nsIURI object based on aURL.
|
||||
*
|
||||
* @deprecated Use Services.io.newURI directly instead.
|
||||
*/
|
||||
makeURI(aURL, aOriginCharset, aBaseURI) {
|
||||
return Services.io.newURI(aURL, aOriginCharset, aBaseURI);
|
||||
},
|
||||
|
||||
/**
|
||||
* @deprecated Use Services.io.newFileURI directly instead.
|
||||
*/
|
||||
makeFileURI(aFile) {
|
||||
return Services.io.newFileURI(aFile);
|
||||
},
|
||||
|
||||
/**
|
||||
* For a given DOM element, returns its position in "screen"
|
||||
* coordinates. In a content process, the coordinates returned will
|
||||
@ -559,7 +539,7 @@ var BrowserUtils = {
|
||||
linkText = selectionStr.trim();
|
||||
if (/^(?:https?|ftp):/i.test(linkText)) {
|
||||
try {
|
||||
url = this.makeURI(linkText);
|
||||
url = Services.io.newURI(linkText);
|
||||
} catch (ex) {}
|
||||
} else if (/^(?:[a-z\d-]+\.)+[a-z]+$/i.test(linkText)) {
|
||||
// Check if this could be a valid url, just missing the protocol.
|
||||
|
Loading…
Reference in New Issue
Block a user