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. Tests IndexedDB tree element on resources panel.
Expanded IndexedDB tree element. Expanded IndexedDB tree element.
Dumping IndexedDB tree: Dumping IndexedDB tree:
(empty) (empty)
Creating database.
Created database. Created database.
Refreshing.
Refreshed.
Dumping IndexedDB tree: Dumping IndexedDB tree:
database: testDatabase - http://127.0.0.1:8000 database: testDatabase - http://127.0.0.1:8000
Object store: testObjectStore Object store: testObjectStore
Index: testIndexName Index: testIndexName
Navigating to another security origin.
Navigated to another security origin. Navigated to another security origin.
Page reloaded.
Dumping IndexedDB tree: Dumping IndexedDB tree:
(empty) (empty)
Navigating back.
Navigated back. Navigated back.
Page reloaded. Refreshing.
Refreshed.
Dumping IndexedDB tree: Dumping IndexedDB tree:
database: testDatabase - http://127.0.0.1:8000 database: testDatabase - http://127.0.0.1:8000
Object store: testObjectStore Object store: testObjectStore
Index: testIndexName Index: testIndexName
Deleting database.
Deleted database. Deleted database.
Refreshing.
Refreshed.
Dumping IndexedDB tree: Dumping IndexedDB tree:
(empty) (empty)
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
await TestRunner.loadModule('console_test_runner'); await TestRunner.loadModule('console_test_runner');
var mainFrameId = TestRunner.resourceTreeModel.mainFrame.id; var mainFrameId;
var indexedDBModel; var indexedDBModel;
var withoutIndexedDBURL = 'http://localhost:8000/devtools/indexeddb/resources/without-indexed-db.html'; 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 databaseName = 'testDatabase';
var objectStoreName = 'testObjectStore'; var objectStoreName = 'testObjectStore';
var indexName = 'testIndexName'; var indexName = 'testIndexName';
...@@ -43,65 +43,72 @@ ...@@ -43,65 +43,72 @@
} }
} }
// Start with non-resources panel. await TestRunner.navigatePromise(originalURL);
UI.viewManager.showView('console'); await ApplicationTestRunner.setupIndexedDBHelpers();
mainFrameId = TestRunner.resourceTreeModel.mainFrame.id;
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.');
}
TestRunner.addSniffer(Resources.IndexedDBTreeElement.prototype, '_indexedDBLoaded', indexedDBLoaded, true); // Start with non-resources panel.
function indexedDBLoaded() { await TestRunner.showPanel('console');
TestRunner.addResult('Database loaded.');
}
// Switch to resources panel. // Switch to resources panel.
UI.viewManager.showView('resources'); await TestRunner.showPanel('resources');
TestRunner.addResult('Expanded IndexedDB tree element.'); TestRunner.addResult('Expanded IndexedDB tree element.');
UI.panels.resources._sidebar.indexedDBListTreeElement.expand(); UI.panels.resources._sidebar.indexedDBListTreeElement.expand();
ApplicationTestRunner.dumpIndexedDBTree(); ApplicationTestRunner.dumpIndexedDBTree();
TestRunner.addResult('Created database.'); TestRunner.addResult('Creating database.');
createDatabase(databaseCreated); createDatabase(databaseCreated);
function databaseCreated() { function databaseCreated() {
TestRunner.addResult('Created database.');
indexedDBModel = ApplicationTestRunner.indexedDBModel(); indexedDBModel = ApplicationTestRunner.indexedDBModel();
indexedDBModel.addEventListener(Resources.IndexedDBModel.Events.DatabaseLoaded, databaseLoaded); indexedDBModel.addEventListener(Resources.IndexedDBModel.Events.DatabaseLoaded, databaseLoaded);
UI.panels.resources._sidebar.indexedDBListTreeElement.refreshIndexedDB(); UI.panels.resources._sidebar.indexedDBListTreeElement.refreshIndexedDB();
TestRunner.addResult('Refreshing.');
} }
function databaseLoaded() { function databaseLoaded() {
TestRunner.addResult('Refreshed.');
indexedDBModel.removeEventListener(Resources.IndexedDBModel.Events.DatabaseLoaded, databaseLoaded); indexedDBModel.removeEventListener(Resources.IndexedDBModel.Events.DatabaseLoaded, databaseLoaded);
ApplicationTestRunner.dumpIndexedDBTree(); ApplicationTestRunner.dumpIndexedDBTree();
TestRunner.addResult('Navigated to another security origin.'); TestRunner.addResult('Navigating to another security origin.');
TestRunner.navigate(withoutIndexedDBURL, navigatedAway); TestRunner.navigate(withoutIndexedDBURL, navigatedAway);
} }
function navigatedAway() { function navigatedAway() {
TestRunner.addResult('Navigated to another security origin.');
ApplicationTestRunner.dumpIndexedDBTree(); ApplicationTestRunner.dumpIndexedDBTree();
TestRunner.addResult('Navigated back.'); TestRunner.addResult('Navigating back.');
TestRunner.navigate(originalURL, navigatedBack); TestRunner.navigate(originalURL, navigatedBack);
} }
function 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(); ApplicationTestRunner.dumpIndexedDBTree();
TestRunner.addResult('Deleted database.'); await ApplicationTestRunner.setupIndexedDBHelpers();
mainFrameId = TestRunner.resourceTreeModel.mainFrame.id;
TestRunner.addResult('Deleting database.');
deleteDatabase(databaseDeleted); deleteDatabase(databaseDeleted);
} }
function databaseDeleted() { function databaseDeleted() {
TestRunner.addResult('Deleted database.');
TestRunner.addResult('Refreshing.');
UI.panels.resources._sidebar.indexedDBListTreeElement.refreshIndexedDB(); UI.panels.resources._sidebar.indexedDBListTreeElement.refreshIndexedDB();
TestRunner.addSniffer( TestRunner.addSniffer(
Resources.IndexedDBModel.prototype, '_updateOriginDatabaseNames', databaseNamesLoadedAfterDeleting, false); Resources.IndexedDBModel.prototype, '_updateOriginDatabaseNames', databaseNamesLoadedAfterDeleting, false);
} }
function databaseNamesLoadedAfterDeleting() { function databaseNamesLoadedAfterDeleting() {
TestRunner.addResult('Refreshed.');
ApplicationTestRunner.dumpIndexedDBTree(); ApplicationTestRunner.dumpIndexedDBTree();
UI.panels.resources._sidebar.indexedDBListTreeElement.collapse(); UI.panels.resources._sidebar.indexedDBListTreeElement.collapse();
TestRunner.completeTest(); TestRunner.completeTest();
......
...@@ -180,7 +180,7 @@ ApplicationTestRunner.deleteIDBValueAsync = function(databaseName, objectStoreNa ...@@ -180,7 +180,7 @@ ApplicationTestRunner.deleteIDBValueAsync = function(databaseName, objectStoreNa
'deleteIDBValueAsync(\'' + databaseName + '\', \'' + objectStoreName + '\', \'' + key + '\')'); 'deleteIDBValueAsync(\'' + databaseName + '\', \'' + objectStoreName + '\', \'' + key + '\')');
}; };
TestRunner.deprecatedInitAsync(` var __indexedDBHelpers = `
function dispatchCallback(callbackId) { function dispatchCallback(callbackId) {
console.log(callbackId); console.log(callbackId);
} }
...@@ -448,4 +448,10 @@ TestRunner.deprecatedInitAsync(` ...@@ -448,4 +448,10 @@ TestRunner.deprecatedInitAsync(`
} }
return promise; 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