| Index: LayoutTests/inspector/storage-panel-dom-storage-undo-redo.html
|
| diff --git a/LayoutTests/inspector/storage-panel-dom-storage-undo-redo.html b/LayoutTests/inspector/storage-panel-dom-storage-undo-redo.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8de1c131430fafa8032a83c9731a04893ce2ec6a
|
| --- /dev/null
|
| +++ b/LayoutTests/inspector/storage-panel-dom-storage-undo-redo.html
|
| @@ -0,0 +1,227 @@
|
| +<html>
|
| +<head>
|
| +<script src="../http/tests/inspector/inspector-test.js"></script>
|
| +<script>
|
| +
|
| +function initializeDOMStorage()
|
| +{
|
| + localStorage.clear();
|
| + sessionStorage.clear();
|
| +}
|
| +
|
| +function test()
|
| +{
|
| + // Resources panel must be visible
|
| + WebInspector.showPanel("resources");
|
| +
|
| + var LocalStorage;
|
| + var SessionStorage;
|
| + var storages = WebInspector.domStorageModel.storages();
|
| + for (var i = 0; i < storages.length; ++i) {
|
| + var storage = storages[i];
|
| + if (storage.isLocalStorage)
|
| + LocalStorage = storage;
|
| + else
|
| + SessionStorage = storage;
|
| + }
|
| +
|
| + function dumpDataGrid(next)
|
| + {
|
| + InspectorTest.addResult((this.isLocalStorage ? "localStorage: " : "sessionStorage: ") + "contents");
|
| + var dataGrid = WebInspector.panels.resources._domStorageViews.get(this)._dataGrid;
|
| + var nodes = dataGrid.rootNode().children;
|
| + var rows = [];
|
| + for (var i = 0; i < nodes.length; ++i) {
|
| + var node = nodes[i];
|
| + if (node._data.key.length)
|
| + rows.push(node._data.key + node._data.value);
|
| + }
|
| + rows.sort();
|
| + InspectorTest.addResult("[" + rows.join() + "]");
|
| + next();
|
| + }
|
| +
|
| + function show(storage)
|
| + {
|
| + WebInspector.panels.resources._showDOMStorage(storage);
|
| + }
|
| +
|
| + function undo(operations, next)
|
| + {
|
| + for (var i = 0; i < operations; ++i)
|
| + this.undo();
|
| + InspectorTest.runAfterPendingDispatches(dumpDataGrid.bind(this, next));
|
| + }
|
| +
|
| + function redo(operations, next)
|
| + {
|
| + for (var i = 0; i < operations; ++i)
|
| + this.redo();
|
| + InspectorTest.runAfterPendingDispatches(dumpDataGrid.bind(this, next));
|
| + }
|
| +
|
| + function addKeyValuePair(storage, key, value)
|
| + {
|
| + var dataGrid = WebInspector.panels.resources._domStorageViews.get(storage)._dataGrid;
|
| + var creationNode = dataGrid.rootNode().children[dataGrid.rootNode().children.length - 1];
|
| +
|
| + var elementKey = creationNode._element.children[0];
|
| + dataGrid._startEditing(elementKey);
|
| + elementKey.textContent = key;
|
| + elementKey.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
|
| +
|
| + var elementValue = creationNode._element.children[1];
|
| + dataGrid._startEditing(elementValue);
|
| + elementValue.textContent = "=" + value;
|
| + elementValue.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
|
| + }
|
| +
|
| + function modifyValueForKey(storage, key, newValue)
|
| + {
|
| + var dataGrid = WebInspector.panels.resources._domStorageViews.get(storage)._dataGrid;
|
| + var children = dataGrid.rootNode().children;
|
| +
|
| + var modificationNode;
|
| + for (var i = 0; i < children.length; ++i) {
|
| + if (children[i]._element.children[0].textContent === key) {
|
| + modificationNode = children[i];
|
| + break;
|
| + }
|
| + }
|
| +
|
| + var elementValue = modificationNode._element.children[1];
|
| + dataGrid._startEditing(elementValue);
|
| + elementValue.textContent = "=" + newValue;
|
| + elementValue.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
|
| + }
|
| +
|
| + function changeKey(storage, oldKey, newKey)
|
| + {
|
| + var dataGrid = WebInspector.panels.resources._domStorageViews.get(storage)._dataGrid;
|
| + var children = dataGrid.rootNode().children;
|
| +
|
| + var modificationNode;
|
| + for (var i = 0; i < children.length; ++i) {
|
| + if (children[i]._element.children[0].textContent === oldKey) {
|
| + modificationNode = children[i];
|
| + break;
|
| + }
|
| + }
|
| + var elementKey = modificationNode._element.children[0];
|
| + dataGrid._startEditing(elementKey);
|
| + elementKey.textContent = newKey;
|
| + elementKey.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
|
| + }
|
| +
|
| + InspectorTest.runTestSuite([
|
| + function initialize(next)
|
| + {
|
| + function initialized(result)
|
| + {
|
| + InspectorTest.addResult("Initialized localStorage and sessionStorage by clearing entries");
|
| + next();
|
| + }
|
| + InspectorTest.evaluateInPage("initializeDOMStorage()", initialized );
|
| + },
|
| +
|
| + function addLocalStorageEntries(next)
|
| + {
|
| + function domStorageViewShown()
|
| + {
|
| + addKeyValuePair(this, "a1", "b1");
|
| + addKeyValuePair(this, "a2", "b2");
|
| + InspectorTest.runAfterPendingDispatches(dumpDataGrid.bind(this, next));
|
| + }
|
| + show(LocalStorage);
|
| + InspectorTest.runAfterPendingDispatches(domStorageViewShown.bind(LocalStorage));
|
| + },
|
| +
|
| + function undoLocalStorageLastAddition(next)
|
| + {
|
| + show(LocalStorage);
|
| + InspectorTest.runAfterPendingDispatches(undo.bind(LocalStorage, 2, next));
|
| + },
|
| +
|
| + function addSessionStorageEntries(next)
|
| + {
|
| + function domStorageViewShown()
|
| + {
|
| + addKeyValuePair(this, "p1", "q1");
|
| + addKeyValuePair(this, "p2", "q2");
|
| + addKeyValuePair(this, "p3", "q3");
|
| + addKeyValuePair(this, "p4", "q4");
|
| + InspectorTest.runAfterPendingDispatches(dumpDataGrid.bind(this, next));
|
| + }
|
| + show(SessionStorage);
|
| + InspectorTest.runAfterPendingDispatches(domStorageViewShown.bind(SessionStorage));
|
| + },
|
| +
|
| + function redoLocalStorageLastAddition(next)
|
| + {
|
| + show(LocalStorage);
|
| + InspectorTest.runAfterPendingDispatches(redo.bind(LocalStorage, 2, next));
|
| + },
|
| +
|
| + function undoSessionStorageLastAddition(next)
|
| + {
|
| + show(SessionStorage);
|
| + InspectorTest.runAfterPendingDispatches(undo.bind(SessionStorage, 2, next));
|
| + },
|
| +
|
| + function modifyLocalStorageValues(next)
|
| + {
|
| + function domStorageViewShown()
|
| + {
|
| + modifyValueForKey(this, "a1", "x1");
|
| + modifyValueForKey(this, "a2", "x2");
|
| + InspectorTest.runAfterPendingDispatches(dumpDataGrid.bind(this, next));
|
| + }
|
| + show(LocalStorage);
|
| + InspectorTest.runAfterPendingDispatches(domStorageViewShown.bind(LocalStorage));
|
| + },
|
| +
|
| + function undoLocalStorageModifications(next)
|
| + {
|
| + show(LocalStorage);
|
| + InspectorTest.runAfterPendingDispatches(undo.bind(LocalStorage, 2, next));
|
| + },
|
| +
|
| + function redoLocalStorageModifications(next)
|
| + {
|
| + show(LocalStorage);
|
| + InspectorTest.runAfterPendingDispatches(redo.bind(LocalStorage, 2, next));
|
| + },
|
| +
|
| + function modifySessionStorageEntriesKey(next)
|
| + {
|
| + function domStorageViewShown()
|
| + {
|
| + changeKey(this, "p1", "m1");
|
| + changeKey(this, "p2", "m2");
|
| + changeKey(this, "p3", "m3");
|
| + InspectorTest.runAfterPendingDispatches(dumpDataGrid.bind(this, next));
|
| + }
|
| + show(SessionStorage);
|
| + InspectorTest.runAfterPendingDispatches(domStorageViewShown.bind(SessionStorage));
|
| + },
|
| +
|
| + function undoLocalStorageModifications(next)
|
| + {
|
| + show(LocalStorage);
|
| + InspectorTest.runAfterPendingDispatches(undo.bind(LocalStorage, 2, next));
|
| + },
|
| +
|
| + function undoSessionStorageKeyModifications(next)
|
| + {
|
| + show(SessionStorage);
|
| + InspectorTest.runAfterPendingDispatches(undo.bind(SessionStorage, 3, next));
|
| + },
|
| + ]);
|
| +}
|
| +</script>
|
| +</head>
|
| +
|
| + <body onload="runTest()">
|
| +<p>This test demonstrates the undo/redo operations performed on the storage views</p>
|
| +</body>
|
| +</html>
|
|
|