Bug 841407 - Replace usage of enablePrivilege in inspector tests. r=bholley
authorBenjamin Peterson <benjamin@python.org>
Fri, 15 Feb 2013 09:34:46 -0500
changeset 122036 87081ae8b6d6c8c2955b26bcf940820776ce9437
parent 122035 d999c65753ea3c6ea49d130f9a24f067bbe33704
child 122037 c774937ce22738f880a882085f32f3fec8d654f9
push id24315
push userryanvm@gmail.com
push dateFri, 15 Feb 2013 21:34:37 +0000
treeherdermozilla-central@7bd555e2acfa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs841407
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 841407 - Replace usage of enablePrivilege in inspector tests. r=bholley
layout/inspector/tests/test_bug462787.html
layout/inspector/tests/test_bug462789.html
layout/inspector/tests/test_bug522601.xhtml
layout/inspector/tests/test_bug536379-2.html
layout/inspector/tests/test_bug536379.html
layout/inspector/tests/test_bug557726.html
layout/inspector/tests/test_bug609549.xhtml
layout/inspector/tests/test_bug806192.html
layout/inspector/tests/test_isinheritableproperty.html
--- a/layout/inspector/tests/test_bug462787.html
+++ b/layout/inspector/tests/test_bug462787.html
@@ -16,19 +16,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 462787 **/
 
 function do_test() {
   const INVALID_POINTER = 0x80004003;
-  
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  var utils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
+
+  var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
                              .getService(Components.interfaces.inIDOMUtils);
   try {
     utils.getCSSStyleRules(null); 
     ok(false, "expected an exception"); 
   }
   catch(e) { is(e.result, INVALID_POINTER, "got the expected exception"); }
 
   try {
--- a/layout/inspector/tests/test_bug462789.html
+++ b/layout/inspector/tests/test_bug462789.html
@@ -18,19 +18,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script type="application/javascript">
 
 /** Test for Bug 462789 **/
 
 function do_test() {
   const ERROR_FAILURE = 0x80004005;
   const DOCUMENT_NODE_TYPE = 9;
 
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  var utils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
-                             .getService(Components.interfaces.inIDOMUtils);
+  var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
+                             .getService(SpecialPowers.Ci.inIDOMUtils);
 
   var iframe = document.getElementById("bug462789_iframe");
   var docElement = iframe.contentDocument.documentElement;
   var body = docElement.children[1];
   var rule = iframe.contentDocument.styleSheets[0].cssRules[0];
   var text = body.firstChild;
 
   try {
@@ -58,17 +57,17 @@ function do_test() {
     is(res.nodeType, DOCUMENT_NODE_TYPE, "getParentForNode(docElement, true)");
     res = utils.getParentForNode(text, true);
     is(res.tagName, "BODY", "getParentForNode(text, true)");
   }
   catch(e) { ok(false, "got an unexpected exception:" + e); }
 
   try {
     var res = utils.getBindingURLs(docElement);
-    is(res instanceof Components.interfaces["nsIArray"], true, "getBindingURLs result type");
+    is(SpecialPowers.unwrap(res) instanceof SpecialPowers.Ci["nsIArray"], true, "getBindingURLs result type");
     is(res.length, 0, "getBindingURLs array length");
   }
   catch(e) { ok(false, "got an unexpected exception:" + e); }
 
   try {
     utils.getContentState(docElement);
     ok(true, "Should not throw"); 
   }
--- a/layout/inspector/tests/test_bug522601.xhtml
+++ b/layout/inspector/tests/test_bug522601.xhtml
@@ -25,32 +25,31 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 522601 **/
 SimpleTest.waitForExplicitFinish();
 
 function testFunc(walker, func, expectedNode, str) {
-  var oldCurrent = walker.currentNode;
-  var newNode = walker[func]();
+  var oldCurrent = SpecialPowers.unwrap(walker.currentNode);
+  var newNode = SpecialPowers.unwrap(walker[func]());
   is(newNode, expectedNode, "Unexpected node after " + str);
-  is(walker.currentNode, newNode ? newNode : oldCurrent,
+  is(SpecialPowers.unwrap(walker.currentNode), newNode ? newNode : oldCurrent,
      "Unexpected current node after " + str);
 }
 
 addLoadEvent(function() {
-  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
   var walkerNonAnon =
-    Components.classes["@mozilla.org/inspector/deep-tree-walker;1"]
-              .createInstance(Components.interfaces.inIDeepTreeWalker);
+    SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
+              .createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
   walkerNonAnon.init($("display"), NodeFilter.SHOW_ALL);
   walkerNonAnon.showAnonymousContent = false;
 
-  is(walkerNonAnon.currentNode, $("display"), "Unexpected non-anon root");
+  is(SpecialPowers.unwrap(walkerNonAnon.currentNode), $("display"), "Unexpected non-anon root");
   testFunc(walkerNonAnon, "nextNode", $("s").previousSibling,
            "step to some text");
   testFunc(walkerNonAnon, "nextNode", $("s"), "step to span");
   testFunc(walkerNonAnon, "nextNode", $("s").firstChild, "step to span text");
   testFunc(walkerNonAnon, "nextNode", $("s").nextSibling, "step to more text");
   testFunc(walkerNonAnon, "nextNode", $("b"), "step to bold");
   testFunc(walkerNonAnon, "nextNode", $("b").firstChild, "step to bold text");
   testFunc(walkerNonAnon, "nextNode", $("i1"), "step to first italic");
@@ -82,17 +81,17 @@ addLoadEvent(function() {
            "step previousSibling to span");
   testFunc(walkerNonAnon, "previousSibling", $("s").previousSibling,
            "step previousSibling to display first child");
   testFunc(walkerNonAnon, "previousSibling", null,
            "step previousSibling past end");
 
   // Move the walker over to the end
   while (walkerNonAnon.nextNode()) { /* do nothing */ }
-  is(walkerNonAnon.currentNode, $("i2").firstChild, "unexpected last node");
+  is(SpecialPowers.unwrap(walkerNonAnon.currentNode), $("i2").firstChild, "unexpected last node");
   testFunc(walkerNonAnon, "previousNode", $("i2"), "step back to second italic");
   testFunc(walkerNonAnon, "previousNode", $("i1").nextSibling,
            "step back to more bold text");
   testFunc(walkerNonAnon, "previousNode", $("i1").firstChild,
            "step back to first italic text");
   testFunc(walkerNonAnon, "previousNode", $("i1"), "step back to first italic");
   testFunc(walkerNonAnon, "previousNode", $("b").firstChild,
            "step back to bold text");
@@ -105,22 +104,22 @@ addLoadEvent(function() {
   testFunc(walkerNonAnon, "previousNode", $("display"),
            "step back to root");
   testFunc(walkerNonAnon, "previousNode", null,
            "step back past root");
 
   var anonDiv = document.getAnonymousNodes($("display"))[0];
 
   var walkerAnon =
-    Components.classes["@mozilla.org/inspector/deep-tree-walker;1"]
-              .createInstance(Components.interfaces.inIDeepTreeWalker);
+    SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
+              .createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
   walkerAnon.showAnonymousContent = true;
   walkerAnon.init($("display"), NodeFilter.SHOW_ALL);
 
-  is(walkerAnon.currentNode, $("display"), "Unexpected anon root");
+  is(SpecialPowers.unwrap(walkerAnon.currentNode), $("display"), "Unexpected anon root");
   testFunc(walkerAnon, "nextNode", anonDiv,
            "step to anonymous div");
   testFunc(walkerAnon, "nextNode", $("s").previousSibling,
            "step to some text (anon)");
   testFunc(walkerAnon, "nextNode", $("s").nextSibling, "step to more text (anon)");
   testFunc(walkerAnon, "nextNode", $("b"), "step to bold (anon)");
   testFunc(walkerAnon, "nextNode", $("b").firstChild, "step to bold text (anon)");
   testFunc(walkerAnon, "nextNode", $("i1"), "step to first italic (anon)");
--- a/layout/inspector/tests/test_bug536379-2.html
+++ b/layout/inspector/tests/test_bug536379-2.html
@@ -13,20 +13,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=536379">Mozilla Bug 536379</a>
 <p id="display"></p>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 536379 **/
 
-netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-
-const CI = Components.interfaces;
-const CC = Components.classes;
+const CI = SpecialPowers.Ci;
+const CC = SpecialPowers.Cc;
 
 var domUtils =
   CC["@mozilla.org/inspector/dom-utils;1"].getService(CI.inIDOMUtils);
 var rules = domUtils.getCSSStyleRules(document.getElementById("display"));
 var firstPRule =
   rules.GetElementAt(rules.Count() - 2).QueryInterface(CI.nsIDOMCSSStyleRule);
 firstPRule.style.removeProperty("color");
 ok(true, "should not crash");
--- a/layout/inspector/tests/test_bug536379.html
+++ b/layout/inspector/tests/test_bug536379.html
@@ -13,35 +13,33 @@ https://bugzilla.mozilla.org/show_bug.cg
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=536379">Mozilla Bug 536379</a>
 <p id="display"></p>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 536379 **/
 
-netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-
-const CI = Components.interfaces;
-const CC = Components.classes;
+const CI = SpecialPowers.Ci;
+const CC = SpecialPowers.Cc;
 
 var domUtils =
   CC["@mozilla.org/inspector/dom-utils;1"].getService(CI.inIDOMUtils);
 var rules = domUtils.getCSSStyleRules(document.getElementById("display"));
 var firstPRule =
   rules.GetElementAt(rules.Count() - 2).QueryInterface(CI.nsIDOMCSSStyleRule);
 firstPRule.style.removeProperty("color");
 ok(true, "should not crash");
 
 var links = document.getElementsByTagName("link");
 is(links.length, 3, "links.length");
-is(firstPRule.parentStyleSheet, links[1].sheet, "sheet match for first P rule");
+is(SpecialPowers.unwrap(firstPRule.parentStyleSheet), links[1].sheet, "sheet match for first P rule");
 var secondPRule =
   rules.GetElementAt(rules.Count() - 1).QueryInterface(CI.nsIDOMCSSStyleRule);
-is(secondPRule.parentStyleSheet, links[2].sheet, "sheet match for second P rule");
+is(SpecialPowers.unwrap(secondPRule.parentStyleSheet), links[2].sheet, "sheet match for second P rule");
 is(links[1].href, links[2].href, "links should have same href");
 isnot(links[1].sheet, links[2].sheet, "links should have different sheets");
 isnot(firstPRule, secondPRule, "rules should be different");
 isnot(firstPRule.cssText, secondPRule.cssText, "text should be different since property was removed from one");
 
 </script>
 </pre>
 </body>
--- a/layout/inspector/tests/test_bug557726.html
+++ b/layout/inspector/tests/test_bug557726.html
@@ -35,31 +35,30 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 <div id="div1">
   text with :before, :after, and :first-letter pseudo-elements
 </div>
 
 <script type="application/javascript">
 
 /** Test for Bug 557726 **/
-netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
 function getSelectors (rules) {
   var styleElement = document.getElementById("pseudo-style");
   var selectors = [];
   for (var i = 0; i < rules.Count(); i++) {
-    var rule = rules.GetElementAt(i).QueryInterface(Components.interfaces.nsIDOMCSSStyleRule);
-    if (rule.parentStyleSheet.ownerNode == styleElement) // no user agent rules
+    var rule = rules.GetElementAt(i).QueryInterface(SpecialPowers.Ci.nsIDOMCSSStyleRule);
+    if (SpecialPowers.unwrap(rule.parentStyleSheet.ownerNode) == styleElement) // no user agent rules
       selectors.push(rule.selectorText);
   }
   return selectors;
 }
 
-var domUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
-               .getService(Components.interfaces.inIDOMUtils);
+var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
+               .getService(SpecialPowers.Ci.inIDOMUtils);
 
 var div = document.getElementById("div1");
 
 /* empty or missing pseudo-element argument */
 var selectors = getSelectors(domUtils.getCSSStyleRules(div));
 is(selectors.length, 1, "psuedo-element argument should be optional");
 is(selectors[0], "#div1", "should only have the non-pseudo element rule");
 
--- a/layout/inspector/tests/test_bug609549.xhtml
+++ b/layout/inspector/tests/test_bug609549.xhtml
@@ -25,42 +25,41 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 609549 **/
 SimpleTest.waitForExplicitFinish();
 
 addLoadEvent(function() {
-  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-  var domUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"].
-                   getService(Components.interfaces.inIDOMUtils);
+  var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"].
+                   getService(SpecialPowers.Ci.inIDOMUtils);
   ok("getChildrenForNode" in domUtils, "domUtils has no getChildrenForNode");
-  var withoutAnons = domUtils.getChildrenForNode($("bound"), false);
+  var withoutAnons = SpecialPowers.unwrap(domUtils.getChildrenForNode($("bound"), false));
 
   is(withoutAnons.length, $("bound").childNodes.length,
      "withoutAnons should be the same length as childNodes");
   is(withoutAnons[0], $("p"), "didn't get paragraph - without anons");
   is(withoutAnons[1], $("sandwiched"),
      "didn't get sandwiched span - without anons");
 
-  var withAnons = domUtils.getChildrenForNode($("bound"), true);
+  var withAnons = SpecialPowers.unwrap(domUtils.getChildrenForNode($("bound"), true));
 
   is(withAnons.length, 4, "bad withAnons.length");
   is(withAnons[0].getAttribute("anonid"), "box-A",
      "didn't get anonymous box-A");
   is(withAnons[1].getAttribute("anonid"), "box-B",
      "didn't get anonymous box-B");
   is(withAnons[2].getAttribute("anonid"), "box-C",
      "didn't get anonymous box-C");
   is(withAnons[3].id, "p", "didn't get paragraph - with anons");
 
   var bKids = domUtils.getChildrenForNode(withAnons[1], true);
   is(bKids.length, 1, "bKids.length is bad");
-  is(bKids[0], $("sandwiched"),
+  is(SpecialPowers.unwrap(bKids[0]), $("sandwiched"),
      "didn't get sandwiched span inserted into box-B");
 
   SimpleTest.finish();
 });
 
 ]]>
 </script>
 </pre>
--- a/layout/inspector/tests/test_bug806192.html
+++ b/layout/inspector/tests/test_bug806192.html
@@ -7,18 +7,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 806192</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <pre id="test">
 <script type="application/javascript">
 
-netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-const utils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
+const utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
 .getService(Components.interfaces.inIDOMUtils);
 
 try {
     var res = utils.getBindingURLs({});
     ok(false, "didn't get error");
 }
 catch(e) { ok(true, "got expected exception"); }
 </script>
--- a/layout/inspector/tests/test_isinheritableproperty.html
+++ b/layout/inspector/tests/test_isinheritableproperty.html
@@ -8,19 +8,18 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <pre id="test">
 <script type="application/javascript">
 
 function do_test() {
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  var utils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
-    .getService(Components.interfaces.inIDOMUtils);
+  var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
+    .getService(SpecialPowers.Ci.inIDOMUtils);
 
   is(utils.isInheritedProperty("font-size"), true, "font-size is inherited.");
 
   is(utils.isInheritedProperty("min-width"), false, "min-width is not inherited.");
 
   is(utils.isInheritedProperty("font"), true, "shorthand font property is inherited.");
 
   is(utils.isInheritedProperty("border"), false, "shorthand border property not inherited.");