Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: chrome/test/data/fileapi/quota_test.js

Issue 7715024: Add browser_tests for FileAPI with Quota. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Reflected the comments. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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 function truncateFailByQuota(fs) {
6 fs.root.getFile('fd', {create: false, exclusive: false}, function(fileEntry) {
7 fileEntry.createWriter(function(fileWriter) {
8 var failedInTruncate = false;
9 fileWriter.onerror = function(e) {
10 failedInTruncate = true;
11 };
12 fileWriter.onwriteend = function(e) {
13 if (failedInTruncate) {
14 fail(e.currentTarget.error);
15 } else {
16 done();
17 }
18 };
19 fileWriter.truncate(2500 * 1024);
20 }, unexpectedErrorCallback)
21 }, function(e) { fail('Open for 2nd truncate:' + fileErrorToString(e)); } );
22 }
23
24 function requestFileSystemSuccess(fs) {
25 fs.root.getFile('fd', {create: true, exclusive: false}, function(fileEntry) {
26 fileEntry.createWriter(function(fileWriter) {
27 var failedInTruncate = false;
28 fileWriter.onerror = function(e) {
29 debug(e.currentTarget.error);
30 failedInTruncate = true;
31 };
32 fileWriter.onwriteend = function() {
33 if (failedInTruncate) {
34 truncateFailByQuota(fs);
35 } else {
36 fail('Unexpectedly succeeded to truncate. It should fail by quota.');
37 }
38 }
kinuko 2011/09/01 05:11:53 nit: semicolon after '}'
Dai Mikurube (NOT FULLTIME) 2011/09/01 06:54:09 Done.
39 fileWriter.truncate(10000 * 1024);
40 }, unexpectedErrorCallback)
41 }, function(e) { fail('Open for 1st truncate:' + fileErrorToString(e)); } );
42 }
43
44 function quotaSuccess(usage, quota) {
45 if (usage != 0)
46 fail('Usage is not zero: ' + usage);
47 if (quota != 5000 * 1024)
48 fail('Quota is not 5000KiB: ' + quota);
49
50 window.webkitRequestFileSystem(
51 window.TEMPORARY,
52 1024 * 1024,
53 requestFileSystemSuccess,
54 unexpectedErrorCallback);
55 }
56
57 function test() {
58 if (window.webkitStorageInfo) {
59 debug('Querying usage and quota.');
60 webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.TEMPORARY,
61 quotaSuccess,
62 unexpectedErrorCallback);
63 } else {
64 debug('This test requires window.webkitStorageInfo.');
65 }
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698