Chromium Code Reviews| Index: chrome/test/data/fileapi/quota_test.js |
| diff --git a/chrome/test/data/fileapi/quota_test.js b/chrome/test/data/fileapi/quota_test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..30a1f12bf2a44caab6c3f2f6d497c879063e02f9 |
| --- /dev/null |
| +++ b/chrome/test/data/fileapi/quota_test.js |
| @@ -0,0 +1,69 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +function truncateFailByQuota(fs) { |
| + fs.root.getFile('fd', {create: false, exclusive: false}, function(fileEntry) { |
| + fileEntry.createWriter(function(fileWriter) { |
| + var failedInTruncate = false; |
| + fileWriter.onerror = function(e) { |
| + failedInTruncate = true; |
| + }; |
| + fileWriter.onwriteend = function(e) { |
| + if (failedInTruncate) { |
| + fail(e.currentTarget.error); |
| + } else { |
| + done(); |
| + } |
| + }; |
| + fileWriter.truncate(2500 * 1024); |
| + }, unexpectedErrorCallback) |
| + }, 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. (
|
| +} |
| + |
| +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.
|
| + fs.root.getFile('fd', {create: true, exclusive: false}, function(fileEntry) { |
| + fileEntry.createWriter(function(fileWriter) { |
| + var failedInTruncate = false; |
| + fileWriter.onerror = function(e) { |
| + debug(e.currentTarget.error); |
| + failedInTruncate = true; |
| + }; |
| + fileWriter.onwriteend = function() { |
| + if (failedInTruncate) { |
| + truncateFailByQuota(fs); |
| + } else { |
| + 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.
|
| + } |
| + } |
| + fileWriter.truncate(10000 * 1024); |
| + }, unexpectedErrorCallback) |
| + }, function(e) { fail("Open"); } ); |
| +} |
| + |
| +function quotaSuccess(usage, quota) { |
| + origReturnedUsage = returnedUsage = usage; |
| + 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.
|
| + if (origReturnedUsage != 0) |
| + fail("Usage is not zero: " + origReturnedUsage); |
| + if (origReturnedQuota != 5000 * 1024) |
| + fail("Quota is not 5000KiB: " + origReturnedQuota); |
| + |
| + window.webkitRequestFileSystem( |
| + window.TEMPORARY, |
| + 1024 * 1024, |
| + requestSuccess, |
| + unexpectedErrorCallback); |
| +} |
| + |
| +function test() { |
| + if (window.webkitStorageInfo) { |
| + 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.
|
| + debug('Querying usage and quota.'); |
| + webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.TEMPORARY, |
| + quotaSuccess, |
| + unexpectedErrorCallback); |
| + } else { |
| + 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.
|
| + } |
| +} |