Home | History | Annotate | Download | only in appcache
      1 <html manifest="resources/fail-on-update.php">
      2 <script>
      3 if (window.layoutTestController) {
      4     layoutTestController.dumpAsText();
      5     layoutTestController.waitUntilDone();
      6 }
      7 
      8 function setManifestDeleted(state)
      9 {
     10     var req = new XMLHttpRequest;
     11     req.open("GET", "resources/fail-on-update.php?command=" + (state ? "delete" : "reset"), false);
     12     req.send(null);
     13 }
     14 
     15 function test()
     16 {
     17     clearTimeout(timeoutId);
     18 
     19     setManifestDeleted(true);
     20     applicationCache.update();
     21     window.location = 'data:text/html,<p>SUCCESS: No crash.</p>' + 
     22         '<script>' +
     23             'if (window.layoutTestController) layoutTestController.notifyDone();' +
     24         '</scri' + 'pt>';
     25 }
     26 
     27 function resetManifest()
     28 {
     29     if (applicationCache.status != applicationCache.UNCACHED && applicationCache.status != applicationCache.OBSOLETE) {
     30         timeoutId = setTimeout(resetManifest, 100);
     31         return;
     32     }
     33 
     34     setManifestDeleted(false);
     35     location.reload();
     36 }
     37 
     38 applicationCache.addEventListener('noupdate', function() { setTimeout(test, 0) }, false);
     39 applicationCache.addEventListener('cached', function() { setTimeout(test, 0) }, false);
     40 
     41 // If the manifest script happened to be in a wrong state, reset it.
     42 var timeoutId = setTimeout(resetManifest, 100);
     43 
     44 </script>
     45 <p>Test for a particular incorrect assertion failure.</p>
     46 
     47 </html>
     48