Skip to content

Commit

Permalink
Bug 1513445: add tests r=ckerschb
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D26681

--HG--
extra : moz-landing-system : lando
  • Loading branch information
mozfreddyb committed Apr 10, 2019
1 parent e3dae73 commit 23a6ba3
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dom/security/test/general/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ support-files =
[browser_test_FTP_console_warning.js]
support-files =
file_FTP_console_warning.html
[browser_test_assert_systemprincipal_documents.js]
skip-if = !debug && !fuzzing
support-files =
file_assert_systemprincipal_documents.html
file_assert_systemprincipal_documents_iframe.html
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');
});
});
});
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>

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>

0 comments on commit 23a6ba3

Please sign in to comment.