1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/ajax/offline/test_bug460353.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,100 @@ 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>Bug 460353</title> 1.7 + 1.8 +<!-- 1.9 + This test checks that each iframe creates its own 1.10 + scope. Actually, we just check that it loads and updates 1.11 + its associated cache. There is no check that the cache is the 1.12 + expected one, there is no API to gain that information. 1.13 +--> 1.14 + 1.15 +<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.16 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.17 +<script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script> 1.18 + 1.19 +<script class="testbody" type="text/javascript"> 1.20 + 1.21 +var result = new Array(); 1.22 +var expectedUpdates = 3; // 2 iframes and our self 1.23 + 1.24 +applicationCache.oncached = onUpdatePassed; 1.25 +applicationCache.onnoupdate = onUpdatePassed; 1.26 + 1.27 +SpecialPowers.pushPermissions([{'type': 'offline-app', 'allow': true, 'context': document}], init); 1.28 + 1.29 +function onUpdatePassed() 1.30 +{ 1.31 + if (!(--expectedUpdates)) 1.32 + SimpleTest.executeSoon(finish); 1.33 +} 1.34 + 1.35 +function init() 1.36 +{ 1.37 + var iframes = document.getElementsByTagName('iframe'); 1.38 + iframes[0].src = "460353_iframe_nomanifest.html"; 1.39 + iframes[1].src = "460353_iframe_ownmanifest.html"; 1.40 + iframes[2].src = "460353_iframe_samemanifest.html"; 1.41 +} 1.42 + 1.43 +function frameOnLoad(frameid, status) 1.44 +{ 1.45 + var obj = new Object(); 1.46 + result[frameid] = obj; 1.47 + 1.48 + result[frameid].load = true; 1.49 + result[frameid].cacheStatus = status; 1.50 +} 1.51 + 1.52 +function frameOnUpdate(frameid, ok, status) 1.53 +{ 1.54 + result[frameid].update = true; 1.55 + result[frameid].updateOK = ok; 1.56 + result[frameid].cacheStatus = status; 1.57 + 1.58 + onUpdatePassed(); 1.59 +} 1.60 + 1.61 +function finish() 1.62 +{ 1.63 + SimpleTest.ok(result["same"].load || false, "Frame with the same manifest loads"); 1.64 + SimpleTest.ok(result["same"].update || false, "Frame with the same manifest cache update notification"); 1.65 + SimpleTest.ok(result["same"].updateOK || false, "Frame with the same manifest cache update passed OK"); 1.66 + SimpleTest.is(result["same"].cacheStatus || -1, 1, "Frame with the same manifest cache status was IDLE"); 1.67 + 1.68 + SimpleTest.ok(result["diff"].load || false, "Frame with different manifest loads"); 1.69 + SimpleTest.ok(result["diff"].update || false, "Frame with different manifest cache update notification"); 1.70 + SimpleTest.ok(result["diff"].updateOK || false, "Frame with different manifest cache update passed OK"); 1.71 + SimpleTest.is(result["diff"].cacheStatus || -1, 1, "Frame with different manifest cache status was IDLE"); 1.72 + 1.73 + SimpleTest.ok(result["noman"].load || false, "Frame with no manifest loads"); 1.74 + SimpleTest.ok(result["noman"].update == undefined, "Frame with no manifest cache update didn't notify"); 1.75 + SimpleTest.ok(result["noman"].updateOK == undefined, "Frame with no manifest cache update didn't pass"); 1.76 + SimpleTest.is(result["noman"].cacheStatus || -1, -1, "Frame with no manifest cache status was undefined"); 1.77 + 1.78 + OfflineTest.waitForUpdates(function() { 1.79 + cleanCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest"); 1.80 + cleanCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs"); 1.81 + 1.82 + SimpleTest.finish(); 1.83 + }); 1.84 +} 1.85 + 1.86 +function cleanCache(manifestURL) 1.87 +{ 1.88 + var cache = OfflineTest.getActiveCache(manifestURL); 1.89 + dump("Discarding cache for " + manifestURL + " cache=" + cache + "\n"); 1.90 + if (cache) 1.91 + cache.discard(); 1.92 +} 1.93 + 1.94 +SimpleTest.waitForExplicitFinish(); 1.95 + 1.96 +</script> 1.97 + 1.98 +<body> 1.99 + <iframe></iframe> 1.100 + <iframe></iframe> 1.101 + <iframe></iframe> 1.102 +</body> 1.103 +</html>