1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug394300.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + */ 1.8 + 1.9 +// Disables security checking our updates which haven't been signed 1.10 +Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); 1.11 + 1.12 +Components.utils.import("resource://testing-common/httpd.js"); 1.13 +var server; 1.14 + 1.15 +// nsIAddonUpdateCheckListener implementation 1.16 +var updateListener = { 1.17 + _count: 0, 1.18 + 1.19 + onUpdateAvailable: function onAddonUpdateEnded(aAddon, aInstall) { 1.20 + do_check_eq(aInstall.version, 10); 1.21 + }, 1.22 + 1.23 + onNoUpdateAvailable: function onNoUpdateAvailable(aAddon) { 1.24 + do_throw("Expected an available update for " + aAddon.id); 1.25 + }, 1.26 + 1.27 + onUpdateFinished: function onUpdateFinished() { 1.28 + if (++this._count == 2) 1.29 + server.stop(do_test_finished); 1.30 + }, 1.31 +} 1.32 + 1.33 +function run_test() 1.34 +{ 1.35 + // Setup for test 1.36 + do_test_pending(); 1.37 + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); 1.38 + startupManager(); 1.39 + 1.40 + installAllFiles([do_get_addon("test_bug394300_1"), 1.41 + do_get_addon("test_bug394300_2")], function() { 1.42 + 1.43 + restartManager(); 1.44 + 1.45 + AddonManager.getAddonsByIDs(["bug394300_1@tests.mozilla.org", 1.46 + "bug394300_2@tests.mozilla.org"], function(updates) { 1.47 + 1.48 + do_check_neq(updates[0], null); 1.49 + do_check_neq(updates[1], null); 1.50 + 1.51 + server = new HttpServer(); 1.52 + server.registerDirectory("/", do_get_file("data")); 1.53 + server.start(4444); 1.54 + 1.55 + updates[0].findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED); 1.56 + updates[1].findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED); 1.57 + }); 1.58 + }); 1.59 +}