tor-browser

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

trusted-click.js (891B)


      1 /**
      2 * Invokes callback from a trusted click event, avoiding interception by fullscreen element.
      3 *
      4 * @param {Element} container - Element where button will be created and clicked.
      5 */
      6 function trusted_click(container = document.body) {
      7    var document = container.ownerDocument;
      8    var button = document.createElement("button");
      9    button.textContent = "click to continue test";
     10    button.style.display = "block";
     11    button.style.fontSize = "20px";
     12    button.style.padding = "10px";
     13    button.addEventListener("click", () => {
     14        button.remove();
     15    });
     16    container.appendChild(button);
     17    if (window.top !== window) test_driver.set_test_context(window.top);
     18    // Race them for manually testing...
     19    return Promise.race([
     20        test_driver.click(button),
     21        new Promise((resolve) => {
     22            button.addEventListener("click", resolve);
     23        }),
     24    ]);
     25 }