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.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/
     3  */
     5 /**
     6  * Tests that double-click does not go to detail view if the target is a link or button.
     7  */
     9 function test() {
    10   requestLongerTimeout(2);
    12   waitForExplicitFinish();
    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   }]);
    22   run_next_test();
    23 }
    25 function end_test() {
    26   finish();
    27 }
    29 function is_in_list(aManager, view) {
    30   var doc = aManager.document;
    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 }
    36 function is_in_detail(aManager, view) {
    37   var doc = aManager.document;
    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 }
    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");
    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);
    54     wait_for_view_load(aManager, function(aManager) {
    55       info("Part 2");
    56       is_in_detail(aManager, "addons://list/extension");
    58       close_manager(aManager, run_next_test);
    59     });
    60   });
    61 });
    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");
    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     );
    83     wait_for_view_load(aManager, function(aManager) {
    84       info("Part 2");
    85       is_in_list(aManager, "addons://list/extension");
    87       close_manager(aManager, run_next_test);
    88     });
    89   });
    90 });
    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");
    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     );
   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();
   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       );
   121       wait_for_view_load(aManager, function(aManager) {
   122         info("Part 2");
   123         is_in_list(aManager, "addons://list/extension");
   125         close_manager(aManager, run_next_test);
   126       });
   127     }, 0);
   128   });
   129 });

mercurial