Bug 660233 part 1. Fix tests that assume UniversalXPConnect in otherwise-untrusted pages will get one nodePrincipal, documentURIObject, baseURIObject properties. r=mrbkap
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 23 Sep 2011 01:03:50 -0400
changeset 77380 d9cd2e3f0a9a69798cea56698e97ed2159f19595
parent 77379 4309aaa4b59b4f0d3f4d446d7739f76b10e4780a
child 77381 cd43848a03265c2f54ef610d4ac4280e7726e4c6
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersmrbkap
bugs660233
milestone9.0a1
Bug 660233 part 1. Fix tests that assume UniversalXPConnect in otherwise-untrusted pages will get one nodePrincipal, documentURIObject, baseURIObject properties. r=mrbkap
browser/base/content/test/test_offlineNotification.html
caps/tests/mochitest/test_bug470804.html
content/base/test/test_bug353334.html
dom/indexedDB/test/error_events_abort_transactions_iframe.html
dom/indexedDB/test/event_propagation_iframe.html
dom/indexedDB/test/exceptions_in_success_events_iframe.html
dom/indexedDB/test/helpers.js
dom/indexedDB/test/test_third_party.html
dom/tests/browser/Makefile.in
dom/tests/browser/browser_bug396843.js
dom/tests/mochitest/bugs/test_bug396843.html
testing/mochitest/specialpowers/content/specialpowers.js
toolkit/components/viewconfig/content/config.js
toolkit/mozapps/extensions/content/newaddon.js
--- a/browser/base/content/test/test_offlineNotification.html
+++ b/browser/base/content/test/test_offlineNotification.html
@@ -33,18 +33,18 @@ window.addEventListener("message", funct
     is(event.data, "success", "Child was successfully cached.");
 
     if (++numFinished == 3) {
       // Clean up after ourself
       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
       var pm = Components.classes["@mozilla.org/permissionmanager;1"].
                getService(Components.interfaces.nsIPermissionManager);
 
-      pm.remove(frames.testFrame.document.documentURIObject.host, "offline-app");
-      pm.remove(frames.testFrame3.document.documentURIObject.host, "offline-app");
+      pm.remove(frames.testFrame.location.hostname, "offline-app");
+      pm.remove(frames.testFrame3.location.hostname, "offline-app");
 
       SimpleTest.finish();
     }
   }, false);
 
 var count = 0;
 var expectedEvent = "";
 function eventHandler(evt) {
--- a/caps/tests/mochitest/test_bug470804.html
+++ b/caps/tests/mochitest/test_bug470804.html
@@ -20,17 +20,19 @@ https://bugzilla.mozilla.org/show_bug.cg
 /** 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;
+var principal = SpecialPowers.getNodePrincipal(document);
+isnot(principal, undefined, "Should have a principal");
+isnot(principal, null, "Should have a non-null principal");
 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
 }
--- a/content/base/test/test_bug353334.html
+++ b/content/base/test/test_bug353334.html
@@ -27,28 +27,30 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 /** Test for Bug 353334 **/
 SimpleTest.waitForExplicitFinish();
 
 function doPrincipalTest(id) {
   var doc = $(id).contentDocument;
 
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  is(doc.nodePrincipal, document.nodePrincipal,
+  isnot(SpecialPowers.getNodePrincipal(doc), undefined, "Should have a principal");
+  isnot(SpecialPowers.getNodePrincipal(doc), null, "Should have a non-null principal");
+  is(SpecialPowers.getNodePrincipal(doc),
+     SpecialPowers.getNodePrincipal(document),
      "Wrong principal for document in node with id='" + id + "'");
 }
 
 function doContentTest(id) {
   is($(id).contentDocument.documentElement.textContent, "PASS",
      "Script executed in wrong context in node with id='" + id + "'");
 }
 
 function checkPrincipal() {
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  is(document.nodePrincipal instanceof Components.interfaces.nsIPrincipal,
+  is(SpecialPowers.getNodePrincipal(document) instanceof Components.interfaces.nsIPrincipal,
      true,
      "Should be a principal");
 }
 
 addLoadEvent(function() {
   checkPrincipal();
 
   for each (var i in [ "one", "two", "three", "four" ]) {
--- a/dom/indexedDB/test/error_events_abort_transactions_iframe.html
+++ b/dom/indexedDB/test/error_events_abort_transactions_iframe.html
@@ -45,17 +45,17 @@
     }
 
     window.onerror = function(event) {
     };
 
     function testSteps() {
       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
-      let uri = window.document.documentURIObject;
+      let uri = SpecialPowers.getDocumentURIObject(window.document);
       Components.classes["@mozilla.org/permissionmanager;1"]
                 .getService(Components.interfaces.nsIPermissionManager)
                 .add(uri, "indexedDB",
                      Components.interfaces.nsIPermissionManager.ALLOW_ACTION);
 
       let request = mozIndexedDB.open(window.location.pathname);
       request.onerror = errorHandler;
       request.onsuccess = grabEventAndContinueHandler;
--- a/dom/indexedDB/test/event_propagation_iframe.html
+++ b/dom/indexedDB/test/event_propagation_iframe.html
@@ -84,17 +84,17 @@
           finishTest();
         }
       }
     }
 
     function testSteps() {
       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
-      let uri = window.document.documentURIObject;
+      let uri = SpecialPowers.getDocumentURIObject(window.document);
       Components.classes["@mozilla.org/permissionmanager;1"]
                 .getService(Components.interfaces.nsIPermissionManager)
                 .add(uri, "indexedDB",
                      Components.interfaces.nsIPermissionManager.ALLOW_ACTION);
 
       let request = mozIndexedDB.open(window.location.pathname);
       request.onerror = errorHandler;
       request.onsuccess = grabEventAndContinueHandler;
--- a/dom/indexedDB/test/exceptions_in_success_events_iframe.html
+++ b/dom/indexedDB/test/exceptions_in_success_events_iframe.html
@@ -48,17 +48,17 @@
 
     window.onerror = function(event) {
       event.preventDefault();
     };
 
     function testSteps() {
       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
-      let uri = window.document.documentURIObject;
+      let uri = SpecialPowers.getDocumentURIObject(window.document);
       Components.classes["@mozilla.org/permissionmanager;1"]
                 .getService(Components.interfaces.nsIPermissionManager)
                 .add(uri, "indexedDB",
                      Components.interfaces.nsIPermissionManager.ALLOW_ACTION);
 
       let request = mozIndexedDB.open(window.location.pathname);
       request.onerror = errorHandler;
       request.onsuccess = grabEventAndContinueHandler;
--- a/dom/indexedDB/test/helpers.js
+++ b/dom/indexedDB/test/helpers.js
@@ -83,17 +83,17 @@ function addPermission(permission, url)
 
   let uri;
   if (url) {
     uri = Components.classes["@mozilla.org/network/io-service;1"]
                     .getService(Components.interfaces.nsIIOService)
                     .newURI(url, null, null);
   }
   else {
-    uri = window.document.documentURIObject;
+    uri = SpecialPowers.getDocumentURIObject(window.document);
   }
 
   Components.classes["@mozilla.org/permissionmanager;1"]
             .getService(Components.interfaces.nsIPermissionManager)
             .add(uri, permission,
                  Components.interfaces.nsIPermissionManager.ALLOW_ACTION);
 }
 
@@ -103,17 +103,17 @@ function removePermission(permission, ur
 
   let uri;
   if (url) {
     uri = Components.classes["@mozilla.org/network/io-service;1"]
                     .getService(Components.interfaces.nsIIOService)
                     .newURI(url, null, null);
   }
   else {
-    uri = window.document.documentURIObject;
+    uri = SpecialPowers.getDocumentURIObject(window.document);
   }
 
   Components.classes["@mozilla.org/permissionmanager;1"]
             .getService(Components.interfaces.nsIPermissionManager)
             .remove(uri.host, permission);
 }
 
 function setQuota(quota)
--- a/dom/indexedDB/test/test_third_party.html
+++ b/dom/indexedDB/test/test_third_party.html
@@ -61,17 +61,18 @@
     }
 
     function runTest() {
       SimpleTest.waitForExplicitFinish();
 
       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
       Components.classes["@mozilla.org/permissionmanager;1"]
                 .getService(Components.interfaces.nsIPermissionManager)
-                .add(window.document.documentURIObject, "indexedDB",
+                .add(SpecialPowers.getDocumentURIObject(window.document),
+                     "indexedDB",
                      Components.interfaces.nsIPermissionManager.ALLOW_ACTION);
 
       window.addEventListener("message", messageListener, false);
       setiframe();
     }
   </script>
 
 </head>
--- a/dom/tests/browser/Makefile.in
+++ b/dom/tests/browser/Makefile.in
@@ -49,12 +49,13 @@ include $(topsrcdir)/config/rules.mk
 		browser_focus_steal_from_chrome_during_mousedown.js \
 		browser_autofocus_background.js \
 		browser_ConsoleAPITests.js \
 		test-console-api.html \
 		browser_ConsoleStorageAPITests.js \
 		browser_ConsoleStoragePBTest.js \
 		browser_autofocus_preference.js \
 		browser_popup_blocker_save_open_panel.js \
+		browser_bug396843.js \
 		$(NULL)
 
 libs::	$(_BROWSER_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
copy from dom/tests/mochitest/bugs/test_bug396843.html
copy to dom/tests/browser/browser_bug396843.js
--- a/dom/tests/mochitest/bugs/test_bug396843.html
+++ b/dom/tests/browser/browser_bug396843.js
@@ -1,288 +1,294 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=396843
--->
-<head>
-  <title>Test for Bug 396843</title>
-  <script type="text/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=396843">Mozilla Bug 396843</a>
-<p id="display">
-  <iframe src="http://example.org:80/" id="t"></iframe>
-</p>
-<div id="content" style="display: none">
-  
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
+function test() {
+    /** Test for Bug 396843 **/
+    waitForExplicitFinish();
 
-/** Test for Bug 396843 **/
-SimpleTest.waitForExplicitFinish();
+    function testInDocument(doc, documentID) {
+        
+        var allNodes = [];
+        var XMLNodes = [];
 
-var allNodes = [];
-var XMLNodes = [];
-
-// HTML
-function HTML_TAG(name) {
-  allNodes.push(document.createElement(name));
-}
+        // HTML
+        function HTML_TAG(name) {
+            allNodes.push(doc.createElement(name));
+        }
 
-/* List copy/pasted from nsHTMLTagList.h */
-HTML_TAG("a", "Anchor")
-HTML_TAG("abbr", "Span")
-HTML_TAG("acronym", "Span")
-HTML_TAG("address", "Span")
-HTML_TAG("applet", "SharedObject")
-HTML_TAG("area", "Area")
-HTML_TAG("b", "Span")
-HTML_TAG("base", "Shared")
-HTML_TAG("basefont", "Span")
-HTML_TAG("bdo", "Span")
-HTML_TAG("bgsound", "Span")
-HTML_TAG("big", "Span")
-HTML_TAG("blink", "Span")
-HTML_TAG("blockquote", "Shared")
-HTML_TAG("body", "Body")
-HTML_TAG("br", "BR")
-HTML_TAG("button", "Button")
-HTML_TAG("canvas", "Canvas")
-HTML_TAG("caption", "TableCaption")
-HTML_TAG("center", "Span")
-HTML_TAG("cite", "Span")
-HTML_TAG("code", "Span")
-HTML_TAG("col", "TableCol")
-HTML_TAG("colgroup", "TableCol")
-HTML_TAG("dd", "Span")
-HTML_TAG("del", "Mod")
-HTML_TAG("dfn", "Span")
-HTML_TAG("dir", "Shared")
-HTML_TAG("div", "Div")
-HTML_TAG("dl", "SharedList")
-HTML_TAG("dt", "Span")
-HTML_TAG("em", "Span")
-HTML_TAG("embed", "SharedObject")
-HTML_TAG("fieldset", "FieldSet")
-HTML_TAG("font", "Font")
-HTML_TAG("form", "Form")
-HTML_TAG("frame", "Frame")
-HTML_TAG("frameset", "FrameSet")
-HTML_TAG("h1", "Heading")
-HTML_TAG("h2", "Heading")
-HTML_TAG("h3", "Heading")
-HTML_TAG("h4", "Heading")
-HTML_TAG("h5", "Heading")
-HTML_TAG("h6", "Heading")
-HTML_TAG("head", "Head")
-HTML_TAG("hr", "HR")
-HTML_TAG("html", "Html")
-HTML_TAG("i", "Span")
-HTML_TAG("iframe", "IFrame")
-HTML_TAG("image", "Span")
-HTML_TAG("img", "Image")
-HTML_TAG("input", "Input")
-HTML_TAG("ins", "Mod")
-HTML_TAG("isindex", "Shared")
-HTML_TAG("kbd", "Span")
-HTML_TAG("keygen", "Span")
-HTML_TAG("label", "Label")
-HTML_TAG("legend", "Legend")
-HTML_TAG("li", "LI")
-HTML_TAG("link", "Link")
-HTML_TAG("listing", "Span")
-HTML_TAG("map", "Map")
-HTML_TAG("marquee", "Div")
-HTML_TAG("menu", "Shared")
-HTML_TAG("meta", "Meta")
-HTML_TAG("multicol", "Span")
-HTML_TAG("nobr", "Span")
-HTML_TAG("noembed", "Div")
-HTML_TAG("noframes", "Div")
-HTML_TAG("noscript", "Div")
-HTML_TAG("object", "Object")
-HTML_TAG("ol", "SharedList")
-HTML_TAG("optgroup", "OptGroup")
-HTML_TAG("option", "Option")
-HTML_TAG("p", "Paragraph")
-HTML_TAG("param", "Shared")
-HTML_TAG("plaintext", "Span")
-HTML_TAG("pre", "Pre")
-HTML_TAG("q", "Shared")
-HTML_TAG("s", "Span")
-HTML_TAG("samp", "Span")
-HTML_TAG("script", "Script")
-HTML_TAG("select", "Select")
-HTML_TAG("small", "Span")
-HTML_TAG("spacer", "Shared")
-HTML_TAG("span", "Span")
-HTML_TAG("strike", "Span")
-HTML_TAG("strong", "Span")
-HTML_TAG("style", "Style")
-HTML_TAG("sub", "Span")
-HTML_TAG("sup", "Span")
-HTML_TAG("table", "Table")
-HTML_TAG("tbody", "TableSection")
-HTML_TAG("td", "TableCell")
-HTML_TAG("textarea", "TextArea")
-HTML_TAG("tfoot", "TableSection")
-HTML_TAG("th", "TableCell")
-HTML_TAG("thead", "TableSection")
-HTML_TAG("title", "Title")
-HTML_TAG("tr", "TableRow")
-HTML_TAG("tt", "Span")
-HTML_TAG("u", "Span")
-HTML_TAG("ul", "SharedList")
-HTML_TAG("var", "Span")
-HTML_TAG("wbr", "Shared")
-HTML_TAG("xmp", "Span")
+        /* List copy/pasted from nsHTMLTagList.h */
+        HTML_TAG("a", "Anchor")
+        HTML_TAG("abbr", "Span")
+        HTML_TAG("acronym", "Span")
+        HTML_TAG("address", "Span")
+        HTML_TAG("applet", "SharedObject")
+        HTML_TAG("area", "Area")
+        HTML_TAG("b", "Span")
+        HTML_TAG("base", "Shared")
+        HTML_TAG("basefont", "Span")
+        HTML_TAG("bdo", "Span")
+        HTML_TAG("bgsound", "Span")
+        HTML_TAG("big", "Span")
+        HTML_TAG("blink", "Span")
+        HTML_TAG("blockquote", "Shared")
+        HTML_TAG("body", "Body")
+        HTML_TAG("br", "BR")
+        HTML_TAG("button", "Button")
+        HTML_TAG("canvas", "Canvas")
+        HTML_TAG("caption", "TableCaption")
+        HTML_TAG("center", "Span")
+        HTML_TAG("cite", "Span")
+        HTML_TAG("code", "Span")
+        HTML_TAG("col", "TableCol")
+        HTML_TAG("colgroup", "TableCol")
+        HTML_TAG("dd", "Span")
+        HTML_TAG("del", "Mod")
+        HTML_TAG("dfn", "Span")
+        HTML_TAG("dir", "Shared")
+        HTML_TAG("div", "Div")
+        HTML_TAG("dl", "SharedList")
+        HTML_TAG("dt", "Span")
+        HTML_TAG("em", "Span")
+        HTML_TAG("embed", "SharedObject")
+        HTML_TAG("fieldset", "FieldSet")
+        HTML_TAG("font", "Font")
+        HTML_TAG("form", "Form")
+        HTML_TAG("frame", "Frame")
+        HTML_TAG("frameset", "FrameSet")
+        HTML_TAG("h1", "Heading")
+        HTML_TAG("h2", "Heading")
+        HTML_TAG("h3", "Heading")
+        HTML_TAG("h4", "Heading")
+        HTML_TAG("h5", "Heading")
+        HTML_TAG("h6", "Heading")
+        HTML_TAG("head", "Head")
+        HTML_TAG("hr", "HR")
+        HTML_TAG("html", "Html")
+        HTML_TAG("i", "Span")
+        HTML_TAG("iframe", "IFrame")
+        HTML_TAG("image", "Span")
+        HTML_TAG("img", "Image")
+        HTML_TAG("input", "Input")
+        HTML_TAG("ins", "Mod")
+        HTML_TAG("isindex", "Shared")
+        HTML_TAG("kbd", "Span")
+        HTML_TAG("keygen", "Span")
+        HTML_TAG("label", "Label")
+        HTML_TAG("legend", "Legend")
+        HTML_TAG("li", "LI")
+        HTML_TAG("link", "Link")
+        HTML_TAG("listing", "Span")
+        HTML_TAG("map", "Map")
+        HTML_TAG("marquee", "Div")
+        HTML_TAG("menu", "Shared")
+        HTML_TAG("meta", "Meta")
+        HTML_TAG("multicol", "Span")
+        HTML_TAG("nobr", "Span")
+        HTML_TAG("noembed", "Div")
+        HTML_TAG("noframes", "Div")
+        HTML_TAG("noscript", "Div")
+        HTML_TAG("object", "Object")
+        HTML_TAG("ol", "SharedList")
+        HTML_TAG("optgroup", "OptGroup")
+        HTML_TAG("option", "Option")
+        HTML_TAG("p", "Paragraph")
+        HTML_TAG("param", "Shared")
+        HTML_TAG("plaintext", "Span")
+        HTML_TAG("pre", "Pre")
+        HTML_TAG("q", "Shared")
+        HTML_TAG("s", "Span")
+        HTML_TAG("samp", "Span")
+        HTML_TAG("script", "Script")
+        HTML_TAG("select", "Select")
+        HTML_TAG("small", "Span")
+        HTML_TAG("spacer", "Shared")
+        HTML_TAG("span", "Span")
+        HTML_TAG("strike", "Span")
+        HTML_TAG("strong", "Span")
+        HTML_TAG("style", "Style")
+        HTML_TAG("sub", "Span")
+        HTML_TAG("sup", "Span")
+        HTML_TAG("table", "Table")
+        HTML_TAG("tbody", "TableSection")
+        HTML_TAG("td", "TableCell")
+        HTML_TAG("textarea", "TextArea")
+        HTML_TAG("tfoot", "TableSection")
+        HTML_TAG("th", "TableCell")
+        HTML_TAG("thead", "TableSection")
+        HTML_TAG("title", "Title")
+        HTML_TAG("tr", "TableRow")
+        HTML_TAG("tt", "Span")
+        HTML_TAG("u", "Span")
+        HTML_TAG("ul", "SharedList")
+        HTML_TAG("var", "Span")
+        HTML_TAG("wbr", "Shared")
+        HTML_TAG("xmp", "Span")
 
-function SVG_TAG(name) {
-  allNodes.push(document.createElementNS("http://www.w3.org/2000/svg", name));
-}
+        function SVG_TAG(name) {
+            allNodes.push(doc.createElementNS("http://www.w3.org/2000/svg", name));
+        }
 
-// List sorta stolen from SVG element factory.
-SVG_TAG("a")
-SVG_TAG("polyline")
-SVG_TAG("polygon")
-SVG_TAG("circle")
-SVG_TAG("ellipse")
-SVG_TAG("line")
-SVG_TAG("rect")
-SVG_TAG("svg")
-SVG_TAG("g")
-SVG_TAG("foreignObject")
-SVG_TAG("path")
-SVG_TAG("text")
-SVG_TAG("tspan")
-SVG_TAG("image")
-SVG_TAG("style")
-SVG_TAG("linearGradient")
-SVG_TAG("metadata")
-SVG_TAG("radialGradient")
-SVG_TAG("stop")
-SVG_TAG("defs")
-SVG_TAG("desc")
-SVG_TAG("script")
-SVG_TAG("use")
-SVG_TAG("symbol")
-SVG_TAG("marker")
-SVG_TAG("title")
-SVG_TAG("clipPath")
-SVG_TAG("textPath")
-SVG_TAG("filter")
-SVG_TAG("feBlend")
-SVG_TAG("feColorMatrix")
-SVG_TAG("feComponentTransfer")
-SVG_TAG("feComposite")
-SVG_TAG("feFuncR")
-SVG_TAG("feFuncG")
-SVG_TAG("feFuncB")
-SVG_TAG("feFuncA")
-SVG_TAG("feGaussianBlur")
-SVG_TAG("feMerge")
-SVG_TAG("feMergeNode")
-SVG_TAG("feMorphology")
-SVG_TAG("feOffset")
-SVG_TAG("feFlood")
-SVG_TAG("feTile")
-SVG_TAG("feTurbulence")
-SVG_TAG("feConvolveMatrix")
-SVG_TAG("feDistantLight")
-SVG_TAG("fePointLight")
-SVG_TAG("feSpotLight")
-SVG_TAG("feDiffuseLighting")
-SVG_TAG("feSpecularLighting")
-SVG_TAG("feDisplacementMap")
-SVG_TAG("feImage")
-SVG_TAG("pattern")
-SVG_TAG("mask")
-SVG_TAG("svgSwitch")
+        // List sorta stolen from SVG element factory.
+        SVG_TAG("a")
+        SVG_TAG("polyline")
+        SVG_TAG("polygon")
+        SVG_TAG("circle")
+        SVG_TAG("ellipse")
+        SVG_TAG("line")
+        SVG_TAG("rect")
+        SVG_TAG("svg")
+        SVG_TAG("g")
+        SVG_TAG("foreignObject")
+        SVG_TAG("path")
+        SVG_TAG("text")
+        SVG_TAG("tspan")
+        SVG_TAG("image")
+        SVG_TAG("style")
+        SVG_TAG("linearGradient")
+        SVG_TAG("metadata")
+        SVG_TAG("radialGradient")
+        SVG_TAG("stop")
+        SVG_TAG("defs")
+        SVG_TAG("desc")
+        SVG_TAG("script")
+        SVG_TAG("use")
+        SVG_TAG("symbol")
+        SVG_TAG("marker")
+        SVG_TAG("title")
+        SVG_TAG("clipPath")
+        SVG_TAG("textPath")
+        SVG_TAG("filter")
+        SVG_TAG("feBlend")
+        SVG_TAG("feColorMatrix")
+        SVG_TAG("feComponentTransfer")
+        SVG_TAG("feComposite")
+        SVG_TAG("feFuncR")
+        SVG_TAG("feFuncG")
+        SVG_TAG("feFuncB")
+        SVG_TAG("feFuncA")
+        SVG_TAG("feGaussianBlur")
+        SVG_TAG("feMerge")
+        SVG_TAG("feMergeNode")
+        SVG_TAG("feMorphology")
+        SVG_TAG("feOffset")
+        SVG_TAG("feFlood")
+        SVG_TAG("feTile")
+        SVG_TAG("feTurbulence")
+        SVG_TAG("feConvolveMatrix")
+        SVG_TAG("feDistantLight")
+        SVG_TAG("fePointLight")
+        SVG_TAG("feSpotLight")
+        SVG_TAG("feDiffuseLighting")
+        SVG_TAG("feSpecularLighting")
+        SVG_TAG("feDisplacementMap")
+        SVG_TAG("feImage")
+        SVG_TAG("pattern")
+        SVG_TAG("mask")
+        SVG_TAG("svgSwitch")
 
-// Toss in some other namespaced stuff too, for good measure
-allNodes.push(document.createElementNS(
-               "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
-               "window"));
-allNodes.push(document.createElementNS("http://www.w3.org/1998/Math/MathML",
-                                       "math"));
-allNodes.push(document.createElementNS("http://www.w3.org/2001/xml-events",
-                                       "testname"));
-allNodes.push(document.createElementNS("bogus.namespace", "testname"));
+        // Toss in some other namespaced stuff too, for good measure
+        // XUL stuff might not be creatable in content documents
+        try {
+            allNodes.push(doc.createElementNS(
+                "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
+                "window"));
+        } catch (e) {}
+        allNodes.push(doc.createElementNS("http://www.w3.org/1998/Math/MathML",
+                                          "math"));
+        allNodes.push(doc.createElementNS("http://www.w3.org/2001/xml-events",
+                                          "testname"));
+        allNodes.push(doc.createElementNS("bogus.namespace", "testname"));
 
-var XMLDoc = document.implementation.createDocument("", "", null);
+        var XMLDoc = doc.implementation.createDocument("", "", null);
 
-// And non-elements
-allNodes.push(document.createTextNode("some text"));
-allNodes.push(document.createComment("some text"));
-allNodes.push(document.createDocumentFragment());
-XMLNodes.push(XMLDoc.createCDATASection("some text"));
-XMLNodes.push(XMLDoc.createProcessingInstruction("PI", "data"));
-               
-function runTest() {
-  ok(document.nodePrincipal === undefined, "Must not have document principal");
-  ok(document.baseURIObject === undefined, "Must not have document base URI");
-  ok(document.documentURIObject === undefined, "Must have document URI");
+        // And non-elements
+        allNodes.push(doc.createTextNode("some text"));
+        allNodes.push(doc.createComment("some text"));
+        allNodes.push(doc.createDocumentFragment());
+        XMLNodes.push(XMLDoc.createCDATASection("some text"));
+        XMLNodes.push(XMLDoc.createProcessingInstruction("PI", "data"));
+        
+        function runTestUnwrapped() {
+            if (!("wrappedJSObject" in doc)) {
+                return;
+            }
+            ok(doc.wrappedJSObject.nodePrincipal === undefined,
+               "Must not have document principal for " + documentID);
+            ok(doc.wrappedJSObject.baseURIObject === undefined,
+               "Must not have document base URI for " + documentID);
+            ok(doc.wrappedJSObject.documentURIObject === undefined,
+               "Must not have document URI for " + documentID);
 
-  for (var i = 0; i < allNodes.length; ++i) {
-    ok(allNodes[i].nodePrincipal === undefined,
-       "Unexpected principal appears for " + allNodes[i].nodeName);
-    ok(allNodes[i].baseURIObject === undefined,
-       "Unexpected base URI appears for " + allNodes[i].nodeName);
-  }
-}
-
-function runTest2() {
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  isnot(document.nodePrincipal, null, "Must have document principal");
-  is(document.nodePrincipal instanceof Components.interfaces.nsIPrincipal,
-     true, "document principal must be a principal");
-  isnot(document.baseURIObject, null, "Must have document base URI");
-  is(document.baseURIObject instanceof Components.interfaces.nsIURI,
-     true, "document base URI must be a URI");
-  isnot(document.documentURIObject, null, "Must have document URI");
-  is(document.documentURIObject instanceof Components.interfaces.nsIURI,
-     true, "document URI must be a URI");
-  is(document.documentURIObject.spec, document.documentURI,
-     "document URI must be the right URI");
+            for (var i = 0; i < allNodes.length; ++i) {
+                ok(allNodes[i].wrappedJSObject.nodePrincipal === undefined,
+                   "Unexpected principal appears for " + allNodes[i].nodeName +
+                   " in " + documentID);
+                ok(allNodes[i].wrappedJSObject.baseURIObject === undefined,
+                   "Unexpected base URI appears for " + allNodes[i].nodeName +
+                   " in " + documentID);
+            }
+        }
+        
+        function runTestProps() {
+            isnot(doc.nodePrincipal, null,
+                  "Must have document principal in " + documentID);
+            is(doc.nodePrincipal instanceof Components.interfaces.nsIPrincipal,
+               true, "document principal must be a principal in " + documentID);
+            isnot(doc.baseURIObject, null,
+                  "Must have document base URI in" + documentID);
+            is(doc.baseURIObject instanceof Components.interfaces.nsIURI,
+               true, "document base URI must be a URI in " + documentID);
+            isnot(doc.documentURIObject, null,
+                  "Must have document URI " + documentID);
+            is(doc.documentURIObject instanceof Components.interfaces.nsIURI,
+               true, "document URI must be a URI in " + documentID);
+            is(doc.documentURIObject.spec, doc.documentURI,
+               "document URI must be the right URI in " + documentID);
      
-  for (var i = 0; i < allNodes.length; ++i) {
-    is(allNodes[i].nodePrincipal, document.nodePrincipal,
-       "Unexpected principal for " + allNodes[i].nodeName);
-    is(allNodes[i].baseURIObject, document.baseURIObject,
-       "Unexpected base URI for " + allNodes[i].nodeName);
-  }
+            for (var i = 0; i < allNodes.length; ++i) {
+                is(allNodes[i].nodePrincipal, doc.nodePrincipal,
+                   "Unexpected principal for " + allNodes[i].nodeName +
+                   " in " + documentID);
+                is(allNodes[i].baseURIObject, doc.baseURIObject,
+                   "Unexpected base URI for " + allNodes[i].nodeName +
+                   " in " + documentID);
+            }
 
-  for (i = 0; i < XMLNodes.length; ++i) {
-    is(XMLNodes[i].nodePrincipal, document.nodePrincipal,
-       "Unexpected principal for " + XMLNodes[i].nodeName);
-    is(XMLNodes[i].baseURIObject.spec, "about:blank",
-       "Unexpected base URI for " + XMLNodes[i].nodeName);
-  }
+            for (i = 0; i < XMLNodes.length; ++i) {
+                is(XMLNodes[i].nodePrincipal, doc.nodePrincipal,
+                   "Unexpected principal for " + XMLNodes[i].nodeName +
+                   " in " + documentID);
+                is(XMLNodes[i].baseURIObject.spec, "about:blank",
+                   "Unexpected base URI for " + XMLNodes[i].nodeName +
+                   " in " + documentID);
+            }
+        }
+
+        runTestUnwrapped();
+        runTestProps();
+        runTestUnwrapped();
+    }
 
-  var doc = $("t").contentDocument;
-  is(doc instanceof $("t").contentWindow.HTMLDocument, true,
-     "Expected an HTMLDocument here");
-  isnot(doc.nodePrincipal, null, "Must have doc principal");
-  is(doc.nodePrincipal instanceof Components.interfaces.nsIPrincipal,
-     true, "doc principal must be a principal");
-  isnot(doc.baseURIObject, null, "Must have doc base URI");
-  is(doc.baseURIObject instanceof Components.interfaces.nsIURI,
-     true, "doc base URI must be a URI");
-  isnot(doc.documentURIObject, null, "Must have doc URI");
-  is(doc.documentURIObject instanceof Components.interfaces.nsIURI,
-     true, "doc URI must be a URI");
-  is(doc.documentURIObject.spec, doc.documentURI,
-     "doc URI must be the right URI");
+    var testsRunning = 2;
+    
+    testInDocument(document, "browser window");
+
+    function newTabTest(url) {
+        var newTab = gBrowser.addTab();
+        var newBrowser = gBrowser.getBrowserForTab(newTab);
+        newBrowser.contentWindow.location.href = url;
+        function testBrowser(event) {
+            newBrowser.removeEventListener("load", testBrowser, true);
+            is(event.target, newBrowser.contentDocument,
+               "Unexpected target in " + url);
+            testInDocument(newBrowser.contentDocument, url);
+
+            gBrowser.removeTab(newTab);
+
+            --testsRunning;
+            if (testsRunning == 0) {
+                finish();
+            }
+        }
+        newBrowser.addEventListener("load", testBrowser, true);
+    }
+
+    newTabTest("about:blank");
+    newTabTest("about:config");
 }
-
-addLoadEvent(runTest);
-addLoadEvent(runTest2);
-addLoadEvent(runTest);
-addLoadEvent(SimpleTest.finish);
-
-</script>
-</pre>
-</body>
-</html>
-
--- a/dom/tests/mochitest/bugs/test_bug396843.html
+++ b/dom/tests/mochitest/bugs/test_bug396843.html
@@ -227,62 +227,16 @@ function runTest() {
   for (var i = 0; i < allNodes.length; ++i) {
     ok(allNodes[i].nodePrincipal === undefined,
        "Unexpected principal appears for " + allNodes[i].nodeName);
     ok(allNodes[i].baseURIObject === undefined,
        "Unexpected base URI appears for " + allNodes[i].nodeName);
   }
 }
 
-function runTest2() {
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  isnot(document.nodePrincipal, null, "Must have document principal");
-  is(document.nodePrincipal instanceof Components.interfaces.nsIPrincipal,
-     true, "document principal must be a principal");
-  isnot(document.baseURIObject, null, "Must have document base URI");
-  is(document.baseURIObject instanceof Components.interfaces.nsIURI,
-     true, "document base URI must be a URI");
-  isnot(document.documentURIObject, null, "Must have document URI");
-  is(document.documentURIObject instanceof Components.interfaces.nsIURI,
-     true, "document URI must be a URI");
-  is(document.documentURIObject.spec, document.documentURI,
-     "document URI must be the right URI");
-     
-  for (var i = 0; i < allNodes.length; ++i) {
-    is(allNodes[i].nodePrincipal, document.nodePrincipal,
-       "Unexpected principal for " + allNodes[i].nodeName);
-    is(allNodes[i].baseURIObject, document.baseURIObject,
-       "Unexpected base URI for " + allNodes[i].nodeName);
-  }
-
-  for (i = 0; i < XMLNodes.length; ++i) {
-    is(XMLNodes[i].nodePrincipal, document.nodePrincipal,
-       "Unexpected principal for " + XMLNodes[i].nodeName);
-    is(XMLNodes[i].baseURIObject.spec, "about:blank",
-       "Unexpected base URI for " + XMLNodes[i].nodeName);
-  }
-
-  var doc = $("t").contentDocument;
-  is(doc instanceof $("t").contentWindow.HTMLDocument, true,
-     "Expected an HTMLDocument here");
-  isnot(doc.nodePrincipal, null, "Must have doc principal");
-  is(doc.nodePrincipal instanceof Components.interfaces.nsIPrincipal,
-     true, "doc principal must be a principal");
-  isnot(doc.baseURIObject, null, "Must have doc base URI");
-  is(doc.baseURIObject instanceof Components.interfaces.nsIURI,
-     true, "doc base URI must be a URI");
-  isnot(doc.documentURIObject, null, "Must have doc URI");
-  is(doc.documentURIObject instanceof Components.interfaces.nsIURI,
-     true, "doc URI must be a URI");
-  is(doc.documentURIObject.spec, doc.documentURI,
-     "doc URI must be the right URI");
-}
-
-addLoadEvent(runTest);
-addLoadEvent(runTest2);
 addLoadEvent(runTest);
 addLoadEvent(SimpleTest.finish);
 
 </script>
 </pre>
 </body>
 </html>
 
--- a/testing/mochitest/specialpowers/content/specialpowers.js
+++ b/testing/mochitest/specialpowers/content/specialpowers.js
@@ -401,16 +401,28 @@ SpecialPowers.prototype = {
     this._mfl.close();
   },
 
   addCategoryEntry: function(category, entry, value, persists, replace) {
     Cc["@mozilla.org/categorymanager;1"].
       getService(Components.interfaces.nsICategoryManager).
       addCategoryEntry(category, entry, value, persists, replace);
   },
+
+  getNodePrincipal: function(aNode) {
+      return aNode.nodePrincipal;
+  },
+
+  getNodeBaseURIObject: function(aNode) {
+      return aNode.baseURIObject;
+  },
+
+  getDocumentURIObject: function(aDocument) {
+      return aDocument.documentURIObject;
+  },
 };
 
 // Expose everything but internal APIs (starting with underscores) to
 // web content.
 SpecialPowers.prototype.__exposedProps__ = {};
 for each (i in Object.keys(SpecialPowers.prototype).filter(function(v) {return v.charAt(0) != "_";})) {
   SpecialPowers.prototype.__exposedProps__[i] = "r";
 }
--- a/toolkit/components/viewconfig/content/config.js
+++ b/toolkit/components/viewconfig/content/config.js
@@ -414,18 +414,19 @@ function ShowPrefs()
 
   document.getElementById("configDeck").setAttribute("selectedIndex", 1);
   document.getElementById("configTreeKeyset").removeAttribute("disabled");
   if (!document.getElementById("showWarningNextTime").checked)
     gPrefBranch.setBoolPref("general.warnOnAboutConfig", false);
 
   // Process about:config?filter=<string>
   var textbox = document.getElementById("textbox");
-  var uri = document.documentURIObject;
-  var matches = /[?&]filter\=([^&]+)/i.exec(uri.path);
+  // About URIs don't support query params, so do this manually
+  var loc = document.location.href;
+  var matches = /[?&]filter\=([^&]+)/i.exec(loc);
   if (matches)
     textbox.value = decodeURIComponent(matches[1]);
 
   // Even if we did not set the filter string via the URL query,
   // textbox might have been set via some other mechanism
   if (textbox.value)
     FilterPrefs();
   textbox.focus();
--- a/toolkit/mozapps/extensions/content/newaddon.js
+++ b/toolkit/mozapps/extensions/content/newaddon.js
@@ -51,17 +51,17 @@ var EnableListener = {
       window.close();
   }
 }
 AddonManager.addAddonListener(EnableListener);
 
 function initialize() {
   // About URIs don't implement nsIURL so we have to find the query string
   // manually
-  let spec = document.documentURIObject.spec;
+  let spec = document.location.href;
   let pos = spec.indexOf("?");
   let query = "";
   if (pos >= 0)
     query = spec.substring(pos + 1);
 
   let bundle = Services.strings.createBundle("chrome://mozapps/locale/extensions/newaddon.properties");
 
   // Just assume the query is "id=<id>"