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

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"); } );
kinuko 2011/08/30 12:12:04 is it intentional not to use unexpectedErrorCallba
Dai Mikurube (NOT FULLTIME) 2011/08/30 12:58:30 It will be useful to show where the test fails. (
22 }
23
24 function requestSuccess(fs) {
kinuko 2011/08/30 12:12:04 nit: requestSuccess -> requestFileSystemSuccess fo
Dai Mikurube (NOT FULLTIME) 2011/08/30 12:58:30 Done.
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("No error by quota");
kinuko 2011/08/30 12:12:04 'Unexpectedly succeeded' ?
Dai Mikurube (NOT FULLTIME) 2011/08/30 12:58:30 Done.
37 }
38 }
39 fileWriter.truncate(10000 * 1024);
40 }, unexpectedErrorCallback)
41 }, function(e) { fail("Open"); } );
42 }
43
44 function quotaSuccess(usage, quota) {
45 origReturnedUsage = returnedUsage = usage;
46 origReturnedQuota = returnedQuota = quota;
kinuko 2011/08/30 12:12:04 returned{Usage,Quota} variables are not used?
Dai Mikurube (NOT FULLTIME) 2011/08/30 12:58:30 Done.
47 if (origReturnedUsage != 0)
48 fail("Usage is not zero: " + origReturnedUsage);
49 if (origReturnedQuota != 5000 * 1024)
50 fail("Quota is not 5000KiB: " + origReturnedQuota);
51
52 window.webkitRequestFileSystem(
53 window.TEMPORARY,
54 1024 * 1024,
55 requestSuccess,
56 unexpectedErrorCallback);
57 }
58
59 function test() {
60 if (window.webkitStorageInfo) {
61 window.jsTestIsAsync = true;
kinuko 2011/08/30 12:12:04 Not used/referred? (This variable is usually refer
Dai Mikurube (NOT FULLTIME) 2011/08/30 12:58:30 Done.
62 debug('Querying usage and quota.');
63 webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.TEMPORARY,
64 quotaSuccess,
65 unexpectedErrorCallback);
66 } else {
67 debug("This test requires window.webkitStorageInfo.");
kinuko 2011/08/30 12:12:04 nit: " -> '
Dai Mikurube (NOT FULLTIME) 2011/08/30 12:58:30 Done.
68 }
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698