tor-browser

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

accessibility.js (6629B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 const protocol = require("resource://devtools/shared/protocol.js");
      8 const { Arg, generateActorSpec, RetVal, types } = protocol;
      9 
     10 types.addActorType("accessible");
     11 
     12 /**
     13 * Accessible with children listed in the ancestry structure calculated by the
     14 * walker.
     15 */
     16 types.addDictType("accessibleWithChildren", {
     17  // Accessible
     18  accessible: "accessible",
     19  // Accessible's children
     20  children: "array:accessible",
     21 });
     22 
     23 /**
     24 * Data passed via "audit-event" to the client. It may include type, a list of
     25 * ancestries for accessible actors that have failing accessibility checks or
     26 * a progress information.
     27 */
     28 types.addDictType("auditEventData", {
     29  type: "string",
     30  // List of ancestries (array:accessibleWithChildren)
     31  ancestries: "nullable:array:array:accessibleWithChildren",
     32  // Audit progress information
     33  progress: "nullable:json",
     34 });
     35 
     36 /**
     37 * Accessible relation object described by its type that also includes relation targets.
     38 */
     39 types.addDictType("accessibleRelation", {
     40  // Accessible relation type
     41  type: "string",
     42  // Accessible relation's targets
     43  targets: "array:accessible",
     44 });
     45 
     46 const accessibleSpec = generateActorSpec({
     47  typeName: "accessible",
     48 
     49  events: {
     50    "actions-change": {
     51      type: "actionsChange",
     52      actions: Arg(0, "array:string"),
     53    },
     54    "name-change": {
     55      type: "nameChange",
     56      name: Arg(0, "string"),
     57      parent: Arg(1, "nullable:accessible"),
     58    },
     59    "value-change": {
     60      type: "valueChange",
     61      value: Arg(0, "string"),
     62    },
     63    "description-change": {
     64      type: "descriptionChange",
     65      description: Arg(0, "string"),
     66    },
     67    "states-change": {
     68      type: "statesChange",
     69      states: Arg(0, "array:string"),
     70    },
     71    "attributes-change": {
     72      type: "attributesChange",
     73      attributes: Arg(0, "json"),
     74    },
     75    "shortcut-change": {
     76      type: "shortcutChange",
     77      shortcut: Arg(0, "string"),
     78    },
     79    reorder: {
     80      type: "reorder",
     81      childCount: Arg(0, "number"),
     82    },
     83    "text-change": {
     84      type: "textChange",
     85    },
     86    "index-in-parent-change": {
     87      type: "indexInParentChange",
     88      indexInParent: Arg(0, "number"),
     89    },
     90    audited: {
     91      type: "audited",
     92      audit: Arg(0, "nullable:json"),
     93    },
     94  },
     95 
     96  methods: {
     97    audit: {
     98      request: { options: Arg(0, "nullable:json") },
     99      response: {
    100        audit: RetVal("nullable:json"),
    101      },
    102    },
    103    children: {
    104      request: {},
    105      response: {
    106        children: RetVal("array:accessible"),
    107      },
    108    },
    109    getRelations: {
    110      request: {},
    111      response: {
    112        relations: RetVal("array:accessibleRelation"),
    113      },
    114    },
    115    hydrate: {
    116      request: {},
    117      response: {
    118        properties: RetVal("json"),
    119      },
    120    },
    121    snapshot: {
    122      request: {},
    123      response: {
    124        snapshot: RetVal("json"),
    125      },
    126    },
    127  },
    128 });
    129 
    130 const accessibleWalkerSpec = generateActorSpec({
    131  typeName: "accessiblewalker",
    132 
    133  events: {
    134    "document-ready": {
    135      type: "documentReady",
    136    },
    137    "picker-accessible-picked": {
    138      type: "pickerAccessiblePicked",
    139      accessible: Arg(0, "nullable:accessible"),
    140    },
    141    "picker-accessible-previewed": {
    142      type: "pickerAccessiblePreviewed",
    143      accessible: Arg(0, "nullable:accessible"),
    144    },
    145    "picker-accessible-hovered": {
    146      type: "pickerAccessibleHovered",
    147      accessible: Arg(0, "nullable:accessible"),
    148    },
    149    "picker-accessible-canceled": {
    150      type: "pickerAccessibleCanceled",
    151    },
    152    "highlighter-event": {
    153      type: "highlighter-event",
    154      data: Arg(0, "json"),
    155    },
    156    "audit-event": {
    157      type: "audit-event",
    158      audit: Arg(0, "auditEventData"),
    159    },
    160  },
    161 
    162  methods: {
    163    children: {
    164      request: {},
    165      response: {
    166        children: RetVal("array:accessible"),
    167      },
    168    },
    169    getAccessibleFor: {
    170      request: { node: Arg(0, "domnode") },
    171      response: {
    172        accessible: RetVal("nullable:accessible"),
    173      },
    174    },
    175    getAncestry: {
    176      request: { accessible: Arg(0, "accessible") },
    177      response: {
    178        ancestry: RetVal("array:accessibleWithChildren"),
    179      },
    180    },
    181    startAudit: {
    182      request: { options: Arg(0, "nullable:json") },
    183    },
    184    highlightAccessible: {
    185      request: {
    186        accessible: Arg(0, "accessible"),
    187        options: Arg(1, "nullable:json"),
    188      },
    189      response: {
    190        value: RetVal("nullable:boolean"),
    191      },
    192    },
    193    unhighlight: {
    194      request: {},
    195    },
    196    pick: {},
    197    pickAndFocus: {},
    198    cancelPick: {},
    199    showTabbingOrder: {
    200      request: {
    201        elm: Arg(0, "domnode"),
    202        index: Arg(1, "number"),
    203      },
    204      response: {
    205        tabbingOrderInfo: RetVal("json"),
    206      },
    207    },
    208    hideTabbingOrder() {},
    209  },
    210 });
    211 
    212 const simulatorSpec = generateActorSpec({
    213  typeName: "simulator",
    214 
    215  methods: {
    216    simulate: {
    217      request: { options: Arg(0, "nullable:json") },
    218      response: {
    219        value: RetVal("boolean"),
    220      },
    221    },
    222  },
    223 });
    224 
    225 const accessibilitySpec = generateActorSpec({
    226  typeName: "accessibility",
    227 
    228  events: {
    229    init: {
    230      type: "init",
    231    },
    232    shutdown: {
    233      type: "shutdown",
    234    },
    235  },
    236 
    237  methods: {
    238    getTraits: {
    239      request: {},
    240      response: { traits: RetVal("json") },
    241    },
    242    bootstrap: {
    243      request: {},
    244      response: {
    245        state: RetVal("json"),
    246      },
    247    },
    248    getWalker: {
    249      request: {},
    250      response: {
    251        walker: RetVal("accessiblewalker"),
    252      },
    253    },
    254    getSimulator: {
    255      request: {},
    256      response: {
    257        simulator: RetVal("nullable:simulator"),
    258      },
    259    },
    260  },
    261 });
    262 
    263 const parentAccessibilitySpec = generateActorSpec({
    264  typeName: "parentaccessibility",
    265 
    266  events: {
    267    "can-be-disabled-change": {
    268      type: "canBeDisabledChange",
    269      canBeDisabled: Arg(0, "boolean"),
    270    },
    271    "can-be-enabled-change": {
    272      type: "canBeEnabledChange",
    273      canBeEnabled: Arg(0, "boolean"),
    274    },
    275  },
    276 
    277  methods: {
    278    bootstrap: {
    279      request: {},
    280      response: {
    281        state: RetVal("json"),
    282      },
    283    },
    284    enable: {
    285      request: {},
    286      response: {},
    287    },
    288    disable: {
    289      request: {},
    290      response: {},
    291    },
    292  },
    293 });
    294 
    295 exports.accessibleSpec = accessibleSpec;
    296 exports.accessibleWalkerSpec = accessibleWalkerSpec;
    297 exports.accessibilitySpec = accessibilitySpec;
    298 exports.parentAccessibilitySpec = parentAccessibilitySpec;
    299 exports.simulatorSpec = simulatorSpec;