| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 function startTestSoon() { | 5 function startTestSoon() { |
| 6 window.setTimeout(test, 0); | 6 window.setTimeout(test, 0); |
| 7 } | 7 } |
| 8 | 8 |
| 9 function test() { | 9 function test() { |
| 10 try { | 10 try { |
| 11 debug('Checking window.localStorage'); | 11 debug('Checking window.localStorage'); |
| 12 sanityCheck(window.localStorage); | 12 sanityCheck(window.localStorage); |
| 13 debug('Checking window.sessionStorage'); | 13 debug('Checking window.sessionStorage'); |
| 14 sanityCheck(window.sessionStorage); | 14 sanityCheck(window.sessionStorage); |
| 15 done(); | 15 done(); |
| 16 } catch(e) { | 16 } catch(e) { |
| 17 fail(e); | 17 fail(e); |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 function sanityCheck(storage) { | 21 function sanityCheck(storage) { |
| 22 storage["preload"] = "done"; |
| 23 checkEqual("done", storage["preload"], |
| 24 "storage['preload'] != 'done' after addition"); |
| 25 |
| 22 storage.clear(); | 26 storage.clear(); |
| 23 | 27 |
| 24 checkEqual(0, storage.length, | 28 checkEqual(0, storage.length, |
| 25 "storage.length != 0 at start"); | 29 "storage.length != 0 at start"); |
| 26 checkEqual(null, storage.getItem("foo"), | 30 checkEqual(null, storage.getItem("foo"), |
| 27 "getItem('foo') != null prior to addition"); | 31 "getItem('foo') != null prior to addition"); |
| 28 checkEqual(null, storage.key(0), | 32 checkEqual(null, storage.key(0), |
| 29 "key(0) != null prior to addition"); | 33 "key(0) != null prior to addition"); |
| 30 | 34 |
| 31 storage.setItem("foo", "bar"); | 35 storage.setItem("foo", "bar"); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 79 } |
| 76 | 80 |
| 77 function checkEqual(lhs, rhs, errorMessage) { | 81 function checkEqual(lhs, rhs, errorMessage) { |
| 78 if (lhs !== rhs) | 82 if (lhs !== rhs) |
| 79 throw errorMessage; | 83 throw errorMessage; |
| 80 } | 84 } |
| 81 | 85 |
| 82 function makeLargeString(minimumSize) { | 86 function makeLargeString(minimumSize) { |
| 83 return Array(minimumSize).join("X"); | 87 return Array(minimumSize).join("X"); |
| 84 } | 88 } |
| OLD | NEW |