Title: [205042] trunk
Revision
205042
Author
[email protected]
Date
2016-08-26 13:59:13 -0700 (Fri, 26 Aug 2016)

Log Message

Web Inspector: Test and address issues in IndexedDB.requestData
https://bugs.webkit.org/show_bug.cgi?id=161178
<rdar://problem/28002467>

Reviewed by Brian Burg.

Source/WebCore:

Test: inspector/indexeddb/requestData.html

* inspector/InspectorIndexedDBAgent.cpp:
(idbKeyRangeFromKeyRange):
Parsing was too strict. "lower" and "upper" keys are optional.

(WebCore::DataLoader::execute):
Ensure the skip count is passed forward.

LayoutTests:

* inspector/indexeddb/requestData-expected.txt: Added.
* inspector/indexeddb/requestData.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (205041 => 205042)


--- trunk/LayoutTests/ChangeLog	2016-08-26 20:59:09 UTC (rev 205041)
+++ trunk/LayoutTests/ChangeLog	2016-08-26 20:59:13 UTC (rev 205042)
@@ -1,3 +1,14 @@
+2016-08-26  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Test and address issues in IndexedDB.requestData
+        https://bugs.webkit.org/show_bug.cgi?id=161178
+        <rdar://problem/28002467>
+
+        Reviewed by Brian Burg.
+
+        * inspector/indexeddb/requestData-expected.txt: Added.
+        * inspector/indexeddb/requestData.html: Added.
+
 2016-08-25  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Provide a way to clear an IndexedDB object store

Added: trunk/LayoutTests/inspector/indexeddb/requestData-expected.txt (0 => 205042)


