test_bug470804.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=470804
  5. -->
  6. <head>
  7. <title>Test for Bug 470804</title>
  8. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  10. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=470804">Mozilla Bug 470804</a>
  13. <p id="display"></p>
  14. <div id="content" style="display: none">
  15. </div>
  16. <pre id="test">
  17. <script type="application/javascript">
  18. /** Test for Bug 470804
  19. Passing a null targetURL to checkLoadURIWithPrincipal shouldn't crash
  20. **/
  21. const nsIScriptSecurityManager = SpecialPowers.Ci.nsIScriptSecurityManager;
  22. var secMan = SpecialPowers.Services.scriptSecurityManager;
  23. var principal = SpecialPowers.wrap(document).nodePrincipal;
  24. isnot(principal, undefined, "Should have a principal");
  25. isnot(principal, null, "Should have a non-null principal");
  26. is(secMan.isSystemPrincipal(principal), false,
  27. "Shouldn't have system principal here");
  28. try {
  29. secMan.checkLoadURIWithPrincipal(principal, null,
  30. nsIScriptSecurityManager.STANDARD);
  31. } catch (e) {
  32. // throwing is fine, it's just crashing that's bad
  33. }
  34. ok(true, "Survival", "We should get here without crashing");
  35. </script>
  36. </pre>
  37. </body>
  38. </html>