Bug 791244 test fixup - allow for the pref to be unset by default, r=gfritzsche
authorBenjamin Smedberg <benjamin@smedbergs.us>
Tue, 20 Nov 2012 10:32:41 -0500
changeset 117023 6b7555896aa32adfe0d0a553075d997a1d7bb1c8
parent 117022 722b6d63295b7b3ae255f76ccfc8180af90bcd9a
child 117024 c075f70f87aa6c9cd9e62d173244c8af9841ade7
push id1714
push userbsmedberg@mozilla.com
push dateTue, 20 Nov 2012 15:33:21 +0000
treeherdermozilla-beta@c075f70f87aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs791244
milestone18.0
Bug 791244 test fixup - allow for the pref to be unset by default, r=gfritzsche
dom/plugins/test/mochitest/test_hang_submit.xul
--- a/dom/plugins/test/mochitest/test_hang_submit.xul
+++ b/dom/plugins/test/mochitest/test_hang_submit.xul
@@ -27,19 +27,27 @@ if (isOSXLion || isOSXMtnLion) {
 
 Components.utils.import("resource://gre/modules/NetUtil.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 const crashReporter = Cc["@mozilla.org/toolkit/crash-reporter;1"].getService(Ci.nsICrashReporter);
-const oldServerPref = Services.prefs.getCharPref("toolkit.crashreporter.pluginHangSubmitURL");
 const SERVER_URL = "http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs";
 
+const serverPrefName = "toolkit.crashreporter.pluginHangSubmitURL";
+
+var oldServerPref;
+try {
+  oldServerPref = Services.prefs.getCharPref(serverPrefName);
+}
+catch(e) {
+}
+
 const oldTimeoutPref = Services.prefs.getIntPref("dom.ipc.plugins.timeoutSecs");
 
 var testObserver = {
   observe: function(subject, topic, data) {
     if (data == "submitting") // not done yet
       return;
     is(data, "success", "report should have been submitted successfully");
     is(topic, "crash-report-status", "Checking correct topic");
@@ -76,17 +84,22 @@ var testObserver = {
     // Next unregister our observer
     Services.obs.removeObserver(testObserver, "crash-report-status");
 
     // Then re-set MOZ_CRASHREPORTER_NO_REPORT
     let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
     env.set("MOZ_CRASHREPORTER_NO_REPORT", "1");
 
     // Finally re-set prefs
-    Services.prefs.setCharPref("toolkit.crashreporter.pluginHangSubmitURL", oldServerPref);
+    if (oldServerPref === undefined) {
+      Services.prefs.clearUserPref(serverPrefName);
+    }
+    else {
+      Services.prefs.setCharPref(serverPrefName, oldServerPref);
+    }
     Services.prefs.setIntPref("dom.ipc.plugins.timeoutSecs", oldTimeoutPref);
     SimpleTest.finish();
   },
 
   QueryInterface: function(iid) {
     if (iid.equals(Ci.nsIObserver) ||
         iid.equals(Ci.nsISupportsWeakReference) ||
         iid.equals(Ci.nsISupports))