blob: 503eb707c132170349b5da981a862a64bbb237f9 [file] [log] [blame]
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script src="../http/tests/inspector/resources-test.js"></script>
<script>
function populateDOMStorage()
{
localStorage.clear();
sessionStorage.clear();
localStorage["resource-history"] = "{}"; // This mitigates file:// localstorage conflict.
// Fill local and session storage with some random strings.
for (var i = 0; i < 10; i++) {
localStorage["a" + i] = "=value" + i + ", ";
sessionStorage["b" + i] = "=value" + (i+10) + ", ";
}
}
function test()
{
InspectorTest.evaluateInPage("populateDOMStorage()", function(result) {
InspectorTest.addResult("Populated local and session storage");
});
function name(storage)
{
return storage.isLocalStorage ? "Local storage" : "Session storage";
}
function dumpDataGridContent(dataGrid)
{
var nodes = dataGrid.rootNode().children;
var rows = [];
for (var i = 0; i < nodes.length; ++i) {
var node = nodes[i];
if (!node.isCreationNode)
rows.push(node._data.key + node._data.value);
}
rows.sort();
InspectorTest.addResult("KeyValue pairs: " + rows.join(''));
}
function testStorageInView(storages) {
var storage = storages.shift();
if (!storage) {
InspectorTest.addResult("DONE");
InspectorTest.completeTest();
return;
}
UI.panels.resources.showDOMStorage(storage);
InspectorTest.addResult("Did show: " + name(storage));
InspectorTest.deprecatedRunAfterPendingDispatches(function() {
InspectorTest.addResult(name(storage) + " content: ");
var view = UI.panels.resources._domStorageView;
dumpDataGridContent(view._dataGrid);
InspectorTest.deprecatedRunAfterPendingDispatches(() => testStorageInView(storages));
});
}
InspectorTest.deprecatedRunAfterPendingDispatches(function() {
var storages = InspectorTest.domStorageModel().storages();
if (storages)
testStorageInView(storages.slice());
else
InspectorTest.addResult("FAIL: no DOM storages found.");
});
}
</script>
</head>
<body onload="runTest()">
<p>
Test that storage panel is present and that it contains correct data for local and session DOM storages.
</p>
</body>
</html>