Home | History | Annotate | Download | only in appcache
      1 <html manifest="resources/progress-counter.manifest">
      2 <script>
      3 if (window.layoutTestController) {
      4     layoutTestController.dumpAsText()
      5     layoutTestController.waitUntilDone();
      6 }
      7 
      8 var expectedTotal = 2
      9 var eventsReceived = 0;
     10 
     11 function done() {
     12     if (window.layoutTestController)
     13         layoutTestController.notifyDone();
     14 }
     15 
     16 function progress(event)
     17 {
     18     if (!event.lengthComputable) {
     19         document.getElementById('result').innerHTML = "FAILURE: expected progressEvent.lengthComputable to be true";
     20         done();
     21         return;
     22     }
     23     if (event.total != expectedTotal) {
     24         document.getElementById('result').innerHTML = "FAILURE: expected progressEvent.total to be " + expectedTotal + " but was " + event.total;
     25         done();
     26         return;
     27     }
     28     if (event.loaded != eventsReceived) {
     29         document.getElementById('result').innerHTML = "FAILURE: expected progressEvent.loaded to be " + eventsReceived + " but was " + event.loaded;
     30         done();
     31         return;
     32     }
     33     eventsReceived++;
     34 }
     35 
     36 function cached()
     37 {
     38     if (eventsReceived != 3) {
     39         document.getElementById('result').innerHTML = "FAILURE: expected 3 progress events, but got " + eventsReceived;
     40         done();
     41         return;
     42     }
     43 
     44     document.getElementById('result').innerHTML = "SUCCESS";
     45     done();
     46 }
     47 
     48 function noupdate()
     49 {
     50     document.getElementById('result').innerHTML = "FAILURE: unable to conduct test since the appcache already exists, please remove the appcache and try again";
     51     done();
     52 }
     53 
     54 applicationCache.addEventListener('cached', cached, false);
     55 applicationCache.addEventListener('noupdate', noupdate, false);
     56 applicationCache.addEventListener('progress', progress, false);
     57 
     58 </script>
     59 <div>This tests that the lengthComputable / loaded / total properties of the progress event are set correctly.</div>
     60 
     61 <div id="result">FAILURE</div>
     62 </html>
     63