4 https://bugzilla.mozilla.org/show_bug.cgi?id=732413
7 <title>Test for Bug
732413</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=732413">Mozilla Bug
732413</a>
14 <div id=
"content" style=
"display: none">
18 <script type=
"application/javascript">
20 /** Test for Bug
732413
21 Passing DISALLOW_INHERIT_PRINCIPAL flag should be effective even if
22 aPrincipal is the system principal.
25 const nsIScriptSecurityManager = SpecialPowers.Ci.nsIScriptSecurityManager;
26 var secMan = SpecialPowers.Cc[
"@mozilla.org/scriptsecuritymanager;1"]
27 .getService(nsIScriptSecurityManager);
28 var sysPrincipal = secMan.getSystemPrincipal();
29 isnot(sysPrincipal, undefined,
"Should have a principal");
30 isnot(sysPrincipal, null,
"Should have a non-null principal");
31 is(sysPrincipal.isSystemPrincipal, true,
32 "Should have system principal here");
35 var inheritingURI = SpecialPowers.Services.io.newURI(
"javascript:1+1");
37 // First try a normal call to checkLoadURIWithPrincipal
39 secMan.checkLoadURIWithPrincipal(sysPrincipal, inheritingURI,
40 nsIScriptSecurityManager.STANDARD);
41 ok(true,
"checkLoadURI allowed the load");
43 ok(false,
"checkLoadURI failed unexpectedly: " + e);
46 // Now call checkLoadURIWithPrincipal with DISALLOW_INHERIT_PRINCIPAL
48 secMan.checkLoadURIWithPrincipal(sysPrincipal, inheritingURI,
49 nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
50 ok(false,
"checkLoadURI allowed the load unexpectedly");
52 ok(true,
"checkLoadURI prevented load of principal-inheriting URI");