diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-11 07:03:16 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-11 07:03:16 -0500 |
commit | 203eb0f61a09372310a2a8fb57e169cb3f47800b (patch) | |
tree | 8490329d3dae4de3c7ffd127bce1f65fdc009abd /toolkit/mozapps/extensions/test/browser/browser_bug562854.js | |
parent | e45706ca3acbb6530419433212becc61d5953a2d (diff) | |
parent | 8f6d3dab81c7f8f97ef197e26ab9439b09735b8f (diff) | |
download | UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar.gz UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar.lz UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar.xz UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.zip |
Merge branch 'ext-work'FF_Checkpoint_1
Diffstat (limited to 'toolkit/mozapps/extensions/test/browser/browser_bug562854.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/browser/browser_bug562854.js | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug562854.js b/toolkit/mozapps/extensions/test/browser/browser_bug562854.js new file mode 100644 index 000000000..4c06cebb7 --- /dev/null +++ b/toolkit/mozapps/extensions/test/browser/browser_bug562854.js @@ -0,0 +1,129 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/** + * Tests that double-click does not go to detail view if the target is a link or button. + */ + +function test() { + requestLongerTimeout(2); + + waitForExplicitFinish(); + + var gProvider = new MockProvider(); + gProvider.createAddons([{ + id: "test1@tests.mozilla.org", + name: "Test add-on 1", + description: "foo", + operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE + }]); + + run_next_test(); +} + +function end_test() { + finish(); +} + +function is_in_list(aManager, view) { + var doc = aManager.document; + + is(doc.getElementById("categories").selectedItem.value, view, "Should be on the right category"); + is(doc.getElementById("view-port").selectedPanel.id, "list-view", "Should be on the right view"); +} + +function is_in_detail(aManager, view) { + var doc = aManager.document; + + is(doc.getElementById("categories").selectedItem.value, view, "Should be on the right category"); + is(doc.getElementById("view-port").selectedPanel.id, "detail-view", "Should be on the right view"); +} + +// Check that double-click does something. +add_test(function() { + open_manager("addons://list/extension", function(aManager) { + info("Part 1"); + is_in_list(aManager, "addons://list/extension"); + + var addon = get_addon_element(aManager, "test1@tests.mozilla.org"); + addon.parentNode.ensureElementIsVisible(addon); + EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 1 }, aManager); + EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 2 }, aManager); + + wait_for_view_load(aManager, function(aManager) { + info("Part 2"); + is_in_detail(aManager, "addons://list/extension"); + + close_manager(aManager, run_next_test); + }); + }); +}); + +// Check that double-click does nothing when over the disable button. +add_test(function() { + open_manager("addons://list/extension", function(aManager) { + info("Part 1"); + is_in_list(aManager, "addons://list/extension"); + + var addon = get_addon_element(aManager, "test1@tests.mozilla.org"); + addon.parentNode.ensureElementIsVisible(addon); + EventUtils.synthesizeMouseAtCenter( + aManager.document.getAnonymousElementByAttribute(addon, "anonid", "disable-btn"), + { clickCount: 1 }, + aManager + ); + // The disable button is replaced by the enable button when clicked on. + EventUtils.synthesizeMouseAtCenter( + aManager.document.getAnonymousElementByAttribute(addon, "anonid", "enable-btn"), + { clickCount: 2 }, + aManager + ); + + wait_for_view_load(aManager, function(aManager) { + info("Part 2"); + is_in_list(aManager, "addons://list/extension"); + + close_manager(aManager, run_next_test); + }); + }); +}); + +// Check that double-click does nothing when over the undo button. +add_test(function() { + open_manager("addons://list/extension", function(aManager) { + info("Part 1"); + is_in_list(aManager, "addons://list/extension"); + + var addon = get_addon_element(aManager, "test1@tests.mozilla.org"); + addon.parentNode.ensureElementIsVisible(addon); + EventUtils.synthesizeMouseAtCenter( + aManager.document.getAnonymousElementByAttribute(addon, "anonid", "remove-btn"), + { clickCount: 1 }, + aManager + ); + + // The undo button is removed when clicked on. + // We need to wait for the UI to catch up. + setTimeout(function() { + var target = aManager.document.getAnonymousElementByAttribute(addon, "anonid", "undo-btn"); + var rect = target.getBoundingClientRect(); + var addonRect = addon.getBoundingClientRect(); + + EventUtils.synthesizeMouse(target, rect.width / 2, rect.height / 2, { clickCount: 1 }, aManager); + EventUtils.synthesizeMouse(addon, + rect.left - addonRect.left + rect.width / 2, + rect.top - addonRect.top + rect.height / 2, + { clickCount: 2 }, + aManager + ); + + wait_for_view_load(aManager, function(aManager) { + info("Part 2"); + is_in_list(aManager, "addons://list/extension"); + + close_manager(aManager, run_next_test); + }); + }, 0); + }); +}); |