dom/tests/mochitest/ajax/offline/test_cancelOfflineCache.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/ajax/offline/test_cancelOfflineCache.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
     1.5 +<head>
     1.6 +<title>Cancel offline cache</title>
     1.7 +
     1.8 +<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +<script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
    1.10 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.11 +
    1.12 +<script type="text/javascript">
    1.13 +
    1.14 +var manifest = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest";
    1.15 +var manifestURI = Cc["@mozilla.org/network/io-service;1"]
    1.16 +                  .getService(Ci.nsIIOService)
    1.17 +                  .newURI(manifest, null, null);
    1.18 +var updateService = Cc['@mozilla.org/offlinecacheupdate-service;1']
    1.19 +                    .getService(Ci.nsIOfflineCacheUpdateService);
    1.20 +
    1.21 +function manifestCached () {
    1.22 +  OfflineTest.ok(false, "The update was supposed to be canceled");
    1.23 +
    1.24 +  OfflineTest.teardownAndFinish();
    1.25 +}
    1.26 +
    1.27 +function onError () {
    1.28 +  OfflineTest.ok(true, "Expected error: Update canceled");
    1.29 +
    1.30 +  OfflineTest.teardownAndFinish();
    1.31 +}
    1.32 +
    1.33 +function onProgress () {
    1.34 +  var i = 0;
    1.35 +  while (i < updateService.numUpdates) {
    1.36 +    var update = updateService.getUpdate(i);
    1.37 +    if (update.manifestURI.spec == manifestURI.spec) {
    1.38 +      update.cancel();
    1.39 +      return;
    1.40 +    }
    1.41 +    i++;
    1.42 +  }
    1.43 +}
    1.44 +
    1.45 +if (OfflineTest.setup()) {
    1.46 +  applicationCache.onerror = OfflineTest.priv(onError);
    1.47 +  applicationCache.onnoupdate = OfflineTest.failEvent;
    1.48 +  applicationCache.onprogress = OfflineTest.priv(onProgress);
    1.49 +  applicationCache.oncached = OfflineTest.priv(manifestCached);
    1.50 +}
    1.51 +
    1.52 +SimpleTest.waitForExplicitFinish();
    1.53 +
    1.54 +</script>
    1.55 +
    1.56 +</head>
    1.57 +
    1.58 +<body>
    1.59 +
    1.60 +</body>
    1.61 +</html>

mercurial