diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-10 02:51:36 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-10 02:51:36 -0500 |
commit | 37d5300335d81cecbecc99812747a657588c63eb (patch) | |
tree | 765efa3b6a56bb715d9813a8697473e120436278 /toolkit/mozapps/webextensions/test/browser/browser_bug562854.js | |
parent | b2bdac20c02b12f2057b9ef70b0a946113a00e00 (diff) | |
parent | 4fb11cd5966461bccc3ed1599b808237be6b0de9 (diff) | |
download | UXP-37d5300335d81cecbecc99812747a657588c63eb.tar UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.gz UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.lz UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.xz UXP-37d5300335d81cecbecc99812747a657588c63eb.zip |
Merge branch 'ext-work'
Diffstat (limited to 'toolkit/mozapps/webextensions/test/browser/browser_bug562854.js')
-rw-r--r-- | toolkit/mozapps/webextensions/test/browser/browser_bug562854.js | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/toolkit/mozapps/webextensions/test/browser/browser_bug562854.js b/toolkit/mozapps/webextensions/test/browser/browser_bug562854.js new file mode 100644 index 000000000..53e890b71 --- /dev/null +++ b/toolkit/mozapps/webextensions/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(get_current_view(aManager).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(get_current_view(aManager).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); + }); +}); |