michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * This test ensures that when the extension manager UI is open and a michael@0: * restartless extension is installed from the web, its correct name appears michael@0: * when the download and installation complete. See bug 562992. michael@0: */ michael@0: michael@0: var gManagerWindow; michael@0: var gProvider; michael@0: var gInstall; michael@0: michael@0: const EXTENSION_NAME = "Wunderbar"; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: gProvider = new MockProvider(); michael@0: michael@0: open_manager("addons://list/extension", function (aWindow) { michael@0: gManagerWindow = aWindow; michael@0: run_next_test(); michael@0: }); michael@0: } michael@0: michael@0: function end_test() { michael@0: close_manager(gManagerWindow, function () { michael@0: finish(); michael@0: }); michael@0: } michael@0: michael@0: // Create a MockInstall with a MockAddon payload and add it to the provider, michael@0: // causing the onNewInstall event to fire, which in turn will cause a new michael@0: // "installing" item to appear in the list of extensions. michael@0: add_test(function () { michael@0: let addon = new MockAddon(undefined, EXTENSION_NAME, "extension", true); michael@0: gInstall = new MockInstall(undefined, undefined, addon); michael@0: gInstall.addTestListener({ michael@0: onNewInstall: function () { michael@0: run_next_test(); michael@0: } michael@0: }); michael@0: gProvider.addInstall(gInstall); michael@0: }); michael@0: michael@0: // Finish the install, which will cause the "installing" item to be converted michael@0: // to an "installed" item, which should have the correct add-on name. michael@0: add_test(function () { michael@0: gInstall.addTestListener({ michael@0: onInstallEnded: function () { michael@0: let list = gManagerWindow.document.getElementById("addon-list"); michael@0: michael@0: // To help prevent future breakage, don't assume the item is the only one michael@0: // in the list, or that it's first in the list. Find it by name. michael@0: for (let i = 0; i < list.itemCount; i++) { michael@0: let item = list.getItemAtIndex(i); michael@0: if (item.getAttribute("name") === EXTENSION_NAME) { michael@0: ok(true, "Item with correct name found"); michael@0: run_next_test(); michael@0: return; michael@0: } michael@0: } michael@0: ok(false, "Item with correct name was not found"); michael@0: run_next_test(); michael@0: } michael@0: }); michael@0: gInstall.install(); michael@0: });