1<html> 2<head> 3<script> 4 5// Helpers. 6 7function log(message) { 8 document.getElementById("console").innerHTML += message + "<br>"; 9} 10 11// Start and end. 12 13function startTest() { 14 if (window.layoutTestController) { 15 layoutTestController.clearAllApplicationCaches(); 16 layoutTestController.dumpApplicationCacheDelegateCallbacks(); 17 layoutTestController.setApplicationCacheOriginQuota(20*1024); 18 layoutTestController.dumpAsText(); 19 layoutTestController.waitUntilDone(); 20 } 21 22 addFirstIFrame(); 23} 24 25function finishTest() { 26 if (window.layoutTestController) 27 layoutTestController.notifyDone(); 28} 29 30// Stages. 31 32function addIFrameWithContinuation(src, continuation) { 33 window.onmessage = continuation; 34 var iframe = document.createElement("iframe"); 35 iframe.src = src; 36 document.body.appendChild(iframe); 37} 38 39function addFirstIFrame() { 40 // Expected to succeed. 41 addIFrameWithContinuation("resources/quota-origin-iframe-1.html", function(event) { 42 log(event.data); 43 addSecondIFrame(); 44 }); 45} 46 47function addSecondIFrame() { 48 // Expected to fail, then increase the quota. 49 // NOTE: When this fails, the exceed callback will automatically increase it back to the default quota size. 50 addIFrameWithContinuation("resources/quota-origin-iframe-2.html", function(event) { 51 log(event.data); 52 addThirdIFrame(); 53 }); 54} 55 56function addThirdIFrame() { 57 // Expected to succeed. 58 addIFrameWithContinuation("resources/quota-origin-iframe-3.html", function(event) { 59 log(event.data); 60 finishTest(); 61 }); 62} 63 64</script> 65</head> 66<body onload="startTest()"> 67<p>This test checks that per-origin application cache quotas are enforced.</p> 68<p> 69 This test sets the quota for the origin to 20kb, and attempts to fill 70 it up with 2 iframes that are 13kb each. The application cache download 71 process should fail on the 2nd iframe and the UI Delegate should be 72 informed of the exceeded quota. Increasing the size to 40kb. A 3rd 73 iframe is added, which should succeed. 74</p> 75<pre id="console"></pre> 76</body> 77</html> 78