tor-browser

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

test_indexedDB.html (1552B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Bug 1188750 - WebCrypto must ensure NSS is initialized before deserializing</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"?>
      8 </head>
      9 <body>
     10  <script type="application/javascript">
     11    /*
     12     * Bug 1188750 - The WebCrypto API must ensure that NSS was initialized
     13     * for the current process before trying to deserialize objects like
     14     * CryptoKeys from e.g. IndexedDB.
     15     */
     16    "use strict";
     17 
     18    const TEST_URI = "https://example.com/tests/" +
     19                     "dom/crypto/test/file_indexedDB.html";
     20 
     21    function createFrame() {
     22      let frame = document.createElement("iframe");
     23      frame.src = TEST_URI;
     24 
     25      return new Promise(resolve => {
     26        addEventListener("message", event => {
     27          is(event.source.frameElement, frame,
     28             "Message must come from the correct iframe");
     29          resolve([frame, event.data]);
     30        }, { once: true });
     31 
     32        document.body.appendChild(frame);
     33      });
     34    }
     35 
     36    add_task(async function() {
     37      // Load the test app once, to generate and store keys.
     38      let [frame, result] = await createFrame();
     39      is(result, "ok", "stored keys successfully");
     40      frame.remove();
     41 
     42      // Load the test app again to retrieve stored keys.
     43      let [recFrame, recResult] = await createFrame();
     44      is(recResult, "ok", "retrieved keys successfully");
     45      recFrame.remove();
     46    });
     47  </script>
     48 </body>
     49 </html>