зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1347817 - Principal must always have a valid origin - part 6 - fixing tests, r=ehsan
This commit is contained in:
Родитель
aa6ba86865
Коммит
2c716cd273
|
@ -33,7 +33,7 @@ add_task(function* test_remote_window_open_aboutBlank() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For loading the initial about:blank in non-e10s mode, it will be loaded with
|
* For loading the initial about:blank in non-e10s mode, it will be loaded with
|
||||||
* codebase principal. So we test if it has correct firstPartyDomain set.
|
* a null principal. So we test if it has correct firstPartyDomain set.
|
||||||
*/
|
*/
|
||||||
add_task(function* test_nonremote_window_open_aboutBlank() {
|
add_task(function* test_nonremote_window_open_aboutBlank() {
|
||||||
let win = yield BrowserTestUtils.openNewBrowserWindow({remote: false});
|
let win = yield BrowserTestUtils.openNewBrowserWindow({remote: false});
|
||||||
|
@ -43,8 +43,8 @@ add_task(function* test_nonremote_window_open_aboutBlank() {
|
||||||
|
|
||||||
let attrs = { firstPartyDomain: "about.ef2a7dd5-93bc-417f-a698-142c3116864f.mozilla" };
|
let attrs = { firstPartyDomain: "about.ef2a7dd5-93bc-417f-a698-142c3116864f.mozilla" };
|
||||||
yield ContentTask.spawn(browser, attrs, function* (expectAttrs) {
|
yield ContentTask.spawn(browser, attrs, function* (expectAttrs) {
|
||||||
Assert.ok(content.document.nodePrincipal.isCodebasePrincipal,
|
Assert.ok(!content.document.nodePrincipal.isCodebasePrincipal,
|
||||||
"The principal of non-remote about:blank should be a codebase principal.");
|
"The principal of non-remote about:blank should not be a codebase principal.");
|
||||||
Assert.equal(content.document.nodePrincipal.originAttributes.firstPartyDomain,
|
Assert.equal(content.document.nodePrincipal.originAttributes.firstPartyDomain,
|
||||||
expectAttrs.firstPartyDomain,
|
expectAttrs.firstPartyDomain,
|
||||||
"non-remote about:blank should have firstPartyDomain set");
|
"non-remote about:blank should have firstPartyDomain set");
|
||||||
|
|
|
@ -95,8 +95,9 @@ var gPermissionManager = {
|
||||||
try {
|
try {
|
||||||
uri = Services.io.newURI(input_url);
|
uri = Services.io.newURI(input_url);
|
||||||
principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
|
principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
|
||||||
// If we have ended up with an unknown scheme, the following will throw.
|
if (principal.origin.startsWith("moz-nullprincipal:")) {
|
||||||
principal.origin;
|
throw "Null principal";
|
||||||
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
uri = Services.io.newURI("http://" + input_url);
|
uri = Services.io.newURI("http://" + input_url);
|
||||||
principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
|
principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
|
||||||
|
|
|
@ -300,12 +300,5 @@ function run_test() {
|
||||||
|
|
||||||
var aboutBlankURI = makeURI('about:blank');
|
var aboutBlankURI = makeURI('about:blank');
|
||||||
var aboutBlankPrin = ssm.createCodebasePrincipal(aboutBlankURI, {});
|
var aboutBlankPrin = ssm.createCodebasePrincipal(aboutBlankURI, {});
|
||||||
var thrown = false;
|
do_check_true(/^moz-nullprincipal:\{([0-9]|[a-z]|\-){36}\}$/.test(aboutBlankPrin.origin));
|
||||||
try {
|
|
||||||
aboutBlankPrin.origin;
|
|
||||||
} catch (e) {
|
|
||||||
thrown = true;
|
|
||||||
}
|
|
||||||
do_check_true(thrown);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1634,13 +1634,12 @@ WebSocketImpl::Init(JSContext* aCx,
|
||||||
nsCOMPtr<nsPIDOMWindowInner> innerWindow;
|
nsCOMPtr<nsPIDOMWindowInner> innerWindow;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
bool isNullPrincipal = true;
|
|
||||||
if (principal) {
|
if (principal) {
|
||||||
|
bool isNullPrincipal = true;
|
||||||
isNullPrincipal = principal->GetIsNullPrincipal();
|
isNullPrincipal = principal->GetIsNullPrincipal();
|
||||||
}
|
if (isNullPrincipal || nsContentUtils::IsSystemPrincipal(principal)) {
|
||||||
|
break;
|
||||||
if (!isNullPrincipal) {
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!innerWindow) {
|
if (!innerWindow) {
|
||||||
|
|
|
@ -2551,12 +2551,11 @@ nsGlobalWindow::SetInitialPrincipalToSubject()
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// If we have a document loaded at this point, it had better be about:blank.
|
// If we have a document loaded at this point, it had better be about:blank.
|
||||||
// Otherwise, something is really weird.
|
// Otherwise, something is really weird. An about:blank page has a
|
||||||
nsCOMPtr<nsIURI> uri;
|
// NullPrincipal.
|
||||||
mDoc->NodePrincipal()->GetURI(getter_AddRefs(uri));
|
bool isNullPrincipal;
|
||||||
NS_ASSERTION(uri && NS_IsAboutBlank(uri) &&
|
MOZ_ASSERT(NS_SUCCEEDED(mDoc->NodePrincipal()->GetIsNullPrincipal(&isNullPrincipal)) &&
|
||||||
NS_IsAboutBlank(mDoc->GetDocumentURI()),
|
isNullPrincipal);
|
||||||
"Unexpected original document");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,9 @@ add_task(function* test_isOriginPotentiallyTrustworthy() {
|
||||||
["http://127.0.0.1/", true],
|
["http://127.0.0.1/", true],
|
||||||
["file:///", true],
|
["file:///", true],
|
||||||
["resource:///", true],
|
["resource:///", true],
|
||||||
["app://", true],
|
|
||||||
["moz-extension://", true],
|
["moz-extension://", true],
|
||||||
["wss://example.com/", true],
|
["wss://example.com/", true],
|
||||||
["about:config", false],
|
["about:config", false],
|
||||||
["urn:generic", false],
|
|
||||||
["http://example.net/", true],
|
["http://example.net/", true],
|
||||||
["ws://example.org/", true],
|
["ws://example.org/", true],
|
||||||
["chrome://example.net/content/messenger.xul", false],
|
["chrome://example.net/content/messenger.xul", false],
|
||||||
|
|
Загрузка…
Ссылка в новой задаче