Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / xhr_persistent_fs / main.js
blobddb4ab9f8a925fa7afea0df67dfcd75dff0ecfd3
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.
5 function createFile() {
6 webkitRequestFileSystem(window.PERSISTENT, 1024, gotFS, fail);
7 };
9 function gotFS(fs) {
10 fs.root.getFile("hoge", {create: true, exclusive: false}, gotFileEntry, fail);
13 function gotFileEntry(entry) {
14 entry.createWriter(gotWriter.bind(null, entry), fail);
17 function gotWriter(entry, writer) {
18 writer.write(new Blob(["fuga"]));
19 writer.onwrite = didWrite.bind(null, entry);
20 writer.onerror = fail;
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;
31 function pass() {
32 if (window.chrome && chrome.test && chrome.test.succeed)
33 chrome.test.succeed();
34 document.body.innerText = "PASS";
37 function fail() {
38 if (window.chrome && chrome.test && chrome.test.fail)
39 chrome.test.fail();
40 document.body.innerText = "FAIL";
43 createFile();