tor-browser

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

forms_xorigin.html (2238B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <meta charset="utf-8" />
      5    <title>Forms</title>
      6    <meta name="viewport" content="minimum-scale=1,width=device-width" />
      7  </head>
      8  <body>
      9    <form id="form1">
     10      <input type="text" id="user1" value="foo" />
     11      <input type="password" id="pass1" value="foo" />
     12      <input type="email" id="email1" value="@" />
     13      <input type="number" id="number1" value="0" />
     14      <input type="tel" id="tel1" value="0" />
     15      <input type="submit" value="submit" />
     16    </form>
     17    <input type="Text" id="user2" value="foo" />
     18    <input type="PassWord" id="pass2" maxlength="8" value="foo" />
     19    <input type="button" id="button1" value="foo" />
     20    <input type="checkbox" id="checkbox1" />
     21    <input type="search" id="search1" />
     22    <input type="url" id="url1" />
     23    <input type="hidden" id="hidden1" value="foo" />
     24 
     25    <iframe
     26      id="iframe"
     27      src="http://example.org/tests/junit/forms_iframe.html"
     28    ></iframe>
     29  </body>
     30  <script>
     31    const params = new URL(document.location).searchParams;
     32    const iframe = document.getElementById("iframe").contentWindow;
     33 
     34    function getEventInterface(event) {
     35      if (event instanceof document.defaultView.InputEvent) {
     36        return "InputEvent";
     37      }
     38      if (event instanceof document.defaultView.UIEvent) {
     39        return "UIEvent";
     40      }
     41      if (event instanceof document.defaultView.Event) {
     42        return "Event";
     43      }
     44      return "Unknown";
     45    }
     46 
     47    function getData(key, value) {
     48      return new Promise(resolve =>
     49        document.querySelector(key).addEventListener(
     50          "input",
     51          event => {
     52            resolve([key, event.target.value, value, getEventInterface(event)]);
     53          },
     54          { once: true }
     55        )
     56      );
     57    }
     58 
     59    window.getDataForAllFrames = function (key, value) {
     60      const data = [];
     61      data.push(
     62        new Promise(resolve =>
     63          window.addEventListener(
     64            "message",
     65            event => {
     66              resolve(event.data);
     67            },
     68            { once: true }
     69          )
     70        )
     71      );
     72      iframe.postMessage({ key, value }, "*");
     73      data.push(getData(key, value));
     74      return Promise.all(data);
     75    };
     76  </script>
     77 </html>