--- trunk/LayoutTests/inspector/indexeddb/requestData-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/indexeddb/requestData-expected.txt	2016-08-26 20:59:13 UTC (rev 205042)
@@ -0,0 +1,128 @@
+CONSOLE MESSAGE: line 18: Created Database 'Database1'
+CONSOLE MESSAGE: line 18: Created Database 'Database2'
+CONSOLE MESSAGE: line 18: Created Database 'Database3'
+
+== Running test suite: IndexedDB.requestData
+-- Running test case: ClearDatabases
+-- Running test case: RequestDataBasic
+-- No Index
+PASS: Should be 4 entries.
+PASS: Should not have more entries.
+PASS: Primary key should be ordered by primary key: 1
+PASS: Value should be a remote object for: 'Thirsty Hampster'
+PASS: Primary key should be ordered by primary key: 2
+PASS: Value should be a remote object for: 'Jamming Peacock'
+PASS: Primary key should be ordered by primary key: 3
+PASS: Value should be a remote object for: 'Bustling Badger'
+PASS: Primary key should be ordered by primary key: 4
+PASS: Value should be a remote object for: 'Monstrous Beaver'
+-- Name Index
+PASS: Should be 4 entries.
+PASS: Should not have more entries.
+PASS: Primary key should be ordered by name: 3
+PASS: Key should be ordered by name: 'Bustling Badger'
+PASS: Value should be a remote object for: 'Bustling Badger'
+PASS: Primary key should be ordered by name: 2
+PASS: Key should be ordered by name: 'Jamming Peacock'
+PASS: Value should be a remote object for: 'Jamming Peacock'
+PASS: Primary key should be ordered by name: 4
+PASS: Key should be ordered by name: 'Monstrous Beaver'
+PASS: Value should be a remote object for: 'Monstrous Beaver'
+PASS: Primary key should be ordered by name: 1
+PASS: Key should be ordered by name: 'Thirsty Hampster'
+PASS: Value should be a remote object for: 'Thirsty Hampster'
+-- Email Index
+PASS: Should be 4 entries.
+PASS: Should not have more entries.
+PASS: Primary key should be ordered by email: 3
+PASS: Key should be ordered by email: '[email protected]'
+PASS: Value should be a remote object for: 'Bustling Badger'
+PASS: Primary key should be ordered by email: 4
+PASS: Key should be ordered by email: '[email protected]'
+PASS: Value should be a remote object for: 'Monstrous Beaver'
+FAIL: Primary key should be ordered by email: 2
+PASS: Key should be ordered by email: '[email protected]'
+PASS: Value should be a remote object for: 'Thirsty Hampster'
+FAIL: Primary key should be ordered by email: 1
+PASS: Key should be ordered by email: '[email protected]'
+PASS: Value should be a remote object for: 'Jamming Peacock'
+
+-- Running test case: RequestDataPagination
+-- Page 1
+PASS: Entries length should match page size.
+PASS: Should have more entries.
+PASS: Primary key should be ordered by primary key: 1
+PASS: Value should be a remote object for: 'Thirsty Hampster'
+PASS: Primary key should be ordered by primary key: 2
+PASS: Value should be a remote object for: 'Jamming Peacock'
+-- Page 2
+PASS: Entries length should match page size.
+PASS: Should not have more entries.
+PASS: Primary key should be ordered by primary key: 3
+PASS: Value should be a remote object for: 'Bustling Badger'
+PASS: Primary key should be ordered by primary key: 4
+PASS: Value should be a remote object for: 'Monstrous Beaver'
+
+-- Running test case: RequestDataKeyRangeBounds
+-- Keys >= 'M'
+-- Lower Bound: 'M' (closed)
+-- Upper Bound: -
+PASS: Should be 2 entries.
+PASS: Should not have more entries.
+PASS: Primary key should be ordered by primary key: 4
+PASS: Value should be a remote object for: 'Monstrous Beaver'
+PASS: Primary key should be ordered by primary key: 1
+PASS: Value should be a remote object for: 'Thirsty Hampster'
+-- Keys > 'M'
+-- Lower Bound: 'M' (open)
+-- Upper Bound: -
+PASS: Should be 2 entries.
+PASS: Should not have more entries.
+PASS: Primary key should be ordered by primary key: 4
+PASS: Value should be a remote object for: 'Monstrous Beaver'
+PASS: Primary key should be ordered by primary key: 1
+PASS: Value should be a remote object for: 'Thirsty Hampster'
+-- Keys > 'Monstrous Beaver'
+-- Lower Bound: 'Monstrous Beaver' (open)
+-- Upper Bound: -
+PASS: Should be 1 entry.
+PASS: Should not have more entries.
+PASS: Primary key should be ordered by primary key: 1
+PASS: Value should be a remote object for: 'Thirsty Hampster'
+-- Keys <= 'M'
+-- Lower Bound: -
+-- Upper Bound: 'M' (closed)
+PASS: Should be 2 entries.
+PASS: Should not have more entries.
+PASS: Primary key should be ordered by primary key: 3
+PASS: Value should be a remote object for: 'Bustling Badger'
+PASS: Primary key should be ordered by primary key: 2
+PASS: Value should be a remote object for: 'Jamming Peacock'
+-- Keys <= 'Monstrous Beaver'
+-- Lower Bound: -
+-- Upper Bound: 'Monstrous Beaver' (closed)
+PASS: Should be 3 entries.
+PASS: Should not have more entries.
+PASS: Primary key should be ordered by primary key: 3
+PASS: Value should be a remote object for: 'Bustling Badger'
+PASS: Primary key should be ordered by primary key: 2
+PASS: Value should be a remote object for: 'Jamming Peacock'
+PASS: Primary key should be ordered by primary key: 4
+PASS: Value should be a remote object for: 'Monstrous Beaver'
+-- Keys < 'M'
+-- Lower Bound: -
+-- Upper Bound: 'M' (open)
+PASS: Should be 2 entries.
+PASS: Should not have more entries.
+PASS: Primary key should be ordered by primary key: 3
+PASS: Value should be a remote object for: 'Bustling Badger'
+PASS: Primary key should be ordered by primary key: 2
+PASS: Value should be a remote object for: 'Jamming Peacock'
+-- 'Monstrous Beaver' <= Key <= 'Monstrous Beaver'
+-- Lower Bound: 'Monstrous Beaver' (closed)
+-- Upper Bound: 'Monstrous Beaver' (closed)
+PASS: Should be 1 entry.
+PASS: Should not have more entries.
+PASS: Primary key should be ordered by primary key: 4
+PASS: Value should be a remote object for: 'Monstrous Beaver'
+

