Home | History | Annotate | Download | only in appcache
      1 <html manifest="resources/idempotent-update.manifest">
      2 <body>
      3 <p>Test what applicationCache.update() does if update is already in progess.</p>
      4 <p>Should say DONE, with no failures:</p>
      5 <div id=result></div>
      6 
      7 <script>
      8 if (window.layoutTestController) {
      9     layoutTestController.dumpAsText();
     10     layoutTestController.waitUntilDone();
     11 }
     12 
     13 function log(message)
     14 {
     15     document.getElementById("result").innerHTML += message + "<br>";
     16 }
     17 
     18 function test()
     19 {
     20     // During update, additional update() should be no-op (the spec says that fake checking and
     21     // downloading events need to be dispatched, but that's only when the update algorithm is invoked
     22     // with a browsing context).
     23     if (applicationCache.status != applicationCache.IDLE)
     24         log("FAIL: Unexpected cache status while preparing to test: " + applicationCache.status);
     25     
     26     var checkingCount = 0;
     27     applicationCache.onchecking = function() { if (++checkingCount != 1) log("FAIL: Too many checking events received.") }
     28     
     29     applicationCache.update();
     30     applicationCache.update();
     31     applicationCache.update();
     32     applicationCache.update();
     33     applicationCache.update();
     34 
     35     applicationCache.onnoupdate = done;
     36     applicationCache.oncached = function() { log("FAIL: received unexpected cached event") }
     37 }
     38 
     39 function done()
     40 {
     41     setTimeout(function() {
     42         log("DONE");
     43         if (window.layoutTestController)
     44             layoutTestController.notifyDone();
     45     }, 10);
     46 }
     47 
     48 applicationCache.oncached = test;
     49 applicationCache.onnoupdate = test;
     50 
     51 applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
     52 applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
     53 
     54 </script>
     55 </body>
     56 </html>
     57