toolkit/mozapps/extensions/test/browser/browser_bug562992.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 /**
michael@0 8 * This test ensures that when the extension manager UI is open and a
michael@0 9 * restartless extension is installed from the web, its correct name appears
michael@0 10 * when the download and installation complete. See bug 562992.
michael@0 11 */
michael@0 12
michael@0 13 var gManagerWindow;
michael@0 14 var gProvider;
michael@0 15 var gInstall;
michael@0 16
michael@0 17 const EXTENSION_NAME = "Wunderbar";
michael@0 18
michael@0 19 function test() {
michael@0 20 waitForExplicitFinish();
michael@0 21
michael@0 22 gProvider = new MockProvider();
michael@0 23
michael@0 24 open_manager("addons://list/extension", function (aWindow) {
michael@0 25 gManagerWindow = aWindow;
michael@0 26 run_next_test();
michael@0 27 });
michael@0 28 }
michael@0 29
michael@0 30 function end_test() {
michael@0 31 close_manager(gManagerWindow, function () {
michael@0 32 finish();
michael@0 33 });
michael@0 34 }
michael@0 35
michael@0 36 // Create a MockInstall with a MockAddon payload and add it to the provider,
michael@0 37 // causing the onNewInstall event to fire, which in turn will cause a new
michael@0 38 // "installing" item to appear in the list of extensions.
michael@0 39 add_test(function () {
michael@0 40 let addon = new MockAddon(undefined, EXTENSION_NAME, "extension", true);
michael@0 41 gInstall = new MockInstall(undefined, undefined, addon);
michael@0 42 gInstall.addTestListener({
michael@0 43 onNewInstall: function () {
michael@0 44 run_next_test();
michael@0 45 }
michael@0 46 });
michael@0 47 gProvider.addInstall(gInstall);
michael@0 48 });
michael@0 49
michael@0 50 // Finish the install, which will cause the "installing" item to be converted
michael@0 51 // to an "installed" item, which should have the correct add-on name.
michael@0 52 add_test(function () {
michael@0 53 gInstall.addTestListener({
michael@0 54 onInstallEnded: function () {
michael@0 55 let list = gManagerWindow.document.getElementById("addon-list");
michael@0 56
michael@0 57 // To help prevent future breakage, don't assume the item is the only one
michael@0 58 // in the list, or that it's first in the list. Find it by name.
michael@0 59 for (let i = 0; i < list.itemCount; i++) {
michael@0 60 let item = list.getItemAtIndex(i);
michael@0 61 if (item.getAttribute("name") === EXTENSION_NAME) {
michael@0 62 ok(true, "Item with correct name found");
michael@0 63 run_next_test();
michael@0 64 return;
michael@0 65 }
michael@0 66 }
michael@0 67 ok(false, "Item with correct name was not found");
michael@0 68 run_next_test();
michael@0 69 }
michael@0 70 });
michael@0 71 gInstall.install();
michael@0 72 });

mercurial