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

mercurial