docshell/test/test_forceinheritprincipal_overrule_owner.html
author shindli <shindli@mozilla.com>
Tue, 02 Oct 2018 00:04:57 +0300
changeset 494791 88315c6735dec7bbb70c5933e2b11e7343114f73
parent 494783 docshell/test/mochitest/test_forceinheritprincipal_overrule_owner.html@d0d9cd85f3dba3ba7bd08dc54e2279fae2316570
child 494882 58adc643dcdc20eccb4d30bc454b50420e96c020
permissions -rw-r--r--
Backed out 3 changesets (bug 1417383) for bustages in /builds/worker/workspace/build/src/docshell/test/mochitest/moz.build CLOSED TREE Backed out changeset 44d07650e6fe (bug 1417383) Backed out changeset d0d9cd85f3db (bug 1417383) Backed out changeset ddaef0a8de5f (bug 1417383)

<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>

<script type="text/javascript">

var channel = SpecialPowers.wrap(window).docShell.currentDocumentChannel;
var loadInfo = channel.loadInfo;

// 1) perform some sanity checks
var triggeringPrincipal = channel.loadInfo.triggeringPrincipal.URI.asciiSpec;
var loadingPrincipal = channel.loadInfo.loadingPrincipal.URI.asciiSpec;
var principalToInherit = channel.loadInfo.principalToInherit.URI.asciiSpec;

ok(triggeringPrincipal.startsWith("http://mochi.test:8888/"),
   "initial triggeringPrincipal correct");
ok(loadingPrincipal.startsWith("http://mochi.test:8888/"),
   "initial loadingPrincipal correct");
ok(principalToInherit.startsWith("http://mochi.test:8888/"),
   "initial principalToInherit correct");

// reset principals on the loadinfo
loadInfo.resetPrincipalToInheritToNullPrincipal();

// 2) verify loadInfo contains the correct principals
triggeringPrincipal = channel.loadInfo.triggeringPrincipal.URI.asciiSpec;
loadingPrincipal = channel.loadInfo.loadingPrincipal.URI.asciiSpec;
principalToInherit = channel.loadInfo.principalToInherit;

ok(triggeringPrincipal.startsWith("http://mochi.test:8888/"),
   "triggeringPrincipal after resetting correct");
ok(loadingPrincipal.startsWith("http://mochi.test:8888/"),
   "loadingPrincipal after resetting correct");
ok(principalToInherit.isNullPrincipal,
   "principalToInherit after resetting correct");

// 3) verify that getChannelResultPrincipal returns right principal
var resultPrincipal = SpecialPowers.Services.scriptSecurityManager
                                   .getChannelResultPrincipal(channel);

ok(resultPrincipal.isNullPrincipal,
   "resultPrincipal after resetting correct");

</script>
</pre>
</body>
</html>