WebKit Bugzilla
Attachment 357495 Details for
Bug 156271
: Web Inspector: CSS autocomplete: suggestion hint should be the most commonly used property and not the alphabetically first one
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-156271-20181217162814.patch (text/plain), 80.58 KB, created by
Devin Rousso
on 2018-12-17 16:28:14 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2018-12-17 16:28:14 PST
Size:
80.58 KB
patch
obsolete
>diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index 9152ad45a76b7b16c7970000dfa89f9f834c0cdf..db3e56ee8bd31893dd6432c419b59881176fdb01 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,54 @@ >+2018-12-17 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: CSS autocomplete: suggestion hint should be the most commonly used property and not the alphabetically first one >+ https://bugs.webkit.org/show_bug.cgi?id=156271 >+ <rdar://problem/25588888> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Every time a `WI.CSSProperty` is created/updated, increment/decrement the count of that >+ property's name in the global map of property name counts. When showing CSS completions for >+ property names, initially focus the property with the highest count. >+ >+ * UserInterface/Models/CSSProperty.js: >+ (WI.CSSProperty): >+ (WI.CSSProperty.sortByPropertyNameUsageCount): Added. >+ (WI.CSSProperty._initializePropertyNameCounts): Added. >+ (WI.CSSProperty.prototype.update): >+ (WI.CSSProperty.prototype.remove): >+ (WI.CSSProperty.prototype.set name): >+ (WI.CSSProperty.prototype._updateName): Added. >+ >+ * UserInterface/Base/ObjectStore.js: >+ (WI.ObjectStore._open): >+ (WI.ObjectStore.prototype.async getAll): >+ (WI.ObjectStore.prototype.async getAllKeys): Added. >+ (WI.ObjectStore.prototype.async get): Added. >+ (WI.ObjectStore.prototype.async getObject): Added. >+ (WI.ObjectStore.prototype.async.put): Deleted. >+ (WI.ObjectStore.prototype.async.putObject): Deleted. >+ (WI.ObjectStore.prototype.async.add): Deleted. >+ (WI.ObjectStore.prototype.async.addObject): Deleted. >+ >+ * UserInterface/Views/SpreadsheetStyleProperty.js: >+ (WI.SpreadsheetStyleProperty.prototype.spreadsheetTextFieldInitialCompletionIndex): Added. >+ >+ * UserInterface/Views/SpreadsheetTextField.js: >+ (WI.SpreadsheetTextField.prototype._updateCompletions): >+ Expose a way for the `delegate` to set the initial selection index. >+ >+ * UserInterface/Views/CompletionSuggestionsView.js: >+ (WI.CompletionSuggestionsView.prototype.set selectedIndex): >+ (WI.CompletionSuggestionsView.prototype.selectNext): >+ (WI.CompletionSuggestionsView.prototype.selectPrevious): >+ >+ * UserInterface/Base/Utilities.js: >+ Add utility function for finding the minIndex in an array. >+ >+ * UserInterface/Controllers/AuditManager.js: >+ (WI.AuditManager.prototype.processJSON): >+ (WI.AuditManager.prototype.addDefaultTestsIfNeeded): >+ > 2018-12-15 Nikita Vasilyev <nvasilyev@apple.com> > > Web Inspector: Styles: toggling selected properties may cause data corruption >diff --git a/Source/WebInspectorUI/UserInterface/Base/ObjectStore.js b/Source/WebInspectorUI/UserInterface/Base/ObjectStore.js >index b7bf8931b6608b01c6cbcebaa576aebf0f829bf1..636c7e328c81fc9148b2437b8b33301e2fa2b5db 100644 >--- a/Source/WebInspectorUI/UserInterface/Base/ObjectStore.js >+++ b/Source/WebInspectorUI/UserInterface/Base/ObjectStore.js >@@ -52,7 +52,7 @@ WI.ObjectStore = class ObjectStore > return; > } > >- const version = 1; // Increment this for every edit to `WI.objectStores`. >+ const version = 2; // Increment this for every edit to `WI.objectStores`. > > let databaseRequest = indexedDB.open(WI.ObjectStore._databaseName, version); > databaseRequest.addEventListener("upgradeneeded", (event) => { >@@ -99,26 +99,50 @@ WI.ObjectStore = class ObjectStore > async getAll(...args) > { > if (!WI.ObjectStore.supported()) >- return undefined; >+ return []; > > return this._operation("readonly", (objectStore) => objectStore.getAll(...args)); > } > >- async add(...args) >+ async getAllKeys(...args) >+ { >+ if (!WI.ObjectStore.supported()) >+ return []; >+ >+ return this._operation("readonly", (objectStore) => objectStore.getAllKeys(...args)); >+ } >+ >+ async get(...args) > { > if (!WI.ObjectStore.supported()) > return undefined; > >- return this._operation("readwrite", (objectStore) => objectStore.add(...args)); >+ return this._operation("readonly", (objectStore) => objectStore.get(...args)); > } > >- async addObject(object, ...args) >+ async getObject(object, ...args) >+ { >+ if (!WI.ObjectStore.supported()) >+ return undefined; >+ >+ return this.get(this._resolveKeyPath(object).value, ...args); >+ } >+ >+ async put(...args) >+ { >+ if (!WI.ObjectStore.supported()) >+ return undefined; >+ >+ return this._operation("readwrite", (objectStore) => objectStore.put(...args)); >+ } >+ >+ async putObject(object, ...args) > { > if (!WI.ObjectStore.supported()) > return undefined; > > console.assert(typeof object.toJSON === "function", "ObjectStore cannot store an object without JSON serialization", object.constructor.name); >- let result = await this.add(object.toJSON(), ...args); >+ let result = await this.put(object.toJSON(), ...args); > this.associateObject(object, args[0], result); > return result; > } >@@ -207,4 +231,5 @@ WI.ObjectStore._database = null; > // Be sure to update the `version` above when making changes. > WI.objectStores = { > audits: new WI.ObjectStore("audit-manager-tests", {keyPath: "__id", autoIncrement: true}), >+ cssPropertyNameCounts: new WI.ObjectStore("css-property-name-counts"), > }; >diff --git a/Source/WebInspectorUI/UserInterface/Base/Utilities.js b/Source/WebInspectorUI/UserInterface/Base/Utilities.js >index 94f5a6a6202c001cda16ec5528f20b6390e438c8..4761be14ceb46d40fe03f197433033c18d930d6c 100644 >--- a/Source/WebInspectorUI/UserInterface/Base/Utilities.js >+++ b/Source/WebInspectorUI/UserInterface/Base/Utilities.js >@@ -1339,6 +1339,25 @@ function simpleGlobStringToRegExp(globString, regExpFlags) > return new RegExp(regexString, regExpFlags); > } > >+Object.defineProperty(Array.prototype, "minIndex", >+{ >+ value(comparator) >+ { >+ function defaultComparator(a, b) >+ { >+ return a - b; >+ } >+ comparator = comparator || defaultComparator; >+ >+ let min = 0; >+ for (let i = 1; i < this.length; ++i) { >+ if (comparator(this[min], this[i]) > 0) >+ min = i; >+ } >+ return min; >+ }, >+}); >+ > Object.defineProperty(Array.prototype, "lowerBound", > { > // Return index of the leftmost element that is equal or greater >diff --git a/Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js b/Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js >index 62d7493701c037ab3147fc9449e46ab1dadc8047..a9690e7659d9e2321c4c471d318622781f06cc81 100644 >--- a/Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js >+++ b/Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js >@@ -121,7 +121,7 @@ WI.AuditManager = class AuditManager extends WI.Object > > if (object instanceof WI.AuditTestBase) { > this._addTest(object); >- WI.objectStores.audits.addObject(object); >+ WI.objectStores.audits.putObject(object); > } else if (object instanceof WI.AuditTestResultBase) > this._addResult(object); > >@@ -254,7 +254,7 @@ WI.AuditManager = class AuditManager extends WI.Object > > for (let test of defaultTests) { > this._addTest(test); >- WI.objectStores.audits.addObject(test); >+ WI.objectStores.audits.putObject(test); > } > } > }; >diff --git a/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js b/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js >index 4ba36efc8c3c9a3568e4179bed8cb016bd4d1785..a8bbdc22f92279fd5c82c7e1b6d792f7423a6a3b 100644 >--- a/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js >+++ b/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js >@@ -27,6 +27,8 @@ WI.CSSProperty = class CSSProperty extends WI.Object > { > constructor(index, text, name, value, priority, enabled, overridden, implicit, anonymous, valid, styleSheetTextRange) > { >+ WI.CSSProperty._initializePropertyNameCounts(); >+ > super(); > > this._ownerStyle = null; >@@ -46,6 +48,42 @@ WI.CSSProperty = class CSSProperty extends WI.Object > return name.startsWith("--"); > } > >+ static sortByPropertyNameUsageCount(propertyNameA, propertyNameB) >+ { >+ let countA = WI.CSSProperty._cachedNameCounts[propertyNameA]; >+ let countB = WI.CSSProperty._cachedNameCounts[propertyNameB]; >+ if (isNaN(countA) && !isNaN(countB)) >+ return 1; >+ if (!isNaN(countA) && isNaN(countB)) >+ return -1; >+ if (!isNaN(countA) && !isNaN(countB)) { >+ if (countA !== countB) >+ return countB - countA; >+ let canonicalPropertyNameA = WI.cssManager.canonicalNameForPropertyName(propertyNameA); >+ let canonicalPropertyNameB = WI.cssManager.canonicalNameForPropertyName(propertyNameB); >+ if (canonicalPropertyNameA !== propertyNameA || canonicalPropertyNameB !== propertyNameB) >+ return WI.CSSProperty.sortByPropertyNameUsageCount(canonicalPropertyNameA, canonicalPropertyNameB); >+ } >+ return propertyNameA.extendedLocaleCompare(propertyNameB); >+ } >+ >+ static _initializePropertyNameCounts() >+ { >+ if (WI.CSSProperty._cachedNameCounts) >+ return; >+ >+ WI.CSSProperty._cachedNameCounts = {}; >+ >+ WI.objectStores.cssPropertyNameCounts.getAllKeys().then(async (keys) => { >+ let storedCounts = await Promise.all(keys.map((key) => WI.objectStores.cssPropertyNameCounts.get(key))); >+ for (let i = 0; i < keys.length; ++i) { >+ let property = keys[i]; >+ let currentCount = WI.CSSProperty._cachedNameCounts[property] || 0; >+ WI.CSSProperty._cachedNameCounts[property] = currentCount + storedCounts[i]; >+ } >+ }); >+ } >+ > // Public > > get ownerStyle() >@@ -100,7 +138,6 @@ WI.CSSProperty = class CSSProperty extends WI.Object > this._overridden = overridden; > > this._text = text; >- this._name = name; > this._rawValue = value; > this._priority = priority; > this._enabled = enabled; >@@ -111,6 +148,7 @@ WI.CSSProperty = class CSSProperty extends WI.Object > this._variable = name.startsWith("--"); > this._styleSheetTextRange = styleSheetTextRange || null; > >+ this._updateName(name); > this._relatedShorthandProperty = null; > this._relatedLonghandProperties = []; > >@@ -126,7 +164,7 @@ WI.CSSProperty = class CSSProperty extends WI.Object > remove() > { > // Setting name or value to an empty string removes the entire CSSProperty. >- this._name = ""; >+ this._updateName(""); > const forceRemove = true; > this._updateStyleText(forceRemove); > } >@@ -182,7 +220,7 @@ WI.CSSProperty = class CSSProperty extends WI.Object > if (name === this._name) > return; > >- this._name = name; >+ this._updateName(name); > this._updateStyleText(); > } > >@@ -335,6 +373,41 @@ WI.CSSProperty = class CSSProperty extends WI.Object > > // Private > >+ _updateName(name) >+ { >+ if (name === this._name) >+ return; >+ >+ let changeCount = (propertyName, delta) => { >+ if (!propertyName || this._implicit || this._anonymous || !this._enabled) >+ return; >+ >+ let oldCount = WI.CSSProperty._cachedNameCounts[propertyName]; >+ >+ // Allow property counts to be updated if the property name has already been counted before. >+ // This can happen when inspecting a device that has different CSS properties enabled. >+ if (isNaN(oldCount) && WI.CSSCompletions.cssNameCompletions && !WI.CSSCompletions.cssNameCompletions.isValidPropertyName(propertyName)) >+ return; >+ >+ let newCount = Math.max(0, (oldCount || 0) + delta); >+ WI.CSSProperty._cachedNameCounts[propertyName] = newCount; >+ >+ WI.objectStores.cssPropertyNameCounts.get(propertyName).then(async (count) => { >+ count = Math.max(0, (count || oldCount || 0) + delta); >+ await WI.objectStores.cssPropertyNameCounts.put(count, propertyName); >+ WI.CSSProperty._cachedNameCounts[propertyName] = count; >+ }); >+ >+ let canonicalName = WI.cssManager.canonicalNameForPropertyName(propertyName); >+ if (canonicalName !== propertyName) >+ changeCount(canonicalName, delta); >+ }; >+ >+ changeCount(this._name, -1); >+ this._name = name; >+ changeCount(this._name, 1); >+ } >+ > _updateStyleText(forceRemove = false) > { > let text = ""; >@@ -405,6 +478,8 @@ WI.CSSProperty = class CSSProperty extends WI.Object > } > }; > >+WI.CSSProperty._cachedNameCounts = null; >+ > WI.CSSProperty.Event = { > Changed: "css-property-changed", > OverriddenStatusChanged: "css-property-overridden-status-changed" >diff --git a/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js b/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js >index 30cc228e6f625ce770324fcfbdb83a98e076ff1b..1dd49d23aeac6d903af09b2a6ecf81ac29d577de 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js >@@ -77,6 +77,9 @@ WI.CompletionSuggestionsView = class CompletionSuggestionsView extends WI.Object > > selectedItemElement.classList.add(WI.CompletionSuggestionsView.SelectedItemStyleClassName); > selectedItemElement.scrollIntoViewIfNeeded(false); >+ >+ if (this._delegate && this._delegate.completionSuggestionsSelectedCompletion) >+ this._delegate.completionSuggestionsSelectedCompletion(this, selectedItemElement.textContent); > } > > selectNext() >@@ -87,10 +90,6 @@ WI.CompletionSuggestionsView = class CompletionSuggestionsView extends WI.Object > this.selectedIndex = 0; > else > ++this.selectedIndex; >- >- var selectedItemElement = this._selectedItemElement; >- if (selectedItemElement && this._delegate && typeof this._delegate.completionSuggestionsSelectedCompletion === "function") >- this._delegate.completionSuggestionsSelectedCompletion(this, selectedItemElement.textContent); > } > > selectPrevious() >@@ -99,10 +98,6 @@ WI.CompletionSuggestionsView = class CompletionSuggestionsView extends WI.Object > this.selectedIndex = this._containerElement.children.length - 1; > else > --this.selectedIndex; >- >- var selectedItemElement = this._selectedItemElement; >- if (selectedItemElement && this._delegate && typeof this._delegate.completionSuggestionsSelectedCompletion === "function") >- this._delegate.completionSuggestionsSelectedCompletion(this, selectedItemElement.textContent); > } > > isHandlingClickEvent() >diff --git a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js >index 9ae9fa9112fcc6f33fad003f7d5bdc3c674d1e49..135d4e0fc1271d038d16ec9344020375fc1ef73c 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js >@@ -389,6 +389,13 @@ WI.SpreadsheetStyleProperty = class SpreadsheetStyleProperty extends WI.Object > this._nameTextField.startEditing(); > } > >+ spreadsheetTextFieldInitialCompletionIndex(textField, completions) >+ { >+ if (textField === this._nameTextField) >+ return completions.minIndex(WI.CSSProperty.sortByPropertyNameUsageCount); >+ return 0; >+ } >+ > // Private > > _isEditable() >diff --git a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js >index 02b74bd84fe392bbd2766e2b5d72d9eb31b66a9a..fc4c0741d05eb91bc7361437c18ff80b5c4fd38d 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js >@@ -392,8 +392,10 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > > this._suggestionsView.selectedIndex = NaN; > if (completionPrefix) { >- // Select first item and call completionSuggestionsSelectedCompletion. >- this._suggestionsView.selectNext(); >+ if (this._delegate && this._delegate.spreadsheetTextFieldInitialCompletionIndex) >+ this._suggestionsView.selectedIndex = this._delegate.spreadsheetTextFieldInitialCompletionIndex(this, completions); >+ else >+ this._suggestionsView.selectNext(); > } else > this.suggestionHint = ""; > } >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 28d445a7e29d4973bf15c1efc13310112a215c30..2080cd6fbda45c2a8204252126286ebf3ab42085 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,27 @@ >+2018-12-17 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: CSS autocomplete: suggestion hint should be the most commonly used property and not the alphabetically first one >+ https://bugs.webkit.org/show_bug.cgi?id=156271 >+ <rdar://problem/25588888> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * inspector/css/css-property-expected.txt: >+ * inspector/css/css-property.html: >+ >+ * inspector/unit-tests/array-utilities-expected.txt: >+ * inspector/unit-tests/array-utilities.html: >+ >+ * inspector/unit-tests/objectStore/delete-expected.txt: >+ * inspector/unit-tests/objectStore/delete.html: >+ * inspector/unit-tests/objectStore/deleteObject-expected.txt: >+ * inspector/unit-tests/objectStore/deleteObject.html: >+ * inspector/unit-tests/objectStore/put-expected.txt: Renamed from LayoutTests/inspector/unit-tests/objectStore/add-expected.txt. >+ * inspector/unit-tests/objectStore/put.html: Renamed from LayoutTests/inspector/unit-tests/objectStore/add.html. >+ * inspector/unit-tests/objectStore/putObject-expected.txt: Renamed from LayoutTests/inspector/unit-tests/objectStore/addObject-expected.txt. >+ * inspector/unit-tests/objectStore/putObject.html: Renamed from LayoutTests/inspector/unit-tests/objectStore/addObject.html. >+ * inspector/unit-tests/objectStore/resources/objectStore-utilities.js: >+ > 2018-12-15 Youenn Fablet <youenn@apple.com> > > Make RTCRtpSender.setParameters to activate specific encodings >diff --git a/LayoutTests/inspector/css/css-property-expected.txt b/LayoutTests/inspector/css/css-property-expected.txt >index 7b7d402ce6f96ca1ba2ab003f8a5a9321c8d0058..238923f3a25200638480d89e20be624ad7e15040 100644 >--- a/LayoutTests/inspector/css/css-property-expected.txt >+++ b/LayoutTests/inspector/css/css-property-expected.txt >@@ -2,6 +2,13 @@ Testing methods of CSSProperty. > > > == Running test suite: CSSProperty >+-- Running test case: CSSProperty.NameCount >+PASS: "display" should have at least 2 counts. >+PASS: "background-repeat" should have at least 1 count. >+PASS: "background-repeat-x" should not be counted. >+PASS: "background-repeat-y" should not be counted. >+PASS: "background-repeat-invalid" should not be counted. >+ > -- Running test case: CSSProperty.prototype.get valid > PASS: "background-repeat" is a valid property. > PASS: "background-repeat-x" is an invalid property. >diff --git a/LayoutTests/inspector/css/css-property.html b/LayoutTests/inspector/css/css-property.html >index 0ce1bffd76c2ee09d915671432d70ebd151bf1d6..072db2771ad0d8ef12f3339a46016f13318562ba 100644 >--- a/LayoutTests/inspector/css/css-property.html >+++ b/LayoutTests/inspector/css/css-property.html >@@ -8,6 +8,18 @@ function test() { > > let suite = InspectorTest.createAsyncSuite("CSSProperty"); > >+ suite.addTestCase({ >+ name: "CSSProperty.NameCount", >+ description: "Ensure that the name counts are being tracked.", >+ async test() { >+ InspectorTest.expectGreaterThanOrEqual(WI.CSSProperty._cachedNameCounts["display"], 2, `"display" should have at least 2 counts.`); >+ InspectorTest.expectGreaterThanOrEqual(WI.CSSProperty._cachedNameCounts["background-repeat"], 1, `"background-repeat" should have at least 1 count.`); >+ InspectorTest.expectThat(!("background-repeat-x" in WI.CSSProperty._cachedNameCounts), `"background-repeat-x" should not be counted.`); >+ InspectorTest.expectThat(!("background-repeat-y" in WI.CSSProperty._cachedNameCounts), `"background-repeat-y" should not be counted.`); >+ InspectorTest.expectThat(!("background-repeat-invalid" in WI.CSSProperty._cachedNameCounts), `"background-repeat-invalid" should not be counted.`); >+ } >+ }); >+ > suite.addTestCase({ > name: "CSSProperty.prototype.get valid", > description: "Ensure valid, invalid, and internal-only have correct valid state.", >@@ -250,6 +262,8 @@ function test() { > > <style> > div#x { >+ display: initial; >+ display: initial; > background-repeat: repeat; > background-repeat-x: repeat; > background-repeat-invalid: repeat; >diff --git a/LayoutTests/inspector/unit-tests/array-utilities-expected.txt b/LayoutTests/inspector/unit-tests/array-utilities-expected.txt >index 0b24225a40de69bcf1fee272a75aefdc37d8a9b5..6ca8e5ec69f3fd5ed4916b1981cd56a31181c5cf 100644 >--- a/LayoutTests/inspector/unit-tests/array-utilities-expected.txt >+++ b/LayoutTests/inspector/unit-tests/array-utilities-expected.txt >@@ -1,5 +1,14 @@ > > == Running test suite: ArrayUtilities >+-- Running test case: Array.prototype.minIndex >+PASS: minIndex of an empty array should be 0. >+PASS: minIndex of an array with one item should be the index of the item. >+PASS: minIndex of an increasing array should be 0. >+PASS: minIndex of an decreasing array should be length - 1. >+PASS: minIndex of a mixed array should be the index of the smallest item. >+PASS: minIndex of an array with duplicates should be the index of the smallest item. >+PASS: minIndex with a comparator of a mixed array should be the index of the smallest item. >+ > -- Running test case: Array.prototype.lowerBound > PASS: lowerBound of a value before the first value should produce the first index. > PASS: lowerBound of a value in the list should return the value's index. >diff --git a/LayoutTests/inspector/unit-tests/array-utilities.html b/LayoutTests/inspector/unit-tests/array-utilities.html >index ca9c58f6de2e850b4a245d8372688eb4be4ee669..9527bc574d093301b004c917077e21dace09681e 100644 >--- a/LayoutTests/inspector/unit-tests/array-utilities.html >+++ b/LayoutTests/inspector/unit-tests/array-utilities.html >@@ -7,6 +7,24 @@ function test() > { > let suite = InspectorTest.createSyncSuite("ArrayUtilities"); > >+ suite.addTestCase({ >+ name: "Array.prototype.minIndex", >+ test() { >+ InspectorTest.expectEqual([].minIndex(), 0, "minIndex of an empty array should be 0."); >+ InspectorTest.expectEqual([1].minIndex(), 0, "minIndex of an array with one item should be the index of the item."); >+ InspectorTest.expectEqual([1, 2, 3, 4].minIndex(), 0, "minIndex of an increasing array should be 0."); >+ InspectorTest.expectEqual([4, 3, 2, 1].minIndex(), 3, "minIndex of an decreasing array should be length - 1."); >+ InspectorTest.expectEqual([3, 4, 1, 2].minIndex(), 2, "minIndex of a mixed array should be the index of the smallest item."); >+ InspectorTest.expectEqual([3, 1, 1, 3].minIndex(), 1, "minIndex of an array with duplicates should be the index of the smallest item."); >+ >+ let objs = [{value: 3}, {value: 4}, {value: 1}, {value: 2}]; >+ let comparator = (a, b) => a.value - b.value; >+ InspectorTest.expectEqual(objs.minIndex(comparator), 2, "minIndex with a comparator of a mixed array should be the index of the smallest item."); >+ >+ return true; >+ } >+ }); >+ > suite.addTestCase({ > name: "Array.prototype.lowerBound", > test() { >diff --git a/LayoutTests/inspector/unit-tests/objectStore/add-expected.txt b/LayoutTests/inspector/unit-tests/objectStore/add-expected.txt >deleted file mode 100644 >index 1426e0c43bd6289df622ee45bcd023abd0de3f63..0000000000000000000000000000000000000000 >--- a/LayoutTests/inspector/unit-tests/objectStore/add-expected.txt >+++ /dev/null >@@ -1,78 +0,0 @@ >-Tests WI.ObjectStore.prototype.add. >- >- >-== Running test suite: WI.ObjectStore.prototype.add >--- Running test case: WI.ObjectStore.prototype.add.NoParameters >-PASS: Should produce an exception. >-TypeError: Not enough arguments >-[] >- >--- Running test case: WI.ObjectStore.prototype.add.Boolean >-add: [false] >-add: [false,true] >-[false,true] >- >--- Running test case: WI.ObjectStore.prototype.add.Number >-add: [11] >-add: [11,22] >-[11,22] >- >--- Running test case: WI.ObjectStore.prototype.add.String >-add: ["foo"] >-add: ["foo","bar"] >-["foo","bar"] >- >--- Running test case: WI.ObjectStore.prototype.add.Array >-add: [[11]] >-add: [[11],[22]] >-[[11],[22]] >- >--- Running test case: WI.ObjectStore.prototype.add.Null >-add: [null] >-[null] >- >--- Running test case: WI.ObjectStore.prototype.add.Object.WithoutKeyPathOrAutoIncrement >-PASS: Should produce an exception. >-DataError: Failed to store record in an IDBObjectStore: The object store uses out-of-line keys and has no key generator and the key parameter was not provided. >-[] >- >--- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathMissingOnObjectWithoutAutoIncrement >-PASS: Should produce an exception. >-DataError: Failed to store record in an IDBObjectStore: Evaluating the object store's key path did not yield a value. >-[] >- >--- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithoutAutoIncrement >-add: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1}] >-add: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] >-[{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] >- >--- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathMissingOnObjectWithAutoIncrement >-add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1}] >-add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] >-[{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] >- >--- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithAutoIncrement >-add: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1}] >-add: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] >-[{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] >- >--- Running test case: WI.ObjectStore.prototype.add.Object.AutoIncrementWithoutKeyPath >-add: [{"a":1}] >-add: [{"a":1},{"b":2}] >-[{"a":1},{"b":2}] >- >--- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithoutAutoIncrement.Sub >-add: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1}] >-add: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] >-[{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] >- >--- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathMissingOnObjectWithAutoIncrement.Sub >-add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}}] >-add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] >-[{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] >- >--- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithAutoIncrement.Sub >-add: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1}] >-add: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] >-[{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] >- >diff --git a/LayoutTests/inspector/unit-tests/objectStore/add.html b/LayoutTests/inspector/unit-tests/objectStore/add.html >deleted file mode 100644 >index 7515f77d717041df9bcd2e2adfa8ef8733995305..0000000000000000000000000000000000000000 >--- a/LayoutTests/inspector/unit-tests/objectStore/add.html >+++ /dev/null >@@ -1,152 +0,0 @@ >-<!DOCTYPE html> >-<html> >-<head> >-<script src="../../../http/tests/inspector/resources/inspector-test.js"></script> >-<script src="resources/objectStore-utilities.js"></script> >-<script> >-function test() >-{ >- let suite = InspectorTest.ObjectStore.createSuite("WI.ObjectStore.prototype.add"); >- >- function testAdd(name, {options, tests}) { >- InspectorTest.ObjectStore.wrapTest(name, async function() { >- InspectorTest.ObjectStore.createObjectStore(options); >- >- for (let {value, expected} of tests) >- await InspectorTest.ObjectStore.add(value, expected); >- }); >- } >- >- InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.add.NoParameters", async function() { >- let objectStore = InspectorTest.ObjectStore.createObjectStore(); >- >- await InspectorTest.expectException(async function() { >- await objectStore.add(); >- await objectStore.add(InspectorTest.ObjectStore.basicObject2); >- }); >- }); >- >- testAdd("WI.ObjectStore.prototype.add.Boolean", { >- options: {autoIncrement: true}, >- tests: [ >- {value: false, expected: 1}, >- {value: true, expected: 2}, >- ], >- }); >- >- testAdd("WI.ObjectStore.prototype.add.Number", { >- options: {autoIncrement: true}, >- tests: [ >- {value: 11, expected: 1}, >- {value: 22, expected: 2}, >- ], >- }); >- >- testAdd("WI.ObjectStore.prototype.add.String", { >- options: {autoIncrement: true}, >- tests: [ >- {value: "foo", expected: 1}, >- {value: "bar", expected: 2}, >- ], >- }); >- >- testAdd("WI.ObjectStore.prototype.add.Array", { >- options: {autoIncrement: true}, >- tests: [ >- {value: [11], expected: 1}, >- {value: [22], expected: 2}, >- ], >- }); >- >- testAdd("WI.ObjectStore.prototype.add.Null", { >- options: {autoIncrement: true}, >- tests: [ >- {value: null, expected: 1}, >- ], >- }); >- >- InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.add.Object.WithoutKeyPathOrAutoIncrement", async function() { >- let objectStore = InspectorTest.ObjectStore.createObjectStore(); >- >- await InspectorTest.expectException(async function() { >- await objectStore.add(InspectorTest.ObjectStore.basicObject1); >- await objectStore.add(InspectorTest.ObjectStore.basicObject2); >- }); >- }); >- >- InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.add.Object.KeyPathMissingOnObjectWithoutAutoIncrement", async function() { >- const options = { >- keyPath: "KeyPathMissingOnObjectWithoutAutoIncrement", >- }; >- let objectStore = InspectorTest.ObjectStore.createObjectStore(options); >- >- await InspectorTest.expectException(async function() { >- await objectStore.add(InspectorTest.ObjectStore.basicObject1); >- await objectStore.add(InspectorTest.ObjectStore.basicObject2); >- }); >- }); >- >- testAdd("WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithoutAutoIncrement", { >- options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement"}, >- tests: [ >- {value: {KeyPathSetOnObjectWithoutAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >- {value: {KeyPathSetOnObjectWithoutAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >- ], >- }); >- >- testAdd("WI.ObjectStore.prototype.add.Object.KeyPathMissingOnObjectWithAutoIncrement", { >- options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement", autoIncrement: true}, >- tests: [ >- {value: InspectorTest.ObjectStore.basicObject1, expected: 1}, >- {value: InspectorTest.ObjectStore.basicObject2, expected: 2}, >- ], >- }); >- >- testAdd("WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithAutoIncrement", { >- options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement", autoIncrement: true}, >- tests: [ >- {value: {KeyPathSetOnObjectWithAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >- {value: {KeyPathSetOnObjectWithAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >- ], >- }); >- >- testAdd("WI.ObjectStore.prototype.add.Object.AutoIncrementWithoutKeyPath", { >- options: {autoIncrement: true}, >- tests: [ >- {value: InspectorTest.ObjectStore.basicObject1, expected: 1}, >- {value: InspectorTest.ObjectStore.basicObject2, expected: 2}, >- ], >- }); >- >- testAdd("WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithoutAutoIncrement.Sub", { >- options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement.Sub"}, >- tests: [ >- {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >- {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >- ], >- }); >- >- testAdd("WI.ObjectStore.prototype.add.Object.KeyPathMissingOnObjectWithAutoIncrement.Sub", { >- options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement.Sub", autoIncrement: true}, >- tests: [ >- {value: InspectorTest.ObjectStore.basicObject1, expected: 1}, >- {value: InspectorTest.ObjectStore.basicObject2, expected: 2}, >- ], >- }); >- >- testAdd("WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithAutoIncrement.Sub", { >- options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement.Sub", autoIncrement: true}, >- tests: [ >- {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >- {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >- ], >- }); >- >- suite.runTestCasesAndFinish(); >-} >-</script> >-</head> >-<body onload="runTest()"> >- <p>Tests WI.ObjectStore.prototype.add.</p> >-</body> >-</html> >diff --git a/LayoutTests/inspector/unit-tests/objectStore/addObject-expected.txt b/LayoutTests/inspector/unit-tests/objectStore/addObject-expected.txt >deleted file mode 100644 >index f7fce7652ab216ab68424183b815c898cce83d5f..0000000000000000000000000000000000000000 >--- a/LayoutTests/inspector/unit-tests/objectStore/addObject-expected.txt >+++ /dev/null >@@ -1,54 +0,0 @@ >-Tests WI.ObjectStore.prototype.addObject. >- >- >-== Running test suite: WI.ObjectStore.prototype.addObject >--- Running test case: WI.ObjectStore.prototype.addObject.NoParameters >-PASS: Should produce an exception. >-TypeError: undefined is not an object (evaluating 'object.toJSON') >-[] >- >--- Running test case: WI.ObjectStore.prototype.addObject.WithoutKeyPathOrAutoIncrement >-PASS: Should produce an exception. >-DataError: Failed to store record in an IDBObjectStore: The object store uses out-of-line keys and has no key generator and the key parameter was not provided. >-[] >- >--- Running test case: WI.ObjectStore.prototype.addObject.KeyPathMissingOnObjectWithoutAutoIncrement >-PASS: Should produce an exception. >-DataError: Failed to store record in an IDBObjectStore: Evaluating the object store's key path did not yield a value. >-[] >- >--- Running test case: WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithoutAutoIncrement >-addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1}] >-addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] >-[{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] >- >--- Running test case: WI.ObjectStore.prototype.addObject.KeyPathMissingOnObjectWithAutoIncrement >-addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1}] >-addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] >-[{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] >- >--- Running test case: WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithAutoIncrement >-addObject: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1}] >-addObject: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] >-[{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] >- >--- Running test case: WI.ObjectStore.prototype.addObject.AutoIncrementWithoutKeyPath >-addObject: [{"a":1}] >-addObject: [{"a":1},{"b":2}] >-[{"a":1},{"b":2}] >- >--- Running test case: WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithoutAutoIncrement.Sub >-addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1}] >-addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] >-[{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] >- >--- Running test case: WI.ObjectStore.prototype.addObject.KeyPathMissingOnObjectWithAutoIncrement.Sub >-addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}}] >-addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] >-[{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] >- >--- Running test case: WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithAutoIncrement.Sub >-addObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1}] >-addObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] >-[{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] >- >diff --git a/LayoutTests/inspector/unit-tests/objectStore/addObject.html b/LayoutTests/inspector/unit-tests/objectStore/addObject.html >deleted file mode 100644 >index 03523fb5f821a63ea7800073c7511b8d42ba85de..0000000000000000000000000000000000000000 >--- a/LayoutTests/inspector/unit-tests/objectStore/addObject.html >+++ /dev/null >@@ -1,113 +0,0 @@ >-<!DOCTYPE html> >-<html> >-<head> >-<script src="../../../http/tests/inspector/resources/inspector-test.js"></script> >-<script src="resources/objectStore-utilities.js"></script> >-<script> >-function test() >-{ >- let suite = InspectorTest.ObjectStore.createSuite("WI.ObjectStore.prototype.addObject"); >- >- function testAddObject(name, {options, tests}) { >- InspectorTest.ObjectStore.wrapTest(name, async function() { >- InspectorTest.ObjectStore.createObjectStore(options); >- >- for (let {value, expected} of tests) >- await InspectorTest.ObjectStore.addObject(new InspectorTest.ObjectStore.TestObject(value), expected); >- }); >- } >- >- InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.addObject.NoParameters", async function() { >- let objectStore = InspectorTest.ObjectStore.createObjectStore(); >- >- await InspectorTest.expectException(async function() { >- await objectStore.addObject(); >- await objectStore.addObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2)); >- }); >- }); >- >- InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.addObject.WithoutKeyPathOrAutoIncrement", async function() { >- let objectStore = InspectorTest.ObjectStore.createObjectStore(); >- >- await InspectorTest.expectException(async function() { >- await objectStore.addObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject1)); >- await objectStore.addObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2)); >- }); >- }); >- >- InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.addObject.KeyPathMissingOnObjectWithoutAutoIncrement", async function() { >- const options = { >- keyPath: "KeyPathMissingOnObjectWithoutAutoIncrement", >- }; >- let objectStore = InspectorTest.ObjectStore.createObjectStore(options); >- >- await InspectorTest.expectException(async function() { >- await objectStore.addObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject1)); >- await objectStore.addObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2)); >- }); >- }); >- >- testAddObject("WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithoutAutoIncrement", { >- options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement"}, >- tests: [ >- {value: {KeyPathSetOnObjectWithoutAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >- {value: {KeyPathSetOnObjectWithoutAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >- ], >- }); >- >- testAddObject("WI.ObjectStore.prototype.addObject.KeyPathMissingOnObjectWithAutoIncrement", { >- options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement", autoIncrement: true}, >- tests: [ >- {value: InspectorTest.ObjectStore.basicObject1, expected: 1}, >- {value: InspectorTest.ObjectStore.basicObject2, expected: 2}, >- ], >- }); >- >- testAddObject("WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithAutoIncrement", { >- options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement", autoIncrement: true}, >- tests: [ >- {value: {KeyPathSetOnObjectWithAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >- {value: {KeyPathSetOnObjectWithAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >- ], >- }); >- >- testAddObject("WI.ObjectStore.prototype.addObject.AutoIncrementWithoutKeyPath", { >- options: {autoIncrement: true}, >- tests: [ >- {value: InspectorTest.ObjectStore.basicObject1, expected: 1}, >- {value: InspectorTest.ObjectStore.basicObject2, expected: 2}, >- ], >- }); >- >- testAddObject("WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithoutAutoIncrement.Sub", { >- options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement.Sub"}, >- tests: [ >- {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >- {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >- ], >- }); >- >- testAddObject("WI.ObjectStore.prototype.addObject.KeyPathMissingOnObjectWithAutoIncrement.Sub", { >- options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement.Sub", autoIncrement: true}, >- tests: [ >- {value: InspectorTest.ObjectStore.basicObject1, expected: 1}, >- {value: InspectorTest.ObjectStore.basicObject2, expected: 2}, >- ], >- }); >- >- testAddObject("WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithAutoIncrement.Sub", { >- options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement.Sub", autoIncrement: true}, >- tests: [ >- {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >- {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >- ], >- }); >- >- suite.runTestCasesAndFinish(); >-} >-</script> >-</head> >-<body onload="runTest()"> >- <p>Tests WI.ObjectStore.prototype.addObject.</p> >-</body> >-</html> >diff --git a/LayoutTests/inspector/unit-tests/objectStore/delete-expected.txt b/LayoutTests/inspector/unit-tests/objectStore/delete-expected.txt >index 4483e5ce5606a3284f62692c7c2bb786963b1693..94e8f06589461181aab025eb30764fa13d7558a4 100644 >--- a/LayoutTests/inspector/unit-tests/objectStore/delete-expected.txt >+++ b/LayoutTests/inspector/unit-tests/objectStore/delete-expected.txt >@@ -3,47 +3,47 @@ Tests WI.ObjectStore.prototype.delete. > > == Running test suite: WI.ObjectStore.prototype.delete > -- Running test case: WI.ObjectStore.prototype.delete.NoParameters >-add: [{"b":2}] >+put: [{"b":2}] > PASS: Should produce an exception. > TypeError: Not enough arguments > [{"b":2}] > > -- Running test case: WI.ObjectStore.prototype.delete.MissingObject >-add: [{"b":2}] >+put: [{"b":2}] > PASS: Should produce an exception. > DataError: Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key. > [{"b":2}] > > -- Running test case: WI.ObjectStore.prototype.delete.Boolean >-add: [false] >-add: [false,true] >+put: [false] >+put: [false,true] > delete: [true] > delete: [] > [] > > -- Running test case: WI.ObjectStore.prototype.delete.Number >-add: [11] >-add: [11,22] >+put: [11] >+put: [11,22] > delete: [22] > delete: [] > [] > > -- Running test case: WI.ObjectStore.prototype.delete.String >-add: ["foo"] >-add: ["foo","bar"] >+put: ["foo"] >+put: ["foo","bar"] > delete: ["bar"] > delete: [] > [] > > -- Running test case: WI.ObjectStore.prototype.delete.Array >-add: [[11]] >-add: [[11],[22]] >+put: [[11]] >+put: [[11],[22]] > delete: [[22]] > delete: [] > [] > > -- Running test case: WI.ObjectStore.prototype.delete.Null >-add: [null] >+put: [null] > delete: [] > [] > >@@ -58,50 +58,50 @@ DataError: Failed to store record in an IDBObjectStore: Evaluating the object st > [] > > -- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathSetOnObjectWithoutAutoIncrement >-add: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1}] >-add: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] >+put: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1}] >+put: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] > delete: [{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] > delete: [] > [] > > -- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathMissingOnObjectWithAutoIncrement >-add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1}] >-add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] >+put: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1}] >+put: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] > delete: [{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] > delete: [] > [] > > -- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathSetOnObjectWithAutoIncrement >-add: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1}] >-add: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] >+put: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1}] >+put: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] > delete: [{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] > delete: [] > [] > > -- Running test case: WI.ObjectStore.prototype.delete.Object.AutoIncrementWithoutKeyPath >-add: [{"a":1}] >-add: [{"a":1},{"b":2}] >+put: [{"a":1}] >+put: [{"a":1},{"b":2}] > delete: [{"b":2}] > delete: [] > [] > > -- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathSetOnObjectWithoutAutoIncrement.Sub >-add: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1}] >-add: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] >+put: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1}] >+put: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] > delete: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] > delete: [] > [] > > -- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathMissingOnObjectWithAutoIncrement.Sub >-add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}}] >-add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] >+put: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}}] >+put: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] > delete: [{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] > delete: [] > [] > > -- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathSetOnObjectWithAutoIncrement.Sub >-add: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1}] >-add: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] >+put: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1}] >+put: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] > delete: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] > delete: [] > [] >diff --git a/LayoutTests/inspector/unit-tests/objectStore/delete.html b/LayoutTests/inspector/unit-tests/objectStore/delete.html >index 5d59691a72defc37a09efdbfd6e0817fdaf1dd3f..e62ac164b385ccab67ab457d75f505ef3a6d53ca 100644 >--- a/LayoutTests/inspector/unit-tests/objectStore/delete.html >+++ b/LayoutTests/inspector/unit-tests/objectStore/delete.html >@@ -14,7 +14,7 @@ function test() > > let keys = []; > for (let {value, expected} of tests) >- keys.push(await InspectorTest.ObjectStore.add(value, expected)); >+ keys.push(await InspectorTest.ObjectStore.put(value, expected)); > > for (let key of keys) > await InspectorTest.ObjectStore.delete(key); >@@ -29,7 +29,7 @@ function test() > > try { > // This call may fail on WK1 >- await InspectorTest.ObjectStore.add(InspectorTest.ObjectStore.basicObject2, 1); >+ await InspectorTest.ObjectStore.put(InspectorTest.ObjectStore.basicObject2, 1); > } catch { } > > await InspectorTest.expectException(async () => { >@@ -44,7 +44,7 @@ function test() > }; > let objectStore = InspectorTest.ObjectStore.createObjectStore(options); > >- await InspectorTest.ObjectStore.add(InspectorTest.ObjectStore.basicObject2, 1); >+ await InspectorTest.ObjectStore.put(InspectorTest.ObjectStore.basicObject2, 1); > > await InspectorTest.expectException(async () => { > await objectStore.delete(InspectorTest.ObjectStore.basicObject1); >@@ -95,8 +95,8 @@ function test() > let objectStore = InspectorTest.ObjectStore.createObjectStore(); > > await InspectorTest.expectException(async function() { >- await objectStore.add(InspectorTest.ObjectStore.basicObject1); >- await objectStore.add(InspectorTest.ObjectStore.basicObject2); >+ await objectStore.put(InspectorTest.ObjectStore.basicObject1); >+ await objectStore.put(InspectorTest.ObjectStore.basicObject2); > }); > }); > >@@ -107,8 +107,8 @@ function test() > let objectStore = InspectorTest.ObjectStore.createObjectStore(options); > > await InspectorTest.expectException(async function() { >- await objectStore.add(InspectorTest.ObjectStore.basicObject1); >- await objectStore.add(InspectorTest.ObjectStore.basicObject2); >+ await objectStore.put(InspectorTest.ObjectStore.basicObject1); >+ await objectStore.put(InspectorTest.ObjectStore.basicObject2); > }); > }); > >diff --git a/LayoutTests/inspector/unit-tests/objectStore/deleteObject-expected.txt b/LayoutTests/inspector/unit-tests/objectStore/deleteObject-expected.txt >index d9d9ad9629c76ada0f0060df70e223e62f067a1f..586fd05ce115e583c3e86fa0c888cbe755119e35 100644 >--- a/LayoutTests/inspector/unit-tests/objectStore/deleteObject-expected.txt >+++ b/LayoutTests/inspector/unit-tests/objectStore/deleteObject-expected.txt >@@ -3,13 +3,13 @@ Tests WI.ObjectStore.prototype.deleteObject. > > == Running test suite: WI.ObjectStore.prototype.deleteObject > -- Running test case: WI.ObjectStore.prototype.deleteObject.NoParameters >-add: [{"_object":{"b":2}}] >+put: [{"_object":{"b":2}}] > PASS: Should produce an exception. > TypeError: undefined is not an object (evaluating 'object[key]') > [{"_object":{"b":2}}] > > -- Running test case: WI.ObjectStore.prototype.deleteObject.MissingObject >-add: [{"_object":{"b":2}}] >+put: [{"_object":{"b":2}}] > PASS: Should produce an exception. > DataError: Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key range. > [{"_object":{"b":2}}] >@@ -30,50 +30,50 @@ DataError: Failed to store record in an IDBObjectStore: Evaluating the object st > [] > > -- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathSetOnObjectWithoutAutoIncrement >-addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1}] >-addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] >+putObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1}] >+putObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] > deleteObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] > deleteObject: [] > [] > > -- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathMissingOnObjectWithAutoIncrement >-addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1}] >-addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] >+putObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1}] >+putObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] > deleteObject: [{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] > deleteObject: [] > [] > > -- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathSetOnObjectWithAutoIncrement >-addObject: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1}] >-addObject: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] >+putObject: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1}] >+putObject: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] > deleteObject: [{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] > deleteObject: [] > [] > > -- Running test case: WI.ObjectStore.prototype.deleteObject.AutoIncrementWithoutKeyPath >-addObject: [{"a":1}] >-addObject: [{"a":1},{"b":2}] >+putObject: [{"a":1}] >+putObject: [{"a":1},{"b":2}] > deleteObject: [{"b":2}] > deleteObject: [] > [] > > -- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathSetOnObjectWithoutAutoIncrement.Sub >-addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1}] >-addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] >+putObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1}] >+putObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] > deleteObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] > deleteObject: [] > [] > > -- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathMissingOnObjectWithAutoIncrement.Sub >-addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}}] >-addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] >+putObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}}] >+putObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] > deleteObject: [{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] > deleteObject: [] > [] > > -- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathSetOnObjectWithAutoIncrement.Sub >-addObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1}] >-addObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] >+putObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1}] >+putObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] > deleteObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] > deleteObject: [] > [] >diff --git a/LayoutTests/inspector/unit-tests/objectStore/deleteObject.html b/LayoutTests/inspector/unit-tests/objectStore/deleteObject.html >index 8235bb225435b62bb5f114fa0f39c618df83d7f0..d9707fea5591932fed3009ab40f67c83f9dbe51b 100644 >--- a/LayoutTests/inspector/unit-tests/objectStore/deleteObject.html >+++ b/LayoutTests/inspector/unit-tests/objectStore/deleteObject.html >@@ -15,7 +15,7 @@ function test() > let objects = [] > for (let {value, expected} of tests) { > let object = new InspectorTest.ObjectStore.TestObject(value); >- await InspectorTest.ObjectStore.addObject(object, expected); >+ await InspectorTest.ObjectStore.putObject(object, expected); > objects.push(object); > } > >@@ -34,7 +34,7 @@ function test() > > try { > // This call may fail on WK1 >- await InspectorTest.ObjectStore.add(object, 1); >+ await InspectorTest.ObjectStore.put(object, 1); > } catch { } > > await InspectorTest.expectException(async () => { >@@ -49,7 +49,7 @@ function test() > }; > let objectStore = InspectorTest.ObjectStore.createObjectStore(options); > >- await InspectorTest.ObjectStore.add(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2), 1); >+ await InspectorTest.ObjectStore.put(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2), 1); > > await InspectorTest.expectException(async () => { > await objectStore.deleteObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject1)); >@@ -73,8 +73,8 @@ function test() > let objectStore = InspectorTest.ObjectStore.createObjectStore(); > > await InspectorTest.expectException(async function() { >- await objectStore.add(InspectorTest.ObjectStore.basicObject1); >- await objectStore.add(InspectorTest.ObjectStore.basicObject2); >+ await objectStore.put(InspectorTest.ObjectStore.basicObject1); >+ await objectStore.put(InspectorTest.ObjectStore.basicObject2); > }); > }); > >@@ -85,8 +85,8 @@ function test() > let objectStore = InspectorTest.ObjectStore.createObjectStore(options); > > await InspectorTest.expectException(async function() { >- await objectStore.add(InspectorTest.ObjectStore.basicObject1); >- await objectStore.add(InspectorTest.ObjectStore.basicObject2); >+ await objectStore.put(InspectorTest.ObjectStore.basicObject1); >+ await objectStore.put(InspectorTest.ObjectStore.basicObject2); > }); > }); > >diff --git a/LayoutTests/inspector/unit-tests/objectStore/put-expected.txt b/LayoutTests/inspector/unit-tests/objectStore/put-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..b348d90319871bfc8041eaefbfc6e68dcdfab69e >--- /dev/null >+++ b/LayoutTests/inspector/unit-tests/objectStore/put-expected.txt >@@ -0,0 +1,78 @@ >+Tests WI.ObjectStore.prototype.put. >+ >+ >+== Running test suite: WI.ObjectStore.prototype.put >+-- Running test case: WI.ObjectStore.prototype.put.NoParameters >+PASS: Should produce an exception. >+TypeError: Not enough arguments >+[] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Boolean >+put: [false] >+put: [false,true] >+[false,true] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Number >+put: [11] >+put: [11,22] >+[11,22] >+ >+-- Running test case: WI.ObjectStore.prototype.put.String >+put: ["foo"] >+put: ["foo","bar"] >+["foo","bar"] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Array >+put: [[11]] >+put: [[11],[22]] >+[[11],[22]] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Null >+put: [null] >+[null] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Object.WithoutKeyPathOrAutoIncrement >+PASS: Should produce an exception. >+DataError: Failed to store record in an IDBObjectStore: The object store uses out-of-line keys and has no key generator and the key parameter was not provided. >+[] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Object.KeyPathMissingOnObjectWithoutAutoIncrement >+PASS: Should produce an exception. >+DataError: Failed to store record in an IDBObjectStore: Evaluating the object store's key path did not yield a value. >+[] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Object.KeyPathSetOnObjectWithoutAutoIncrement >+put: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1}] >+put: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] >+[{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Object.KeyPathMissingOnObjectWithAutoIncrement >+put: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1}] >+put: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] >+[{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Object.KeyPathSetOnObjectWithAutoIncrement >+put: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1}] >+put: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] >+[{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Object.AutoIncrementWithoutKeyPath >+put: [{"a":1}] >+put: [{"a":1},{"b":2}] >+[{"a":1},{"b":2}] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Object.KeyPathSetOnObjectWithoutAutoIncrement.Sub >+put: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1}] >+put: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] >+[{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Object.KeyPathMissingOnObjectWithAutoIncrement.Sub >+put: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}}] >+put: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] >+[{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] >+ >+-- Running test case: WI.ObjectStore.prototype.put.Object.KeyPathSetOnObjectWithAutoIncrement.Sub >+put: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1}] >+put: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] >+[{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] >+ >diff --git a/LayoutTests/inspector/unit-tests/objectStore/put.html b/LayoutTests/inspector/unit-tests/objectStore/put.html >new file mode 100644 >index 0000000000000000000000000000000000000000..701e692c2eee8fe80feb65f40a129a7baba0a171 >--- /dev/null >+++ b/LayoutTests/inspector/unit-tests/objectStore/put.html >@@ -0,0 +1,152 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../http/tests/inspector/resources/inspector-test.js"></script> >+<script src="resources/objectStore-utilities.js"></script> >+<script> >+function test() >+{ >+ let suite = InspectorTest.ObjectStore.createSuite("WI.ObjectStore.prototype.put"); >+ >+ function testPut(name, {options, tests}) { >+ InspectorTest.ObjectStore.wrapTest(name, async function() { >+ InspectorTest.ObjectStore.createObjectStore(options); >+ >+ for (let {value, expected} of tests) >+ await InspectorTest.ObjectStore.put(value, expected); >+ }); >+ } >+ >+ InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.put.NoParameters", async function() { >+ let objectStore = InspectorTest.ObjectStore.createObjectStore(); >+ >+ await InspectorTest.expectException(async function() { >+ await objectStore.put(); >+ await objectStore.put(InspectorTest.ObjectStore.basicObject2); >+ }); >+ }); >+ >+ testPut("WI.ObjectStore.prototype.put.Boolean", { >+ options: {autoIncrement: true}, >+ tests: [ >+ {value: false, expected: 1}, >+ {value: true, expected: 2}, >+ ], >+ }); >+ >+ testPut("WI.ObjectStore.prototype.put.Number", { >+ options: {autoIncrement: true}, >+ tests: [ >+ {value: 11, expected: 1}, >+ {value: 22, expected: 2}, >+ ], >+ }); >+ >+ testPut("WI.ObjectStore.prototype.put.String", { >+ options: {autoIncrement: true}, >+ tests: [ >+ {value: "foo", expected: 1}, >+ {value: "bar", expected: 2}, >+ ], >+ }); >+ >+ testPut("WI.ObjectStore.prototype.put.Array", { >+ options: {autoIncrement: true}, >+ tests: [ >+ {value: [11], expected: 1}, >+ {value: [22], expected: 2}, >+ ], >+ }); >+ >+ testPut("WI.ObjectStore.prototype.put.Null", { >+ options: {autoIncrement: true}, >+ tests: [ >+ {value: null, expected: 1}, >+ ], >+ }); >+ >+ InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.put.Object.WithoutKeyPathOrAutoIncrement", async function() { >+ let objectStore = InspectorTest.ObjectStore.createObjectStore(); >+ >+ await InspectorTest.expectException(async function() { >+ await objectStore.put(InspectorTest.ObjectStore.basicObject1); >+ await objectStore.put(InspectorTest.ObjectStore.basicObject2); >+ }); >+ }); >+ >+ InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.put.Object.KeyPathMissingOnObjectWithoutAutoIncrement", async function() { >+ const options = { >+ keyPath: "KeyPathMissingOnObjectWithoutAutoIncrement", >+ }; >+ let objectStore = InspectorTest.ObjectStore.createObjectStore(options); >+ >+ await InspectorTest.expectException(async function() { >+ await objectStore.put(InspectorTest.ObjectStore.basicObject1); >+ await objectStore.put(InspectorTest.ObjectStore.basicObject2); >+ }); >+ }); >+ >+ testPut("WI.ObjectStore.prototype.put.Object.KeyPathSetOnObjectWithoutAutoIncrement", { >+ options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement"}, >+ tests: [ >+ {value: {KeyPathSetOnObjectWithoutAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >+ {value: {KeyPathSetOnObjectWithoutAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >+ ], >+ }); >+ >+ testPut("WI.ObjectStore.prototype.put.Object.KeyPathMissingOnObjectWithAutoIncrement", { >+ options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement", autoIncrement: true}, >+ tests: [ >+ {value: InspectorTest.ObjectStore.basicObject1, expected: 1}, >+ {value: InspectorTest.ObjectStore.basicObject2, expected: 2}, >+ ], >+ }); >+ >+ testPut("WI.ObjectStore.prototype.put.Object.KeyPathSetOnObjectWithAutoIncrement", { >+ options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement", autoIncrement: true}, >+ tests: [ >+ {value: {KeyPathSetOnObjectWithAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >+ {value: {KeyPathSetOnObjectWithAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >+ ], >+ }); >+ >+ testPut("WI.ObjectStore.prototype.put.Object.AutoIncrementWithoutKeyPath", { >+ options: {autoIncrement: true}, >+ tests: [ >+ {value: InspectorTest.ObjectStore.basicObject1, expected: 1}, >+ {value: InspectorTest.ObjectStore.basicObject2, expected: 2}, >+ ], >+ }); >+ >+ testPut("WI.ObjectStore.prototype.put.Object.KeyPathSetOnObjectWithoutAutoIncrement.Sub", { >+ options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement.Sub"}, >+ tests: [ >+ {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >+ {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >+ ], >+ }); >+ >+ testPut("WI.ObjectStore.prototype.put.Object.KeyPathMissingOnObjectWithAutoIncrement.Sub", { >+ options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement.Sub", autoIncrement: true}, >+ tests: [ >+ {value: InspectorTest.ObjectStore.basicObject1, expected: 1}, >+ {value: InspectorTest.ObjectStore.basicObject2, expected: 2}, >+ ], >+ }); >+ >+ testPut("WI.ObjectStore.prototype.put.Object.KeyPathSetOnObjectWithAutoIncrement.Sub", { >+ options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement.Sub", autoIncrement: true}, >+ tests: [ >+ {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >+ {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >+ ], >+ }); >+ >+ suite.runTestCasesAndFinish(); >+} >+</script> >+</head> >+<body onload="runTest()"> >+ <p>Tests WI.ObjectStore.prototype.put.</p> >+</body> >+</html> >diff --git a/LayoutTests/inspector/unit-tests/objectStore/putObject-expected.txt b/LayoutTests/inspector/unit-tests/objectStore/putObject-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..517404a66feb1b8c3e203642bd7ccdacea75e640 >--- /dev/null >+++ b/LayoutTests/inspector/unit-tests/objectStore/putObject-expected.txt >@@ -0,0 +1,54 @@ >+Tests WI.ObjectStore.prototype.putObject. >+ >+ >+== Running test suite: WI.ObjectStore.prototype.putObject >+-- Running test case: WI.ObjectStore.prototype.putObject.NoParameters >+PASS: Should produce an exception. >+TypeError: undefined is not an object (evaluating 'object.toJSON') >+[] >+ >+-- Running test case: WI.ObjectStore.prototype.putObject.WithoutKeyPathOrAutoIncrement >+PASS: Should produce an exception. >+DataError: Failed to store record in an IDBObjectStore: The object store uses out-of-line keys and has no key generator and the key parameter was not provided. >+[] >+ >+-- Running test case: WI.ObjectStore.prototype.putObject.KeyPathMissingOnObjectWithoutAutoIncrement >+PASS: Should produce an exception. >+DataError: Failed to store record in an IDBObjectStore: Evaluating the object store's key path did not yield a value. >+[] >+ >+-- Running test case: WI.ObjectStore.prototype.putObject.KeyPathSetOnObjectWithoutAutoIncrement >+putObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1}] >+putObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] >+[{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}] >+ >+-- Running test case: WI.ObjectStore.prototype.putObject.KeyPathMissingOnObjectWithAutoIncrement >+putObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1}] >+putObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] >+[{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}] >+ >+-- Running test case: WI.ObjectStore.prototype.putObject.KeyPathSetOnObjectWithAutoIncrement >+putObject: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1}] >+putObject: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] >+[{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}] >+ >+-- Running test case: WI.ObjectStore.prototype.putObject.AutoIncrementWithoutKeyPath >+putObject: [{"a":1}] >+putObject: [{"a":1},{"b":2}] >+[{"a":1},{"b":2}] >+ >+-- Running test case: WI.ObjectStore.prototype.putObject.KeyPathSetOnObjectWithoutAutoIncrement.Sub >+putObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1}] >+putObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] >+[{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}] >+ >+-- Running test case: WI.ObjectStore.prototype.putObject.KeyPathMissingOnObjectWithAutoIncrement.Sub >+putObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}}] >+putObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] >+[{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}] >+ >+-- Running test case: WI.ObjectStore.prototype.putObject.KeyPathSetOnObjectWithAutoIncrement.Sub >+putObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1}] >+putObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] >+[{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}] >+ >diff --git a/LayoutTests/inspector/unit-tests/objectStore/putObject.html b/LayoutTests/inspector/unit-tests/objectStore/putObject.html >new file mode 100644 >index 0000000000000000000000000000000000000000..683b1d5f7ad062344a54d278b74fbd741f16c02d >--- /dev/null >+++ b/LayoutTests/inspector/unit-tests/objectStore/putObject.html >@@ -0,0 +1,113 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../http/tests/inspector/resources/inspector-test.js"></script> >+<script src="resources/objectStore-utilities.js"></script> >+<script> >+function test() >+{ >+ let suite = InspectorTest.ObjectStore.createSuite("WI.ObjectStore.prototype.putObject"); >+ >+ function testPutObject(name, {options, tests}) { >+ InspectorTest.ObjectStore.wrapTest(name, async function() { >+ InspectorTest.ObjectStore.createObjectStore(options); >+ >+ for (let {value, expected} of tests) >+ await InspectorTest.ObjectStore.putObject(new InspectorTest.ObjectStore.TestObject(value), expected); >+ }); >+ } >+ >+ InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.putObject.NoParameters", async function() { >+ let objectStore = InspectorTest.ObjectStore.createObjectStore(); >+ >+ await InspectorTest.expectException(async function() { >+ await objectStore.putObject(); >+ await objectStore.putObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2)); >+ }); >+ }); >+ >+ InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.putObject.WithoutKeyPathOrAutoIncrement", async function() { >+ let objectStore = InspectorTest.ObjectStore.createObjectStore(); >+ >+ await InspectorTest.expectException(async function() { >+ await objectStore.putObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject1)); >+ await objectStore.putObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2)); >+ }); >+ }); >+ >+ InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.putObject.KeyPathMissingOnObjectWithoutAutoIncrement", async function() { >+ const options = { >+ keyPath: "KeyPathMissingOnObjectWithoutAutoIncrement", >+ }; >+ let objectStore = InspectorTest.ObjectStore.createObjectStore(options); >+ >+ await InspectorTest.expectException(async function() { >+ await objectStore.putObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject1)); >+ await objectStore.putObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2)); >+ }); >+ }); >+ >+ testPutObject("WI.ObjectStore.prototype.putObject.KeyPathSetOnObjectWithoutAutoIncrement", { >+ options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement"}, >+ tests: [ >+ {value: {KeyPathSetOnObjectWithoutAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >+ {value: {KeyPathSetOnObjectWithoutAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >+ ], >+ }); >+ >+ testPutObject("WI.ObjectStore.prototype.putObject.KeyPathMissingOnObjectWithAutoIncrement", { >+ options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement", autoIncrement: true}, >+ tests: [ >+ {value: InspectorTest.ObjectStore.basicObject1, expected: 1}, >+ {value: InspectorTest.ObjectStore.basicObject2, expected: 2}, >+ ], >+ }); >+ >+ testPutObject("WI.ObjectStore.prototype.putObject.KeyPathSetOnObjectWithAutoIncrement", { >+ options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement", autoIncrement: true}, >+ tests: [ >+ {value: {KeyPathSetOnObjectWithAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >+ {value: {KeyPathSetOnObjectWithAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >+ ], >+ }); >+ >+ testPutObject("WI.ObjectStore.prototype.putObject.AutoIncrementWithoutKeyPath", { >+ options: {autoIncrement: true}, >+ tests: [ >+ {value: InspectorTest.ObjectStore.basicObject1, expected: 1}, >+ {value: InspectorTest.ObjectStore.basicObject2, expected: 2}, >+ ], >+ }); >+ >+ testPutObject("WI.ObjectStore.prototype.putObject.KeyPathSetOnObjectWithoutAutoIncrement.Sub", { >+ options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement.Sub"}, >+ tests: [ >+ {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >+ {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >+ ], >+ }); >+ >+ testPutObject("WI.ObjectStore.prototype.putObject.KeyPathMissingOnObjectWithAutoIncrement.Sub", { >+ options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement.Sub", autoIncrement: true}, >+ tests: [ >+ {value: InspectorTest.ObjectStore.basicObject1, expected: 1}, >+ {value: InspectorTest.ObjectStore.basicObject2, expected: 2}, >+ ], >+ }); >+ >+ testPutObject("WI.ObjectStore.prototype.putObject.KeyPathSetOnObjectWithAutoIncrement.Sub", { >+ options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement.Sub", autoIncrement: true}, >+ tests: [ >+ {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42}, >+ {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99}, >+ ], >+ }); >+ >+ suite.runTestCasesAndFinish(); >+} >+</script> >+</head> >+<body onload="runTest()"> >+ <p>Tests WI.ObjectStore.prototype.putObject.</p> >+</body> >+</html> >diff --git a/LayoutTests/inspector/unit-tests/objectStore/resources/objectStore-utilities.js b/LayoutTests/inspector/unit-tests/objectStore/resources/objectStore-utilities.js >index adb4f6b9b82ccdec33e1dd25eb108e5726f02702..69c21630d16395b6f83225e7aa43534c3edea53d 100644 >--- a/LayoutTests/inspector/unit-tests/objectStore/resources/objectStore-utilities.js >+++ b/LayoutTests/inspector/unit-tests/objectStore/resources/objectStore-utilities.js >@@ -25,22 +25,22 @@ TestPage.registerInitializer(() => { > return WI.ObjectStore.__testObjectStore; > }; > >- InspectorTest.ObjectStore.add = async function(value, expected) { >- let result = await WI.ObjectStore.__testObjectStore.add(value); >+ InspectorTest.ObjectStore.put = async function(value, expected) { >+ let result = await WI.ObjectStore.__testObjectStore.put(value); > InspectorTest.assert(result === expected, `the key of the added item should be ${expected}, but is actually ${result}`); > >- await InspectorTest.ObjectStore.logValues("add: "); >+ await InspectorTest.ObjectStore.logValues("put: "); > return result; > }; > >- InspectorTest.ObjectStore.addObject = async function(object, expected) { >- let result = await WI.ObjectStore.__testObjectStore.addObject(object); >+ InspectorTest.ObjectStore.putObject = async function(object, expected) { >+ let result = await WI.ObjectStore.__testObjectStore.putObject(object); > InspectorTest.assert(result === expected, `the key of the added item should be ${expected}, but is actually ${result}`); > > let resolved = WI.ObjectStore.__testObjectStore._resolveKeyPath(object); > InspectorTest.assert(resolved.value === expected, `the resolved keyPath on the object should equal ${expected}, but is actually ${resolved.value}`); > >- await InspectorTest.ObjectStore.logValues("addObject: "); >+ await InspectorTest.ObjectStore.logValues("putObject: "); > return result; > }; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
hi
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 156271
:
351706
|
352014
|
352469
|
353610
|
353746
|
353903
|
353912
|
355544
|
356633
|
356646
|
356648
|
356652
|
356657
|
357495