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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:00f217b03df5
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
4
5 /**
6 * Tests that double-click does not go to detail view if the target is a link or button.
7 */
8
9 function test() {
10 requestLongerTimeout(2);
11
12 waitForExplicitFinish();
13
14 var gProvider = new MockProvider();
15 gProvider.createAddons([{
16 id: "test1@tests.mozilla.org",
17 name: "Test add-on 1",
18 description: "foo",
19 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
20 }]);
21
22 run_next_test();
23 }
24
25 function end_test() {
26 finish();
27 }
28
29 function is_in_list(aManager, view) {
30 var doc = aManager.document;
31
32 is(doc.getElementById("categories").selectedItem.value, view, "Should be on the right category");
33 is(doc.getElementById("view-port").selectedPanel.id, "list-view", "Should be on the right view");
34 }
35
36 function is_in_detail(aManager, view) {
37 var doc = aManager.document;
38
39 is(doc.getElementById("categories").selectedItem.value, view, "Should be on the right category");
40 is(doc.getElementById("view-port").selectedPanel.id, "detail-view", "Should be on the right view");
41 }
42
43 // Check that double-click does something.
44 add_test(function() {
45 open_manager("addons://list/extension", function(aManager) {
46 info("Part 1");
47 is_in_list(aManager, "addons://list/extension");
48
49 var addon = get_addon_element(aManager, "test1@tests.mozilla.org");
50 addon.parentNode.ensureElementIsVisible(addon);
51 EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 1 }, aManager);
52 EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 2 }, aManager);
53
54 wait_for_view_load(aManager, function(aManager) {
55 info("Part 2");
56 is_in_detail(aManager, "addons://list/extension");
57
58 close_manager(aManager, run_next_test);
59 });
60 });
61 });
62
63 // Check that double-click does nothing when over the disable button.
64 add_test(function() {
65 open_manager("addons://list/extension", function(aManager) {
66 info("Part 1");
67 is_in_list(aManager, "addons://list/extension");
68
69 var addon = get_addon_element(aManager, "test1@tests.mozilla.org");
70 addon.parentNode.ensureElementIsVisible(addon);
71 EventUtils.synthesizeMouseAtCenter(
72 aManager.document.getAnonymousElementByAttribute(addon, "anonid", "disable-btn"),
73 { clickCount: 1 },
74 aManager
75 );
76 // The disable button is replaced by the enable button when clicked on.
77 EventUtils.synthesizeMouseAtCenter(
78 aManager.document.getAnonymousElementByAttribute(addon, "anonid", "enable-btn"),
79 { clickCount: 2 },
80 aManager
81 );
82
83 wait_for_view_load(aManager, function(aManager) {
84 info("Part 2");
85 is_in_list(aManager, "addons://list/extension");
86
87 close_manager(aManager, run_next_test);
88 });
89 });
90 });
91
92 // Check that double-click does nothing when over the undo button.
93 add_test(function() {
94 open_manager("addons://list/extension", function(aManager) {
95 info("Part 1");
96 is_in_list(aManager, "addons://list/extension");
97
98 var addon = get_addon_element(aManager, "test1@tests.mozilla.org");
99 addon.parentNode.ensureElementIsVisible(addon);
100 EventUtils.synthesizeMouseAtCenter(
101 aManager.document.getAnonymousElementByAttribute(addon, "anonid", "remove-btn"),
102 { clickCount: 1 },
103 aManager
104 );
105
106 // The undo button is removed when clicked on.
107 // We need to wait for the UI to catch up.
108 setTimeout(function() {
109 var target = aManager.document.getAnonymousElementByAttribute(addon, "anonid", "undo-btn");
110 var rect = target.getBoundingClientRect();
111 var addonRect = addon.getBoundingClientRect();
112
113 EventUtils.synthesizeMouse(target, rect.width / 2, rect.height / 2, { clickCount: 1 }, aManager);
114 EventUtils.synthesizeMouse(addon,
115 rect.left - addonRect.left + rect.width / 2,
116 rect.top - addonRect.top + rect.height / 2,
117 { clickCount: 2 },
118 aManager
119 );
120
121 wait_for_view_load(aManager, function(aManager) {
122 info("Part 2");
123 is_in_list(aManager, "addons://list/extension");
124
125 close_manager(aManager, run_next_test);
126 });
127 }, 0);
128 });
129 });

mercurial