tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_1008559_anchor_undo_restore.js (2937B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const kAnchorAttribute = "cui-anchorid";
      7 
      8 /**
      9 * Check that anchor gets set correctly when moving an item from the panel to the toolbar
     10 * and into the palette.
     11 */
     12 add_task(async function () {
     13  CustomizableUI.addWidgetToArea(
     14    "history-panelmenu",
     15    CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
     16  );
     17  await startCustomizing();
     18  let button = document.getElementById("history-panelmenu");
     19  is(
     20    button.getAttribute(kAnchorAttribute),
     21    "nav-bar-overflow-button",
     22    "Button (" + button.id + ") starts out with correct anchor"
     23  );
     24 
     25  let navbar = CustomizableUI.getCustomizationTarget(
     26    document.getElementById("nav-bar")
     27  );
     28  let onMouseUp = BrowserTestUtils.waitForEvent(navbar, "mouseup");
     29  simulateItemDrag(button, navbar);
     30  await onMouseUp;
     31  is(
     32    CustomizableUI.getPlacementOfWidget(button.id).area,
     33    "nav-bar",
     34    "Button (" + button.id + ") ends up in nav-bar"
     35  );
     36 
     37  ok(
     38    !button.hasAttribute(kAnchorAttribute),
     39    "Button (" + button.id + ") has no anchor in toolbar"
     40  );
     41 
     42  CustomizableUI.addWidgetToArea(
     43    "history-panelmenu",
     44    CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
     45  );
     46 
     47  is(
     48    button.getAttribute(kAnchorAttribute),
     49    "nav-bar-overflow-button",
     50    "Button (" + button.id + ") has anchor again"
     51  );
     52 
     53  let resetButton = document.getElementById("customization-reset-button");
     54  ok(!resetButton.hasAttribute("disabled"), "Should be able to reset now.");
     55  await gCustomizeMode.reset();
     56 
     57  ok(
     58    !button.hasAttribute(kAnchorAttribute),
     59    "Button (" + button.id + ") once again has no anchor in customize panel"
     60  );
     61 
     62  await endCustomizing();
     63 });
     64 
     65 /**
     66 * Check that anchor gets set correctly when moving an item from the panel to the toolbar
     67 * using 'reset'
     68 */
     69 add_task(async function () {
     70  await startCustomizing();
     71  let button = document.getElementById("stop-reload-button");
     72  ok(
     73    !button.hasAttribute(kAnchorAttribute),
     74    "Button (" + button.id + ") has no anchor in toolbar"
     75  );
     76 
     77  let panel = document.getElementById(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);
     78  let onMouseUp = BrowserTestUtils.waitForEvent(panel, "mouseup");
     79  simulateItemDrag(button, panel);
     80  await onMouseUp;
     81  is(
     82    CustomizableUI.getPlacementOfWidget(button.id).area,
     83    CustomizableUI.AREA_FIXED_OVERFLOW_PANEL,
     84    "Button (" + button.id + ") ends up in panel"
     85  );
     86  is(
     87    button.getAttribute(kAnchorAttribute),
     88    "nav-bar-overflow-button",
     89    "Button (" + button.id + ") has correct anchor in the panel"
     90  );
     91 
     92  let resetButton = document.getElementById("customization-reset-button");
     93  ok(!resetButton.hasAttribute("disabled"), "Should be able to reset now.");
     94  await gCustomizeMode.reset();
     95 
     96  ok(
     97    !button.hasAttribute(kAnchorAttribute),
     98    "Button (" + button.id + ") once again has no anchor in toolbar"
     99  );
    100 
    101  await endCustomizing();
    102 });