| 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 { | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 53              "storage['name'] != 'value' after addition"); | 53              "storage['name'] != 'value' after addition"); | 
| 54 | 54 | 
| 55   storage.clear(); | 55   storage.clear(); | 
| 56 | 56 | 
| 57   checkEqual(0, storage.length, | 57   checkEqual(0, storage.length, | 
| 58              "storage.length != 0 after clear"); | 58              "storage.length != 0 after clear"); | 
| 59 | 59 | 
| 60   var tooLarge =  makeLargeString((5 * 1024 * 1024) + 1); | 60   var tooLarge =  makeLargeString((5 * 1024 * 1024) + 1); | 
| 61   try { | 61   try { | 
| 62     storage.setItem("tooLarge", tooLarge); | 62     storage.setItem("tooLarge", tooLarge); | 
| 63     throw "failed to throw execption for very large value"; | 63     throw "failed to throw exception for very large value"; | 
| 64   } catch(ex) { | 64   } catch(ex) { | 
| 65     checkEqual(ex.code, 22, | 65     checkEqual(ex.code, 22, | 
| 66                "ex.code != 22 for attempt to store a very large value"); | 66                "ex.code != 22 for attempt to store a very large value"); | 
| 67   } | 67   } | 
| 68   try { | 68   try { | 
| 69     storage.setItem(tooLarge, "key is too large"); | 69     storage.setItem(tooLarge, "key is too large"); | 
| 70     throw "failed to throw execption for very large key"; | 70     throw "failed to throw exception for very large key"; | 
| 71   } catch(ex) { | 71   } catch(ex) { | 
| 72     checkEqual(ex.code, 22, | 72     checkEqual(ex.code, 22, | 
| 73                "ex.code != 22 for attempt to store a very large key"); | 73                "ex.code != 22 for attempt to store a very large key"); | 
| 74   } | 74   } | 
| 75 } | 75 } | 
| 76 | 76 | 
| 77 function checkEqual(lhs, rhs, errorMessage) { | 77 function checkEqual(lhs, rhs, errorMessage) { | 
| 78   if (lhs !== rhs) | 78   if (lhs !== rhs) | 
| 79     throw errorMessage; | 79     throw errorMessage; | 
| 80 } | 80 } | 
| 81 | 81 | 
| 82 function makeLargeString(minimumSize) { | 82 function makeLargeString(minimumSize) { | 
| 83   return Array(minimumSize).join("X"); | 83   return Array(minimumSize).join("X"); | 
| 84 } | 84 } | 
| OLD | NEW | 
|---|