summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/ajax/offline/test_bug744719-cancel.html
blob: 53955790d11a40c89edd421b23dde5d65047ca62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/744719-cancel.cacheManifest">
<head>
<title>parallel load canceled</title>

<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />

<script type="text/javascript">

/*
  Manifest refers a large number of resource to load.  The 10th item however is a reference to a non-existing
  resource that cancels the load.  This test checks we cancel all loads and don't leak any of the other resources
  after cancelation.
*/

if (SpecialPowers.isMainProcess()) {
  ok(applicationCache.mozItems.length == 0,
     "applicationCache.mozItems should be available and empty before associating with a cache.");
}

function updateCanceled()
{
  OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/744719-cancel.cacheManifest", false, null);
  OfflineTest.checkCache("http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", false, null);
  OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", false, null);

  OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/nonexistent744719?010", false, null);

  var URL = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/subresource744719.html?";
  OfflineTest.checkCache(URL + "001", false, null);
  OfflineTest.checkCache(URL + "002", false, null);
  OfflineTest.checkCache(URL + "003", false, null);
  OfflineTest.checkCache(URL + "004", false, null);
  OfflineTest.checkCache(URL + "005", false, null);
  OfflineTest.checkCache(URL + "006", false, null);
  OfflineTest.checkCache(URL + "007", false, null);
  OfflineTest.checkCache(URL + "008", false, null);
  OfflineTest.checkCache(URL + "009", false, null);
  OfflineTest.checkCache(URL + "011", false, null);
  OfflineTest.checkCache(URL + "012", false, null);
  OfflineTest.checkCache(URL + "013", false, null);
  OfflineTest.checkCache(URL + "014", false, null);
  OfflineTest.checkCache(URL + "015", false, null);
  OfflineTest.checkCache(URL + "016", false, null);
  OfflineTest.checkCache(URL + "017", false, null);
  OfflineTest.checkCache(URL + "018", false, null);
  OfflineTest.checkCache(URL + "019", false, null);
  OfflineTest.checkCache(URL + "020", false, null);
  OfflineTest.checkCache(URL + "021", false, null);
  OfflineTest.checkCache(URL + "022", false, null);
  OfflineTest.checkCache(URL + "023", false, null);
  OfflineTest.checkCache(URL + "024", false, null);
  OfflineTest.checkCache(URL + "025", false, null);
  OfflineTest.checkCache(URL + "026", false, null);
  OfflineTest.checkCache(URL + "027", false, null);
  OfflineTest.checkCache(URL + "028", false, null);
  OfflineTest.checkCache(URL + "029", false, null);
  OfflineTest.checkCache(URL + "030", false, null);

  OfflineTest.teardownAndFinish();
}

if (OfflineTest.setup()) {
  // Wait some time after the update has been canceled to catch potential leaks of channels that would cause
  // unwanted items to be cached regardless the update has been canceled with a failure.
  var privUpdateCanceled = OfflineTest.priv(updateCanceled);
  applicationCache.onerror = function() {window.setTimeout(privUpdateCanceled, 1000)};

  // We don't expect this update to finish correctly.
  applicationCache.oncached = OfflineTest.failEvent;
}

SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");

</script>

</head>

<body>

</body>
</html>