2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2009-06-23 12:16:45 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bug 497578 - begin download of a complete update after a failure applying a
|
|
|
|
* partial update.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const PRIVATEBROWSING_CONTRACT_ID = "@mozilla.org/privatebrowsing;1";
|
|
|
|
|
|
|
|
function run_test() {
|
|
|
|
// Return early if Private Browsing is unavailable.
|
|
|
|
if (!(PRIVATEBROWSING_CONTRACT_ID in AUS_Cc))
|
|
|
|
return;
|
|
|
|
|
|
|
|
do_test_pending();
|
2010-10-19 21:28:29 -07:00
|
|
|
do_register_cleanup(end_test);
|
|
|
|
|
|
|
|
logTestInfo("testing Bug 497578 - begin download of a complete update " +
|
|
|
|
"after a failure to apply a partial update with " +
|
|
|
|
"browser.privatebrowsing.autostart set to true");
|
2009-06-23 12:16:45 -07:00
|
|
|
|
|
|
|
removeUpdateDirsAndFiles();
|
2010-03-03 10:56:47 -08:00
|
|
|
setUpdateChannel();
|
2009-06-23 12:16:45 -07:00
|
|
|
|
2010-09-13 23:57:19 -07:00
|
|
|
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
|
2009-06-23 12:16:45 -07:00
|
|
|
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
|
|
|
|
"Fake Window Watcher",
|
|
|
|
"@mozilla.org/embedcomp/window-watcher;1",
|
|
|
|
WindowWatcherFactory);
|
|
|
|
|
|
|
|
// Enable automatic app update so that after the failed partial is found the
|
|
|
|
// complete update will start to download automatically.
|
2010-05-26 13:16:57 -07:00
|
|
|
Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, true);
|
|
|
|
Services.prefs.setBoolPref("browser.privatebrowsing.autostart", true);
|
2009-06-23 12:16:45 -07:00
|
|
|
|
2010-08-13 23:03:36 -07:00
|
|
|
do_execute_soon(run_test_pt1);
|
2009-06-23 12:16:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function end_test() {
|
2010-09-13 23:57:19 -07:00
|
|
|
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
|
|
|
|
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
|
|
|
|
WindowWatcherFactory);
|
2009-06-23 12:16:45 -07:00
|
|
|
cleanUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
function run_test_pt1() {
|
|
|
|
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
|
2010-09-13 23:57:19 -07:00
|
|
|
let url = URL_HOST + URL_PATH + "/partial.mar";
|
|
|
|
let patches = getLocalPatchString("partial", url, null, null, null, null,
|
2009-06-23 12:16:45 -07:00
|
|
|
STATE_FAILED) +
|
|
|
|
getLocalPatchString(null, null, null, null, null, null,
|
|
|
|
STATE_NONE);
|
2010-09-13 23:57:19 -07:00
|
|
|
let updates = getLocalUpdateString(patches, null, null, "version 1.0", "1.0",
|
2010-03-03 10:56:47 -08:00
|
|
|
null, null, null, null, url);
|
2009-06-23 12:16:45 -07:00
|
|
|
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
|
|
|
|
writeStatusFile(STATE_FAILED);
|
|
|
|
|
2010-03-03 10:56:47 -08:00
|
|
|
standardInit();
|
|
|
|
|
2010-10-19 21:28:29 -07:00
|
|
|
logTestInfo("testing activeUpdate.state should equal STATE_DOWNLOADING " +
|
|
|
|
"prior to entering private browsing");
|
2009-10-12 12:12:30 -07:00
|
|
|
do_check_eq(gUpdateManager.activeUpdate.state, STATE_DOWNLOADING);
|
2009-06-23 12:16:45 -07:00
|
|
|
|
2010-09-13 23:57:19 -07:00
|
|
|
let privBrowsing = AUS_Cc[PRIVATEBROWSING_CONTRACT_ID].
|
2009-06-23 12:16:45 -07:00
|
|
|
getService(AUS_Ci.nsIPrivateBrowsingService).
|
|
|
|
QueryInterface(AUS_Ci.nsIObserver);
|
|
|
|
|
|
|
|
privBrowsing.observe(null, "profile-after-change", "");
|
2010-10-19 21:28:29 -07:00
|
|
|
logTestInfo("Testing: private mode should be entered automatically");
|
2009-06-23 12:16:45 -07:00
|
|
|
do_check_true(privBrowsing.privateBrowsingEnabled);
|
|
|
|
|
2010-10-19 21:28:29 -07:00
|
|
|
logTestInfo("Testing: private browsing is auto-started");
|
2009-06-23 12:16:45 -07:00
|
|
|
do_check_true(privBrowsing.autoStarted);
|
|
|
|
|
2010-08-13 23:03:36 -07:00
|
|
|
// Give private browsing time to reset necko.
|
|
|
|
do_execute_soon(run_test_pt2);
|
2009-06-23 12:16:45 -07:00
|
|
|
}
|
|
|
|
function run_test_pt2() {
|
2010-10-19 21:28:29 -07:00
|
|
|
logTestInfo("Testing: update count should equal 1");
|
2009-06-23 12:16:45 -07:00
|
|
|
do_check_eq(gUpdateManager.updateCount, 1);
|
2010-10-19 21:28:29 -07:00
|
|
|
logTestInfo("Testing: activeUpdate should not equal null");
|
2009-06-23 12:16:45 -07:00
|
|
|
do_check_neq(gUpdateManager.activeUpdate, null);
|
2010-10-19 21:28:29 -07:00
|
|
|
logTestInfo("Testing: activeUpdate.state should not equal null");
|
2009-06-23 12:16:45 -07:00
|
|
|
do_check_neq(gUpdateManager.activeUpdate.state, null);
|
2010-10-19 21:28:29 -07:00
|
|
|
logTestInfo("Testing: activeUpdate.state should equal STATE_DOWNLOADING");
|
2009-06-23 12:16:45 -07:00
|
|
|
do_check_eq(gUpdateManager.activeUpdate.state, STATE_DOWNLOADING);
|
2010-10-19 21:28:29 -07:00
|
|
|
|
|
|
|
do_test_finished();
|
2009-06-23 12:16:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Prevent the attempt to display the Update wizard for the failed update
|
|
|
|
var WindowWatcher = {
|
|
|
|
openWindow: function(parent, url, name, features, args) {
|
|
|
|
},
|
|
|
|
|
|
|
|
QueryInterface: function(iid) {
|
2010-09-13 23:57:19 -07:00
|
|
|
if (iid.equals(AUS_Ci.nsIWindowWatcher) ||
|
|
|
|
iid.equals(AUS_Ci.nsISupports))
|
2009-06-23 12:16:45 -07:00
|
|
|
return this;
|
|
|
|
|
|
|
|
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var WindowWatcherFactory = {
|
|
|
|
createInstance: function createInstance(outer, iid) {
|
|
|
|
if (outer != null)
|
|
|
|
throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
|
|
|
|
return WindowWatcher.QueryInterface(iid);
|
|
|
|
}
|
|
|
|
};
|