tor-browser

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

test_double_submit.html (807B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test for multiple submissions in straightline code</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      7 </head>
      8 <body>
      9 <script>
     10 
     11 add_task(async function double_submit() {
     12  dump("test start\n");
     13  let popup = window.open("file_double_submit.html");
     14  await new Promise(resolve => {
     15    popup.addEventListener("load", resolve, {once: true})
     16  });
     17 
     18  let numCalls = 0;
     19  popup.addEventListener("beforeunload", () => {
     20    numCalls++;
     21    info("beforeunload called " + numCalls + " times");
     22  });
     23 
     24  info("clicking button");
     25  popup.document.querySelector("button").click();
     26 
     27  is(numCalls, 1, "beforeunload should only fire once");
     28  popup.close();
     29 });
     30 
     31 </script>
     32 </body>
     33 </html>