TestController should clear all fetch caches when resetting its state
[WebKit-https.git] / LayoutTests / http / tests / cache-storage / cache-clearing-all.https.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Cache Storage: testing Cache persistency</title>
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 </head>
8 <body>
9     <script>
10 promise_test(test => {
11     return self.caches.keys().then(keys => {
12         var pending = [];
13         for (key of keys)
14             pending.push(self.caches.delete(keys[0]));
15         return Promise.all(pending);
16     });
17 }, "Cleaning existing caches");
18
19 promise_test(async (test) => {
20     var cache = await self.caches.open("test-cache-records-persistency");
21     await cache.put("https://example.com/foo", new Response("body", { statusText: "status" }));
22
23     if (!window.testRunner)
24         return Promise.reject("test runner needed");
25     testRunner.clearDOMCaches();
26
27     var keys = await self.caches.keys();
28     assert_equals(keys.length, 0, "keys should be empty");
29
30     cache = await self.caches.open("test-cache-records-persistency");
31     keys = await cache.keys();
32     assert_equals(keys.length, 0, "records should be empty");
33 }, 'Clearing all disk cache');
34     </script>
35 </body>
36 </html>