Crashtest for Bug 470804 crash [@ NS_GetInnermostURI - nsScriptSecurityManager::CheckLoadURIWithPrincipal], r=bz
authorPhil Ringnalda <philringnalda@gmail.com>
Thu, 01 Jan 2009 15:45:23 -0800
changeset 23240 59c1cdb2cf7e802acd2c4ee7eacab82a16d990c8
parent 23239 dce664edeace818dbf47c8a9b69a1fcd43217bc0
child 23241 eb870a41e5cb91328694e18285202fc1b6c7d028
push id4407
push userphilringnalda@gmail.com
push dateThu, 01 Jan 2009 23:46:12 +0000
treeherdermozilla-central@eb870a41e5cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs470804
milestone1.9.2a1pre
Crashtest for Bug 470804 crash [@ NS_GetInnermostURI - nsScriptSecurityManager::CheckLoadURIWithPrincipal], r=bz
caps/tests/mochitest/Makefile.in
caps/tests/mochitest/test_bug470804.html
--- a/caps/tests/mochitest/Makefile.in
+++ b/caps/tests/mochitest/Makefile.in
@@ -43,12 +43,13 @@ VPATH		= @srcdir@
 relativesrcdir  = caps/tests/mochitest
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = 	test_bug423375.html \
                 test_bug246699.html \
                 test_bug292789.html \
+		test_bug470804.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/caps/tests/mochitest/test_bug470804.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=470804
+-->
+<head>
+  <title>Test for Bug 470804</title>
+  <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=470804">Mozilla Bug 470804</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 470804
+    Passing a null targetURL to checkLoadURIWithPrincipal shouldn't crash
+ **/
+
+netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+const nsIScriptSecurityManager = Components.interfaces.nsIScriptSecurityManager;
+var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
+                       .getService(nsIScriptSecurityManager);
+var principal = document.nodePrincipal;
+is(secMan.isSystemPrincipal(principal), false,
+   "Shouldn't have system principal here");
+try {
+  secMan.checkLoadURIWithPrincipal(principal, null,
+                                   nsIScriptSecurityManager.STANDARD);
+} catch (e) {
+  // throwing is fine, it's just crashing that's bad
+}
+ok(true, "Survival", "We should get here without crashing");
+</script>
+</pre>
+</body>
+</html>