Bug 714276. NodesFromRect should be a chrome-only API. r=smaug
authorFelipe Gomes <felipc@gmail.com>
Fri, 27 Jan 2012 16:54:03 -0800
changeset 88067 5095046dc23cc052fc855cf9b862b3b17b93b208
parent 88066 40b1a7a5e6309a941ad41bd1986cdde93c9f91cc
child 88068 ca20586c4cd4e1ab6a786d20c02770da1cc71f01
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs714276
milestone12.0a1
Bug 714276. NodesFromRect should be a chrome-only API. r=smaug
dom/base/nsDOMWindowUtils.cpp
dom/tests/mochitest/chrome/489127.html
dom/tests/mochitest/chrome/Makefile.in
dom/tests/mochitest/chrome/test_nodesFromRect.html
dom/tests/mochitest/general/489127.html
dom/tests/mochitest/general/Makefile.in
dom/tests/mochitest/general/test_nodesFromRect.html
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -915,16 +915,20 @@ nsDOMWindowUtils::ElementFromPoint(float
 NS_IMETHODIMP
 nsDOMWindowUtils::NodesFromRect(float aX, float aY,
                                 float aTopSize, float aRightSize,
                                 float aBottomSize, float aLeftSize,
                                 bool aIgnoreRootScrollFrame,
                                 bool aFlushLayout,
                                 nsIDOMNodeList** aReturn)
 {
+  if (!IsUniversalXPConnectCapable()) {
+    return NS_ERROR_DOM_SECURITY_ERR;
+  }
+
   nsCOMPtr<nsIDocument> doc(do_QueryInterface(mWindow->GetExtantDocument()));
   NS_ENSURE_STATE(doc);
 
   return doc->NodesFromRectHelper(aX, aY, aTopSize, aRightSize, aBottomSize, aLeftSize, 
                                   aIgnoreRootScrollFrame, aFlushLayout, aReturn);
 }
 
 static already_AddRefed<gfxImageSurface>
rename from dom/tests/mochitest/general/489127.html
rename to dom/tests/mochitest/chrome/489127.html
--- a/dom/tests/mochitest/general/489127.html
+++ b/dom/tests/mochitest/chrome/489127.html
@@ -1,23 +1,21 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>nsIDOMWindowUtils::nodesFromRect test - bug 489127</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
 <script type="application/javascript;version=1.8">
 
   let SimpleTest = window.opener.SimpleTest;
   function ok() { window.opener.ok.apply(window.opener, arguments); }
   function done() { window.opener.done.apply(window.opener, arguments); }
   let e = {};
 
-  // Enable privileges so we can use nsIDOMWindowUtils interface
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
   let dwu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                   .getInterface(Components.interfaces.nsIDOMWindowUtils);
 
   /*
     nsIDOMNodeList nodesFromRect(in float aX,
                                  in float aY,
                                  in float aTopSize, 
                                  in float aRightSize,
--- a/dom/tests/mochitest/chrome/Makefile.in
+++ b/dom/tests/mochitest/chrome/Makefile.in
@@ -67,16 +67,18 @@ include $(topsrcdir)/config/rules.mk
 		test_DOMWindowCreated.xul \
 		DOMWindowCreated_chrome.xul \
 		DOMWindowCreated_content.html \
 		test_sandbox_image.xul \
 		test_cyclecollector.xul \
 		test_resize_move_windows.xul \
 		test_popup_blocker_chrome.xul \
 		test_moving_xhr.xul \
+		test_nodesFromRect.html \
+		489127.html \
 		$(NULL)
 
 ifeq (WINNT,$(OS_ARCH))
 _TEST_FILES += \
 		test_sizemode_attribute.xul \
 		sizemode_attribute.xul \
 		$(NULL)
 endif
rename from dom/tests/mochitest/general/test_nodesFromRect.html
rename to dom/tests/mochitest/chrome/test_nodesFromRect.html
--- a/dom/tests/mochitest/general/test_nodesFromRect.html
+++ b/dom/tests/mochitest/chrome/test_nodesFromRect.html
@@ -1,14 +1,14 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>nsIDOMWindowUtils::nodesFromRect test - bug 489127</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
 <script type="application/javascript">
   SimpleTest.waitForExplicitFinish();
   function done() {
     testwindow.close();
     SimpleTest.finish();
   }
   var testwindow = window.open("489127.html", '_new', 'width=600,height=400');
 </script>
--- a/dom/tests/mochitest/general/Makefile.in
+++ b/dom/tests/mochitest/general/Makefile.in
@@ -43,17 +43,16 @@ relativesrcdir  = dom/tests/mochitest/ge
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = \
 		test_outerHTML.html \
 		test_outerHTML.xhtml \
 		497633.html \
-		489127.html \
 		historyframes.html \
 		test_497898.html \
 		test_bug504220.html \
 		test_bug628069_1.html \
 		test_bug628069_2.html \
 		file_bug628069.html \
 		test_bug631440.html \
 		test_bug653364.html \
@@ -61,17 +60,16 @@ include $(topsrcdir)/config/rules.mk
 		test_clientRects.html \
 		test_consoleAPI.html \
 		test_domWindowUtils.html \
 		test_domWindowUtils_scrollXY.html \
 		test_offsets.html \
 		test_offsets.js \
 		test_windowProperties.html \
 		test_clipboard_events.html \
-		test_nodesFromRect.html \
 		test_frameElementWrapping.html \
 		file_frameElementWrapping.html \
 		test_framedhistoryframes.html \
 		test_windowedhistoryframes.html \
 		test_focusrings.xul \
 		file_moving_xhr.html \
 		test_vibrator.html \
 		browserFrameHelpers.js \