Diff
Modified: trunk/LayoutTests/ChangeLog (205085 => 205086)
--- trunk/LayoutTests/ChangeLog 2016-08-27 22:13:44 UTC (rev 205085)
+++ trunk/LayoutTests/ChangeLog 2016-08-28 00:10:29 UTC (rev 205086)
@@ -1,3 +1,30 @@
+2016-08-27 Joseph Pecoraro <[email protected]>
+
+ Race between creating/deleting a database in test
+ https://bugs.webkit.org/show_bug.cgi?id=161285
+
+ Reviewed by Darin Adler.
+
+ Because IndexedDB creation is asynchronous, we were not waiting for the
+ database to be completely open before sending more commands. These
+ could race and give unexpected results. Wait for the database to be
+ successfully created before interacting with it.
+
+ * inspector/indexeddb/resources/utilities.js:
+ (createEmptyDatabase):
+ (createDatabaseWithStores):
+ Send a single when the database creation is completed.
+
+ * inspector/indexeddb/clearObjectStore-expected.txt:
+ * inspector/indexeddb/clearObjectStore.html:
+ * inspector/indexeddb/deleteDatabaseNamesWithSpace.html:
+ * inspector/indexeddb/requestData-expected.txt:
+ * inspector/indexeddb/requestDatabase-expected.txt:
+ * inspector/indexeddb/requestDatabase.html:
+ * inspector/indexeddb/requestDatabaseNames.html:
+ Listen for the database created signal before proceeding
+ with the test.
+
2016-08-27 Ryosuke Niwa <[email protected]>
adoptcallback
Modified: trunk/LayoutTests/inspector/indexeddb/clearObjectStore-expected.txt (205085 => 205086)
--- trunk/LayoutTests/inspector/indexeddb/clearObjectStore-expected.txt 2016-08-27 22:13:44 UTC (rev 205085)
+++ trunk/LayoutTests/inspector/indexeddb/clearObjectStore-expected.txt 2016-08-28 00:10:29 UTC (rev 205086)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 18: Created Database 'CompleteDatabase'
+CONSOLE MESSAGE: line 19: Created Database 'CompleteDatabase'
CONSOLE MESSAGE: line 9: Created Database 'EmptyDatabase'
== Running test suite: IndexedDB.clearObjectStore
Modified: trunk/LayoutTests/inspector/indexeddb/clearObjectStore.html (205085 => 205086)
--- trunk/LayoutTests/inspector/indexeddb/clearObjectStore.html 2016-08-27 22:13:44 UTC (rev 205085)
+++ trunk/LayoutTests/inspector/indexeddb/clearObjectStore.html 2016-08-28 00:10:29 UTC (rev 205086)
@@ -71,10 +71,12 @@
name: "NoSuchObjectStore",
test: (resolve, reject) => {
InspectorTest.evaluateInPage("createEmptyDatabase('EmptyDatabase', 1)");
- IndexedDBAgent.requestDatabase(WebInspector.frameResourceManager.mainFrame.securityOrigin, "EmptyDatabase", (error, database) => {
- IndexedDBAgent.clearObjectStore(WebInspector.frameResourceManager.mainFrame.securityOrigin, database.name, "NoSuchObjectStore", (error) => {
- InspectorTest.expectThat(error, "Should be an error attempting to clear an object store that does not exist.");
- resolve();
+ InspectorTest.singleFireEventListener("DatabaseCreated", (event) => {
+ IndexedDBAgent.requestDatabase(WebInspector.frameResourceManager.mainFrame.securityOrigin, "EmptyDatabase", (error, database) => {
+ IndexedDBAgent.clearObjectStore(WebInspector.frameResourceManager.mainFrame.securityOrigin, database.name, "NoSuchObjectStore", (error) => {
+ InspectorTest.expectThat(error, "Should be an error attempting to clear an object store that does not exist.");
+ resolve();
+ });
});
});
}
Modified: trunk/LayoutTests/inspector/indexeddb/deleteDatabaseNamesWithSpace.html (205085 => 205086)
--- trunk/LayoutTests/inspector/indexeddb/deleteDatabaseNamesWithSpace.html 2016-08-27 22:13:44 UTC (rev 205085)
+++ trunk/LayoutTests/inspector/indexeddb/deleteDatabaseNamesWithSpace.html 2016-08-28 00:10:29 UTC (rev 205086)
@@ -24,14 +24,11 @@
name: "EnsureNoDatabases",
description: "Ensure no databases exist at the start.",
test: (resolve, reject) => {
- // FIXME: <https://webkit.org/b/161285> Race between deleting a database and requesting database names seen in test
- setTimeout(() => {
- IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
- InspectorTest.expectNoError(error);
- InspectorTest.expectThat(names.length === 0, "No IndexedDB databases should exist initially.");
- resolve();
- });
- }, 50);
+ IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
+ InspectorTest.expectNoError(error);
+ InspectorTest.expectThat(names.length === 0, "No IndexedDB databases should exist initially.");
+ resolve();
+ });
}
});
@@ -40,11 +37,13 @@
description: "Create a database with spaces in the name.",
test: (resolve, reject) => {
InspectorTest.evaluateInPage("createEmptyDatabase('Database With Space')");
- IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
- InspectorTest.expectNoError(error);
- InspectorTest.expectThat(names.length === 1, "A single IndexedDB database should exist.");
- InspectorTest.log(JSON.stringify(names));
- resolve();
+ InspectorTest.singleFireEventListener("DatabaseCreated", (event) => {
+ IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
+ InspectorTest.expectNoError(error);
+ InspectorTest.expectThat(names.length === 1, "A single IndexedDB database should exist.");
+ InspectorTest.log(JSON.stringify(names));
+ resolve();
+ });
});
}
});
@@ -54,15 +53,12 @@
description: "Delete the database.",
test: (resolve, reject) => {
InspectorTest.evaluateInPage("deleteDatabaseNames(['Database With Space'])");
- // FIXME: <https://webkit.org/b/161285> Race between deleting a database and requesting database names seen in test
- setTimeout(() => {
- IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
- InspectorTest.expectNoError(error);
- InspectorTest.expectThat(names.length === 0, "No IndexedDB databases should exist because we just deleted them.");
- InspectorTest.log(JSON.stringify(names));
- resolve();
- });
- }, 50);
+ IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
+ InspectorTest.expectNoError(error);
+ InspectorTest.expectThat(names.length === 0, "No IndexedDB databases should exist because we just deleted them.");
+ InspectorTest.log(JSON.stringify(names));
+ resolve();
+ });
}
});
Modified: trunk/LayoutTests/inspector/indexeddb/requestData-expected.txt (205085 => 205086)
--- trunk/LayoutTests/inspector/indexeddb/requestData-expected.txt 2016-08-27 22:13:44 UTC (rev 205085)
+++ trunk/LayoutTests/inspector/indexeddb/requestData-expected.txt 2016-08-28 00:10:29 UTC (rev 205086)
@@ -1,6 +1,6 @@
-CONSOLE MESSAGE: line 18: Created Database 'Database1'
-CONSOLE MESSAGE: line 18: Created Database 'Database2'
-CONSOLE MESSAGE: line 18: Created Database 'Database3'
+CONSOLE MESSAGE: line 19: Created Database 'Database1'
+CONSOLE MESSAGE: line 19: Created Database 'Database2'
+CONSOLE MESSAGE: line 19: Created Database 'Database3'
== Running test suite: IndexedDB.requestData
-- Running test case: ClearDatabases
Modified: trunk/LayoutTests/inspector/indexeddb/requestDatabase-expected.txt (205085 => 205086)
--- trunk/LayoutTests/inspector/indexeddb/requestDatabase-expected.txt 2016-08-27 22:13:44 UTC (rev 205085)
+++ trunk/LayoutTests/inspector/indexeddb/requestDatabase-expected.txt 2016-08-28 00:10:29 UTC (rev 205086)
@@ -1,5 +1,5 @@
CONSOLE MESSAGE: line 9: Created Database 'EmptyDatabase'
-CONSOLE MESSAGE: line 18: Created Database 'CompleteDatabase'
+CONSOLE MESSAGE: line 19: Created Database 'CompleteDatabase'
== Running test suite: IndexedDB.requestDatabase
-- Running test case: ClearDatabases
Modified: trunk/LayoutTests/inspector/indexeddb/requestDatabase.html (205085 => 205086)
--- trunk/LayoutTests/inspector/indexeddb/requestDatabase.html 2016-08-27 22:13:44 UTC (rev 205085)
+++ trunk/LayoutTests/inspector/indexeddb/requestDatabase.html 2016-08-28 00:10:29 UTC (rev 205086)
@@ -24,12 +24,14 @@
name: "CreateAndRequestEmptyDatabase",
test: (resolve, reject) => {
InspectorTest.evaluateInPage("createEmptyDatabase('EmptyDatabase', 123)");
- IndexedDBAgent.requestDatabase(WebInspector.frameResourceManager.mainFrame.securityOrigin, "EmptyDatabase", (error, databaseWithObjectStores) => {
- InspectorTest.expectNoError(error);
- InspectorTest.expectThat(databaseWithObjectStores.name === "EmptyDatabase", "Database name should be 'EmptyDatabase'.");
- InspectorTest.expectThat(databaseWithObjectStores.version === 123, "Database version should be 123.");
- InspectorTest.expectThat(databaseWithObjectStores.objectStores.length === 0, "Database should not have any object stores.");
- resolve();
+ InspectorTest.singleFireEventListener("DatabaseCreated", (event) => {
+ IndexedDBAgent.requestDatabase(WebInspector.frameResourceManager.mainFrame.securityOrigin, "EmptyDatabase", (error, databaseWithObjectStores) => {
+ InspectorTest.expectNoError(error);
+ InspectorTest.expectThat(databaseWithObjectStores.name === "EmptyDatabase", "Database name should be 'EmptyDatabase'.");
+ InspectorTest.expectThat(databaseWithObjectStores.version === 123, "Database version should be 123.");
+ InspectorTest.expectThat(databaseWithObjectStores.objectStores.length === 0, "Database should not have any object stores.");
+ resolve();
+ });
});
}
});
@@ -38,34 +40,36 @@
name: "CreateAndRequestDatabaseWithStores",
test: (resolve, reject) => {
InspectorTest.evaluateInPage("createDatabaseWithStores('CompleteDatabase', 456)");
- IndexedDBAgent.requestDatabase(WebInspector.frameResourceManager.mainFrame.securityOrigin, "CompleteDatabase", (error, databaseWithObjectStores) => {
- InspectorTest.expectNoError(error);
- let objectStores = databaseWithObjectStores.objectStores;
- InspectorTest.expectThat(databaseWithObjectStores.name === "CompleteDatabase", "Database name should be 'EmptyDatabase'.");
- InspectorTest.expectThat(databaseWithObjectStores.version === 456, "Database version should be 456.");
- InspectorTest.expectThat(databaseWithObjectStores.objectStores.length === 3, "Database should have 3 object stores.");
+ InspectorTest.singleFireEventListener("DatabaseCreated", (event) => {
+ IndexedDBAgent.requestDatabase(WebInspector.frameResourceManager.mainFrame.securityOrigin, "CompleteDatabase", (error, databaseWithObjectStores) => {
+ InspectorTest.expectNoError(error);
+ let objectStores = databaseWithObjectStores.objectStores;
+ InspectorTest.expectThat(databaseWithObjectStores.name === "CompleteDatabase", "Database name should be 'EmptyDatabase'.");
+ InspectorTest.expectThat(databaseWithObjectStores.version === 456, "Database version should be 456.");
+ InspectorTest.expectThat(databaseWithObjectStores.objectStores.length === 3, "Database should have 3 object stores.");
- InspectorTest.expectThat(objectStores[0].name === "Empty", "Object store should have name 'Empty'.");
- InspectorTest.expectThat(objectStores[0].keyPath.type === "null", "Object store keypath is null.");
- InspectorTest.expectThat(!objectStores[0].autoIncrement, "Object store should not autoIncrement.");
- InspectorTest.expectThat(!objectStores[0].indexes.length, "Object store should have no indexes.");
+ InspectorTest.expectThat(objectStores[0].name === "Empty", "Object store should have name 'Empty'.");
+ InspectorTest.expectThat(objectStores[0].keyPath.type === "null", "Object store keypath is null.");
+ InspectorTest.expectThat(!objectStores[0].autoIncrement, "Object store should not autoIncrement.");
+ InspectorTest.expectThat(!objectStores[0].indexes.length, "Object store should have no indexes.");
- InspectorTest.expectThat(objectStores[1].name === "Reviewers", "Object store should have name 'Reviewers'.");
- InspectorTest.expectThat(objectStores[1].keyPath.type === "null", "Object store keypath is null.");
- InspectorTest.expectThat(objectStores[1].autoIncrement, "Object store should autoIncrement.");
- InspectorTest.expectThat(objectStores[1].indexes.length === 2, "Object store should have 2 indexes.");
- InspectorTest.log("INDEX: " + JSON.stringify(objectStores[1].indexes[0]));
- InspectorTest.log("INDEX: " + JSON.stringify(objectStores[1].indexes[1]));
+ InspectorTest.expectThat(objectStores[1].name === "Reviewers", "Object store should have name 'Reviewers'.");
+ InspectorTest.expectThat(objectStores[1].keyPath.type === "null", "Object store keypath is null.");
+ InspectorTest.expectThat(objectStores[1].autoIncrement, "Object store should autoIncrement.");
+ InspectorTest.expectThat(objectStores[1].indexes.length === 2, "Object store should have 2 indexes.");
+ InspectorTest.log("INDEX: " + JSON.stringify(objectStores[1].indexes[0]));
+ InspectorTest.log("INDEX: " + JSON.stringify(objectStores[1].indexes[1]));
- InspectorTest.expectThat(objectStores[2].name === "Stats", "Object store should have name 'Stats'.");
- InspectorTest.expectThat(objectStores[2].keyPath.type === "string", "Object store keypath is string type.");
- InspectorTest.expectThat(objectStores[2].keyPath.string === "name", "Object store keypath is 'name''.");
- InspectorTest.expectThat(!objectStores[2].autoIncrement, "Object store should not autoIncrement.");
- InspectorTest.expectThat(objectStores[2].indexes.length === 2, "Object store should have 2 indexes.");
- InspectorTest.log("INDEX: " + JSON.stringify(objectStores[2].indexes[0]));
- InspectorTest.log("INDEX: " + JSON.stringify(objectStores[2].indexes[1]));
+ InspectorTest.expectThat(objectStores[2].name === "Stats", "Object store should have name 'Stats'.");
+ InspectorTest.expectThat(objectStores[2].keyPath.type === "string", "Object store keypath is string type.");
+ InspectorTest.expectThat(objectStores[2].keyPath.string === "name", "Object store keypath is 'name''.");
+ InspectorTest.expectThat(!objectStores[2].autoIncrement, "Object store should not autoIncrement.");
+ InspectorTest.expectThat(objectStores[2].indexes.length === 2, "Object store should have 2 indexes.");
+ InspectorTest.log("INDEX: " + JSON.stringify(objectStores[2].indexes[0]));
+ InspectorTest.log("INDEX: " + JSON.stringify(objectStores[2].indexes[1]));
- resolve();
+ resolve();
+ });
});
}
});
Modified: trunk/LayoutTests/inspector/indexeddb/requestDatabaseNames.html (205085 => 205086)
--- trunk/LayoutTests/inspector/indexeddb/requestDatabaseNames.html 2016-08-27 22:13:44 UTC (rev 205085)
+++ trunk/LayoutTests/inspector/indexeddb/requestDatabaseNames.html 2016-08-28 00:10:29 UTC (rev 205086)
@@ -37,11 +37,13 @@
description: "Create a first database.",
test: (resolve, reject) => {
InspectorTest.evaluateInPage("createEmptyDatabase('Database1')");
- IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
- InspectorTest.expectNoError(error);
- InspectorTest.expectThat(names.length === 1, "A single IndexedDB database should exist.");
- InspectorTest.log(JSON.stringify(names));
- resolve();
+ InspectorTest.singleFireEventListener("DatabaseCreated", (event) => {
+ IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
+ InspectorTest.expectNoError(error);
+ InspectorTest.expectThat(names.length === 1, "A single IndexedDB database should exist.");
+ InspectorTest.log(JSON.stringify(names));
+ resolve();
+ });
});
}
});
@@ -51,11 +53,13 @@
description: "Create a second database.",
test: (resolve, reject) => {
InspectorTest.evaluateInPage("createEmptyDatabase('Database2')");
- IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
- InspectorTest.expectNoError(error);
- InspectorTest.expectThat(names.length === 2, "Two IndexedDB databases should exist.");
- InspectorTest.log(JSON.stringify(names));
- resolve();
+ InspectorTest.singleFireEventListener("DatabaseCreated", (event) => {
+ IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
+ InspectorTest.expectNoError(error);
+ InspectorTest.expectThat(names.length === 2, "Two IndexedDB databases should exist.");
+ InspectorTest.log(JSON.stringify(names));
+ resolve();
+ });
});
}
});
@@ -65,11 +69,13 @@
description: "Create a third database with a unicode name.",
test: (resolve, reject) => {
InspectorTest.evaluateInPage("createEmptyDatabase('\u124d')");
- IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
- InspectorTest.expectNoError(error);
- InspectorTest.expectThat(names.length === 3, "Three IndexedDB databases should exist.");
- InspectorTest.log(JSON.stringify(names));
- resolve();
+ InspectorTest.singleFireEventListener("DatabaseCreated", (event) => {
+ IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
+ InspectorTest.expectNoError(error);
+ InspectorTest.expectThat(names.length === 3, "Three IndexedDB databases should exist.");
+ InspectorTest.log(JSON.stringify(names));
+ resolve();
+ });
});
}
});
@@ -79,11 +85,13 @@
description: "Create a fourth database with a unicode name.",
test: (resolve, reject) => {
InspectorTest.evaluateInPage("createEmptyDatabase('\ud800\udf46')");
- IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
- InspectorTest.expectNoError(error);
- InspectorTest.expectThat(names.length === 4, "Four IndexedDB databases should exist.");
- InspectorTest.log(JSON.stringify(names));
- resolve();
+ InspectorTest.singleFireEventListener("DatabaseCreated", (event) => {
+ IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
+ InspectorTest.expectNoError(error);
+ InspectorTest.expectThat(names.length === 4, "Four IndexedDB databases should exist.");
+ InspectorTest.log(JSON.stringify(names));
+ resolve();
+ });
});
}
});
Modified: trunk/LayoutTests/inspector/indexeddb/resources/utilities.js (205085 => 205086)
--- trunk/LayoutTests/inspector/indexeddb/resources/utilities.js 2016-08-27 22:13:44 UTC (rev 205085)
+++ trunk/LayoutTests/inspector/indexeddb/resources/utilities.js 2016-08-28 00:10:29 UTC (rev 205086)
@@ -9,6 +9,7 @@
console.log(`Created Database '${name}'`);
let db = event.target.result;
db.close();
+ TestPage.dispatchEventToFrontend("DatabaseCreated");
});
}
@@ -16,6 +17,7 @@
let request = window.indexedDB.open(name, version);
request.addEventListener("success", function(event) {
console.log(`Created Database '${name}'`);
+ TestPage.dispatchEventToFrontend("DatabaseCreated");
});
request.addEventListener("upgradeneeded", function(event) {