mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1760417
- Make ContentPrincipal more reliable for URIs in the form of scheme://.origin.tld. r=nika,ckerschb
Attempting to get the siteOrigin for a URI of something like "https://.mozilla.org" was returning NS_ERROR_ILLEGAL_VALUE, which caused breakage in parts of the browser UI when trying to initialize a window to point at that URI. It looks like the NS_ERROR_ILLEGAL_VALUE stuff was added back in bug 1491728 as part of an effort to better handle some IPv6 stuff. I tested the STR in bug 1491728 for the original bug, and I cannot reproduce the issue even witht his change. nika suggested that instead of returning NS_ERROR_ILLEGAL_VALUE for this form of URI, we return the same value as `nsIPrincipal.origin`. Differential Revision: https://phabricator.services.mozilla.com/D142493
This commit is contained in:
parent
dd9df31950
commit
063ec88ba4
@ -473,7 +473,8 @@ ContentPrincipal::GetSiteOriginNoSuffix(nsACString& aSiteOrigin) {
|
||||
// If this is an IP address or something like "localhost", we just continue
|
||||
// with gotBaseDomain = false.
|
||||
if (rv != NS_ERROR_HOST_IS_IP_ADDRESS &&
|
||||
rv != NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS) {
|
||||
rv != NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS &&
|
||||
rv != NS_ERROR_INVALID_ARG) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,16 @@ Assert.equal(prinicpal3.originNoSuffix, "https://test1.test2.example.com:5555");
|
||||
Assert.equal(prinicpal3.siteOrigin, "https://example.com^userContextId=5555");
|
||||
Assert.equal(prinicpal3.siteOriginNoSuffix, "https://example.com");
|
||||
|
||||
let uri4 = Services.io.newURI("https://.example.com:6666");
|
||||
let prinicpal4 = scriptSecMan.createContentPrincipal(uri4, {
|
||||
userContextId: 6666,
|
||||
});
|
||||
Assert.ok(prinicpal4.isContentPrincipal);
|
||||
Assert.equal(prinicpal4.origin, "https://.example.com:6666^userContextId=6666");
|
||||
Assert.equal(prinicpal4.originNoSuffix, "https://.example.com:6666");
|
||||
Assert.equal(prinicpal4.siteOrigin, "https://.example.com^userContextId=6666");
|
||||
Assert.equal(prinicpal4.siteOriginNoSuffix, "https://.example.com");
|
||||
|
||||
let aboutURI = Services.io.newURI("about:preferences");
|
||||
let aboutPrincipal = scriptSecMan.createContentPrincipal(aboutURI, {
|
||||
userContextId: 66,
|
||||
|
@ -0,0 +1,38 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { E10SUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/E10SUtils.jsm"
|
||||
);
|
||||
|
||||
/**
|
||||
* Tests for E10SUtils.getRemoteTypeForURIObject method, which is
|
||||
* used to compute preferred remote process types for content given
|
||||
* certain conditions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test that getRemoteTypeForURIObject returns the preferred remote type
|
||||
* when given a URI with an invalid site origin.
|
||||
*
|
||||
* This is a regression test for bug 1760417.
|
||||
*/
|
||||
add_task(async function test_invalid_site_origin() {
|
||||
const INVALID_SITE_ORIGIN_URI = Services.io.newURI(
|
||||
"https://.mozilla.org/this/is/a/test.html"
|
||||
);
|
||||
const EXPECTED_REMOTE_TYPE = `${E10SUtils.FISSION_WEB_REMOTE_TYPE}=https://.mozilla.org`;
|
||||
let result = E10SUtils.getRemoteTypeForURIObject(
|
||||
INVALID_SITE_ORIGIN_URI,
|
||||
true,
|
||||
true,
|
||||
E10SUtils.DEFAULT_REMOTE_TYPE
|
||||
);
|
||||
Assert.equal(
|
||||
result,
|
||||
EXPECTED_REMOTE_TYPE,
|
||||
"Got the expected default remote type."
|
||||
);
|
||||
});
|
@ -19,6 +19,7 @@ support-files =
|
||||
[test_CreditCard.js]
|
||||
[test_DeferredTask.js]
|
||||
skip-if = toolkit == 'android' || (os == 'mac') # osx: Bug 1550141;
|
||||
[test_E10SUtils_getRemoteTypeForURIObject.js]
|
||||
[test_E10SUtils_workers_remote_types.js]
|
||||
[test_FileUtils.js]
|
||||
skip-if = toolkit == 'android'
|
||||
|
Loading…
Reference in New Issue
Block a user