Fix for bug 739898 (Stop using enablePrivilege in test_bug480509.html). r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Tue, 27 Mar 2012 16:31:36 -0700
changeset 93816 183eed448b9d7b09a3ecd98db69066e9863eedbf
parent 93815 c3fd0768d46abdb77d0e51d4bcb52d5adf4d0445
child 93817 f0a104d6cc36c73cc391f979db4ec0c7754314e0
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs739898, 480509
milestone14.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
Fix for bug 739898 (Stop using enablePrivilege in test_bug480509.html). r=bz.
security/manager/ssl/tests/mochitest/bugs/test_bug480509.html
testing/mochitest/tests/SimpleTest/specialpowersAPI.js
--- a/security/manager/ssl/tests/mochitest/bugs/test_bug480509.html
+++ b/security/manager/ssl/tests/mochitest/bugs/test_bug480509.html
@@ -61,18 +61,17 @@ function onFrameLoad()
 
 function onWindowLoad()
 {
   var req = new XMLHttpRequest();
   var certListener = new badCertListener();
   try
   {
     req.open("GET", "https://www.bank1.com/", false);
-    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-    req.channel.notificationCallbacks = certListener;
+    SpecialPowers.setPrivilegedProps(req, "channel.notificationCallbacks", certListener);
     req.send(null);
   }
   catch(ex)
   {
     // ignore
   }
   
   ok(certListener.badCertCaught, "We Caught the invalid certificate");
--- a/testing/mochitest/tests/SimpleTest/specialpowersAPI.js
+++ b/testing/mochitest/tests/SimpleTest/specialpowersAPI.js
@@ -935,16 +935,33 @@ SpecialPowersAPI.prototype = {
       if (obj[p]) {
         obj = obj[p];
       } else {
         return null;
       }
     }
     return obj;
   },
+  setPrivilegedProps: function(obj, props, val) {
+    var parts = props.split('.');
+
+    if (parts.length == 0) {
+      return;
+    }
+
+    for (var i = 0; i < parts.length - 1; i++) {
+      var p = parts[i];
+      if (obj[p]) {
+        obj = obj[p];
+      } else {
+        return;
+      }
+    }
+    obj[parts[i]] = val;
+  },
 
   get focusManager() {
     if (this._fm != null)
       return this._fm;
 
     this._fm = Components.classes["@mozilla.org/focus-manager;1"].
                         getService(Components.interfaces.nsIFocusManager);