tor-browser

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

browser_removeManySpellingErrors.js (9875B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // XXX: We can consolidate this once bug 1930955 lands
      7 // eslint-disable-next-line no-unused-vars
      8 const perfMetadata = {
      9  owner: "Accessibility Team",
     10  name: "browser_removeManySpellingErrors.js",
     11  description:
     12    "Audit a11y performance when removing 500 spelling errors from content editable.",
     13  options: {
     14    default: {
     15      extra_args: ["headless"],
     16      manifest: "perftest.toml",
     17      manifest_flavor: "browser-chrome",
     18      perfherder: true,
     19      perfherder_metrics: [
     20        // Total time for the entire run (this probe is not process specific)
     21        { name: "A11Y_TotalTime", unit: "ms", shouldAlert: true },
     22 
     23        //////////////// PARENT PROCESS
     24 
     25        // Timing metrics
     26        { name: "A11Y_DoInitialUpdate_parent", unit: "ms", shouldAlert: false },
     27        {
     28          name: "A11Y_ProcessQueuedCacheUpdate_parent",
     29          unit: "ms",
     30          shouldAlert: false,
     31        },
     32        {
     33          name: "A11Y_ContentRemovedNode_parent",
     34          unit: "ms",
     35          shouldAlert: false,
     36        },
     37        {
     38          name: "A11Y_ContentRemovedAcc_parent",
     39          unit: "ms",
     40          shouldAlert: false,
     41        },
     42        {
     43          name: "A11Y_PruneOrInsertSubtree_parent",
     44          unit: "ms",
     45          shouldAlert: false,
     46        },
     47        {
     48          name: "A11Y_ShutdownChildrenInSubtree_parent",
     49          unit: "ms",
     50          shouldAlert: false,
     51        },
     52        { name: "A11Y_ShowEvent_parent", unit: "ms", shouldAlert: false },
     53        { name: "A11Y_RecvCache_parent", unit: "ms", shouldAlert: false },
     54        {
     55          name: "A11Y_ProcessShowEvent_parent",
     56          unit: "ms",
     57          shouldAlert: false,
     58        },
     59        { name: "A11Y_CoalesceEvents_parent", unit: "ms", shouldAlert: false },
     60        {
     61          name: "A11Y_CoalesceMutationEvents_parent",
     62          unit: "ms",
     63          shouldAlert: false,
     64        },
     65        {
     66          name: "A11Y_ProcessHideEvent_parent",
     67          unit: "ms",
     68          shouldAlert: false,
     69        },
     70        { name: "A11Y_SendCache_parent", unit: "ms", shouldAlert: false },
     71        { name: "A11Y_WillRefresh_parent", unit: "ms", shouldAlert: false },
     72        {
     73          name: "A11Y_AccessibilityServiceInit_parent",
     74          unit: "ms",
     75          shouldAlert: false,
     76        },
     77        {
     78          name: "A11Y_PlatformShowHideEvent_parent",
     79          unit: "ms",
     80          shouldAlert: false,
     81        },
     82        // Occurrance metrics
     83        {
     84          name: "A11Y_DoInitialUpdate_Count_parent",
     85          unit: "iterations",
     86          shouldAlert: false,
     87        },
     88        {
     89          name: "A11Y_ProcessQueuedCacheUpdate_Count_parent",
     90          unit: "iterations",
     91          shouldAlert: false,
     92        },
     93        {
     94          name: "A11Y_ContentRemovedNode_Count_parent",
     95          unit: "iterations",
     96          shouldAlert: false,
     97        },
     98        {
     99          name: "A11Y_ContentRemovedAcc_Count_parent",
    100          unit: "iterations",
    101          shouldAlert: false,
    102        },
    103        {
    104          name: "A11Y_PruneOrInsertSubtree_Count_parent",
    105          unit: "iterations",
    106          shouldAlert: false,
    107        },
    108        {
    109          name: "A11Y_ShutdownChildrenInSubtree_Count_parent",
    110          unit: "iterations",
    111          shouldAlert: false,
    112        },
    113        {
    114          name: "A11Y_ShowEvent_Count_parent",
    115          unit: "iterations",
    116          shouldAlert: false,
    117        },
    118        {
    119          name: "A11Y_RecvCache_Count_parent",
    120          unit: "iterations",
    121          shouldAlert: false,
    122        },
    123        {
    124          name: "A11Y_ProcessShowEvent_Count_parent",
    125          unit: "iterations",
    126          shouldAlert: false,
    127        },
    128        {
    129          name: "A11Y_CoalesceEvents_Count_parent",
    130          unit: "iterations",
    131          shouldAlert: false,
    132        },
    133        {
    134          name: "A11Y_CoalesceMutationEvents_Count_parent",
    135          unit: "iterations",
    136          shouldAlert: false,
    137        },
    138        {
    139          name: "A11Y_ProcessHideEvent_Count_parent",
    140          unit: "iterations",
    141          shouldAlert: false,
    142        },
    143        {
    144          name: "A11Y_SendCache_Count_parent",
    145          unit: "iterations",
    146          shouldAlert: false,
    147        },
    148        {
    149          name: "A11Y_WillRefresh_Count_parent",
    150          unit: "iterations",
    151          shouldAlert: false,
    152        },
    153        {
    154          name: "A11Y_AccessibilityServiceInit_Count_parent",
    155          unit: "iterations",
    156          shouldAlert: false,
    157        },
    158        {
    159          name: "A11Y_PlatformShowHideEvent_Count_parent",
    160          unit: "iterations",
    161          shouldAlert: false,
    162        },
    163 
    164        //////////////// CONTENT PROCESS
    165 
    166        // Timing metrics
    167        {
    168          name: "A11Y_DoInitialUpdate_content",
    169          unit: "ms",
    170          shouldAlert: false,
    171        },
    172        {
    173          name: "A11Y_ProcessQueuedCacheUpdate_content",
    174          unit: "ms",
    175          shouldAlert: false,
    176        },
    177        {
    178          name: "A11Y_ContentRemovedNode_content",
    179          unit: "ms",
    180          shouldAlert: false,
    181        },
    182        {
    183          name: "A11Y_ContentRemovedAcc_content",
    184          unit: "ms",
    185          shouldAlert: false,
    186        },
    187        {
    188          name: "A11Y_PruneOrInsertSubtree_content",
    189          unit: "ms",
    190          shouldAlert: false,
    191        },
    192        {
    193          name: "A11Y_ShutdownChildrenInSubtree_content",
    194          unit: "ms",
    195          shouldAlert: false,
    196        },
    197        { name: "A11Y_ShowEvent_content", unit: "ms", shouldAlert: false },
    198        { name: "A11Y_RecvCache_content", unit: "ms", shouldAlert: false },
    199        {
    200          name: "A11Y_ProcessShowEvent_content",
    201          unit: "ms",
    202          shouldAlert: false,
    203        },
    204        { name: "A11Y_CoalesceEvents_content", unit: "ms", shouldAlert: false },
    205        {
    206          name: "A11Y_CoalesceMutationEvents_content",
    207          unit: "ms",
    208          shouldAlert: false,
    209        },
    210        {
    211          name: "A11Y_ProcessHideEvent_content",
    212          unit: "ms",
    213          shouldAlert: false,
    214        },
    215        { name: "A11Y_SendCache_content", unit: "ms", shouldAlert: false },
    216        { name: "A11Y_WillRefresh_content", unit: "ms", shouldAlert: false },
    217        {
    218          name: "A11Y_AccessibilityServiceInit_content",
    219          unit: "ms",
    220          shouldAlert: false,
    221        },
    222        {
    223          name: "A11Y_PlatformShowHideEvent_content",
    224          unit: "ms",
    225          shouldAlert: false,
    226        },
    227        // Occurrance metrics
    228        {
    229          name: "A11Y_DoInitialUpdate_Count_content",
    230          unit: "iterations",
    231          shouldAlert: false,
    232        },
    233        {
    234          name: "A11Y_ProcessQueuedCacheUpdate_Count_content",
    235          unit: "iterations",
    236          shouldAlert: false,
    237        },
    238        {
    239          name: "A11Y_ContentRemovedNode_Count_content",
    240          unit: "iterations",
    241          shouldAlert: false,
    242        },
    243        {
    244          name: "A11Y_ContentRemovedAcc_Count_content",
    245          unit: "iterations",
    246          shouldAlert: false,
    247        },
    248        {
    249          name: "A11Y_PruneOrInsertSubtree_Count_content",
    250          unit: "iterations",
    251          shouldAlert: false,
    252        },
    253        {
    254          name: "A11Y_ShutdownChildrenInSubtree_Count_content",
    255          unit: "iterations",
    256          shouldAlert: false,
    257        },
    258        {
    259          name: "A11Y_ShowEvent_Count_content",
    260          unit: "iterations",
    261          shouldAlert: false,
    262        },
    263        {
    264          name: "A11Y_RecvCache_Count_content",
    265          unit: "iterations",
    266          shouldAlert: false,
    267        },
    268        {
    269          name: "A11Y_ProcessShowEvent_Count_content",
    270          unit: "iterations",
    271          shouldAlert: false,
    272        },
    273        {
    274          name: "A11Y_CoalesceEvents_Count_content",
    275          unit: "iterations",
    276          shouldAlert: false,
    277        },
    278        {
    279          name: "A11Y_CoalesceMutationEvents_Count_content",
    280          unit: "iterations",
    281          shouldAlert: false,
    282        },
    283        {
    284          name: "A11Y_ProcessHideEvent_Count_content",
    285          unit: "iterations",
    286          shouldAlert: false,
    287        },
    288        {
    289          name: "A11Y_SendCache_Count_content",
    290          unit: "iterations",
    291          shouldAlert: false,
    292        },
    293        {
    294          name: "A11Y_WillRefresh_Count_content",
    295          unit: "iterations",
    296          shouldAlert: false,
    297        },
    298        {
    299          name: "A11Y_AccessibilityServiceInit_Count_content",
    300          unit: "iterations",
    301          shouldAlert: false,
    302        },
    303        {
    304          name: "A11Y_PlatformShowHideEvent_Count_content",
    305          unit: "iterations",
    306          shouldAlert: false,
    307        },
    308      ],
    309      try_platform: ["linux", "mac", "win"],
    310      verbose: true,
    311    },
    312  },
    313 };
    314 
    315 addAccessibleTask(
    316  `<div id="editable" contenteditable></div>`,
    317  async function testRemoveManySpellingErrors(browser) {
    318    let changed = waitForEvent(EVENT_TEXT_ATTRIBUTE_CHANGED);
    319    await invokeContentTask(browser, [], () => {
    320      const editable = content.document.getElementById("editable");
    321      for (let i = 0; i < 500; ++i) {
    322        const p = content.document.createElement("p");
    323        p.textContent = "tset tset tset";
    324        editable.append(p);
    325      }
    326      editable.focus();
    327    });
    328    // Spell checking is async, so we need to wait for it to happen.
    329    info("Waiting for spell check");
    330    await changed;
    331    await timeThis(async () => {
    332      info("Removing all content from editable");
    333      let reorder = waitForEvent(EVENT_REORDER, "editable");
    334      await invokeContentTask(browser, [], () => {
    335        content.document.getElementById("editable").innerHTML = "";
    336      });
    337      info("Waiting for reorder event");
    338      await reorder;
    339    });
    340  }
    341 );