tor-browser

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

simple_navigator_clipboard_readText.html (1737B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4  <meta charset="utf-8">
      5  <!-- Required by the .js part of the test. In a more ideal world, the script
      6    could be loaded in the .js part; however, currently, that causes other
      7    problems, which would require other changes in test framework code. -->
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/paint_listener.js"></script>
     10  <script src="/tests/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js"></script>
     11  <script src="/tests/gfx/layers/apz/test/mochitest/apz_test_utils.js"></script>
     12 
     13  <script>
     14    function onLoad() {
     15      const readTextResult = document.getElementById("readTextResultId");
     16 
     17      const b1 = document.getElementById("invokeReadTextOnceId");
     18      b1.addEventListener("click", async () => {
     19        navigator.clipboard.readText().then(text => {
     20          readTextResult.textContent = "Resolved: " + text;
     21        }, () => { readTextResult.textContent = "Rejected." });
     22      });
     23 
     24      const b2 = document.getElementById("invokeReadTextTwiceId");
     25      b2.addEventListener("click", async () => {
     26        const t1 = navigator.clipboard.readText();
     27        const t2 = navigator.clipboard.readText();
     28 
     29        const r1 = await t1.then(text => {
     30          return "Resolved 1: " + text;
     31        }, () => { return "Rejected: 1";});
     32 
     33        const r2 = await t2.then(text => {
     34          return "Resolved 2: " + text;
     35        }, () => { return "Rejected: 2";});
     36 
     37        readTextResult.textContent = r1 + "; " + r2;
     38      });
     39    }
     40  </script>
     41  </head>
     42  <body onload="onLoad()">
     43   <button id="invokeReadTextOnceId">1</button>
     44   <button id="invokeReadTextTwiceId">2</button>
     45   <div id="readTextResultId"/>
     46  </body>
     47 </html>