tor-browser

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

browser_jsterm_autocomplete_paste_undo.js (1989B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const TEST_URI =
      7  "data:text/html;charset=utf-8,<!DOCTYPE html><p>test for bug 642615</p>";
      8 
      9 XPCOMUtils.defineLazyServiceGetter(
     10  this,
     11  "clipboardHelper",
     12  "@mozilla.org/widget/clipboardhelper;1",
     13  Ci.nsIClipboardHelper
     14 );
     15 const stringToCopy = "foobazbarBug642615";
     16 
     17 add_task(async function () {
     18  await pushPref("devtools.selfxss.count", 5);
     19 
     20  const hud = await openNewTabAndConsole(TEST_URI);
     21  const { jsterm } = hud;
     22  await clearOutput(hud);
     23  ok(!getInputCompletionValue(hud), "no completeNode.value");
     24 
     25  setInputValue(hud, "doc");
     26 
     27  info("wait for completion value after typing 'docu'");
     28  let onAutocompleteUpdated = jsterm.once("autocomplete-updated");
     29  EventUtils.sendString("u");
     30  await onAutocompleteUpdated;
     31 
     32  const completionValue = getInputCompletionValue(hud);
     33 
     34  info(`Copy "${stringToCopy}" in clipboard`);
     35  await waitForClipboardPromise(
     36    () => clipboardHelper.copyString(stringToCopy),
     37    stringToCopy
     38  );
     39 
     40  setInputValue(hud, "docu");
     41  info("wait for completion update after clipboard paste");
     42  onAutocompleteUpdated = jsterm.once("autocomplete-updated");
     43  EventUtils.synthesizeKey("v", { accelKey: true });
     44 
     45  await onAutocompleteUpdated;
     46 
     47  ok(!getInputCompletionValue(hud), "no completion value after paste");
     48 
     49  info("wait for completion update after undo");
     50  onAutocompleteUpdated = jsterm.once("autocomplete-updated");
     51 
     52  EventUtils.synthesizeKey("z", { accelKey: true });
     53 
     54  await onAutocompleteUpdated;
     55 
     56  checkInputCompletionValue(
     57    hud,
     58    completionValue,
     59    "same completeNode.value after undo"
     60  );
     61 
     62  info("wait for completion update after clipboard paste (ctrl-v)");
     63  onAutocompleteUpdated = jsterm.once("autocomplete-updated");
     64 
     65  EventUtils.synthesizeKey("v", { accelKey: true });
     66 
     67  await onAutocompleteUpdated;
     68  ok(!getInputCompletionValue(hud), "no completion value after paste (ctrl-v)");
     69 });