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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback.cacheManifest">
<head>
<title>Fallback entry test</title>
<script 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 class="testbody" type="text/javascript">
/* globals fallbackFrame */
/**
* This tests that we fall back to the correct fallback entries when loading
* from fallback namespaces listed in the manifest. The test is performed twice
* to make sure that no cache entries are created for the nonexistent items."
* That would lead to a failure to fallback, as there would always be an entry
* in the application cache.
*/
var gStep = 1;
var gChildLoad = false;
var gTopWindow = null;
function manifestUpdated()
{
fallbackFrame.location = "https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html";
// Invokes load of fallback.html
}
function onFallbackLoad(fallbackIdentification)
{
switch (gStep)
{
case 001:
OfflineTest.ok(!gChildLoad, "offline child not load before cache update");
gChildLoad = true;
// no break
case 101:
OfflineTest.is(fallbackIdentification, 1, "fallback for namespace1/ in step " + gStep);
fallbackFrame.location = "https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/sub-non-existing.html";
// Invokes load of fallback.html
break;
case 002:
case 102:
OfflineTest.is(fallbackIdentification, 1, "fallback for namespace1/, sub namespace in name of the frame in step " + gStep);
fallbackFrame.location = "https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html";
// Invokes load of fallback2.html
break;
case 003:
case 103:
OfflineTest.is(fallbackIdentification, 2, "fallback for namespace1/sub/ in step " + gStep);
fallbackFrame.location = "HTTPS://EXAMPLE.COM/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html";
// Invokes load of fallback2.html
break;
case 004:
case 104:
OfflineTest.is(fallbackIdentification, 2, "fallback for namespace1/sub/ in step " + gStep);
// Try opening a non-existing page as a top level document. It must
// fall to fallbackTop.html that identifies it self as '100'.
// Invokes load of fallbackTop.html
gTopWindow = window.open("https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace2/non-existing.html");
break;
case 005:
// Try all over again. This checks there are no entries for non-existing
// pages created/leaked. That would prevent fallback load.
gStep = 100;
fallbackFrame.location = "https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html";
// Invokes load of fallback1.html, again, from the start
// no break
case 105:
OfflineTest.is(fallbackIdentification, 100, "fallback for namespace2/, invoked by a top level document " + gStep);
gTopWindow.close();
gTopWindow = null;
break;
}
if (gStep == 105) {
finalize();
return;
}
++gStep;
}
function finishTest()
{
OfflineTest.teardownAndFinish();
}
function finalize()
{
var entries = [
["https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/sub-non-existing.html", false],
["https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html", false],
["https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html", false],
["https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace2/non-existing.html", false]
];
OfflineTest.checkCacheEntries(entries, finishTest);
}
SimpleTest.waitForExplicitFinish();
if (OfflineTest.setup()) {
applicationCache.onerror = OfflineTest.failEvent;
applicationCache.onupdateready = OfflineTest.failEvent;
applicationCache.oncached = OfflineTest.priv(manifestUpdated);
}
</script>
</head>
<body>
<iframe name="fallbackFrame" src=""></iframe>
</body>
</html>
|