test_imagecache_max_age.html (2551B)
1 <!-- 2 Any copyright is dedicated to the Public Domain. 3 http://creativecommons.org/publicdomain/zero/1.0/ 4 --> 5 <!DOCTYPE HTML> 6 <html> 7 <head> 8 <title>Test that the image cache respects a synthesized image's Cache headers</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 11 </head> 12 <body> 13 <p id="display"></p> 14 <div id="content"> 15 <iframe></iframe> 16 </div> 17 <pre id="test"></pre> 18 <script class="testbody" type="text/javascript"> 19 20 var iframe; 21 var framesLoaded = 0; 22 function runTest() { 23 iframe = document.querySelector("iframe"); 24 iframe.src = "/tests/dom/serviceworkers/test/fetch/imagecache-maxage/register.html"; 25 window.onmessage = function(e) { 26 if (e.data.status == "ok") { 27 ok(e.data.result, e.data.message); 28 } else if (e.data.status == "registrationdone") { 29 iframe.src = "/tests/dom/serviceworkers/test/fetch/imagecache-maxage/index.html"; 30 } else if (e.data.status == "result") { 31 switch (++framesLoaded) { 32 case 1: 33 is(e.data.url, "image-20px.png", "Correct url expected"); 34 is(e.data.url2, "image-20px.png", "Correct url expected"); 35 is(e.data.width, 20, "Correct width expected"); 36 is(e.data.width2, 20, "Correct width expected"); 37 // Wait for 100ms so that the image gets expired. 38 setTimeout(function() { 39 iframe.src = "/tests/dom/serviceworkers/test/fetch/imagecache-maxage/index.html?new" 40 }, 100); 41 break; 42 case 2: 43 is(e.data.url, "image-40px.png", "Correct url expected"); 44 is(e.data.url2, "image-40px.png", "Correct url expected"); 45 is(e.data.width, 40, "Correct width expected"); 46 is(e.data.width2, 40, "Correct width expected"); 47 iframe.src = "/tests/dom/serviceworkers/test/fetch/imagecache-maxage/unregister.html"; 48 break; 49 default: 50 ok(false, "This should never happen"); 51 } 52 } else if (e.data.status == "unregistrationdone") { 53 window.onmessage = null; 54 SimpleTest.finish(); 55 } 56 }; 57 } 58 59 SimpleTest.requestFlakyTimeout("This test needs to simulate the passing of time"); 60 SimpleTest.waitForExplicitFinish(); 61 onload = function() { 62 SpecialPowers.pushPrefEnv({"set": [ 63 ["dom.serviceWorkers.exemptFromPerDomainMax", true], 64 ["dom.serviceWorkers.enabled", true], 65 ["dom.serviceWorkers.testing.enabled", true], 66 ]}, runTest); 67 }; 68 </script> 69 </pre> 70 </body> 71 </html>