tor-browser

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

browser_resize_cancel.js (964B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test that pressing Escape after changing the width or height will revert the change.
      7 
      8 const TEST_URL = "data:text/html;charset=utf-8,";
      9 
     10 addRDMTask(TEST_URL, async function ({ ui }) {
     11  const [widthInput, heightInput] = ui.toolWindow.document.querySelectorAll(
     12    ".text-input.viewport-dimension-input"
     13  );
     14  checkInputCancel(ui, widthInput);
     15  checkInputCancel(ui, heightInput);
     16 });
     17 
     18 function checkInputCancel(ui, input) {
     19  const { Simulate } = ui.toolWindow.require(
     20    "resource://devtools/client/shared/vendor/react-dom-test-utils.js"
     21  );
     22  const value = parseInt(input.value, 10);
     23 
     24  input.focus();
     25  input.value = value + 100;
     26  Simulate.change(input);
     27  EventUtils.synthesizeKey("KEY_Escape", {}, ui.toolWindow);
     28 
     29  is(
     30    parseInt(input.value, 10),
     31    value,
     32    "Input value should be reverted after canceling edit."
     33  );
     34 }