Bug 474763: Enable xpinstall test suite and fix switching on/offline. r=bsmedberg
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 24 Feb 2009 13:12:54 -0800
changeset 25457 37fe6a2a0628a394ced175fb7e4f9aea4a40759d
parent 25456 3c8d3bc99c24d5d00acdee675e56d4e60ba92407
child 25458 ea5ce9416c83e942e60ce55c6ea4b79dc72beae3
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs474763
milestone1.9.2a1pre
Bug 474763: Enable xpinstall test suite and fix switching on/offline. r=bsmedberg
xpinstall/Makefile.in
xpinstall/tests/Makefile.in
xpinstall/tests/browser_offline.js
--- a/xpinstall/Makefile.in
+++ b/xpinstall/Makefile.in
@@ -45,13 +45,13 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= xpinstall
 DIRS		= public src
 
-#ifdef ENABLE_TESTS
-#DIRS += tests
-#endif
+ifdef ENABLE_TESTS
+DIRS += tests
+endif
 
 include $(topsrcdir)/config/rules.mk
--- a/xpinstall/tests/Makefile.in
+++ b/xpinstall/tests/Makefile.in
@@ -75,16 +75,18 @@ include $(topsrcdir)/config/rules.mk
                  browser_localfile.js \
                  browser_localfile2.js \
                  browser_auth.js \
                  browser_auth2.js \
                  browser_auth3.js \
                  browser_offline.js \
                  browser_chrome.js \
                  browser_cancel.js \
+                 browser_navigateaway.js \
+                 browser_navigateaway2.js \
                  unsigned.xpi \
                  signed.xpi \
                  signed2.xpi \
                  signed-untrusted.xpi \
                  signed-tampered.xpi \
                  empty.xpi \
                  corrupt.xpi \
                  enabled.html \
--- a/xpinstall/tests/browser_offline.js
+++ b/xpinstall/tests/browser_offline.js
@@ -18,25 +18,43 @@ function test() {
   var triggers = encodeURIComponent(JSON.stringify({
     "Unsigned XPI": TESTROOT + "unsigned.xpi"
   }));
   gBrowser.selectedTab = gBrowser.addTab();
   gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
 }
 
 function download_progress(addon, value, maxValue) {
-  BrowserOffline.toggleOfflineStatus();
+  var prefs = Components.classes["@mozilla.org/preferences;1"]
+                        .getService(Components.interfaces.nsIPrefBranch);
+  var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+                            .getService(Components.interfaces.nsIIOService2);
+
+  try {
+    ioService.manageOfflineStatus = false;
+    prefs.setBoolPref("browser.offline", true);
+    ioService.offline = true;
+  } catch (ex) {
+  }
 }
 
 function check_xpi_install(addon, status) {
   is(status, -210, "Install should be cancelled");
 }
 
 function finish_test() {
-  BrowserOffline.toggleOfflineStatus();
+  var prefs = Components.classes["@mozilla.org/preferences;1"]
+                        .getService(Components.interfaces.nsIPrefBranch);
+  var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+                            .getService(Components.interfaces.nsIIOService2);
+  try {
+    prefs.setBoolPref("browser.offline", false);
+    ioService.offline = false;
+  } catch (ex) {
+  }
 
   var pm = Components.classes["@mozilla.org/permissionmanager;1"]
                      .getService(Components.interfaces.nsIPermissionManager);
   pm.remove("example.com", "install");
 
   gBrowser.removeCurrentTab();
   Harness.finish();
 }