forked from BrowserWorks/Waterfox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Differential Revision: https://phabricator.services.mozilla.com/D26681 --HG-- extra : moz-landing-system : lando
- Loading branch information
1 parent
e3dae73
commit 23a6ba3
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
dom/security/test/general/browser_test_assert_systemprincipal_documents.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//"use strict" | ||
|
||
const kTestPath = getRootDirectory(gTestPath); | ||
const kTestURI = kTestPath + "file_assert_systemprincipal_documents.html"; | ||
|
||
add_task(async function setup() { | ||
// We expect the assertion in function | ||
// AssertSystemPrincipalMustNotLoadRemoteDocuments as defined in | ||
// file dom/security/nsContentSecurityManager.cpp | ||
SimpleTest.expectAssertions(1); | ||
|
||
await SpecialPowers.pushPrefEnv({ | ||
"set": [["security.disallow_non_local_systemprincipal_in_tests", true]], | ||
}); | ||
}); | ||
|
||
add_task(async function open_test_iframe_in_tab() { | ||
// This looks at the iframe (load type SUBDOCUMENT) | ||
await BrowserTestUtils.withNewTab({ gBrowser, url: kTestURI}, async (browser) => { | ||
await ContentTask.spawn(browser, {}, async function() { | ||
let outerPrincipal = content.document.nodePrincipal; | ||
ok(outerPrincipal.isSystemPrincipal, "Sanity: Using SystemPrincipal for test file on chrome://"); | ||
|
||
const iframeWin = content.document.getElementById("testframe").contentWindow; | ||
const iframeChannel = iframeWin.docShell.currentDocumentChannel; | ||
ok(iframeChannel.loadInfo.loadingPrincipal.isSystemPrincipal, 'LoadingPrincipal for iframe is SystemPrincipal'); | ||
}); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
dom/security/test/general/file_assert_systemprincipal_documents.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Bug 1513445: Assert not loading web documents into system land</title> | ||
</head> | ||
<body> | ||
<h1>This page loads documents from the SystemPrincipal (which causes the assertion)</h1> | ||
<iframe type="chrome" id="testframe" src="http://example.com/browser/dom/security/test/general/file_assert_systemprincipal_documents_iframe.html"></iframe> | ||
</body> | ||
</html> | ||
|
9 changes: 9 additions & 0 deletions
9
dom/security/test/general/file_assert_systemprincipal_documents_iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Bug 1513445: Assert not loading web documents into system land</title> | ||
</head> | ||
<body> | ||
<h1>This is the iframe</h1> | ||
</body> | ||
</html> |