- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / fileapi / background.js
1 // Copyright (c) 2011 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 var fileSystem = null;
6
7 console.log("Requesting a filesystem...");
8 webkitRequestFileSystem(window.TEMPORARY, 100, getFileSystem, errorCallback);
9
10 function getFileSystem(fs) {
11   fileSystem = fs;
12   console.log("DONE requesting filesystem: " + fileSystem.name);
13   fileSystem.root.getDirectory('dir', {create:true},
14                                directoryCallback, errorCallback);
15 }
16
17 function directoryCallback(directory) {
18   console.log("DONE creating directory: " + directory.path);
19   directory.getFile('file', {create:true}, fileCallback, errorCallback);
20 }
21
22 function fileCallback(file) {
23   console.log("DONE creating file: " + file.path);
24
25   // See if we get the same filesystem space in the tab.
26   console.log("Opening tab...");
27   chrome.tabs.create({
28     url: "tab.html"
29   });
30 }
31
32 function errorCallback(error) {
33   chrome.test.fail("Got unexpected error: " + error.code);
34 }