Commit d1f7fd6d authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

Fix http/tests/devtools/indexeddb/resources-panel.js

Bug: none
Change-Id: I2ac1d32df262d07d9756dd466a7022ab2e90596c
Reviewed-on: https://chromium-review.googlesource.com/898386Reviewed-by: default avatarEugene Ostroukhov <eostroukhov@chromium.org>
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534039}
parent 96625b50
CONSOLE MESSAGE: line 2: InspectorTest.IndexedDB_callback1
CONSOLE MESSAGE: line 2: InspectorTest.IndexedDB_callback2
CONSOLE MESSAGE: line 2: InspectorTest.IndexedDB_callback3
CONSOLE MESSAGE: line 2: InspectorTest.IndexedDB_callback4
CONSOLE MESSAGE: line 2: InspectorTest.IndexedDB_callback5
CONSOLE MESSAGE: line 2: InspectorTest.IndexedDB_callback6
Tests IndexedDB tree element on resources panel.
Expanded IndexedDB tree element.
Dumping IndexedDB tree:
(empty)
Creating database.
Created database.
Refreshing.
Refreshed.
Dumping IndexedDB tree:
database: testDatabase - http://127.0.0.1:8000
Object store: testObjectStore
Index: testIndexName
Navigating to another security origin.
Navigated to another security origin.
Page reloaded.
Dumping IndexedDB tree:
(empty)
Navigating back.
Navigated back.
Page reloaded.
Refreshing.
Refreshed.
Dumping IndexedDB tree:
database: testDatabase - http://127.0.0.1:8000
Object store: testObjectStore
Index: testIndexName
Deleting database.
Deleted database.
Refreshing.
Refreshed.
Dumping IndexedDB tree:
(empty)
......@@ -10,10 +10,10 @@
await TestRunner.loadModule('console_test_runner');
var mainFrameId = TestRunner.resourceTreeModel.mainFrame.id;
var mainFrameId;
var indexedDBModel;
var withoutIndexedDBURL = 'http://localhost:8000/devtools/indexeddb/resources/without-indexed-db.html';
var originalURL = 'http://127.0.0.1:8000/devtools/indexeddb/resources-panel.js';
var originalURL = 'http://127.0.0.1:8000/devtools/indexeddb/resources/with-indexed-db.html';
var databaseName = 'testDatabase';
var objectStoreName = 'testObjectStore';
var indexName = 'testIndexName';
......@@ -43,65 +43,72 @@
}
}
// Start with non-resources panel.
UI.viewManager.showView('console');
TestRunner.addSniffer(Resources.IndexedDBTreeElement.prototype, '_indexedDBAdded', indexedDBAdded, true);
function indexedDBAdded() {
TestRunner.addResult('Database added.');
}
TestRunner.addSniffer(Resources.IndexedDBTreeElement.prototype, '_indexedDBRemoved', indexedDBRemoved, true);
function indexedDBRemoved() {
TestRunner.addResult('Database removed.');
}
await TestRunner.navigatePromise(originalURL);
await ApplicationTestRunner.setupIndexedDBHelpers();
mainFrameId = TestRunner.resourceTreeModel.mainFrame.id;
TestRunner.addSniffer(Resources.IndexedDBTreeElement.prototype, '_indexedDBLoaded', indexedDBLoaded, true);
function indexedDBLoaded() {
TestRunner.addResult('Database loaded.');
}
// Start with non-resources panel.
await TestRunner.showPanel('console');
// Switch to resources panel.
UI.viewManager.showView('resources');
await TestRunner.showPanel('resources');
TestRunner.addResult('Expanded IndexedDB tree element.');
UI.panels.resources._sidebar.indexedDBListTreeElement.expand();
ApplicationTestRunner.dumpIndexedDBTree();
TestRunner.addResult('Created database.');
TestRunner.addResult('Creating database.');
createDatabase(databaseCreated);
function databaseCreated() {
TestRunner.addResult('Created database.');
indexedDBModel = ApplicationTestRunner.indexedDBModel();
indexedDBModel.addEventListener(Resources.IndexedDBModel.Events.DatabaseLoaded, databaseLoaded);
UI.panels.resources._sidebar.indexedDBListTreeElement.refreshIndexedDB();
TestRunner.addResult('Refreshing.');
}
function databaseLoaded() {
TestRunner.addResult('Refreshed.');
indexedDBModel.removeEventListener(Resources.IndexedDBModel.Events.DatabaseLoaded, databaseLoaded);
ApplicationTestRunner.dumpIndexedDBTree();
TestRunner.addResult('Navigated to another security origin.');
TestRunner.addResult('Navigating to another security origin.');
TestRunner.navigate(withoutIndexedDBURL, navigatedAway);
}
function navigatedAway() {
TestRunner.addResult('Navigated to another security origin.');
ApplicationTestRunner.dumpIndexedDBTree();
TestRunner.addResult('Navigated back.');
TestRunner.addResult('Navigating back.');
TestRunner.navigate(originalURL, navigatedBack);
}
function navigatedBack() {
TestRunner.addResult('Navigated back.');
indexedDBModel.addEventListener(Resources.IndexedDBModel.Events.DatabaseLoaded, databaseLoaded2);
UI.panels.resources._sidebar.indexedDBListTreeElement.refreshIndexedDB();
TestRunner.addResult('Refreshing.');
}
async function databaseLoaded2() {
TestRunner.addResult('Refreshed.');
indexedDBModel.removeEventListener(Resources.IndexedDBModel.Events.DatabaseLoaded, databaseLoaded2);
ApplicationTestRunner.dumpIndexedDBTree();
TestRunner.addResult('Deleted database.');
await ApplicationTestRunner.setupIndexedDBHelpers();
mainFrameId = TestRunner.resourceTreeModel.mainFrame.id;
TestRunner.addResult('Deleting database.');
deleteDatabase(databaseDeleted);
}
function databaseDeleted() {
TestRunner.addResult('Deleted database.');
TestRunner.addResult('Refreshing.');
UI.panels.resources._sidebar.indexedDBListTreeElement.refreshIndexedDB();
TestRunner.addSniffer(
Resources.IndexedDBModel.prototype, '_updateOriginDatabaseNames', databaseNamesLoadedAfterDeleting, false);
}
function databaseNamesLoadedAfterDeleting() {
TestRunner.addResult('Refreshed.');
ApplicationTestRunner.dumpIndexedDBTree();
UI.panels.resources._sidebar.indexedDBListTreeElement.collapse();
TestRunner.completeTest();
......
......@@ -180,7 +180,7 @@ ApplicationTestRunner.deleteIDBValueAsync = function(databaseName, objectStoreNa
'deleteIDBValueAsync(\'' + databaseName + '\', \'' + objectStoreName + '\', \'' + key + '\')');
};
TestRunner.deprecatedInitAsync(`
var __indexedDBHelpers = `
function dispatchCallback(callbackId) {
console.log(callbackId);
}
......@@ -448,4 +448,10 @@ TestRunner.deprecatedInitAsync(`
}
return promise;
}
`);
`;
ApplicationTestRunner.setupIndexedDBHelpers = function() {
return TestRunner.evaluateInPagePromise(__indexedDBHelpers);
};
TestRunner.deprecatedInitAsync(__indexedDBHelpers);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment