OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 function createFile() { |
| 6 webkitRequestFileSystem(window.PERSISTENT, 1024, gotFS, fail); |
| 7 }; |
| 8 |
| 9 function gotFS(fs) { |
| 10 fs.root.getFile("hoge", {create: true, exclusive: false}, gotFileEntry, fail); |
| 11 } |
| 12 |
| 13 function gotFileEntry(entry) { |
| 14 entry.createWriter(gotWriter.bind(null, entry), fail); |
| 15 } |
| 16 |
| 17 function gotWriter(entry, writer) { |
| 18 writer.write(new Blob(["fuga"])); |
| 19 writer.onwrite = didWrite.bind(null, entry); |
| 20 writer.onerror = fail; |
| 21 } |
| 22 |
| 23 function didWrite(entry) { |
| 24 var xhr = new XMLHttpRequest(); |
| 25 xhr.open("GET", entry.toURL()); |
| 26 xhr.send(); |
| 27 xhr.onload = pass; |
| 28 xhr.onerror = fail; |
| 29 } |
| 30 |
| 31 function pass() { |
| 32 if (window.chrome && chrome.test && chrome.test.succeed) |
| 33 chrome.test.succeed(); |
| 34 document.body.innerText = "PASS"; |
| 35 } |
| 36 |
| 37 function fail() { |
| 38 if (window.chrome && chrome.test && chrome.test.fail) |
| 39 chrome.test.fail(); |
| 40 document.body.innerText = "FAIL"; |
| 41 } |
| 42 |
| 43 createFile(); |
OLD | NEW |