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 93877 ba46fc01fb32dd772a7082f4bd9d0fc63d0a8700
parent 93876 b2c747fcacead8f9b60111d0ae02c034152ceb1a
child 93878 5f4d6e20b6de14213fc80367794c3ac84a39089a
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);