docshell/test/mochitest/test_forceinheritprincipal_overrule_owner.html
author Byron Campen [:bwc] <docfaraday@gmail.com>
Mon, 29 Apr 2019 15:51:30 +0000
changeset 471964 f8a6a019f873aaebc47740ea1423c0985aaedf69
parent 469640 c9c0c6f2eed54a187e124942e53c3660b4cf17d8
permissions -rw-r--r--
Bug 1531803 - Part 3: Only set track id on JsepTrack if we're configured to emit track ids in SDP, and simplify some code. r=mjf Differential Revision: https://phabricator.services.mozilla.com/D25796

<!DOCTYPE html>
<html>
<head>
  <script 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>