Bug 832512 - Don't create SOWs for chrome code. r=bz, a=lsblakk
authorBobby Holley <bobbyholley@gmail.com>
Tue, 22 Jan 2013 23:06:26 +0100
changeset 127302 ee5b2e692449a2c4bdd83924d4e0e14f7a44dae5
parent 127301 26eda9e60b4df2ee68a9c37c40f459c531df0e05
child 127303 4be66100afd168ca823522d147ef7648243b802f
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, lsblakk
bugs832512
milestone20.0a2
Bug 832512 - Don't create SOWs for chrome code. r=bz, a=lsblakk
content/base/src/nsINode.cpp
layout/base/tests/chrome/test_bug370436.html
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -2351,17 +2351,19 @@ nsINode::WrapObject(JSContext *aCx, JSOb
       !hasHadScriptHandlingObject &&
       !nsContentUtils::IsCallerChrome()) {
     Throw<true>(aCx, NS_ERROR_UNEXPECTED);
     *aTriedToWrap = true;
     return nullptr;
   }
 
   JSObject* obj = WrapNode(aCx, aScope, aTriedToWrap);
-  if (obj && ChromeOnlyAccess()) {
+  if (obj && ChromeOnlyAccess() &&
+      !nsContentUtils::IsSystemPrincipal(NodePrincipal()))
+  {
     // Create a new wrapper and cache it.
     JSAutoCompartment ac(aCx, obj);
     JSObject* wrapper = xpc::WrapperFactory::WrapSOWObject(aCx, obj);
     if (!wrapper) {
       ClearWrapper();
       return nullptr;
     }
     dom::SetSystemOnlyWrapper(obj, this, *wrapper);
--- a/layout/base/tests/chrome/test_bug370436.html
+++ b/layout/base/tests/chrome/test_bug370436.html
@@ -9,32 +9,33 @@
 	<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>        
 	<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 </head>
 <body>
 
 <script class="testbody" type="application/javascript">
 <!--
 words = new Array()
+const Ci = Components.interfaces;
 
 function expandStringOffsetToWord(data, offset)
 {
 	if (data == undefined) return "";
 
 	var m1 = data.substr(0, offset).match(/\w+$/) || "";
 	var m2 = data.substr(offset).match(/^\w+/) || "";
 	return m1 + m2;
 }
 
 function onContextMenu(e)
 {
-	netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
 	var node = e.rangeParent;
 	var offset = e.rangeOffset;
+	var utils = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+	is(utils.getClassName(node), "Text", "Shouldn't have SOWs in chrome");
 
 	var word = expandStringOffsetToWord(node.data, offset);
 	words.push(word);
 }
 
 function startTest()
 {
 	ta = document.getElementById('blah');