Added: trunk/LayoutTests/inspector/indexeddb/requestData.html (0 => 205042)


--- trunk/LayoutTests/inspector/indexeddb/requestData.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/indexeddb/requestData.html	2016-08-26 20:59:13 UTC (rev 205042)
@@ -0,0 +1,343 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+function test()
+{
+    function objectPropertyPreview(remoteObject, name) {
+        for (let propertyPreview of remoteObject.preview.propertyPreviews) {
+            if (propertyPreview.name === name)
+                return propertyPreview;
+        }
+        return null;
+    }
+
+    let suite = InspectorTest.createAsyncSuite("IndexedDB.requestData");
+
+    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: "RequestDataBasic",
+        description: "Request data for an object store with different indexes.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage("createDatabaseWithStores('Database1', 1)");
+            IndexedDBAgent.requestDatabase(WebInspector.frameResourceManager.mainFrame.securityOrigin, "Database1", (error, database) => {
+                InspectorTest.expectNoError(error);
+
+                let [emptyObjectStore, reviewersObjectStore, statsObjectStore] = database.objectStores;
+                const securityOrigin = WebInspector.frameResourceManager.mainFrame.securityOrigin;
+                const skipCount = 0;
+                const pageSize = 10;
+
+                let indexName = "";
+                IndexedDBAgent.requestData(securityOrigin, database.name, reviewersObjectStore.name, indexName, skipCount, pageSize, (error, entries, hasMore) => {
+                    InspectorTest.log("-- No Index");
+                    InspectorTest.expectNoError(error);
+                    InspectorTest.expectThat(entries.length === 4, "Should be 4 entries.");
+                    InspectorTest.expectThat(!hasMore, "Should not have more entries.");
+
+                    let expectedPrimaryKeyOrder = [1, 2, 3, 4];
+                    let expectedNamesOrderedByPrimaryKey = ["Thirsty Hampster", "Jamming Peacock", "Bustling Badger", "Monstrous Beaver"];
+                    for (let i = 0; i < entries.length; ++i) {
+                        let entryPayload = entries[i];
+                        let primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
+                        let value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
+                        InspectorTest.expectThat(primaryKey.value === expectedPrimaryKeyOrder[i], `Primary key should be ordered by primary key: ${expectedPrimaryKeyOrder[i]}`);
+                        InspectorTest.expectThat(objectPropertyPreview(value, "name").value === expectedNamesOrderedByPrimaryKey[i], `Value should be a remote object for: '${expectedNamesOrderedByPrimaryKey[i]}'`);
+                    }
+                });
+
+                indexName = "Name Index";
+                IndexedDBAgent.requestData(securityOrigin, database.name, reviewersObjectStore.name, indexName, skipCount, pageSize, (error, entries, hasMore) => {
+                    InspectorTest.log("-- Name Index");
+                    InspectorTest.expectNoError(error);
+                    InspectorTest.expectThat(entries.length === 4, "Should be 4 entries.");
+                    InspectorTest.expectThat(!hasMore, "Should not have more entries.");
+
+                    let expectedPrimaryKeyOrder = [3, 2, 4, 1];
+                    let expectedKeysOrderedByName = ["Bustling Badger", "Jamming Peacock", "Monstrous Beaver", "Thirsty Hampster"];
+                    let expectedNamesOrderedByName = expectedKeysOrderedByName;
+                    for (let i = 0; i < entries.length; ++i) {
+                        let entryPayload = entries[i];
+                        let primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
+                        let key = WebInspector.RemoteObject.fromPayload(entryPayload.key);
+                        let value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
+                        InspectorTest.expectThat(primaryKey.value === expectedPrimaryKeyOrder[i], `Primary key should be ordered by name: ${expectedPrimaryKeyOrder[i]}`);
+                        InspectorTest.expectThat(key.value === expectedKeysOrderedByName[i], `Key should be ordered by name: '${expectedKeysOrderedByName[i]}'`);
+                        InspectorTest.expectThat(objectPropertyPreview(value, "name").value === expectedNamesOrderedByName[i], `Value should be a remote object for: '${expectedNamesOrderedByName[i]}'`);
+                    }
+                });
+
+                indexName = "Email Index";
+                IndexedDBAgent.requestData(securityOrigin, database.name, reviewersObjectStore.name, indexName, skipCount, pageSize, (error, entries, hasMore) => {
+                    InspectorTest.log("-- Email Index");
+                    InspectorTest.expectNoError(error);
+                    InspectorTest.expectThat(entries.length === 4, "Should be 4 entries.");
+                    InspectorTest.expectThat(!hasMore, "Should not have more entries.");
+
+                    let expectedPrimaryKeyOrder = [3, 4, 2, 1];
+                    let expectedKeysOrderedByEmail = ["[email protected]", "[email protected]", "[email protected]", "[email protected]"];
+                    let expectedNamesOrderedByEmail = ["Bustling Badger", "Monstrous Beaver", "Thirsty Hampster", "Jamming Peacock"];
+                    for (let i = 0; i < entries.length; ++i) {
+                        let entryPayload = entries[i];
+                        let primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
+                        let key = WebInspector.RemoteObject.fromPayload(entryPayload.key);
+                        let value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
+                        InspectorTest.expectThat(primaryKey.value === expectedPrimaryKeyOrder[i], `Primary key should be ordered by email: ${expectedPrimaryKeyOrder[i]}`);
+                        InspectorTest.expectThat(key.value === expectedKeysOrderedByEmail[i], `Key should be ordered by email: '${expectedKeysOrderedByEmail[i]}'`);
+                        InspectorTest.expectThat(objectPropertyPreview(value, "name").value === expectedNamesOrderedByEmail[i], `Value should be a remote object for: '${expectedNamesOrderedByEmail[i]}'`);
+                    }
+                });
+
+                InspectorBackend.runAfterPendingDispatches(resolve);
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "RequestDataPagination",
+        description: "Request data for an object store with paginated requests.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage("createDatabaseWithStores('Database2', 1)");
+            IndexedDBAgent.requestDatabase(WebInspector.frameResourceManager.mainFrame.securityOrigin, "Database2", (error, database) => {
+                InspectorTest.expectNoError(error);
+
+                let [emptyObjectStore, reviewersObjectStore, statsObjectStore] = database.objectStores;
+                const securityOrigin = WebInspector.frameResourceManager.mainFrame.securityOrigin;
+                const indexName = "";
+                const pageSize = 2;
+
+                let skipCount = 0;
+                IndexedDBAgent.requestData(securityOrigin, database.name, reviewersObjectStore.name, indexName, skipCount, pageSize, (error, entries, hasMore) => {
+                    InspectorTest.log("-- Page 1");
+                    InspectorTest.expectNoError(error);
+                    InspectorTest.expectThat(entries.length === 2, "Entries length should match page size.");
+                    InspectorTest.expectThat(hasMore, "Should have more entries.");
+
+                    let expectedPrimaryKeyOrder = [1, 2];
+                    let expectedNamesOrderedByPrimaryKey = ["Thirsty Hampster", "Jamming Peacock"];
+                    for (let i = 0; i < entries.length; ++i) {
+                        let entryPayload = entries[i];
+                        let primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
+                        let value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
+                        InspectorTest.expectThat(primaryKey.value === expectedPrimaryKeyOrder[i], `Primary key should be ordered by primary key: ${expectedPrimaryKeyOrder[i]}`);
+                        InspectorTest.expectThat(objectPropertyPreview(value, "name").value === expectedNamesOrderedByPrimaryKey[i], `Value should be a remote object for: '${expectedNamesOrderedByPrimaryKey[i]}'`);
+                    }
+                });
+
+                skipCount = 2;
+                IndexedDBAgent.requestData(securityOrigin, database.name, reviewersObjectStore.name, indexName, skipCount, pageSize, (error, entries, hasMore) => {
+                    InspectorTest.log("-- Page 2");
+                    InspectorTest.expectNoError(error);
+                    InspectorTest.expectThat(entries.length === 2, "Entries length should match page size.");
+                    InspectorTest.expectThat(!hasMore, "Should not have more entries.");
+
+                    let expectedPrimaryKeyOrder = [3, 4];
+                    let expectedNamesOrderedByPrimaryKey = ["Bustling Badger", "Monstrous Beaver"];
+                    for (let i = 0; i < entries.length; ++i) {
+                        let entryPayload = entries[i];
+                        let primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
+                        let value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
+                        InspectorTest.expectThat(primaryKey.value === expectedPrimaryKeyOrder[i], `Primary key should be ordered by primary key: ${expectedPrimaryKeyOrder[i]}`);
+                        InspectorTest.expectThat(objectPropertyPreview(value, "name").value === expectedNamesOrderedByPrimaryKey[i], `Value should be a remote object for: '${expectedNamesOrderedByPrimaryKey[i]}'`);
+                    }
+                });
+
+                InspectorBackend.runAfterPendingDispatches(resolve);
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "RequestDataKeyRangeBounds",
+        description: "Request key range bounded data for an object store.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage("createDatabaseWithStores('Database3', 1)");
+            IndexedDBAgent.requestDatabase(WebInspector.frameResourceManager.mainFrame.securityOrigin, "Database3", (error, database) => {
+                InspectorTest.expectNoError(error);
+
+                let [emptyObjectStore, reviewersObjectStore, statsObjectStore] = database.objectStores;
+                const securityOrigin = WebInspector.frameResourceManager.mainFrame.securityOrigin;
+                const indexName = "Name Index";
+                const skipCount = 0;
+                const pageSize = 10;
+
+                function stringKeyWithString(string) {
+                    return {type: "string", string};
+                }
+
+                // Index: Name Index
+                // Keys: [3, 2, 4, 1]
+                // Values: ["Bustling Badger", "Jamming Peacock", "Monstrous Beaver", "Thirsty Hampster"];
+
+                // Keys >= "M"
+                let keyRange = {lower: stringKeyWithString("M"), lowerOpen: false, upperOpen: true};
+                IndexedDBAgent.requestData(securityOrigin, database.name, reviewersObjectStore.name, indexName, skipCount, pageSize, keyRange, (error, entries, hasMore) => {
+                    InspectorTest.log("-- Keys >= 'M'");
+                    InspectorTest.log("-- Lower Bound: 'M' (closed)");
+                    InspectorTest.log("-- Upper Bound: -");
+                    InspectorTest.expectNoError(error);
+                    InspectorTest.expectThat(entries.length === 2, "Should be 2 entries.");
+                    InspectorTest.expectThat(!hasMore, "Should not have more entries.");
+
+                    let expectedPrimaryKeyOrder = [4, 1];
+                    let expectedNamesOrderedByPrimaryKey = ["Monstrous Beaver", "Thirsty Hampster"];
+                    for (let i = 0; i < entries.length; ++i) {
+                        let entryPayload = entries[i];
+                        let primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
+                        let value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
+                        InspectorTest.expectThat(primaryKey.value === expectedPrimaryKeyOrder[i], `Primary key should be ordered by primary key: ${expectedPrimaryKeyOrder[i]}`);
+                        InspectorTest.expectThat(objectPropertyPreview(value, "name").value === expectedNamesOrderedByPrimaryKey[i], `Value should be a remote object for: '${expectedNamesOrderedByPrimaryKey[i]}'`);
+                    }
+                });
+
+                // Keys > "M"
+                keyRange = {lower: stringKeyWithString("M"), lowerOpen: true, upperOpen: true};
+                IndexedDBAgent.requestData(securityOrigin, database.name, reviewersObjectStore.name, indexName, skipCount, pageSize, keyRange, (error, entries, hasMore) => {
+                    InspectorTest.log("-- Keys > 'M'");
+                    InspectorTest.log("-- Lower Bound: 'M' (open)");
+                    InspectorTest.log("-- Upper Bound: -");
+                    InspectorTest.expectNoError(error);
+                    InspectorTest.expectThat(entries.length === 2, "Should be 2 entries.");
+                    InspectorTest.expectThat(!hasMore, "Should not have more entries.");
+
+                    let expectedPrimaryKeyOrder = [4, 1];
+                    let expectedNamesOrderedByPrimaryKey = ["Monstrous Beaver", "Thirsty Hampster"];
+                    for (let i = 0; i < entries.length; ++i) {
+                        let entryPayload = entries[i];
+                        let primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
+                        let value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
+                        InspectorTest.expectThat(primaryKey.value === expectedPrimaryKeyOrder[i], `Primary key should be ordered by primary key: ${expectedPrimaryKeyOrder[i]}`);
+                        InspectorTest.expectThat(objectPropertyPreview(value, "name").value === expectedNamesOrderedByPrimaryKey[i], `Value should be a remote object for: '${expectedNamesOrderedByPrimaryKey[i]}'`);
+                    }
+                });
+
+                // Keys > "Monstrous Beaver"
+                keyRange = {lower: stringKeyWithString("Monstrous Beaver"), lowerOpen: true, upperOpen: true};
+                IndexedDBAgent.requestData(securityOrigin, database.name, reviewersObjectStore.name, indexName, skipCount, pageSize, keyRange, (error, entries, hasMore) => {
+                    InspectorTest.log("-- Keys > 'Monstrous Beaver'");
+                    InspectorTest.log("-- Lower Bound: 'Monstrous Beaver' (open)");
+                    InspectorTest.log("-- Upper Bound: -");
+                    InspectorTest.expectNoError(error);
+                    InspectorTest.expectThat(entries.length === 1, "Should be 1 entry.");
+                    InspectorTest.expectThat(!hasMore, "Should not have more entries.");
+
+                    let expectedPrimaryKeyOrder = [1];
+                    let expectedNamesOrderedByPrimaryKey = ["Thirsty Hampster"];
+                    for (let i = 0; i < entries.length; ++i) {
+                        let entryPayload = entries[i];
+                        let primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
+                        let value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
+                        InspectorTest.expectThat(primaryKey.value === expectedPrimaryKeyOrder[i], `Primary key should be ordered by primary key: ${expectedPrimaryKeyOrder[i]}`);
+                        InspectorTest.expectThat(objectPropertyPreview(value, "name").value === expectedNamesOrderedByPrimaryKey[i], `Value should be a remote object for: '${expectedNamesOrderedByPrimaryKey[i]}'`);
+                    }
+                });
+
+                // Keys <= "M"
+                keyRange = {upper: stringKeyWithString("M"), lowerOpen: true, upperOpen: false};
+                IndexedDBAgent.requestData(securityOrigin, database.name, reviewersObjectStore.name, indexName, skipCount, pageSize, keyRange, (error, entries, hasMore) => {
+                    InspectorTest.log("-- Keys <= 'M'");
+                    InspectorTest.log("-- Lower Bound: -");
+                    InspectorTest.log("-- Upper Bound: 'M' (closed)");
+                    InspectorTest.expectNoError(error);
+                    InspectorTest.expectThat(entries.length === 2, "Should be 2 entries.");
+                    InspectorTest.expectThat(!hasMore, "Should not have more entries.");
+
+                    let expectedPrimaryKeyOrder = [3, 2];
+                    let expectedNamesOrderedByPrimaryKey = ["Bustling Badger", "Jamming Peacock"];
+                    for (let i = 0; i < entries.length; ++i) {
+                        let entryPayload = entries[i];
+                        let primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
+                        let value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
+                        InspectorTest.expectThat(primaryKey.value === expectedPrimaryKeyOrder[i], `Primary key should be ordered by primary key: ${expectedPrimaryKeyOrder[i]}`);
+                        InspectorTest.expectThat(objectPropertyPreview(value, "name").value === expectedNamesOrderedByPrimaryKey[i], `Value should be a remote object for: '${expectedNamesOrderedByPrimaryKey[i]}'`);
+                    }
+                });
+
+                // Keys <= "Monstrous Beaver"
+                keyRange = {upper: stringKeyWithString("Monstrous Beaver"), lowerOpen: true, upperOpen: false};
+                IndexedDBAgent.requestData(securityOrigin, database.name, reviewersObjectStore.name, indexName, skipCount, pageSize, keyRange, (error, entries, hasMore) => {
+                    InspectorTest.log("-- Keys <= 'Monstrous Beaver'");
+                    InspectorTest.log("-- Lower Bound: -");
+                    InspectorTest.log("-- Upper Bound: 'Monstrous Beaver' (closed)");
+                    InspectorTest.expectNoError(error);
+                    InspectorTest.expectThat(entries.length === 3, "Should be 3 entries.");
+                    InspectorTest.expectThat(!hasMore, "Should not have more entries.");
+
+                    let expectedPrimaryKeyOrder = [3, 2, 4];
+                    let expectedNamesOrderedByPrimaryKey = ["Bustling Badger", "Jamming Peacock", "Monstrous Beaver"];
+                    for (let i = 0; i < entries.length; ++i) {
+                        let entryPayload = entries[i];
+                        let primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
+                        let value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
+                        InspectorTest.expectThat(primaryKey.value === expectedPrimaryKeyOrder[i], `Primary key should be ordered by primary key: ${expectedPrimaryKeyOrder[i]}`);
+                        InspectorTest.expectThat(objectPropertyPreview(value, "name").value === expectedNamesOrderedByPrimaryKey[i], `Value should be a remote object for: '${expectedNamesOrderedByPrimaryKey[i]}'`);
+                    }
+                });
+
+                // Keys < "M"
+                keyRange = {upper: stringKeyWithString("M"), lowerOpen: true, upperOpen: true};
+                IndexedDBAgent.requestData(securityOrigin, database.name, reviewersObjectStore.name, indexName, skipCount, pageSize, keyRange, (error, entries, hasMore) => {
+                    InspectorTest.log("-- Keys < 'M'");
+                    InspectorTest.log("-- Lower Bound: -");
+                    InspectorTest.log("-- Upper Bound: 'M' (open)");
+                    InspectorTest.expectNoError(error);
+                    InspectorTest.expectThat(entries.length === 2, "Should be 2 entries.");
+                    InspectorTest.expectThat(!hasMore, "Should not have more entries.");
+
+                    let expectedPrimaryKeyOrder = [3, 2];
+                    let expectedNamesOrderedByPrimaryKey = ["Bustling Badger", "Jamming Peacock"];
+                    for (let i = 0; i < entries.length; ++i) {
+                        let entryPayload = entries[i];
+                        let primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
+                        let value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
+                        InspectorTest.expectThat(primaryKey.value === expectedPrimaryKeyOrder[i], `Primary key should be ordered by primary key: ${expectedPrimaryKeyOrder[i]}`);
+                        InspectorTest.expectThat(objectPropertyPreview(value, "name").value === expectedNamesOrderedByPrimaryKey[i], `Value should be a remote object for: '${expectedNamesOrderedByPrimaryKey[i]}'`);
+                    }
+                });
+
+                // "Monstrous Beaver" <= Key <= "Monstrous Beaver"
+                keyRange = {lower: stringKeyWithString("Monstrous Beaver"), upper: stringKeyWithString("Monstrous Beaver"), lowerOpen: false, upperOpen: false};
+                IndexedDBAgent.requestData(securityOrigin, database.name, reviewersObjectStore.name, indexName, skipCount, pageSize, keyRange, (error, entries, hasMore) => {
+                    InspectorTest.log("-- 'Monstrous Beaver' <= Key <= 'Monstrous Beaver'");
+                    InspectorTest.log("-- Lower Bound: 'Monstrous Beaver' (closed)");
+                    InspectorTest.log("-- Upper Bound: 'Monstrous Beaver' (closed)");
+                    InspectorTest.expectNoError(error);
+                    InspectorTest.expectThat(entries.length === 1, "Should be 1 entry.");
+                    InspectorTest.expectThat(!hasMore, "Should not have more entries.");
+
+                    let expectedPrimaryKeyOrder = [4];
+                    let expectedNamesOrderedByPrimaryKey = ["Monstrous Beaver"];
+                    for (let i = 0; i < entries.length; ++i) {
+                        let entryPayload = entries[i];
+                        let primaryKey = WebInspector.RemoteObject.fromPayload(entryPayload.primaryKey);
+                        let value = WebInspector.RemoteObject.fromPayload(entryPayload.value);
+                        InspectorTest.expectThat(primaryKey.value === expectedPrimaryKeyOrder[i], `Primary key should be ordered by primary key: ${expectedPrimaryKeyOrder[i]}`);
+                        InspectorTest.expectThat(objectPropertyPreview(value, "name").value === expectedNamesOrderedByPrimaryKey[i], `Value should be a remote object for: '${expectedNamesOrderedByPrimaryKey[i]}'`);
+                    }
+                });
+
+                InspectorBackend.runAfterPendingDispatches(resolve);
+            });
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (205041 => 205042)


--- trunk/Source/WebCore/ChangeLog	2016-08-26 20:59:09 UTC (rev 205041)
+++ trunk/Source/WebCore/ChangeLog	2016-08-26 20:59:13 UTC (rev 205042)
@@ -1,3 +1,20 @@
+2016-08-26  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Test and address issues in IndexedDB.requestData
+        https://bugs.webkit.org/show_bug.cgi?id=161178
+        <rdar://problem/28002467>
+
+        Reviewed by Brian Burg.
+
+        Test: inspector/indexeddb/requestData.html
+
+        * inspector/InspectorIndexedDBAgent.cpp:
+        (idbKeyRangeFromKeyRange):
+        Parsing was too strict. "lower" and "upper" keys are optional.
+
+        (WebCore::DataLoader::execute):
+        Ensure the skip count is passed forward.
+
 2016-08-25  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Provide a way to clear an IndexedDB object store

Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (205041 => 205042)


--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2016-08-26 20:59:09 UTC (rev 205041)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2016-08-26 20:59:13 UTC (rev 205042)
@@ -335,19 +335,21 @@
 
 static RefPtr<IDBKeyRange> idbKeyRangeFromKeyRange(const InspectorObject* keyRange)
 {
+    RefPtr<IDBKey> idbLower;
     RefPtr<InspectorObject> lower;
-    if (!keyRange->getObject(ASCIILiteral("lower"), lower))
-        return nullptr;
-    RefPtr<IDBKey> idbLower = idbKeyFromInspectorObject(lower.get());
-    if (!idbLower)
-        return nullptr;
+    if (keyRange->getObject(ASCIILiteral("lower"), lower)) {
+        idbLower = idbKeyFromInspectorObject(lower.get());
+        if (!idbLower)
+            return nullptr;
+    }
 
+    RefPtr<IDBKey> idbUpper;
     RefPtr<InspectorObject> upper;
-    if (!keyRange->getObject(ASCIILiteral("upper"), upper))
-        return nullptr;
-    RefPtr<IDBKey> idbUpper = idbKeyFromInspectorObject(upper.get());
-    if (!idbUpper)
-        return nullptr;
+    if (keyRange->getObject(ASCIILiteral("upper"), upper)) {
+        idbUpper = idbKeyFromInspectorObject(upper.get());
+        if (!idbUpper)
+            return nullptr;
+    }
 
     bool lowerOpen;
     if (!keyRange->getBoolean(ASCIILiteral("lowerOpen"), lowerOpen))
@@ -504,7 +506,7 @@
             return;
         }
 
-        Ref<OpenCursorCallback> openCursorCallback = OpenCursorCallback::create(m_injectedScript, m_requestCallback.copyRef(), 0, m_pageSize);
+        Ref<OpenCursorCallback> openCursorCallback = OpenCursorCallback::create(m_injectedScript, m_requestCallback.copyRef(), m_skipCount, m_pageSize);
         idbRequest->addEventListener(eventNames().successEvent, WTFMove(openCursorCallback), false);
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to