| <body> |
| <pre id="console"></pre> |
| <script> |
| if (window.testRunner) { |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| } |
| |
| function log(msg) { |
| document.getElementById('console').appendChild(document.createTextNode(msg + "\n")); |
| } |
| |
| function readBlob(blob, cb) { |
| var reader = new FileReader(); |
| reader.onload = function() { |
| cb(this.result); |
| }; |
| reader.readAsText(blob); |
| } |
| |
| // Do a synchronous XHR to populate the Blink in-memory cache. (Asynchronous |
| // XHRs currently get evicted on completion.) |
| var syncxhr = new XMLHttpRequest(); |
| syncxhr.open("GET", "resources/get.txt", false); |
| syncxhr.send(); |
| log(syncxhr.responseText); |
| |
| // Download the same resource again, but as a Blob. |
| var asyncxhr = new XMLHttpRequest(); |
| asyncxhr.open("GET", "resources/get.txt", true); |
| asyncxhr.responseType = 'blob' |
| asyncxhr.onload = function() { |
| readBlob(this.response, function(text) { |
| log(text); |
| if (window.testRunner) |
| testRunner.notifyDone(); |
| }); |
| }; |
| asyncxhr.send(); |
| |
| </script> |
| </body> |