Bug 761982 - remove mozprefs.js. r=jmaher
authorBobby Holley <bobbyholley@gmail.com>
Mon, 18 Jun 2012 15:43:00 +0200
changeset 96901 fe927ecb8e1997a96e70e275ad6d02e5c0a12059
parent 96900 bd6e2f1d15915bbdbf627b7790af539155929dd1
child 96902 10e3d0212100603ca39a2f08be6c5e119fead99c
push idunknown
push userunknown
push dateunknown
reviewersjmaher
bugs761982
milestone16.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 761982 - remove mozprefs.js. r=jmaher
dom/tests/mochitest/bugs/test_bug61098.html
testing/mochitest/Makefile.in
testing/mochitest/jar.mn
testing/mochitest/mozprefs.js
--- a/dom/tests/mochitest/bugs/test_bug61098.html
+++ b/dom/tests/mochitest/bugs/test_bug61098.html
@@ -1,17 +1,16 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=61098
 -->
 <head>
   <title>Test for Bug 61098</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="/mozprefs.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/MockObjects.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="runtests();">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=61098">Mozilla Bug 61098</a>
 <p id="display">
 </p>
--- a/testing/mochitest/Makefile.in
+++ b/testing/mochitest/Makefile.in
@@ -63,17 +63,16 @@ include $(topsrcdir)/build/automation-bu
 		harness.xul \
 		browser-test-overlay.xul \
 		browser-test.js \
 		chrome-harness.js \
 		browser-harness.xul \
 		redirect.html \
 		$(topsrcdir)/build/pgo/server-locations.txt \
 		$(topsrcdir)/netwerk/test/httpserver/httpd.js \
-		mozprefs.js \
 		pywebsocket_wrapper.py \
  	 	plain-loop.html \
 		android.json \
 		$(NULL)	
 
 ifeq ($(MOZ_BUILD_APP),mobile/android)
 _SERV_FILES += $(topsrcdir)/mobile/android/base/tests/robocop.ini
 endif
--- a/testing/mochitest/jar.mn
+++ b/testing/mochitest/jar.mn
@@ -1,17 +1,16 @@
 mochikit.jar:
 % content mochikit %content/
   content/browser-harness.xul (browser-harness.xul)
   content/browser-test.js (browser-test.js)
   content/browser-test-overlay.xul (browser-test-overlay.xul)
   content/chrome-harness.js (chrome-harness.js)
   content/harness-overlay.xul (harness-overlay.xul)
   content/harness.xul (harness.xul)
-  content/mozprefs.js (mozprefs.js)
   content/redirect.html (redirect.html)
   content/server.js (server.js)
   content/dynamic/getMyDirectory.sjs (dynamic/getMyDirectory.sjs)
   content/static/harness.css (static/harness.css)
   content/tests/SimpleTest/ChromePowers.js (tests/SimpleTest/ChromePowers.js)
   content/tests/SimpleTest/specialpowersAPI.js (tests/SimpleTest/specialpowersAPI.js)
   content/tests/SimpleTest/SpecialPowersObserverAPI.js (tests/SimpleTest/SpecialPowersObserverAPI.js)
   content/tests/SimpleTest/EventUtils.js (tests/SimpleTest/EventUtils.js)
deleted file mode 100644
--- a/testing/mochitest/mozprefs.js
+++ /dev/null
@@ -1,92 +0,0 @@
-(function() {
-
-  // NOTE: You *must* also include this line in any test that uses this file:
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  
-  var prefService = Components.classes["@mozilla.org/preferences-service;1"]
-                              .getService(Components.interfaces.nsIPrefService);
-
-  function determinePrefKind(branch, prefName) {
-    switch (branch.getPrefType(prefName)) {
-    case branch.PREF_STRING:    return "CharPref";
-    case branch.PREF_INT:       return "IntPref";
-    case branch.PREF_BOOL:      return "BoolPref";
-    default: /* PREF_INVALID */ return "ComplexValue";
-    }
-  }
-  
-  function memoize(fn, obj) {
-    var cache = {}, sep = '___',
-        join = Array.prototype.join;
-    return function() {
-      var key = join.call(arguments, sep);
-      if (!(key in cache))
-        cache[key] = fn.apply(obj, arguments);
-      return cache[key];
-    };
-  }
-  
-  var makeAccessor = memoize(function(pref) {
-    var splat = pref.split('.'),
-        basePref = splat.pop(),
-        branch, kind;
-    
-    try {
-      branch = prefService.getBranch(splat.join('.') + '.')
-    } catch (e) {
-      alert("Calling prefService.getBranch failed: " + 
-        "did you read the NOTE in mozprefs.js?");
-      throw e;
-    }
-    
-    kind = determinePrefKind(branch, basePref);
-    
-    return function(value) {
-      var oldValue = branch['get' + kind](basePref);
-      if (arguments.length > 0)
-        branch['set' + kind](basePref, value);
-      return oldValue;
-    };
-  });
-
-  /* function pref(name[, value[, fn[, obj]]])
-   * -----------------------------------------
-   * Use cases:
-   *
-   *   1. Get the value of the dom.disable_open_during_load preference:
-   *
-   *      pref('dom.disable_open_during_load')
-   *
-   *   2. Set the preference to true, returning the old value:
-   *
-   *      var oldValue = pref('dom.disable_open_during_load', true);
-   *
-   *   3. Set the value of the preference to true just for the duration
-   *      of the specified function's execution:
-   *
-   *      pref('dom.disable_open_during_load', true, function() {
-   *        window.open(this.getUrl()); // fails if still loading
-   *      }, this); // for convenience, allow binding
-   *
-   *      Rationale: Unless a great deal of care is taken to catch all
-   *                 exceptions and restore original preference values,
-   *                 manually setting & restoring preferences can lead
-   *                 to unpredictable test behavior.  The try-finally
-   *                 block below eliminates that risk.
-   */
-  function pref(name, /*optional:*/ value, fn, obj) {
-    var acc = makeAccessor(name);
-    switch (arguments.length) {
-    case 1: return acc();
-    case 2: return acc(value);
-    default:
-      var oldValue = acc(value),
-          extra_args = [].slice.call(arguments, 4);
-      try { return fn.apply(obj, extra_args) }
-      finally { acc(oldValue) } // reset no matter what
-    }
-  };
-  
-  window.pref = pref; // export
- 
-})();