Home | History | Annotate | Download | only in appcache
      1 <html manifest="resources/simple.manifest">
      2 <script>
      3 if (window.layoutTestController) {
      4     layoutTestController.dumpAsText()
      5     layoutTestController.waitUntilDone();
      6 }
      7 
      8 function cached()
      9 {
     10     var hadError = false;
     11     
     12     // Load a resource that does not exist in the cache.
     13     try {
     14         var req = new XMLHttpRequest();
     15         req.open("GET", "resources/not-in-cache.txt", false);
     16         req.send();
     17     } catch (e) {
     18         if (e.code == XMLHttpRequestException.NETWORK_ERR)
     19             hadError = true;
     20     }
     21 
     22     if (!hadError) {
     23         document.getElementById('result').innerHTML = "FAILURE: Did not get the right exception"
     24         return;
     25     }
     26    
     27     // Load a resource that exists in the cache.
     28     try {
     29         var req = new XMLHttpRequest();
     30         req.open("GET", "resources/simple.txt", false);
     31         req.send();
     32     } catch (e) {
     33         document.getElementById('result').innerHTML = "FAILURE: Could not load data from cache"
     34         return;
     35     }
     36         
     37     if (req.responseText != 'Hello, World!') {
     38         document.getElementById('result').innerHTML = "FAILURE: Did not get correct data from cached resource"
     39         return;
     40     }
     41     
     42     document.getElementById('result').innerHTML = "SUCCESS"
     43     
     44     if (window.layoutTestController)
     45         layoutTestController.notifyDone();
     46 }
     47 
     48 applicationCache.addEventListener('cached', cached, false);
     49 applicationCache.addEventListener('noupdate', cached, false);
     50 
     51 </script>
     52 <div>This tests that the application cache works by first loading a file that does not exist in the cache (to verify that a cache has been associated) and then loads a file that is in the cache</div>
     53 
     54 <div id="result">FAILURE</div>
     55 </html>
     56