Diff
Modified: trunk/LayoutTests/ChangeLog (205039 => 205040)
--- trunk/LayoutTests/ChangeLog 2016-08-26 20:59:01 UTC (rev 205039)
+++ trunk/LayoutTests/ChangeLog 2016-08-26 20:59:04 UTC (rev 205040)
@@ -1,5 +1,26 @@
2016-08-25 Joseph Pecoraro <pecor...@apple.com>
+ Web Inspector: Test IndexedDB.requestDatabase
+ https://bugs.webkit.org/show_bug.cgi?id=161122
+
+ Reviewed by Brian Burg.
+
+ * inspector/indexeddb/requestDatabase-expected.txt: Added.
+ * inspector/indexeddb/requestDatabase.html: Added.
+ New tests.
+
+ * inspector/indexeddb/deleteDatabaseNamesWithSpace.html:
+ * inspector/indexeddb/requestDatabaseNames.html:
+ Share code.
+
+ * inspector/indexeddb/resources/utilities.js: Added.
+ (deleteDatabaseNames):
+ (createEmptyDatabase):
+ (createDatabaseWithStores):
+ Helpers that can be used by each test.
+
+2016-08-25 Joseph Pecoraro <pecor...@apple.com>
+
Web Inspector: Modernize inspector/indexeddb tests
https://bugs.webkit.org/show_bug.cgi?id=161113
Modified: trunk/LayoutTests/inspector/indexeddb/deleteDatabaseNamesWithSpace.html (205039 => 205040)
--- trunk/LayoutTests/inspector/indexeddb/deleteDatabaseNamesWithSpace.html 2016-08-26 20:59:01 UTC (rev 205039)
+++ trunk/LayoutTests/inspector/indexeddb/deleteDatabaseNamesWithSpace.html 2016-08-26 20:59:04 UTC (rev 205040)
@@ -2,20 +2,8 @@
<html>
<head>
<script src=""
+<script src=""
<script>
-function createDatabase(name) {
- let request = window.indexedDB.open(name, 1);
- request.addEventListener('success', function(event) {
- console.log(`Created Database '${name}'`);
- event.target.result.close();
- });
-}
-
-function deleteDatabaseNames(names) {
- for (let name of names)
- window.indexedDB.deleteDatabase(name);
-}
-
function test()
{
let suite = InspectorTest.createAsyncSuite("IndexedDB.requestDatabaseNames.spaces");
@@ -48,7 +36,7 @@
name: "CreateDatabaseWithSpacesInName",
description: "Create a database with spaces in the name.",
test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createDatabase('Database With Space')");
+ 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.");
Added: trunk/LayoutTests/inspector/indexeddb/requestDatabase-expected.txt (0 => 205040)
--- trunk/LayoutTests/inspector/indexeddb/requestDatabase-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/indexeddb/requestDatabase-expected.txt 2016-08-26 20:59:04 UTC (rev 205040)
@@ -0,0 +1,32 @@
+CONSOLE MESSAGE: line 9: Created Database 'EmptyDatabase'
+CONSOLE MESSAGE: line 18: Created Database 'CompleteDatabase'
+
+== Running test suite: IndexedDB.requestDatabase
+-- Running test case: ClearDatabases
+-- Running test case: CreateAndRequestEmptyDatabase
+PASS: Database name should be 'EmptyDatabase'.
+PASS: Database version should be 123.
+PASS: Database should not have any object stores.
+
+-- Running test case: CreateAndRequestDatabaseWithStores
+PASS: Database name should be 'EmptyDatabase'.
+PASS: Database version should be 456.
+PASS: Database should have 3 object stores.
+PASS: Object store should have name 'Empty'.
+PASS: Object store keypath is null.
+PASS: Object store should not autoIncrement.
+PASS: Object store should have no indexes.
+PASS: Object store should have name 'Reviewers'.
+PASS: Object store keypath is null.
+PASS: Object store should autoIncrement.
+PASS: Object store should have 2 indexes.
+INDEX: {"name":"Name Index","keyPath":{"type":"string","string":"name"},"unique":false,"multiEntry":false}
+INDEX: {"name":"Email Index","keyPath":{"type":"string","string":"email"},"unique":true,"multiEntry":false}
+PASS: Object store should have name 'Stats'.
+PASS: Object store keypath is string type.
+PASS: Object store keypath is 'name''.
+PASS: Object store should not autoIncrement.
+PASS: Object store should have 2 indexes.
+INDEX: {"name":"Directory Name Index","keyPath":{"type":"string","string":"name"},"unique":true,"multiEntry":false}
+INDEX: {"name":"File Count Index","keyPath":{"type":"string","string":"count"},"unique":false,"multiEntry":false}
+
Added: trunk/LayoutTests/inspector/indexeddb/requestDatabase.html (0 => 205040)
--- trunk/LayoutTests/inspector/indexeddb/requestDatabase.html (rev 0)
+++ trunk/LayoutTests/inspector/indexeddb/requestDatabase.html 2016-08-26 20:59:04 UTC (rev 205040)
@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("IndexedDB.requestDatabase");
+
+ suite.addTestCase({
+ name: "ClearDatabases",
+ description: "Remove any existing IndexedDB databases.",
+ test: (resolve, reject) => {
+ // FIXME: Remove any existing IndexedDB databases that might exist to workaround:
+ // <https://webkit.org/b/148006> Each test should run with its own clean data store
+ IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, (error, names) => {
+ InspectorTest.evaluateInPage("deleteDatabaseNames(" + JSON.stringify(names) + ")", resolve);
+ });
+ }
+ });
+
+ suite.addTestCase({
+ 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();
+ });
+ }
+ });
+
+ suite.addTestCase({
+ 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.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[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();
+ });
+ }
+ });
+
+ // FIXME: <https://webkit.org/b/161121> Web Inspector: IndexedDB.requestDatabase() should not create a database if one did not exist
+ // suite.addTestCase({
+ // name: "NoSuchDatabase",
+ // description: "Request a database that does not exist.",
+ // test: (resolve, reject) => {
+ // IndexedDBAgent.requestDatabase(WebInspector.frameResourceManager.mainFrame.securityOrigin, "NameDoesNotExist", (error, databaseWithObjectStores) => {
+ // InspectorTest.expectThat(error, "Should be an error trying to request a database that does not exist.");
+ // InspectorTest.log(JSON.stringify(databaseWithObjectStores));
+ // resolve();
+ // });
+ // }
+ // });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+</body>
+</html>
Modified: trunk/LayoutTests/inspector/indexeddb/requestDatabaseNames.html (205039 => 205040)
--- trunk/LayoutTests/inspector/indexeddb/requestDatabaseNames.html 2016-08-26 20:59:01 UTC (rev 205039)
+++ trunk/LayoutTests/inspector/indexeddb/requestDatabaseNames.html 2016-08-26 20:59:04 UTC (rev 205040)
@@ -2,20 +2,8 @@
<html>
<head>
<script src=""
+<script src=""
<script>
-function createDatabase(name) {
- let request = window.indexedDB.open(name, 1);
- request.addEventListener('success', function(event) {
- console.log(`Created Database '${name}'`);
- event.target.result.close();
- });
-}
-
-function deleteDatabaseNames(names) {
- for (let name of names)
- window.indexedDB.deleteDatabase(name);
-}
-
function test()
{
let suite = InspectorTest.createAsyncSuite("IndexedDB.requestDatabaseNames");
@@ -48,7 +36,7 @@
name: "CreateDatabase1",
description: "Create a first database.",
test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createDatabase('Database1')");
+ 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.");
@@ -62,7 +50,7 @@
name: "CreateDatabase2",
description: "Create a second database.",
test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createDatabase('Database2')");
+ 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.");
@@ -76,7 +64,7 @@
name: "CreateDatabase3",
description: "Create a third database with a unicode name.",
test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createDatabase('\u124d')");
+ 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.");
@@ -90,7 +78,7 @@
name: "CreateDatabase4",
description: "Create a fourth database with a unicode name.",
test: (resolve, reject) => {
- InspectorTest.evaluateInPage("createDatabase('\ud800\udf46')");
+ 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.");
Added: trunk/LayoutTests/inspector/indexeddb/resources/utilities.js (0 => 205040)
--- trunk/LayoutTests/inspector/indexeddb/resources/utilities.js (rev 0)
+++ trunk/LayoutTests/inspector/indexeddb/resources/utilities.js 2016-08-26 20:59:04 UTC (rev 205040)
@@ -0,0 +1,52 @@
+function deleteDatabaseNames(names) {
+ for (let name of names)
+ window.indexedDB.deleteDatabase(name);
+}
+
+function createEmptyDatabase(name, version=1) {
+ let request = window.indexedDB.open(name, version);
+ request.addEventListener('success', function(event) {
+ console.log(`Created Database '${name}'`);
+ let db = event.target.result;
+ db.close();
+ });
+}
+
+function createDatabaseWithStores(name, version) {
+ let request = window.indexedDB.open(name, version);
+ request.addEventListener("success", function(event) {
+ console.log(`Created Database '${name}'`);
+ });
+
+ request.addEventListener("upgradeneeded", function(event) {
+ let db = event.target.result;
+
+ // Reviewers => {name, email}
+ let reviewerObjectStore = db.createObjectStore("Reviewers", {autoIncrement: true});
+ reviewerObjectStore.createIndex("Name Index", "name", {unique: false});
+ reviewerObjectStore.createIndex("Email Index", "email", {unique: true});
+
+ // Stats => {name, count}
+ let statsObjectStore = db.createObjectStore("Stats", {keyPath: "name"});
+ statsObjectStore.createIndex("Directory Name Index", "name", {unique: true});
+ statsObjectStore.createIndex("File Count Index", "count", {unique: false});
+
+ // Empty => any value
+ let lastObjectStore = db.createObjectStore("Empty");
+
+ // Populate once stores are created.
+ lastObjectStore.transaction._oncomplete_ = (event) => {
+ let reviewerObjectStore = db.transaction("Reviewers", "readwrite").objectStore("Reviewers");
+ reviewerObjectStore.add({name: "Thirsty Hampster", email: "hamps...@webkit.org"});
+ reviewerObjectStore.add({name: "Jamming Peacock", email: "peac...@webkit.org"});
+ reviewerObjectStore.add({name: "Bustling Badger", email: "bad...@webkit.org"});
+ reviewerObjectStore.add({name: "Monstrous Beaver", email: "bea...@webkit.org"});
+
+ let statsObjectStore = db.transaction("Stats", "readwrite").objectStore("Stats");
+ statsObjectStore.add({name: "Images", count: 250, extensions: ["png", "svg"]});
+ statsObjectStore.add({name: "Models", count: 109, extensions: ["js"]});
+ statsObjectStore.add({name: "Views", count: 436, extensions: ["css", "js"]});
+ statsObjectStore.add({name: "Controllers", count: 41, extensions: ["css", "js"]});
+ };
+ });
+};