| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <body> | |
| 4 <p id="result"> | |
| 5 </p> | |
| 6 <script> | |
| 7 var expected = -1; | |
| 8 function getFileWriter(callback) { | |
| 9 webkitRequestFileSystem(PERSISTENT, 1024, function(fs) { | |
| 10 fs.root.getFile("/caching-test.js", {create:true}, function(file) { | |
| 11 file.createWriter(function(writer) { | |
| 12 writer.onwriteend = function() { | |
| 13 writer.onwriteend = undefined; | |
| 14 callback(file, writer); | |
| 15 } | |
| 16 writer.truncate(0); | |
| 17 }); | |
| 18 }); | |
| 19 }); | |
| 20 } | |
| 21 | |
| 22 function writeRandToFile(writer, callback) { | |
| 23 var rand = Math.round(Math.random() * 1000); | |
| 24 writer.onwriteend = function() { | |
| 25 callback(rand); | |
| 26 }; | |
| 27 writer.write(new Blob(['document.getElementById("result").innerHTML = (exp
ected == ' + rand + ') ? "SUCCESS" : "FAILURE";'], {type:'text/plain'})); | |
| 28 } | |
| 29 | |
| 30 getFileWriter(function(file, writer) { | |
| 31 writeRandToFile(writer, function(rand) { | |
| 32 var script = document.createElement('script'); | |
| 33 script.src = file.toURL(); | |
| 34 if (window.location.search != '?reload=1') { | |
| 35 script.onload = function() { | |
| 36 window.location.href = window.location.href + '?reload=1' | |
| 37 }; | |
| 38 } else { | |
| 39 script.onload = function() { | |
| 40 file.remove(function() { | |
| 41 if (window.testRunner) { | |
| 42 testRunner.notifyDone(); | |
| 43 } | |
| 44 }); | |
| 45 }; | |
| 46 } | |
| 47 expected = rand; | |
| 48 document.body.appendChild(script); | |
| 49 }); | |
| 50 }); | |
| 51 | |
| 52 if (window.testRunner) { | |
| 53 testRunner.dumpAsText(); | |
| 54 testRunner.waitUntilDone(); | |
| 55 } | |
| 56 </script> | |
| 57 </body> | |
| 58 </html> | |
| OLD | NEW |