Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../http/tests/inspector/inspector-test.js"></script> |
| 4 <script> | 4 <script> |
| 5 | 5 |
| 6 function clearDOMStorage() | 6 function clearDOMStorage() |
| 7 { | 7 { |
| 8 localStorage.clear(); | 8 localStorage.clear(); |
| 9 sessionStorage.clear(); | 9 sessionStorage.clear(); |
| 10 } | 10 } |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 var theSessionStorage; | 32 var theSessionStorage; |
| 33 var storages = WebInspector.domStorageModel.storages(); | 33 var storages = WebInspector.domStorageModel.storages(); |
| 34 for (var i = 0; i < storages.length; ++i) { | 34 for (var i = 0; i < storages.length; ++i) { |
| 35 var storage = storages[i]; | 35 var storage = storages[i]; |
| 36 if (storage.isLocalStorage) | 36 if (storage.isLocalStorage) |
| 37 theLocalStorage = storage; | 37 theLocalStorage = storage; |
| 38 else | 38 else |
| 39 theSessionStorage = storage; | 39 theSessionStorage = storage; |
| 40 } | 40 } |
| 41 | 41 |
| 42 function dumpDOMStorage(next) | 42 function dumpDOMStorage(storage, callback) |
| 43 { | 43 { |
| 44 if (this.isLocalStorage) | 44 if (storage.isLocalStorage) |
| 45 InspectorTest.evaluateInPage("getDOMStorageEntries(true)", storageEn triesReceived.bind(this)); | 45 InspectorTest.evaluateInPage("getDOMStorageEntries(true)", storageEn triesReceived); |
| 46 else | 46 else |
| 47 InspectorTest.evaluateInPage("getDOMStorageEntries(false)", storageE ntriesReceived.bind(this)); | 47 InspectorTest.evaluateInPage("getDOMStorageEntries(false)", storageE ntriesReceived); |
| 48 | 48 |
| 49 function storageEntriesReceived(entries) | 49 function storageEntriesReceived(entries) |
| 50 { | 50 { |
| 51 InspectorTest.addResult((this.isLocalStorage ? "LocalStorage" : "Ses sionStorage") + " contents:" + entries.description); | 51 InspectorTest.addResult((storage.isLocalStorage ? "LocalStorage" : " SessionStorage") + " contents:" + entries.description); |
| 52 next(); | 52 callback(); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 function show(storage) | 56 function show(storage) |
| 57 { | 57 { |
| 58 WebInspector.panels.resources._showDOMStorage(storage); | 58 WebInspector.panels.resources._showDOMStorage(storage); |
| 59 } | 59 } |
| 60 | 60 |
| 61 function undo(operations, next) | 61 function undo(storage, operations, next) |
| 62 { | 62 { |
| 63 for (var i = 0; i < operations; ++i) | 63 var i = 1; |
| 64 this.undo(); | 64 show(storage); |
| 65 InspectorTest.runAfterPendingDispatches(dumpDOMStorage.bind(this, next)) ; | 65 InspectorTest.runAfterPendingDispatches(undoOnce); |
| 66 | |
| 67 function undoOnce() | |
| 68 { | |
| 69 if (i <= operations) { | |
| 70 setTimeout(perform, 0); | |
|
pfeldman
2013/08/27 14:27:34
Please don't use setTimeout in tests. It most like
| |
| 71 function perform() | |
| 72 { | |
| 73 storage.undo(); | |
| 74 ++i; | |
| 75 InspectorTest.runAfterPendingDispatches(undoOnce); | |
| 76 } | |
| 77 } else | |
| 78 dumpDOMStorage(storage, next); | |
| 79 } | |
| 66 } | 80 } |
| 67 | 81 |
| 68 function redo(operations, next) | 82 function redo(storage, operations, next) |
| 69 { | 83 { |
| 70 for (var i = 0; i < operations; ++i) | 84 var i = 1; |
| 71 this.redo(); | 85 show(storage); |
| 72 InspectorTest.runAfterPendingDispatches(dumpDOMStorage.bind(this, next)) ; | 86 InspectorTest.runAfterPendingDispatches(redoOnce); |
| 87 | |
| 88 function redoOnce() | |
| 89 { | |
| 90 if (i <= operations) { | |
| 91 setTimeout(perform, 0); | |
| 92 function perform() | |
| 93 { | |
| 94 storage.redo(); | |
| 95 ++i; | |
| 96 InspectorTest.runAfterPendingDispatches(redoOnce); | |
| 97 } | |
| 98 } else | |
| 99 dumpDOMStorage(storage, next); | |
| 100 } | |
| 73 } | 101 } |
| 74 | 102 |
| 75 function addKeyValuePair(storage, key, value) | 103 function addKeyValuePair(storage, key, value, callback) |
| 76 { | 104 { |
| 77 var dataGrid = WebInspector.panels.resources._domStorageViews.get(storag e)._dataGrid; | 105 var dataGrid = WebInspector.panels.resources._domStorageViews.get(storag e)._dataGrid; |
| 78 var creationNode = dataGrid.rootNode().children.peekLast(); | 106 var creationNode = dataGrid.rootNode().children.peekLast(); |
| 79 | 107 |
| 80 var elementKey = creationNode._element.children[0]; | 108 InspectorTest.runAfterPendingDispatches(addKey.bind(null, dataGrid, crea tionNode)); |
| 81 dataGrid._startEditing(elementKey); | 109 function addKey(dataGrid, creationNode) |
| 82 elementKey.textContent = key; | 110 { |
| 83 elementKey.dispatchEvent(InspectorTest.createKeyEvent("Enter")); | 111 var elementKey = creationNode._element.children[0]; |
| 112 dataGrid._startEditing(elementKey); | |
| 113 elementKey.textContent = key; | |
| 114 elementKey.dispatchEvent(InspectorTest.createKeyEvent("Enter")); | |
| 84 | 115 |
| 85 var elementValue = creationNode._element.children[1]; | 116 InspectorTest.runAfterPendingDispatches(addValue.bind(null, dataGrid , creationNode)); |
| 86 dataGrid._startEditing(elementValue); | 117 |
| 87 elementValue.textContent = value; | 118 function addValue(dataGrid, creationNode) |
| 88 elementValue.dispatchEvent(InspectorTest.createKeyEvent("Enter")); | 119 { |
| 120 var elementValue = creationNode._element.children[1]; | |
| 121 dataGrid._startEditing(elementValue); | |
| 122 elementValue.textContent = value; | |
| 123 elementValue.dispatchEvent(InspectorTest.createKeyEvent("Enter") ); | |
| 124 InspectorTest.runAfterPendingDispatches(callback); | |
| 125 } | |
| 126 } | |
| 89 } | 127 } |
| 90 | 128 |
| 91 function modifyValueForKey(storage, key, newValue) | 129 function modifyValueForKey(storage, key, newValue, callback) |
| 92 { | 130 { |
| 93 var dataGrid = WebInspector.panels.resources._domStorageViews.get(storag e)._dataGrid; | 131 var dataGrid = WebInspector.panels.resources._domStorageViews.get(storag e)._dataGrid; |
| 94 var children = dataGrid.rootNode().children; | 132 var children = dataGrid.rootNode().children; |
| 95 | 133 |
| 96 var modificationNode; | 134 InspectorTest.runAfterPendingDispatches(modifyValue.bind(null, dataGrid, children)); |
| 97 for (var i = 0; i < children.length; ++i) { | 135 function modifyValue(dataGrid, children) |
| 98 if (children[i]._element.children[0].textContent === key) { | 136 { |
| 99 modificationNode = children[i]; | 137 var modificationNode; |
| 100 break; | 138 for (var i = 0; i < children.length; ++i) { |
| 139 if (children[i]._element.children[0].textContent === key) { | |
| 140 modificationNode = children[i]; | |
| 141 break; | |
| 142 } | |
| 101 } | 143 } |
| 144 | |
| 145 var elementValue = modificationNode._element.children[1]; | |
| 146 dataGrid._startEditing(elementValue); | |
| 147 elementValue.textContent = newValue; | |
| 148 elementValue.dispatchEvent(InspectorTest.createKeyEvent("Enter")); | |
| 149 InspectorTest.runAfterPendingDispatches(callback); | |
| 102 } | 150 } |
| 103 | |
| 104 var elementValue = modificationNode._element.children[1]; | |
| 105 dataGrid._startEditing(elementValue); | |
| 106 elementValue.textContent = newValue; | |
| 107 elementValue.dispatchEvent(InspectorTest.createKeyEvent("Enter")); | |
| 108 } | 151 } |
| 109 | 152 |
| 110 function changeKey(storage, oldKey, newKey) | 153 function changeKey(storage, oldKey, newKey, callback) |
| 111 { | 154 { |
| 112 var dataGrid = WebInspector.panels.resources._domStorageViews.get(storag e)._dataGrid; | 155 var dataGrid = WebInspector.panels.resources._domStorageViews.get(storag e)._dataGrid; |
| 113 var children = dataGrid.rootNode().children; | 156 var children = dataGrid.rootNode().children; |
| 114 | 157 |
| 115 var modificationNode; | 158 InspectorTest.runAfterPendingDispatches(modifyKey.bind(null, dataGrid, c hildren)); |
| 116 for (var i = 0; i < children.length; ++i) { | 159 function modifyKey(dataGrid, children) |
| 117 if (children[i]._element.children[0].textContent === oldKey) { | 160 { |
| 118 modificationNode = children[i]; | 161 var modificationNode; |
| 119 break; | 162 for (var i = 0; i < children.length; ++i) { |
| 163 if (children[i]._element.children[0].textContent === oldKey) { | |
| 164 modificationNode = children[i]; | |
| 165 break; | |
| 166 } | |
| 167 } | |
| 168 var elementKey = modificationNode._element.children[0]; | |
| 169 dataGrid._startEditing(elementKey); | |
| 170 elementKey.textContent = newKey; | |
| 171 elementKey.dispatchEvent(InspectorTest.createKeyEvent("Enter")); | |
| 172 setTimeout(perform, 0); | |
| 173 function perform() | |
| 174 { | |
| 175 InspectorTest.runAfterPendingDispatches(callback); | |
| 120 } | 176 } |
| 121 } | 177 } |
| 122 var elementKey = modificationNode._element.children[0]; | |
| 123 dataGrid._startEditing(elementKey); | |
| 124 elementKey.textContent = newKey; | |
| 125 elementKey.dispatchEvent(InspectorTest.createKeyEvent("Enter")); | |
| 126 } | 178 } |
| 127 | 179 |
| 180 function addStorageEntries(storage, entries, autoSuffix, keyPrefix, valuePre fix, next) | |
| 181 { | |
| 182 var i = 1; | |
| 183 show(storage); | |
| 184 InspectorTest.runAfterPendingDispatches(domStorageViewShown); | |
| 185 | |
| 186 function domStorageViewShown() | |
| 187 { | |
| 188 if (i <= entries) { | |
| 189 if (autoSuffix) | |
| 190 addKeyValuePair(storage, keyPrefix + i, valuePrefix + i, dom StorageViewShown); | |
| 191 else | |
| 192 addKeyValuePair(storage, keyPrefix, valuePrefix, domStorageV iewShown); | |
| 193 ++i; | |
| 194 } else | |
| 195 dumpDOMStorage(storage, next); | |
| 196 } | |
| 197 } | |
| 198 | |
| 199 function setStorageEntryValue(storage, key, newValue, dumpStorage, callback) | |
| 200 { | |
| 201 show(storage); | |
| 202 InspectorTest.runAfterPendingDispatches(domStorageViewShown); | |
| 203 | |
| 204 function domStorageViewShown() | |
| 205 { | |
| 206 if (dumpStorage) | |
| 207 modifyValueForKey(storage, key, newValue, dumpDOMStorage.bind(nu ll, storage, callback)); | |
| 208 else | |
| 209 modifyValueForKey(storage, key, newValue, callback); | |
| 210 } | |
| 211 } | |
| 212 | |
| 213 function setStorageEntryKey(storage, oldKey, newKey, dumpStorage, callback) | |
| 214 { | |
| 215 show(storage); | |
| 216 InspectorTest.runAfterPendingDispatches(domStorageViewShown); | |
| 217 | |
| 218 function domStorageViewShown() | |
| 219 { | |
| 220 setTimeout(perform, 0); | |
| 221 function perform() | |
| 222 { | |
| 223 if (dumpStorage) | |
| 224 changeKey(storage, oldKey, newKey, dumpDOMStorage.bind(null, storage, callback)); | |
| 225 else | |
| 226 changeKey(storage, oldKey, newKey, callback); | |
| 227 } | |
| 228 } | |
| 229 } | |
| 230 | |
| 231 | |
| 128 InspectorTest.runTestSuite([ | 232 InspectorTest.runTestSuite([ |
| 129 function initialize(next) | 233 function initialize(next) |
| 130 { | 234 { |
| 131 InspectorTest.evaluateInPage("clearDOMStorage()", initialized); | 235 InspectorTest.evaluateInPage("clearDOMStorage()", initialized); |
| 132 | 236 |
| 133 function initialized(result) | 237 function initialized(result) |
| 134 { | 238 { |
| 135 InspectorTest.addResult("Initialized localStorage and sessionSto rage by clearing entries."); | 239 InspectorTest.addResult("Initialized localStorage and sessionSto rage by clearing entries."); |
| 136 next(); | 240 next(); |
| 137 } | 241 } |
| 138 }, | 242 }, |
| 139 | 243 |
| 140 function undoLocalStorageWithEmptyStack(next) | 244 function undoLocalStorageWithEmptyStack(next) |
| 141 { | 245 { |
| 142 show(theLocalStorage); | 246 undo(theLocalStorage, 10, next); |
| 143 InspectorTest.runAfterPendingDispatches(undo.bind(theLocalStorage, 1 0, next)); | |
| 144 }, | 247 }, |
| 145 | 248 |
| 146 function redoLocalStorageWithEmptyStack(next) | 249 function redoLocalStorageWithEmptyStack(next) |
| 147 { | 250 { |
| 148 show(theLocalStorage); | 251 redo(theLocalStorage, 10, next); |
| 149 InspectorTest.runAfterPendingDispatches(redo.bind(theLocalStorage, 1 0, next)); | |
| 150 }, | 252 }, |
| 151 | 253 |
| 152 function localStorageUndoInterlacedWithAddition(next) | 254 function localStorageUndoInterlacedWithAddition(next) |
| 153 { | 255 { |
| 154 show(theLocalStorage); | 256 addStorageEntries(theLocalStorage, 2, true, "a", "b", performFirstUn do); |
| 155 InspectorTest.runAfterPendingDispatches(domStorageViewShown.bind(the LocalStorage)); | 257 function performFirstUndo() |
| 156 function domStorageViewShown() | |
| 157 { | 258 { |
| 158 addKeyValuePair(this, "a1", "b1"); | 259 undo(theLocalStorage, 2, addOneMoreEntry); |
| 159 addKeyValuePair(this, "a2", "b2"); | 260 function addOneMoreEntry() |
| 160 InspectorTest.runAfterPendingDispatches(undo.bind(theLocalStorag e, 2, firstUndoDone.bind(null, next))); | |
| 161 | |
| 162 function firstUndoDone(callback) | |
| 163 { | 261 { |
| 164 addKeyValuePair(theLocalStorage, "a3", "b3"); | 262 addStorageEntries(theLocalStorage, 1, false, "a3", "b3", per formNextUndo); |
| 165 InspectorTest.runAfterPendingDispatches(dumpDOMStorage.bind( theLocalStorage, nextUndoDone.bind(null, callback))); | 263 function performNextUndo() |
| 166 | |
| 167 function nextUndoDone(callback) | |
| 168 { | 264 { |
| 169 InspectorTest.runAfterPendingDispatches(undo.bind(theLoc alStorage, 2, callback)); | 265 undo(theLocalStorage, 2, next); |
| 170 } | 266 } |
| 171 } | 267 } |
| 172 } | 268 } |
| 173 }, | 269 }, |
| 174 | 270 |
| 175 function addLocalStorageEntries(next) | 271 function addLocalStorageEntries(next) |
| 176 { | 272 { |
| 177 show(theLocalStorage); | 273 addStorageEntries(theLocalStorage, 2, true, "a", "b", next); |
| 178 InspectorTest.runAfterPendingDispatches(domStorageViewShown.bind(the LocalStorage)); | |
| 179 | |
| 180 function domStorageViewShown() | |
| 181 { | |
| 182 addKeyValuePair(this, "a1", "b1"); | |
| 183 addKeyValuePair(this, "a2", "b2"); | |
| 184 InspectorTest.runAfterPendingDispatches(dumpDOMStorage.bind(this , next)); | |
| 185 } | |
| 186 }, | 274 }, |
| 187 | 275 |
| 188 function undoLocalStorageLastAddition(next) | 276 function undoLocalStorageLastAddition(next) |
| 189 { | 277 { |
| 190 show(theLocalStorage); | 278 undo(theLocalStorage, 2, next); |
| 191 InspectorTest.runAfterPendingDispatches(undo.bind(theLocalStorage, 2 , next)); | |
| 192 }, | 279 }, |
| 193 | 280 |
| 194 function undoSessionStorageWithEmptyStack(next) | 281 function undoSessionStorageWithEmptyStack(next) |
| 195 { | 282 { |
| 196 show(theSessionStorage); | 283 undo(theSessionStorage, 10, next); |
| 197 InspectorTest.runAfterPendingDispatches(undo.bind(theSessionStorage, 10, next)); | |
| 198 }, | 284 }, |
| 199 | 285 |
| 200 function redoSessionStorageWithEmptyStack(next) | 286 function redoSessionStorageWithEmptyStack(next) |
| 201 { | 287 { |
| 202 show(theSessionStorage); | 288 redo(theSessionStorage, 10, next); |
| 203 InspectorTest.runAfterPendingDispatches(redo.bind(theSessionStorage, 10, next)); | |
| 204 }, | 289 }, |
| 205 | 290 |
| 206 function undoLocalStorageBeyondBounds(next) | 291 function undoLocalStorageBeyondBounds(next) |
| 207 { | 292 { |
| 208 InspectorTest.addResult("The entry a1=b1 is removed and any attempt to undo beyond it shouldn't cause any failure!") | 293 InspectorTest.addResult("The entry a1=b1 is removed and any attempt to undo beyond it shouldn't cause any failure!") |
| 209 show(theLocalStorage); | 294 undo(theLocalStorage, 10, next); |
| 210 InspectorTest.runAfterPendingDispatches(undo.bind(theLocalStorage, 1 0, next)); | |
| 211 }, | 295 }, |
| 212 | 296 |
| 213 function addSessionStorageEntries(next) | 297 function addSessionStorageEntries(next) |
| 214 { | 298 { |
| 215 show(theSessionStorage); | 299 addStorageEntries(theSessionStorage, 4, true, "p", "q", next); |
| 216 InspectorTest.runAfterPendingDispatches(domStorageViewShown.bind(the SessionStorage)); | |
| 217 | |
| 218 function domStorageViewShown() | |
| 219 { | |
| 220 addKeyValuePair(this, "p1", "q1"); | |
| 221 addKeyValuePair(this, "p2", "q2"); | |
| 222 addKeyValuePair(this, "p3", "q3"); | |
| 223 addKeyValuePair(this, "p4", "q4"); | |
| 224 InspectorTest.runAfterPendingDispatches(dumpDOMStorage.bind(this , next)); | |
| 225 } | |
| 226 }, | 300 }, |
| 227 | 301 |
| 228 function redoLocalStorageBeyondBounds(next) | 302 function redoLocalStorageBeyondBounds(next) |
| 229 { | 303 { |
| 230 InspectorTest.addResult("The entry a1=b1 and a2=b2 is added back and any attempt to redo beyond it shouldn't cause any failure!") | 304 InspectorTest.addResult("The entry a1=b1 and a2=b2 is added back and any attempt to redo beyond it shouldn't cause any failure!") |
| 231 show(theLocalStorage); | 305 redo(theLocalStorage, 10, next); |
| 232 InspectorTest.runAfterPendingDispatches(redo.bind(theLocalStorage, 1 0, next)); | |
| 233 }, | 306 }, |
| 234 | 307 |
| 235 function undoSessionStorageLastAddition(next) | 308 function undoSessionStorageLastAddition(next) |
| 236 { | 309 { |
| 237 show(theSessionStorage); | 310 undo(theSessionStorage, 2, next); |
| 238 InspectorTest.runAfterPendingDispatches(undo.bind(theSessionStorage, 2, next)); | |
| 239 }, | 311 }, |
| 240 | 312 |
| 241 function modifyLocalStorageValues(next) | 313 function modifyLocalStorageValues(next) |
| 242 { | 314 { |
| 243 show(theLocalStorage); | 315 setStorageEntryValue(theLocalStorage, "a1", "x1", false, modifyAnoth erValue); |
| 244 InspectorTest.runAfterPendingDispatches(domStorageViewShown.bind(the LocalStorage)); | 316 function modifyAnotherValue() |
| 245 | |
| 246 function domStorageViewShown() | |
| 247 { | 317 { |
| 248 modifyValueForKey(this, "a1", "x1"); | 318 setStorageEntryValue(theLocalStorage, "a2", "x2", true, next); |
| 249 modifyValueForKey(this, "a2", "x2"); | |
| 250 InspectorTest.runAfterPendingDispatches(dumpDOMStorage.bind(this , next)); | |
| 251 } | 319 } |
| 252 }, | 320 }, |
| 253 | 321 |
| 254 function undoLocalStorageModifications(next) | 322 function undoLocalStorageModifications(next) |
| 255 { | 323 { |
| 256 show(theLocalStorage); | 324 undo(theLocalStorage, 2, next); |
| 257 InspectorTest.runAfterPendingDispatches(undo.bind(theLocalStorage, 2 , next)); | |
| 258 }, | 325 }, |
| 259 | 326 |
| 260 function redoSessionStorageLastAddition(next) | 327 function redoSessionStorageLastAddition(next) |
| 261 { | 328 { |
| 262 show(theSessionStorage); | 329 redo(theSessionStorage, 2, next); |
| 263 InspectorTest.runAfterPendingDispatches(redo.bind(theSessionStorage, 2, next)); | |
| 264 }, | 330 }, |
| 265 | 331 |
| 266 function redoLocalStorageModifications(next) | 332 function redoLocalStorageModifications(next) |
| 267 { | 333 { |
| 268 show(theLocalStorage); | 334 show(theLocalStorage); |
| 269 InspectorTest.runAfterPendingDispatches(redo.bind(theLocalStorage, 2 , next)); | 335 redo(theLocalStorage, 2, next); |
| 270 }, | 336 }, |
| 271 | 337 |
| 272 function modifySessionStorageEntriesKey(next) | 338 function modifySessionStorageEntriesKey(next) |
| 273 { | 339 { |
| 274 show(theSessionStorage); | 340 setStorageEntryKey(theSessionStorage, "p1", "m1", false, firstDone); |
| 275 InspectorTest.runAfterPendingDispatches(domStorageViewShown.bind(the SessionStorage)); | 341 function firstDone() |
| 276 | |
| 277 function domStorageViewShown() | |
| 278 { | 342 { |
| 279 changeKey(this, "p1", "m1"); | 343 setStorageEntryKey(theSessionStorage, "p2", "m2", false, secondD one); |
| 280 changeKey(this, "p2", "m2"); | 344 function secondDone() |
| 281 changeKey(this, "p3", "m3"); | 345 { |
| 282 changeKey(this, "p4", "m4"); | 346 setStorageEntryKey(theSessionStorage, "p3", "m3", false, thi rdDone); |
| 283 InspectorTest.runAfterPendingDispatches(dumpDOMStorage.bind(this , next)); | 347 function thirdDone() |
| 348 { | |
| 349 setStorageEntryKey(theSessionStorage, "p4", "m4", true, next); | |
| 350 } | |
| 351 } | |
| 284 } | 352 } |
| 285 }, | 353 }, |
| 286 | 354 |
| 287 function undoLocalStorageModifications(next) | 355 function undoLocalStorageModifications(next) |
| 288 { | 356 { |
| 289 show(theLocalStorage); | 357 undo(theLocalStorage, 2, next); |
| 290 InspectorTest.runAfterPendingDispatches(undo.bind(theLocalStorage, 2 , next)); | |
| 291 }, | 358 }, |
| 292 | 359 |
| 293 function undoSessionStorageKeyModifications(next) | 360 function undoSessionStorageKeyModifications(next) |
| 294 { | 361 { |
| 295 show(theSessionStorage); | 362 undo(theSessionStorage, 8, next); |
| 296 InspectorTest.runAfterPendingDispatches(undo.bind(theSessionStorage, 8, next)); | |
| 297 }, | 363 }, |
| 298 | 364 |
| 299 function validateMaxUndoRedoStackDepth(next) | 365 function validateMaxUndoRedoStackDepth(next) |
| 300 { | 366 { |
| 301 show(theLocalStorage); | 367 var stackDepth = WebInspector.DOMStorageHistory.MAX_UNDO_STACK_DEPTH ; |
| 302 InspectorTest.runAfterPendingDispatches(domStorageViewShown.bind(the LocalStorage)); | 368 InspectorTest.addResult("Undo/redo stack depth limit is " + stackDep th); |
| 369 InspectorTest.addResult("Performing " + (2 * stackDepth) + " actions "); | |
| 370 addStorageEntries(theLocalStorage, stackDepth, true, "x", "y", undoM oreThanDepth); | |
| 303 | 371 |
| 304 function domStorageViewShown() | 372 function undoMoreThanDepth() |
| 305 { | 373 { |
| 306 var stackDepth = WebInspector.DOMStorageHistory.MAX_UNDO_STACK_D EPTH; | 374 InspectorTest.addResult("Performing undo operation three times t he depth i.e. " + (3 * stackDepth) + " times but only last " + stackDepth + " op erations are undone"); |
| 307 InspectorTest.addResult("Undo/redo stack depth limit is " + stac kDepth); | 375 undo(theLocalStorage, (3 * stackDepth), next); |
| 308 InspectorTest.addResult("Performing " + (2 * stackDepth) + " act ions"); | 376 } |
| 309 for (var i = 1; i <= stackDepth; ++i) | 377 }, |
| 310 addKeyValuePair(this, "x" + i, "y" + i); | |
| 311 | 378 |
| 312 InspectorTest.runAfterPendingDispatches(dumpDOMStorage.bind(this , undoMoreThanDepth)); | 379 function resetDOMStorageHistoryUponPageModification(next) |
| 313 | 380 { |
| 314 function undoMoreThanDepth() | 381 InspectorTest.addResult("Adding u1=v1 and u2=v2 in the localStorage" ); |
| 382 addStorageEntries(theLocalStorage, 2, true, "u", "v", tryUndoOnce); | |
| 383 function tryUndoOnce() | |
| 384 { | |
| 385 InspectorTest.addResult(""); | |
| 386 InspectorTest.addResult("Performing undo for removing u2=v2") | |
| 387 undo(theLocalStorage, 2, pageModifiesTheStorage); | |
| 388 function pageModifiesTheStorage() | |
| 315 { | 389 { |
| 316 InspectorTest.addResult("Performing undo operation three tim es the depth i.e. " + (3 * stackDepth) + " times but only last " + stackDepth + " operations are undone"); | 390 InspectorTest.addResult(""); |
| 317 InspectorTest.runAfterPendingDispatches(undo.bind(theLocalSt orage, (3 * stackDepth), next)); | 391 InspectorTest.addResult("Page has modified the storage by ad ding u3=v3"); |
| 392 InspectorTest.evaluateInPage("localStorage['u3'] = 'v3'", mo dificationDone); | |
| 393 function modificationDone() | |
| 394 { | |
| 395 InspectorTest.addResult(""); | |
| 396 InspectorTest.addResult("Undo wont work anymore as page modification has cleared the history.") | |
| 397 undo(theLocalStorage, 10, tryRedo); | |
| 398 function tryRedo() | |
| 399 { | |
| 400 InspectorTest.addResult(""); | |
| 401 InspectorTest.addResult("Redo wont work anymore as p age modification has cleared the history.") | |
| 402 redo(theLocalStorage, 10, next); | |
| 403 } | |
| 404 } | |
| 318 } | 405 } |
| 319 } | 406 } |
| 320 }, | 407 }, |
| 321 | 408 |
| 322 function clearDOMStorageAndFinish(next) | 409 function clearDOMStorageAndFinish(next) |
| 323 { | 410 { |
| 324 InspectorTest.evaluateInPage("clearDOMStorage()", finishTest); | 411 InspectorTest.evaluateInPage("clearDOMStorage()", finishTest); |
| 325 | 412 |
| 326 function finishTest(result) | 413 function finishTest(result) |
| 327 { | 414 { |
| 328 InspectorTest.addResult("Finished DOMStorage undo/redo tests and cleared localStorage and sessionStorage entries."); | 415 InspectorTest.addResult("Finished DOMStorage undo/redo tests and cleared localStorage and sessionStorage entries."); |
| 329 next(); | 416 next(); |
| 330 } | 417 } |
| 331 } | 418 } |
| 332 ]); | 419 ]); |
| 333 } | 420 } |
| 334 </script> | 421 </script> |
| 335 </head> | 422 </head> |
| 336 <body onload="runTest()"> | 423 <body onload="runTest()"> |
| 337 <p>This test checks the undo/redo operations are performed correctly on the DOM storage views</p> | 424 <p>This test checks the undo/redo operations are performed correctly on the DOM storage views</p> |
| 338 </body> | 425 </body> |
| 339 </html> | 426 </html> |
| OLD | NEW |