Diff
Modified: trunk/LayoutTests/ChangeLog (119900 => 119901)
--- trunk/LayoutTests/ChangeLog 2012-06-09 11:49:03 UTC (rev 119900)
+++ trunk/LayoutTests/ChangeLog 2012-06-09 12:01:18 UTC (rev 119901)
@@ -1,3 +1,13 @@
+2012-06-08 Vsevolod Vlasov <[email protected]>
+
+ IndexedDB: Inspector should handle null, string, and array keyPaths
+ https://bugs.webkit.org/show_bug.cgi?id=84303
+
+ Reviewed by Pavel Feldman.
+
+ * http/tests/inspector/indexeddb/database-structure-expected.txt:
+ * http/tests/inspector/indexeddb/database-structure.html:
+
2012-06-09 Sudarsana Nagineni <[email protected]>
[EFL] Gardening failure case on EFL build bot
Modified: trunk/LayoutTests/http/tests/inspector/indexeddb/database-structure-expected.txt (119900 => 119901)
--- trunk/LayoutTests/http/tests/inspector/indexeddb/database-structure-expected.txt 2012-06-09 11:49:03 UTC (rev 119900)
+++ trunk/LayoutTests/http/tests/inspector/indexeddb/database-structure-expected.txt 2012-06-09 12:01:18 UTC (rev 119901)
@@ -21,7 +21,7 @@
version: 1
objectStores:
testObjectStore1
- keyPath: test.key.path
+ keyPath: "test.key.path"
indexes:
Dumping database:
@@ -29,10 +29,10 @@
version: 2
objectStores:
testObjectStore1
- keyPath: test.key.path
+ keyPath: "test.key.path"
indexes:
testObjectStore2
- keyPath:
+ keyPath: null
indexes:
Dumping database:
@@ -40,13 +40,13 @@
version: 3
objectStores:
testObjectStore1
- keyPath: test.key.path
+ keyPath: "test.key.path"
indexes:
testObjectStore2
- keyPath:
+ keyPath: null
indexes:
testIndexName1
- keyPath: key.path1
+ keyPath: ""
unique: false
multiEntry: true
@@ -55,17 +55,17 @@
version: 4
objectStores:
testObjectStore1
- keyPath: test.key.path
+ keyPath: "test.key.path"
indexes:
testObjectStore2
- keyPath:
+ keyPath: null
indexes:
testIndexName1
- keyPath: key.path1
+ keyPath: ""
unique: false
multiEntry: true
testIndexName2
- keyPath: key.path2
+ keyPath: ["key.path1","key.path2"]
unique: true
multiEntry: false
@@ -74,13 +74,13 @@
version: 5
objectStores:
testObjectStore1
- keyPath: test.key.path
+ keyPath: "test.key.path"
indexes:
testObjectStore2
- keyPath:
+ keyPath: null
indexes:
testIndexName1
- keyPath: key.path1
+ keyPath: ""
unique: false
multiEntry: true
@@ -89,10 +89,10 @@
version: 6
objectStores:
testObjectStore1
- keyPath: test.key.path
+ keyPath: "test.key.path"
indexes:
testObjectStore2
- keyPath:
+ keyPath: null
indexes:
Dumping database:
@@ -100,7 +100,7 @@
version: 7
objectStores:
testObjectStore1
- keyPath: test.key.path
+ keyPath: "test.key.path"
indexes:
Dumping database:
Modified: trunk/LayoutTests/http/tests/inspector/indexeddb/database-structure.html (119900 => 119901)
--- trunk/LayoutTests/http/tests/inspector/indexeddb/database-structure.html 2012-06-09 11:49:03 UTC (rev 119900)
+++ trunk/LayoutTests/http/tests/inspector/indexeddb/database-structure.html 2012-06-09 12:01:18 UTC (rev 119901)
@@ -27,7 +27,7 @@
for (var i = 0; i < objectStoreNames.length; ++i) {
var objectStore = database.objectStores[objectStoreNames[i]];
InspectorTest.addResult(" " + objectStore.name);
- InspectorTest.addResult(" keyPath: " + objectStore.keyPath);
+ InspectorTest.addResult(" keyPath: " + JSON.stringify(objectStore.keyPath));
InspectorTest.addResult(" indexes: ");
var indexNames = [];
for (var indexName in objectStore.indexes)
@@ -36,7 +36,7 @@
for (var j = 0; j < indexNames.length; ++j) {
var index = objectStore.indexes[indexNames[j]];
InspectorTest.addResult(" " + index.name);
- InspectorTest.addResult(" keyPath: " + index.keyPath);
+ InspectorTest.addResult(" keyPath: " + JSON.stringify(index.keyPath));
InspectorTest.addResult(" unique: " + index.unique);
InspectorTest.addResult(" multiEntry: " + index.multiEntry);
}
@@ -82,7 +82,7 @@
{
dumpDatabase();
- InspectorTest.createObjectStore(mainFrameId, databaseName, "testObjectStore2", "", false, step8);
+ InspectorTest.createObjectStore(mainFrameId, databaseName, "testObjectStore2", null, false, step8);
}
function step8()
@@ -95,7 +95,7 @@
{
dumpDatabase();
- InspectorTest.createObjectStoreIndex(mainFrameId, databaseName, "testObjectStore2", "testIndexName1", "key.path1", false, true, step10);
+ InspectorTest.createObjectStoreIndex(mainFrameId, databaseName, "testObjectStore2", "testIndexName1", "", false, true, step10);
}
function step10()
@@ -108,7 +108,7 @@
{
dumpDatabase();
- InspectorTest.createObjectStoreIndex(mainFrameId, databaseName, "testObjectStore2", "testIndexName2", "key.path2", true, false, step12);
+ InspectorTest.createObjectStoreIndex(mainFrameId, databaseName, "testObjectStore2", "testIndexName2", ["key.path1", "key.path2"], true, false, step12);
}
function step12()
Modified: trunk/Source/WebCore/ChangeLog (119900 => 119901)
--- trunk/Source/WebCore/ChangeLog 2012-06-09 11:49:03 UTC (rev 119900)
+++ trunk/Source/WebCore/ChangeLog 2012-06-09 12:01:18 UTC (rev 119901)
@@ -1,5 +1,34 @@
2012-06-08 Vsevolod Vlasov <[email protected]>
+ IndexedDB: Inspector should handle null, string, and array keyPaths
+ https://bugs.webkit.org/show_bug.cgi?id=84303
+
+ Reviewed by Pavel Feldman.
+
+ Supported different key path types and updated tests to cover each case.
+ Key path strings are now highlighted in the DataGrid column headers.
+
+ * inspector/Inspector.json:
+ * inspector/InspectorIndexedDBAgent.cpp:
+ (WebCore):
+ * inspector/front-end/IndexedDBModel.js:
+ (WebInspector.IndexedDBModel.idbKeyPathFromKeyPath):
+ (WebInspector.IndexedDBModel.keyPathStringFromIDBKeyPath):
+ (WebInspector.IndexedDBModel.prototype._loadDatabase.callback):
+ (WebInspector.IndexedDBModel.prototype._loadDatabase):
+ (WebInspector.IndexedDBModel.ObjectStore.prototype.get keyPathString):
+ (WebInspector.IndexedDBModel.Index.prototype.get keyPathString):
+ * inspector/front-end/IndexedDBViews.js:
+ (WebInspector.IDBDataView.prototype._createDataGrid):
+ (WebInspector.IDBDataView.prototype._keyColumnHeaderFragment):
+ (WebInspector.IDBDataView.prototype._keyPathStringFragment):
+ (WebInspector.IDBDataGridNode.prototype.createCell):
+ * inspector/front-end/ResourcesPanel.js:
+ (WebInspector.IDBObjectStoreTreeElement.prototype._updateTooltip):
+ (WebInspector.IDBIndexTreeElement.prototype._updateTooltip):
+
+2012-06-08 Vsevolod Vlasov <[email protected]>
+
Web Inspector: Increase size limits for resource content cached in InspectorResourceAgent.
https://bugs.webkit.org/show_bug.cgi?id=88674
Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js
(Binary files differ)
Modified: trunk/Source/WebCore/inspector/Inspector.json (119900 => 119901)
--- trunk/Source/WebCore/inspector/Inspector.json 2012-06-09 11:49:03 UTC (rev 119900)
+++ trunk/Source/WebCore/inspector/Inspector.json 2012-06-09 12:01:18 UTC (rev 119901)
@@ -1096,7 +1096,7 @@
"description": "Object store.",
"properties": [
{ "name": "name", "type": "string", "description": "Object store name." },
- { "name": "keyPath", "type": "string", "description": "Object store key path." },
+ { "name": "keyPath", "$ref": "KeyPath", "description": "Object store key path." },
{ "name": "indexes", "type": "array", "items": { "$ref": "ObjectStoreIndex" }, "description": "Indexes in this object store." }
]
},
@@ -1106,7 +1106,7 @@
"description": "Object store index.",
"properties": [
{ "name": "name", "type": "string", "description": "Index name." },
- { "name": "keyPath", "type": "string", "description": "Index key path." },
+ { "name": "keyPath", "$ref": "KeyPath", "description": "Index key path." },
{ "name": "unique", "type": "boolean", "description": "If true, index is unique." },
{ "name": "multiEntry", "type": "boolean", "description": "If true, index allows multiple entries for a key." }
]
@@ -1137,12 +1137,22 @@
{
"id": "DataEntry",
"type": "object",
- "description": "Key.",
+ "description": "Data entry.",
"properties": [
{ "name": "key", "$ref": "Key", "description": "Key." },
{ "name": "primaryKey", "$ref": "Key", "description": "Primary key." },
{ "name": "value", "$ref": "Runtime.RemoteObject", "description": "Value." }
]
+ },
+ {
+ "id": "KeyPath",
+ "type": "object",
+ "description": "Key path.",
+ "properties": [
+ { "name": "type", "type": "string", "enum": ["null", "string", "array"], "description": "Key path type." },
+ { "name": "string", "type": "string", "optional": true, "description": "String value." },
+ { "name": "array", "type": "array", "optional": true, "items": { "type": "string" }, "description": "Array value." }
+ ]
}
],
"commands": [
Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (119900 => 119901)
--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2012-06-09 11:49:03 UTC (rev 119900)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2012-06-09 12:01:18 UTC (rev 119901)
@@ -70,6 +70,7 @@
using WebCore::TypeBuilder::IndexedDB::DatabaseWithObjectStores;
using WebCore::TypeBuilder::IndexedDB::DataEntry;
using WebCore::TypeBuilder::IndexedDB::Key;
+using WebCore::TypeBuilder::IndexedDB::KeyPath;
using WebCore::TypeBuilder::IndexedDB::KeyRange;
using WebCore::TypeBuilder::IndexedDB::ObjectStore;
using WebCore::TypeBuilder::IndexedDB::ObjectStoreIndex;
@@ -226,23 +227,31 @@
return idbIndex;
}
-static String keyPathToString(const IDBKeyPath& keyPath)
+static PassRefPtr<KeyPath> keyPathFromIDBKeyPath(const IDBKeyPath& idbKeyPath)
{
- // FIXME: Replace with handlers for null/string/array types.
- // https://bugs.webkit.org/show_bug.cgi?id=84303
- switch (keyPath.type()) {
+ RefPtr<KeyPath> keyPath;
+ switch (idbKeyPath.type()) {
case IDBKeyPath::NullType:
- return "(none)";
+ keyPath = KeyPath::create().setType(KeyPath::Type::Null);
break;
case IDBKeyPath::StringType:
- return keyPath.string();
+ keyPath = KeyPath::create().setType(KeyPath::Type::String);
+ keyPath->setString(idbKeyPath.string());
break;
- case IDBKeyPath::ArrayType:
- return "[...]";
+ case IDBKeyPath::ArrayType: {
+ keyPath = KeyPath::create().setType(KeyPath::Type::Array);
+ RefPtr<TypeBuilder::Array<String> > array = TypeBuilder::Array<String>::create();
+ const Vector<String>& stringArray = idbKeyPath.array();
+ for (size_t i = 0; i < stringArray.size(); ++i)
+ array->addItem(stringArray[i]);
+ keyPath->setArray(array);
break;
}
- ASSERT_NOT_REACHED();
- return String();
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ return keyPath.release();
}
class DatabaseLoaderCallback : public ExecutableWithDatabase {
@@ -280,7 +289,7 @@
RefPtr<ObjectStoreIndex> objectStoreIndex = ObjectStoreIndex::create()
.setName(idbIndex->name())
- .setKeyPath(keyPathToString(idbIndex->keyPath()))
+ .setKeyPath(keyPathFromIDBKeyPath(idbIndex->keyPath()))
.setUnique(idbIndex->unique())
.setMultiEntry(idbIndex->multiEntry());
indexes->addItem(objectStoreIndex);
@@ -288,7 +297,7 @@
RefPtr<ObjectStore> objectStore = ObjectStore::create()
.setName(idbObjectStore->name())
- .setKeyPath(keyPathToString(idbObjectStore->keyPath()))
+ .setKeyPath(keyPathFromIDBKeyPath(idbObjectStore->keyPath()))
.setIndexes(indexes);
objectStores->addItem(objectStore);
}
Modified: trunk/Source/WebCore/inspector/front-end/IndexedDBModel.js (119900 => 119901)
--- trunk/Source/WebCore/inspector/front-end/IndexedDBModel.js 2012-06-09 11:49:03 UTC (rev 119900)
+++ trunk/Source/WebCore/inspector/front-end/IndexedDBModel.js 2012-06-09 12:01:18 UTC (rev 119901)
@@ -55,6 +55,12 @@
ArrayType: "array"
};
+WebInspector.IndexedDBModel.KeyPathTypes = {
+ NullType: "null",
+ StringType: "string",
+ ArrayType: "array"
+};
+
/**
* @param {IndexedDBAgent.Key} key
*/
@@ -126,6 +132,35 @@
return keyRange;
}
+/**
+ * @param {IndexedDBAgent.KeyPath} keyPath
+ */
+WebInspector.IndexedDBModel.idbKeyPathFromKeyPath = function(keyPath)
+{
+ var idbKeyPath;
+ switch (keyPath.type) {
+ case WebInspector.IndexedDBModel.KeyPathTypes.NullType:
+ idbKeyPath = null;
+ break;
+ case WebInspector.IndexedDBModel.KeyPathTypes.StringType:
+ idbKeyPath = keyPath.string;
+ break;
+ case WebInspector.IndexedDBModel.KeyPathTypes.ArrayType:
+ idbKeyPath = keyPath.array;
+ break;
+ }
+ return idbKeyPath;
+}
+
+WebInspector.IndexedDBModel.keyPathStringFromIDBKeyPath = function(idbKeyPath)
+{
+ if (typeof idbKeyPath === "string")
+ return "\"" + idbKeyPath + "\"";
+ if (idbKeyPath instanceof Array)
+ return "[\"" + idbKeyPath.join("\", \"") + "\"]";
+ return null;
+}
+
WebInspector.IndexedDBModel.EventTypes = {
DatabaseAdded: "DatabaseAdded",
DatabaseRemoved: "DatabaseRemoved",
@@ -354,10 +389,12 @@
this._databases.put(databaseId, databaseModel);
for (var i = 0; i < databaseWithObjectStores.objectStores.length; ++i) {
var objectStore = databaseWithObjectStores.objectStores[i];
- var objectStoreModel = new WebInspector.IndexedDBModel.ObjectStore(objectStore.name, objectStore.keyPath);
+ var objectStoreIDBKeyPath = WebInspector.IndexedDBModel.idbKeyPathFromKeyPath(objectStore.keyPath);
+ var objectStoreModel = new WebInspector.IndexedDBModel.ObjectStore(objectStore.name, objectStoreIDBKeyPath);
for (var j = 0; j < objectStore.indexes.length; ++j) {
var index = objectStore.indexes[j];
- var indexModel = new WebInspector.IndexedDBModel.Index(index.name, index.keyPath, index.unique, index.multiEntry);
+ var indexIDBKeyPath = WebInspector.IndexedDBModel.idbKeyPathFromKeyPath(index.keyPath);
+ var indexModel = new WebInspector.IndexedDBModel.Index(index.name, indexIDBKeyPath, index.unique, index.multiEntry);
objectStoreModel.indexes[indexModel.name] = indexModel;
}
databaseModel.objectStores[objectStoreModel.name] = objectStoreModel;
@@ -499,7 +536,7 @@
/**
* @constructor
* @param {string} name
- * @param {string} keyPath
+ * @param {*} keyPath
*/
WebInspector.IndexedDBModel.ObjectStore = function(name, keyPath)
{
@@ -508,10 +545,20 @@
this.indexes = {};
}
+WebInspector.IndexedDBModel.ObjectStore.prototype = {
+ /**
+ * @type {string}
+ */
+ get keyPathString()
+ {
+ return WebInspector.IndexedDBModel.keyPathStringFromIDBKeyPath(this.keyPath);
+ }
+}
+
/**
* @constructor
* @param {string} name
- * @param {string} keyPath
+ * @param {*} keyPath
*/
WebInspector.IndexedDBModel.Index = function(name, keyPath, unique, multiEntry)
{
@@ -521,6 +568,16 @@
this.multiEntry = multiEntry;
}
+WebInspector.IndexedDBModel.Index.prototype = {
+ /**
+ * @type {string}
+ */
+ get keyPathString()
+ {
+ return WebInspector.IndexedDBModel.keyPathStringFromIDBKeyPath(this.keyPath);
+ }
+}
+
/**
* @constructor
*/
Modified: trunk/Source/WebCore/inspector/front-end/IndexedDBViews.js (119900 => 119901)
--- trunk/Source/WebCore/inspector/front-end/IndexedDBViews.js 2012-06-09 11:49:03 UTC (rev 119900)
+++ trunk/Source/WebCore/inspector/front-end/IndexedDBViews.js 2012-06-09 12:01:18 UTC (rev 119901)
@@ -141,13 +141,11 @@
var keyPath = this._isIndex ? this._index.keyPath : this._objectStore.keyPath;
columns["key"] = {};
- var keyColumnTitle = WebInspector.UIString("Key") + this._keyPathHeader(keyPath);
- columns["key"].title = keyColumnTitle;
-
+ columns["key"].titleDOMFragment = this._keyColumnHeaderFragment(WebInspector.UIString("Key"), keyPath);
+
if (this._isIndex) {
columns["primaryKey"] = {};
- var primaryKeyColumnTitle = WebInspector.UIString("Primary key") + this._keyPathHeader(this._objectStore.keyPath);
- columns["primaryKey"].title = primaryKeyColumnTitle;
+ columns["primaryKey"].titleDOMFragment = this._keyColumnHeaderFragment(WebInspector.UIString("Primary key"), this._objectStore.keyPath);
}
columns["value"] = {};
@@ -158,16 +156,49 @@
},
/**
- * @return {string}
+ * @param {string} prefix
+ * @param {*} keyPath
+ * @return {DocumentFragment}
*/
- _keyPathHeader: function(keyPath)
+ _keyColumnHeaderFragment: function(prefix, keyPath)
{
- if (!keyPath)
- return "";
- return " (" + WebInspector.UIString("keyPath") + ": \"" + keyPath + "\")";
+ var keyColumnHeaderFragment = document.createDocumentFragment();
+ keyColumnHeaderFragment.appendChild(document.createTextNode(prefix));
+ if (keyPath === null)
+ return keyColumnHeaderFragment;
+
+ keyColumnHeaderFragment.appendChild(document.createTextNode(" (" + WebInspector.UIString("Key path: ")));
+ if (keyPath instanceof Array) {
+ keyColumnHeaderFragment.appendChild(document.createTextNode("["));
+ for (var i = 0; i < keyPath.length; ++i) {
+ if (i != 0)
+ keyColumnHeaderFragment.appendChild(document.createTextNode(", "));
+ keyColumnHeaderFragment.appendChild(this._keyPathStringFragment(keyPath[i]));
+ }
+ keyColumnHeaderFragment.appendChild(document.createTextNode("]"));
+ } else {
+ var keyPathString = /** @type {string} */ keyPath;
+ keyColumnHeaderFragment.appendChild(this._keyPathStringFragment(keyPathString));
+ }
+ keyColumnHeaderFragment.appendChild(document.createTextNode(")"));
+ return keyColumnHeaderFragment;
},
/**
+ * @param {string} keyPathString
+ * @return {DocumentFragment}
+ */
+ _keyPathStringFragment: function(keyPathString)
+ {
+ var keyPathStringFragment = document.createDocumentFragment();
+ keyPathStringFragment.appendChild(document.createTextNode("\""));
+ var keyPathSpan = keyPathStringFragment.createChild("span", "source-code console-formatted-string");
+ keyPathSpan.textContent = keyPathString;
+ keyPathStringFragment.appendChild(document.createTextNode("\""));
+ return keyPathStringFragment;
+ },
+
+ /**
* @return {Element}
*/
_createEditorToolbar: function()
@@ -358,7 +389,7 @@
{
var cell = WebInspector.DataGridNode.prototype.createCell.call(this, columnIdentifier);
var value = this.data[columnIdentifier];
-
+
switch (columnIdentifier) {
case "value":
cell.removeChildren();
Modified: trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js (119900 => 119901)
--- trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js 2012-06-09 11:49:03 UTC (rev 119900)
+++ trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js 2012-06-09 12:01:18 UTC (rev 119901)
@@ -1723,7 +1723,8 @@
_updateTooltip: function()
{
- this.tooltip = this._objectStore.keyPath ? (WebInspector.UIString("Key path") + ": " + this._objectStore.keyPath) : "";
+ var keyPathString = this._objectStore.keyPathString;
+ this.tooltip = keyPathString !== null ? (WebInspector.UIString("Key path: ") + keyPathString) : "";
},
onselect: function()
@@ -1797,7 +1798,8 @@
_updateTooltip: function()
{
var tooltipLines = [];
- tooltipLines.push(WebInspector.UIString("Key path") + ": " + this._index.keyPath);
+ var keyPathString = this._index.keyPathString;
+ tooltipLines.push(WebInspector.UIString("Key path: ") + keyPathString);
if (this._index.unique)
tooltipLines.push(WebInspector.UIString("unique"));
if (this._index.multiEntry)