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