2010-03-12 13:53:36 -08:00
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback.cacheManifest">
|
2008-11-05 16:01:06 -08:00
|
|
|
<head>
|
|
|
|
<title>Fallback entry test</title>
|
|
|
|
|
|
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
|
|
|
<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 class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 gManifestUpdated = false;
|
|
|
|
var gStep = 1;
|
|
|
|
var gChildLoad = false;
|
|
|
|
var gTopWindow = null;
|
|
|
|
var gCompleteTimeout = null;
|
|
|
|
|
|
|
|
function manifestUpdated()
|
|
|
|
{
|
|
|
|
gManifestUpdated = true;
|
2010-03-12 13:53:36 -08:00
|
|
|
fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html";
|
2008-11-05 16:01:06 -08:00
|
|
|
// 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);
|
|
|
|
|
2010-03-12 13:53:36 -08:00
|
|
|
fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub-non-existing.html";
|
2008-11-05 16:01:06 -08:00
|
|
|
// 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);
|
|
|
|
|
2010-03-12 13:53:36 -08:00
|
|
|
fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html";
|
2008-11-05 16:01:06 -08:00
|
|
|
// Invokes load of fallback2.html
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 003:
|
|
|
|
case 103:
|
|
|
|
OfflineTest.is(fallbackIdentification, 2, "fallback for namespace1/sub/ in step " + gStep);
|
|
|
|
|
2010-03-12 13:53:36 -08:00
|
|
|
fallbackFrame.location = "HTTP://MOCHI.TEST:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html";
|
2008-11-05 16:01:06 -08:00
|
|
|
// 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'.
|
|
|
|
gCompleteTimeout = window.setTimeout(function() {
|
|
|
|
OfflineTest.ok(false, "Fallback page displayed for top level document");
|
|
|
|
finalize();
|
|
|
|
}, 3000);
|
|
|
|
|
2010-03-12 13:53:36 -08:00
|
|
|
gTopWindow = window.open("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace2/non-existing.html");
|
2008-11-05 16:01:06 -08:00
|
|
|
// Invokes load of fallbackTop.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;
|
2010-03-12 13:53:36 -08:00
|
|
|
fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html";
|
2008-11-05 16:01:06 -08:00
|
|
|
// 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;
|
|
|
|
window.clearTimeout(gCompleteTimeout);
|
|
|
|
gCompleteTimeout = null;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gStep == 105) {
|
|
|
|
finalize();
|
|
|
|
}
|
|
|
|
|
|
|
|
++gStep;
|
|
|
|
}
|
|
|
|
|
|
|
|
function finalize()
|
|
|
|
{
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
|
2010-03-12 13:53:36 -08:00
|
|
|
OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub-non-existing.html", false);
|
|
|
|
OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html", false);
|
|
|
|
OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html", false);
|
|
|
|
OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace2/non-existing.html", false);
|
2008-11-05 16:01:06 -08:00
|
|
|
|
|
|
|
OfflineTest.teardown();
|
|
|
|
OfflineTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
if (OfflineTest.setup()) {
|
|
|
|
applicationCache.onerror = OfflineTest.failEvent;
|
|
|
|
applicationCache.onupdateready = OfflineTest.failEvent;
|
|
|
|
applicationCache.oncached = OfflineTest.priv(manifestUpdated);
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
2010-03-12 13:53:36 -08:00
|
|
|
<iframe name="fallbackFrame" src="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html"></iframe>
|
2008-11-05 16:01:06 -08:00
|
|
|
</body>
|
|
|
|
</html>
|