test_cache_untrusted.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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>Test Cache with QuotaManager Restart</title>
  7. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  8. <script type="text/javascript" src="large_url_list.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  10. </head>
  11. <body>
  12. <script class="testbody" type="text/javascript">
  13. function setupTestIframe() {
  14. return new Promise(function(resolve) {
  15. var iframe = document.createElement("iframe");
  16. iframe.src = "empty.html";
  17. iframe.onload = function() {
  18. window.caches = iframe.contentWindow.caches;
  19. resolve();
  20. };
  21. document.body.appendChild(iframe);
  22. });
  23. }
  24. SimpleTest.waitForExplicitFinish();
  25. SpecialPowers.pushPrefEnv({
  26. "set": [["dom.caches.enabled", true]],
  27. }, function() {
  28. setupTestIframe().then(function() {
  29. return caches.open('foo');
  30. }).then(function(usage) {
  31. ok(false, 'caches should not be usable in untrusted http origin');
  32. }).catch(function(err) {
  33. is(err.name, 'SecurityError', 'caches should reject with SecurityError');
  34. SimpleTest.finish();
  35. });
  36. });
  37. </script>
  38. </body>
  39. </html>