| <!-- webkit-test-runner [ enableBackForwardCache=true ] --> |
| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="/js-test-resources/js-test.js"></script> |
| </head> |
| <body> |
| <script> |
| description('Tests that a page with pending DOMCache activity goes into the page cache.'); |
| jsTestIsAsync = true; |
| let restoredFromPageCache = false; |
| |
| window.addEventListener("pageshow", function(event) { |
| debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache"); |
| if (event.persisted) { |
| testPassed("Page was restored from Page Cache"); |
| restoredFromPageCache = true; |
| } |
| }); |
| |
| function tryCache() |
| { |
| cache.add('resources/blank.txt').then(() => { |
| testPassed("Cache.add() succeeded"); |
| shouldBeTrue("!!restoredFromPageCache"); |
| finishJSTest(); |
| }, (e) => { |
| tryCache(); |
| }); |
| } |
| |
| window.addEventListener("pagehide", function(event) { |
| debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache"); |
| if (!event.persisted) { |
| testFailed("Page failed to enter the Page Cache"); |
| finishJSTest(); |
| } |
| |
| tryCache(); |
| }); |
| |
| onload = () => { |
| setTimeout(() => { |
| caches.open('test').then((_cache) => { |
| cache = _cache; |
| testLink.click(); |
| }); |
| }, 0); |
| } |
| </script> |
| <a id="testLink" href="resources/page-cache-helper.html" style="display: none">Link</a> |
| </body> |
| </html> |