Chromium Code Reviews| Index: chrome/test/data/fileapi/common.js |
| diff --git a/chrome/test/data/fileapi/common.js b/chrome/test/data/fileapi/common.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..12d4a8c11c7891c1487b8837daa7eb578fe4a544 |
| --- /dev/null |
| +++ b/chrome/test/data/fileapi/common.js |
| @@ -0,0 +1,59 @@ |
| +// 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 debug(message) |
| +{ |
| + document.getElementById('status').innerHTML += '<br/>' + message; |
| +} |
| + |
| +function done(message) |
| +{ |
| + if (document.location.hash == '#fail') |
| + return; |
| + if (message) |
| + debug('PASS: ' + message); |
| + else |
| + debug('PASS'); |
| + document.location.hash = '#pass'; |
| +} |
| + |
| +function fail(message) |
| +{ |
| + debug('FAILED: ' + message); |
| + document.location.hash = '#fail'; |
| +} |
| + |
| +function getLog() |
| +{ |
| + return "" + document.getElementById('status').innerHTML; |
|
kinuko
2011/08/30 12:12:04
"" -> '' for consistency?
is this '"" +' placed t
|
| +} |
| + |
| +function fileErrorToString(e) { |
| + switch (e.code) { |
| + case FileError.QUOTA_EXCEEDED_ERR: |
| + msg = 'QUOTA_EXCEEDED_ERR'; |
|
kinuko
2011/08/30 12:12:04
looks like we can simply do this?
return 'QUOTA_E
|
| + break; |
| + case FileError.NOT_FOUND_ERR: |
| + msg = 'NOT_FOUND_ERR'; |
| + break; |
| + case FileError.SECURITY_ERR: |
| + msg = 'SECURITY_ERR'; |
| + break; |
| + case FileError.INVALID_MODIFICATION_ERR: |
| + msg = 'INVALID_MODIFICATION_ERR'; |
| + break; |
| + case FileError.INVALID_STATE_ERR: |
| + msg = 'INVALID_STATE_ERR'; |
| + break; |
| + default: |
| + msg = 'Unknown Error'; |
| + break; |
| + }; |
|
kinuko
2011/08/30 12:12:04
nit: semicolon is not needed here?
|
| + return msg; |
| +} |
| + |
| +function unexpectedErrorCallback(e) |
| +{ |
| + fail('unexpectedErrorCallback:' + fileErrorToString(e)); |
| +} |