tor-browser

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

browser_markup_keybindings_01.js (1585B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 requestLongerTimeout(2);
      7 
      8 // Tests tabbing through attributes on a node
      9 
     10 const TEST_URL = "data:text/html;charset=utf8,<div id='test' a b c d e></div>";
     11 
     12 add_task(async function () {
     13  const { inspector } = await openInspectorForURL(TEST_URL);
     14 
     15  info("Focusing the tag editor of the test element");
     16  const { editor } = await focusNode("div", inspector);
     17  editor.tag.focus();
     18 
     19  info("Pressing tab and expecting to focus the ID attribute, always first");
     20  EventUtils.sendKey("tab", inspector.panelWin);
     21  checkFocusedAttribute("id");
     22 
     23  info("Hit enter to turn the attribute to edit mode");
     24  EventUtils.sendKey("return", inspector.panelWin);
     25  checkFocusedAttribute("id", true);
     26 
     27  // Check the order of the other attributes in the DOM to the check they appear
     28  // correctly in the markup-view
     29  const attributes = (await getAttributesFromEditor("div", inspector)).slice(1);
     30 
     31  info("Tabbing forward through attributes in edit mode");
     32  for (const attribute of attributes) {
     33    collapseSelectionAndTab(inspector);
     34    checkFocusedAttribute(attribute, true);
     35  }
     36 
     37  info("Tabbing backward through attributes in edit mode");
     38 
     39  // Just reverse the attributes other than id and remove the first one since
     40  // it's already focused now.
     41  const reverseAttributes = attributes.reverse();
     42  reverseAttributes.shift();
     43 
     44  for (const attribute of reverseAttributes) {
     45    collapseSelectionAndShiftTab(inspector);
     46    checkFocusedAttribute(attribute, true);
     47  }
     48 });