tor-browser

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

recursive-exec-command-calls.tentative.html (1240B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Test recursive `Document.execCommand()` calls</title>
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <div contenteditable><br></div>
      7 <script>
      8 "use strict";
      9 
     10 setup({explicit_done: true});
     11 
     12 /**
     13 * This test checks whether the browser allows or disallows recursive
     14 * Document.execCommand() calls.
     15 * https://github.com/w3c/editing/issues/200#issuecomment-578097441
     16 */
     17 function runTests() {
     18  test(function () {
     19    let editor = document.querySelector("div[contenteditable]");
     20    editor.focus();
     21    let counter = 0;
     22    editor.addEventListener("input", event => {
     23      if (++counter < 10) {
     24        let result = document.execCommand("insertText", false, `, ${counter}`);
     25        assert_false(result,
     26            '`execCommand("insertText") in the "input" event listener should return `false`');
     27      }
     28    });
     29    document.execCommand("insertText", false, "0");
     30    assert_equals(editor.textContent, "0",
     31        '`execCommand("insertText") in the "input" event listener should do nothing');
     32  }, "Recursive `Document.execCommand()` shouldn't be supported");
     33  done();
     34 }
     35 
     36 window.addEventListener("load", runTests, {once: true});
     37 </script>