1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/browser/browser_bug562992.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +/** 1.11 + * This test ensures that when the extension manager UI is open and a 1.12 + * restartless extension is installed from the web, its correct name appears 1.13 + * when the download and installation complete. See bug 562992. 1.14 + */ 1.15 + 1.16 +var gManagerWindow; 1.17 +var gProvider; 1.18 +var gInstall; 1.19 + 1.20 +const EXTENSION_NAME = "Wunderbar"; 1.21 + 1.22 +function test() { 1.23 + waitForExplicitFinish(); 1.24 + 1.25 + gProvider = new MockProvider(); 1.26 + 1.27 + open_manager("addons://list/extension", function (aWindow) { 1.28 + gManagerWindow = aWindow; 1.29 + run_next_test(); 1.30 + }); 1.31 +} 1.32 + 1.33 +function end_test() { 1.34 + close_manager(gManagerWindow, function () { 1.35 + finish(); 1.36 + }); 1.37 +} 1.38 + 1.39 +// Create a MockInstall with a MockAddon payload and add it to the provider, 1.40 +// causing the onNewInstall event to fire, which in turn will cause a new 1.41 +// "installing" item to appear in the list of extensions. 1.42 +add_test(function () { 1.43 + let addon = new MockAddon(undefined, EXTENSION_NAME, "extension", true); 1.44 + gInstall = new MockInstall(undefined, undefined, addon); 1.45 + gInstall.addTestListener({ 1.46 + onNewInstall: function () { 1.47 + run_next_test(); 1.48 + } 1.49 + }); 1.50 + gProvider.addInstall(gInstall); 1.51 +}); 1.52 + 1.53 +// Finish the install, which will cause the "installing" item to be converted 1.54 +// to an "installed" item, which should have the correct add-on name. 1.55 +add_test(function () { 1.56 + gInstall.addTestListener({ 1.57 + onInstallEnded: function () { 1.58 + let list = gManagerWindow.document.getElementById("addon-list"); 1.59 + 1.60 + // To help prevent future breakage, don't assume the item is the only one 1.61 + // in the list, or that it's first in the list. Find it by name. 1.62 + for (let i = 0; i < list.itemCount; i++) { 1.63 + let item = list.getItemAtIndex(i); 1.64 + if (item.getAttribute("name") === EXTENSION_NAME) { 1.65 + ok(true, "Item with correct name found"); 1.66 + run_next_test(); 1.67 + return; 1.68 + } 1.69 + } 1.70 + ok(false, "Item with correct name was not found"); 1.71 + run_next_test(); 1.72 + } 1.73 + }); 1.74 + gInstall.install(); 1.75 +});