tor-browser

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

test_chrome_constructor.html (1472B)


      1 <!-- Any copyright is dedicated to the Public Domain.
      2   - http://creativecommons.org/publicdomain/zero/1.0/ -->
      3 <!DOCTYPE HTML>
      4 <html>
      5 <head>
      6  <title>Validate Interfaces Exposed to Workers</title>
      7  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      9 </head>
     10 <body>
     11 <script class="testbody" type="text/javascript">
     12  SimpleTest.waitForExplicitFinish();
     13 
     14  SpecialPowers.pushPrefEnv({
     15    "set": [[ "dom.caches.testing.enabled", true ]],
     16  }, function() {
     17    // attach to a different origin's CacheStorage
     18    var url = "https://example.com/";
     19    var storage = SpecialPowers.createChromeCache("content", url);
     20 
     21    // verify we can use the other origin's CacheStorage as normal
     22    var req = new Request("https://example.com/index.html");
     23    var res = new Response("hello world");
     24    var cache;
     25    storage.open("foo").then(function(c) {
     26      cache = c;
     27      ok(cache, "storage should create cache");
     28      return cache.put(req, res.clone());
     29    }).then(function() {
     30      return cache.match(req);
     31    }).then(function(foundResponse) {
     32      return Promise.all([res.text(), foundResponse.text()]);
     33    }).then(function(results) {
     34      is(results[0], results[1], "cache should contain response");
     35      return storage.delete("foo");
     36    }).then(function(deleted) {
     37      ok(deleted, "storage should delete cache");
     38      SimpleTest.finish();
     39    });
     40  });
     41 </script>
     42 </body>
     43 </html>