Source/WebInspectorUI/ChangeLog

 12018-10-31 Devin Rousso <drousso@apple.com>
 2
 3 Web Inspector: Audit: save imported audits across WebInspector sessions
 4 https://bugs.webkit.org/show_bug.cgi?id=190858
 5 <rdar://problem/45527625>
 6
 7 Reviewed by Brian Burg.
 8
 9 * UserInterface/Base/ObjectStore.js: Added.
 10 (WI.ObjectStore):
 11 (WI.ObjectStore.supported):
 12 (WI.ObjectStore._open):
 13 (WI.ObjectStore.get _databaseName):
 14 (WI.ObjectStore.prototype.associateObject):
 15 (WI.ObjectStore.prototype.async getAll):
 16 (WI.ObjectStore.prototype.async add):
 17 (WI.ObjectStore.prototype.async addObject):
 18 (WI.ObjectStore.prototype.async delete):
 19 (WI.ObjectStore.prototype.async deleteObject):
 20 (WI.ObjectStore.prototype._resolveKeyPath):
 21 (WI.ObjectStore.prototype.async _operation.listener):
 22 (WI.ObjectStore.prototype.async _operation):
 23 Wrapper for a global `IndexedDB` instance for all of WebInspector (per level). Instances of
 24 `WI.ObjectStore` are able to control a given `IDBObjectStore` using a promise-based API.
 25
 26 *NOTE*: due to the constraint that `IDBObjectStore`s are only able to be created when the
 27 owner `IndexedDB` is "upgrade"d, all `WI.ObjectStore` must be declared before the database
 28 is opened for the first time. Additionally, any time a new `WI.ObjectStore` is added, the
 29 `version` needs to be incremented to ensure that the "upgrade" event fires.
 30
 31 To use any of the `*Object` functions, one must implement a `toJSON` on the object provided.
 32 This is so that `WI.ObjectStore` is able to add the resulting identifier value to the owner
 33 object while storing its `toJSON` value in the IndexedDB (e.g. for objects that have cycles).
 34
 35 * UserInterface/Controllers/AuditManager.js:
 36 (WI.AuditManager.prototype.import):
 37 (WI.AuditManager.prototype.loadStoredTests): Added.
 38 (WI.AuditManager.prototype.removeTest): Added.
 39 (WI.AuditManager.prototype._addTest):
 40
 41 * UserInterface/Views/AuditTabContentView.js:
 42 (WI.AuditTabContentView.prototype.initialLayout): Added.
 43 Attempt to load stored audits when the Audit tab is first shown (lazy-load).
 44
 45 * UserInterface/Views/AuditNavigationSidebarPanel.js:
 46 (WI.AuditNavigationSidebarPanel.prototype.initialLayout):
 47 (WI.AuditNavigationSidebarPanel.prototype._handleAuditTestRemoved): Added.
 48
 49 * UserInterface/Views/AuditTreeElement.js:
 50 (WI.AuditTreeElement.prototype.ondelete):
 51 Only allow top-level audits to be deleted, as that is what matches the `WI.ObjectStore`.
 52
 53 * UserInterface/Main.html:
 54 * UserInterface/Test.html:
 55
1562018-10-31 Nikita Vasilyev <nvasilyev@apple.com>
257
358 Web Inspector: Styles: implement copying and deletion of multiple properties

Source/WebInspectorUI/UserInterface/Base/ObjectStore.js

 1/*
 2 * Copyright (C) 2018 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26WI.ObjectStore = class ObjectStore
 27{
 28 constructor(name, options = {})
 29 {
 30 this._name = name;
 31 this._options = options;
 32 }
 33
 34 // Static
 35
 36 static supported()
 37 {
 38 return (!window.InspectorTest || WI.ObjectStore.__testObjectStore) && window.indexedDB;
 39 }
 40
 41 static get _databaseName()
 42 {
 43 let inspectionLevel = InspectorFrontendHost ? InspectorFrontendHost.inspectionLevel() : 1;
 44 let levelString = (inspectionLevel > 1) ? "-" + inspectionLevel : "";
 45 return "com.apple.WebInspector" + levelString;
 46 }
 47
 48 static _open(callback)
 49 {
 50 if (WI.ObjectStore._database) {
 51 callback(WI.ObjectStore._database);
 52 return;
 53 }
 54
 55 const version = 1; // Increment this for every edit to `WI.objectStores`.
 56
 57 let databaseRequest = indexedDB.open(WI.ObjectStore._databaseName, version);
 58 databaseRequest.addEventListener("upgradeneeded", (event) => {
 59 let database = databaseRequest.result;
 60
 61 let objectStores = Object.values(WI.objectStores);
 62 if (WI.ObjectStore.__testObjectStore)
 63 objectStores.push(WI.ObjectStore.__testObjectStore);
 64
 65 let existingNames = new Set;
 66 for (let objectStore of objectStores) {
 67 if (!database.objectStoreNames.contains(objectStore._name))
 68 database.createObjectStore(objectStore._name, objectStore._options);
 69
 70 existingNames.add(objectStore._name);
 71 }
 72
 73 for (let objectStoreName of database.objectStoreNames) {
 74 if (!existingNames.has(objectStoreName))
 75 database.deleteObjectStore(objectStoreName);
 76 }
 77 });
 78 databaseRequest.addEventListener("success", (successEvent) => {
 79 WI.ObjectStore._database = databaseRequest.result;
 80 WI.ObjectStore._database.addEventListener("close", (closeEvent) => {
 81 WI.ObjectStore._database = null;
 82 });
 83
 84 callback(WI.ObjectStore._database);
 85 });
 86 }
 87
 88 // Public
 89
 90 associateObject(object, key, value)
 91 {
 92 if (typeof value === "object")
 93 value = this._resolveKeyPath(value, key).value;
 94
 95 let resolved = this._resolveKeyPath(object, key);
 96 resolved.object[resolved.key] = value;
 97 }
 98
 99 async getAll(...args)
 100 {
 101 if (!WI.ObjectStore.supported())
 102 return undefined;
 103
 104 return this._operation("readonly", (objectStore) => objectStore.getAll(...args));
 105 }
 106
 107 async add(...args)
 108 {
 109 if (!WI.ObjectStore.supported())
 110 return undefined;
 111
 112 return this._operation("readwrite", (objectStore) => objectStore.add(...args));
 113 }
 114
 115 async addObject(object, ...args)
 116 {
 117 if (!WI.ObjectStore.supported())
 118 return undefined;
 119
 120 console.assert(typeof object.toJSON === "function", "ObjectStore cannot store an object without JSON serialization", object.constructor.name);
 121 let result = await this.add(object.toJSON(), ...args);
 122 this.associateObject(object, args[0], result);
 123 return result;
 124 }
 125
 126 async delete(...args)
 127 {
 128 if (!WI.ObjectStore.supported())
 129 return undefined;
 130
 131 return this._operation("readwrite", (objectStore) => objectStore.delete(...args));
 132 }
 133
 134 async deleteObject(object, ...args)
 135 {
 136 if (!WI.ObjectStore.supported())
 137 return undefined;
 138
 139 return this.delete(this._resolveKeyPath(object).value, ...args);
 140 }
 141
 142 // Private
 143
 144 _resolveKeyPath(object, keyPath)
 145 {
 146 keyPath = keyPath || this._options.keyPath || "";
 147
 148 let parts = keyPath.split(".");
 149 let key = parts.splice(-1, 1);
 150 while (parts.length) {
 151 if (!object.hasOwnProperty(parts[0]))
 152 break;
 153 object = object[parts.shift()];
 154 }
 155
 156 if (parts.length)
 157 key = parts.join(".") + "." + key;
 158
 159 return {
 160 object,
 161 key,
 162 value: object[key],
 163 };
 164 }
 165
 166 async _operation(mode, func)
 167 {
 168 // IndexedDB transactions will auto-close if there are no active operations at the end of a
 169 // microtask, so we need to do everything using event listeners instead of promises.
 170 return new Promise((resolve, reject) => {
 171 WI.ObjectStore._open((database) => {
 172 let transaction = database.transaction([this._name], mode);
 173 let objectStore = transaction.objectStore(this._name);
 174 let request = null;
 175
 176 try {
 177 request = func(objectStore);
 178 } catch (e) {
 179 reject(e);
 180 return;
 181 }
 182
 183 function listener(event) {
 184 transaction.removeEventListener("complete", listener);
 185 transaction.removeEventListener("error", listener);
 186 request.removeEventListener("success", listener);
 187 request.removeEventListener("error", listener);
 188
 189 if (request.error) {
 190 reject(request.error);
 191 return;
 192 }
 193
 194 resolve(request.result);
 195 }
 196 transaction.addEventListener("complete", listener, {once: true});
 197 transaction.addEventListener("error", listener, {once: true});
 198 request.addEventListener("success", listener, {once: true});
 199 request.addEventListener("error", listener, {once: true});
 200 });
 201 });
 202 }
 203};
 204
 205WI.ObjectStore._database = null;
 206
 207// Be sure to update the `version` above when making changes.
 208WI.objectStores = {
 209 audits: new WI.ObjectStore("audit-manager-tests", {keyPath: "__id", autoIncrement: true}),
 210};

Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js

@@WI.AuditManager = class AuditManager extends WI.Object
116116 }
117117 }
118118
119  if (object instanceof WI.AuditTestBase)
 119 if (object instanceof WI.AuditTestBase) {
120120 this._addTest(object);
121  else if (object instanceof WI.AuditTestResultBase)
 121 WI.objectStores.audits.addObject(object);
 122 } else if (object instanceof WI.AuditTestResultBase)
122123 this._addResult(object);
123124 });
124125 }

@@WI.AuditManager = class AuditManager extends WI.Object
140141 });
141142 }
142143
 144 loadStoredTests()
 145 {
 146 WI.objectStores.audits.getAll().then(async (tests) => {
 147 for (let payload of tests) {
 148 let test = await WI.AuditTestGroup.fromPayload(payload) || await WI.AuditTestCase.fromPayload(payload);
 149 if (!test)
 150 continue;
 151
 152 const key = null;
 153 WI.objectStores.audits.associateObject(test, key, payload);
 154
 155 this._addTest(test);
 156 }
 157 });
 158 }
 159
 160 removeTest(test)
 161 {
 162 this._tests.remove(test);
 163
 164 this.dispatchEventToListeners(WI.AuditManager.Event.TestRemoved, {test});
 165
 166 WI.objectStores.audits.deleteObject(test);
 167 }
 168
143169 // Private
144170
145171 _addTest(test)

@@WI.AuditManager.RunningState = {
172198WI.AuditManager.Event = {
173199 TestAdded: "audit-manager-test-added",
174200 TestCompleted: "audit-manager-test-completed",
 201 TestRemoved: "audit-manager-test-removed",
175202 TestScheduled: "audit-manager-test-scheduled",
176203};

Source/WebInspectorUI/UserInterface/Main.html

279279 <script src="Base/ImageUtilities.js"></script>
280280 <script src="Base/LoadLocalizedStrings.js"></script>
281281 <script src="Base/MIMETypeUtilities.js"></script>
 282 <script src="Base/ObjectStore.js"></script>
282283 <script src="Base/URLUtilities.js"></script>
283284 <script src="Base/Utilities.js"></script>
284285 <script src="Base/Setting.js"></script>

Source/WebInspectorUI/UserInterface/Test.html

5656 <script src="Base/EventListenerSet.js"></script>
5757 <script src="Base/ImageUtilities.js"></script>
5858 <script src="Base/MIMETypeUtilities.js"></script>
 59 <script src="Base/ObjectStore.js"></script>
5960 <script src="Base/URLUtilities.js"></script>
6061 <script src="Base/Utilities.js"></script>
6162 <script src="Base/Setting.js"></script>

Source/WebInspectorUI/UserInterface/Views/AuditNavigationSidebarPanel.js

@@WI.AuditNavigationSidebarPanel = class AuditNavigationSidebarPanel extends WI.Na
9090
9191 WI.auditManager.addEventListener(WI.AuditManager.Event.TestAdded, this._handleAuditTestAdded, this);
9292 WI.auditManager.addEventListener(WI.AuditManager.Event.TestCompleted, this._handleAuditTestCompleted, this);
 93 WI.auditManager.addEventListener(WI.AuditManager.Event.TestRemoved, this._handleAuditTestRemoved, this);
9394 WI.auditManager.addEventListener(WI.AuditManager.Event.TestScheduled, this._handleAuditTestScheduled, this);
9495
9596 this.contentTreeOutline.addEventListener(WI.TreeOutline.Event.SelectionDidChange, this._treeSelectionDidChange, this);

@@WI.AuditNavigationSidebarPanel = class AuditNavigationSidebarPanel extends WI.Na
147148 this._addResult(result, index);
148149 }
149150
 151 _handleAuditTestRemoved(event)
 152 {
 153 let {test} = event.data;
 154 let treeElement = this.treeElementForRepresentedObject(test);
 155 this.contentTreeOutline.removeChild(treeElement);
 156 }
 157
150158 _handleAuditTestScheduled(event)
151159 {
152160 this._updateStartStopButtonNavigationItemState();

Source/WebInspectorUI/UserInterface/Views/AuditTabContentView.js

@@WI.AuditTabContentView = class AuditTabContentView extends WI.ContentBrowserTabC
8383 super.hidden();
8484 }
8585
 86 // Protected
 87
 88 initialLayout()
 89 {
 90 super.initialLayout();
 91
 92 WI.auditManager.loadStoredTests();
 93 }
 94
8695 // Private
8796
8897 _handleSpace(event)

Source/WebInspectorUI/UserInterface/Views/AuditTreeElement.js

@@WI.AuditTreeElement = class AuditTreeElement extends WI.GeneralTreeElement
9898 }
9999 }
100100
 101 ondelete()
 102 {
 103 if (!(this.representedObject instanceof WI.AuditTestBase))
 104 return false;
 105
 106 if (!(this.parent instanceof WI.TreeOutline))
 107 return false;
 108
 109 WI.auditManager.removeTest(this.representedObject);
 110
 111 return true;
 112 }
 113
101114 populateContextMenu(contextMenu, event)
102115 {
103116 if (WI.auditManager.runningState === WI.AuditManager.RunningState.Inactive) {

LayoutTests/ChangeLog

 12018-10-31 Devin Rousso <drousso@apple.com>
 2
 3 Web Inspector: Audit: save imported audits across WebInspector sessions
 4 https://bugs.webkit.org/show_bug.cgi?id=190858
 5 <rdar://problem/45527625>
 6
 7 Reviewed by Brian Burg.
 8
 9 * inspector/unit-tests/objectStore/add-expected.txt: Added.
 10 * inspector/unit-tests/objectStore/add.html: Added.
 11 * inspector/unit-tests/objectStore/addObject-expected.txt: Added.
 12 * inspector/unit-tests/objectStore/addObject.html: Added.
 13 * inspector/unit-tests/objectStore/basic-expected.txt: Added.
 14 * inspector/unit-tests/objectStore/basic.html: Added.
 15 * inspector/unit-tests/objectStore/delete-expected.txt: Added.
 16 * inspector/unit-tests/objectStore/delete.html: Added.
 17 * inspector/unit-tests/objectStore/deleteObject-expected.txt: Added.
 18 * inspector/unit-tests/objectStore/deleteObject.html: Added.
 19 * inspector/unit-tests/objectStore/resources/objectStore-utilities.js: Added.
 20 (TestPage.registerInitializer.InspectorTest.ObjectStore.TestObject):
 21 (TestPage.registerInitializer.InspectorTest.ObjectStore.TestObject.prototype.toJSON):
 22 (TestPage.registerInitializer.InspectorTest.ObjectStore.createSuite):
 23 (TestPage.registerInitializer.InspectorTest.ObjectStore.createObjectStore):
 24 (TestPage.registerInitializer.InspectorTest.ObjectStore.add):
 25 (TestPage.registerInitializer.InspectorTest.ObjectStore.addObject):
 26 (TestPage.registerInitializer.InspectorTest.ObjectStore.delete):
 27 (TestPage.registerInitializer.InspectorTest.ObjectStore.deleteObject):
 28 (TestPage.registerInitializer.InspectorTest.ObjectStore.logValues):
 29 (TestPage.registerInitializer.InspectorTest.ObjectStore.wrapTest):
 30
1312018-10-31 Alicia Boya García <aboya@igalia.com>
232
333 [MSE] Use tolerance when growing the coded frame group

LayoutTests/inspector/unit-tests/objectStore/add-expected.txt

 1Tests WI.ObjectStore.prototype.add.
 2
 3
 4== Running test suite: WI.ObjectStore.prototype.add
 5-- Running test case: WI.ObjectStore.prototype.add.NoParameters
 6PASS: Should produce an exception.
 7TypeError: Not enough arguments
 8[]
 9
 10-- Running test case: WI.ObjectStore.prototype.add.Boolean
 11add: [false]
 12add: [false,true]
 13[false,true]
 14
 15-- Running test case: WI.ObjectStore.prototype.add.Number
 16add: [11]
 17add: [11,22]
 18[11,22]
 19
 20-- Running test case: WI.ObjectStore.prototype.add.String
 21add: ["foo"]
 22add: ["foo","bar"]
 23["foo","bar"]
 24
 25-- Running test case: WI.ObjectStore.prototype.add.Array
 26add: [[11]]
 27add: [[11],[22]]
 28[[11],[22]]
 29
 30-- Running test case: WI.ObjectStore.prototype.add.Null
 31add: [null]
 32[null]
 33
 34-- Running test case: WI.ObjectStore.prototype.add.Object.WithoutKeyPathOrAutoIncrement
 35PASS: Should produce an exception.
 36DataError: 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.
 37[]
 38
 39-- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathMissingOnObjectWithoutAutoIncrement
 40PASS: Should produce an exception.
 41DataError: Failed to store record in an IDBObjectStore: Evaluating the object store's key path did not yield a value.
 42[]
 43
 44-- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithoutAutoIncrement
 45add: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1}]
 46add: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}]
 47[{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}]
 48
 49-- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathMissingOnObjectWithAutoIncrement
 50add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1}]
 51add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}]
 52[{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}]
 53
 54-- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithAutoIncrement
 55add: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1}]
 56add: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}]
 57[{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}]
 58
 59-- Running test case: WI.ObjectStore.prototype.add.Object.AutoIncrementWithoutKeyPath
 60add: [{"a":1}]
 61add: [{"a":1},{"b":2}]
 62[{"a":1},{"b":2}]
 63
 64-- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithoutAutoIncrement.Sub
 65add: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1}]
 66add: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}]
 67[{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}]
 68
 69-- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathMissingOnObjectWithAutoIncrement.Sub
 70add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}}]
 71add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}]
 72[{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}]
 73
 74-- Running test case: WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithAutoIncrement.Sub
 75add: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1}]
 76add: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}]
 77[{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}]
 78

LayoutTests/inspector/unit-tests/objectStore/add.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../../http/tests/inspector/resources/inspector-test.js"></script>
 5<script src="resources/objectStore-utilities.js"></script>
 6<script>
 7function test()
 8{
 9 let suite = InspectorTest.ObjectStore.createSuite("WI.ObjectStore.prototype.add");
 10
 11 function testAdd(name, {options, tests}) {
 12 InspectorTest.ObjectStore.wrapTest(name, async function() {
 13 InspectorTest.ObjectStore.createObjectStore(options);
 14
 15 for (let {value, expected} of tests)
 16 await InspectorTest.ObjectStore.add(value, expected);
 17 });
 18 }
 19
 20 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.add.NoParameters", async function() {
 21 let objectStore = InspectorTest.ObjectStore.createObjectStore();
 22
 23 await InspectorTest.expectException(async function() {
 24 await objectStore.add();
 25 await objectStore.add(InspectorTest.ObjectStore.basicObject2);
 26 });
 27 });
 28
 29 testAdd("WI.ObjectStore.prototype.add.Boolean", {
 30 options: {autoIncrement: true},
 31 tests: [
 32 {value: false, expected: 1},
 33 {value: true, expected: 2},
 34 ],
 35 });
 36
 37 testAdd("WI.ObjectStore.prototype.add.Number", {
 38 options: {autoIncrement: true},
 39 tests: [
 40 {value: 11, expected: 1},
 41 {value: 22, expected: 2},
 42 ],
 43 });
 44
 45 testAdd("WI.ObjectStore.prototype.add.String", {
 46 options: {autoIncrement: true},
 47 tests: [
 48 {value: "foo", expected: 1},
 49 {value: "bar", expected: 2},
 50 ],
 51 });
 52
 53 testAdd("WI.ObjectStore.prototype.add.Array", {
 54 options: {autoIncrement: true},
 55 tests: [
 56 {value: [11], expected: 1},
 57 {value: [22], expected: 2},
 58 ],
 59 });
 60
 61 testAdd("WI.ObjectStore.prototype.add.Null", {
 62 options: {autoIncrement: true},
 63 tests: [
 64 {value: null, expected: 1},
 65 ],
 66 });
 67
 68 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.add.Object.WithoutKeyPathOrAutoIncrement", async function() {
 69 let objectStore = InspectorTest.ObjectStore.createObjectStore();
 70
 71 await InspectorTest.expectException(async function() {
 72 await objectStore.add(InspectorTest.ObjectStore.basicObject1);
 73 await objectStore.add(InspectorTest.ObjectStore.basicObject2);
 74 });
 75 });
 76
 77 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.add.Object.KeyPathMissingOnObjectWithoutAutoIncrement", async function() {
 78 const options = {
 79 keyPath: "KeyPathMissingOnObjectWithoutAutoIncrement",
 80 };
 81 let objectStore = InspectorTest.ObjectStore.createObjectStore(options);
 82
 83 await InspectorTest.expectException(async function() {
 84 await objectStore.add(InspectorTest.ObjectStore.basicObject1);
 85 await objectStore.add(InspectorTest.ObjectStore.basicObject2);
 86 });
 87 });
 88
 89 testAdd("WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithoutAutoIncrement", {
 90 options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement"},
 91 tests: [
 92 {value: {KeyPathSetOnObjectWithoutAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 93 {value: {KeyPathSetOnObjectWithoutAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 94 ],
 95 });
 96
 97 testAdd("WI.ObjectStore.prototype.add.Object.KeyPathMissingOnObjectWithAutoIncrement", {
 98 options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement", autoIncrement: true},
 99 tests: [
 100 {value: InspectorTest.ObjectStore.basicObject1, expected: 1},
 101 {value: InspectorTest.ObjectStore.basicObject2, expected: 2},
 102 ],
 103 });
 104
 105 testAdd("WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithAutoIncrement", {
 106 options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement", autoIncrement: true},
 107 tests: [
 108 {value: {KeyPathSetOnObjectWithAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 109 {value: {KeyPathSetOnObjectWithAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 110 ],
 111 });
 112
 113 testAdd("WI.ObjectStore.prototype.add.Object.AutoIncrementWithoutKeyPath", {
 114 options: {autoIncrement: true},
 115 tests: [
 116 {value: InspectorTest.ObjectStore.basicObject1, expected: 1},
 117 {value: InspectorTest.ObjectStore.basicObject2, expected: 2},
 118 ],
 119 });
 120
 121 testAdd("WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithoutAutoIncrement.Sub", {
 122 options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement.Sub"},
 123 tests: [
 124 {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 125 {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 126 ],
 127 });
 128
 129 testAdd("WI.ObjectStore.prototype.add.Object.KeyPathMissingOnObjectWithAutoIncrement.Sub", {
 130 options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement.Sub", autoIncrement: true},
 131 tests: [
 132 {value: InspectorTest.ObjectStore.basicObject1, expected: 1},
 133 {value: InspectorTest.ObjectStore.basicObject2, expected: 2},
 134 ],
 135 });
 136
 137 testAdd("WI.ObjectStore.prototype.add.Object.KeyPathSetOnObjectWithAutoIncrement.Sub", {
 138 options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement.Sub", autoIncrement: true},
 139 tests: [
 140 {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 141 {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 142 ],
 143 });
 144
 145 suite.runTestCasesAndFinish();
 146}
 147</script>
 148</head>
 149<body onload="runTest()">
 150 <p>Tests WI.ObjectStore.prototype.add.</p>
 151</body>
 152</html>

LayoutTests/inspector/unit-tests/objectStore/addObject-expected.txt

 1Tests WI.ObjectStore.prototype.addObject.
 2
 3
 4== Running test suite: WI.ObjectStore.prototype.addObject
 5-- Running test case: WI.ObjectStore.prototype.addObject.NoParameters
 6PASS: Should produce an exception.
 7TypeError: undefined is not an object (evaluating 'object.toJSON')
 8[]
 9
 10-- Running test case: WI.ObjectStore.prototype.addObject.WithoutKeyPathOrAutoIncrement
 11PASS: Should produce an exception.
 12DataError: 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.
 13[]
 14
 15-- Running test case: WI.ObjectStore.prototype.addObject.KeyPathMissingOnObjectWithoutAutoIncrement
 16PASS: Should produce an exception.
 17DataError: Failed to store record in an IDBObjectStore: Evaluating the object store's key path did not yield a value.
 18[]
 19
 20-- Running test case: WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithoutAutoIncrement
 21addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1}]
 22addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}]
 23[{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}]
 24
 25-- Running test case: WI.ObjectStore.prototype.addObject.KeyPathMissingOnObjectWithAutoIncrement
 26addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1}]
 27addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}]
 28[{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}]
 29
 30-- Running test case: WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithAutoIncrement
 31addObject: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1}]
 32addObject: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}]
 33[{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}]
 34
 35-- Running test case: WI.ObjectStore.prototype.addObject.AutoIncrementWithoutKeyPath
 36addObject: [{"a":1}]
 37addObject: [{"a":1},{"b":2}]
 38[{"a":1},{"b":2}]
 39
 40-- Running test case: WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithoutAutoIncrement.Sub
 41addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1}]
 42addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}]
 43[{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}]
 44
 45-- Running test case: WI.ObjectStore.prototype.addObject.KeyPathMissingOnObjectWithAutoIncrement.Sub
 46addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}}]
 47addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}]
 48[{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}]
 49
 50-- Running test case: WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithAutoIncrement.Sub
 51addObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1}]
 52addObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}]
 53[{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}]
 54

LayoutTests/inspector/unit-tests/objectStore/addObject.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../../http/tests/inspector/resources/inspector-test.js"></script>
 5<script src="resources/objectStore-utilities.js"></script>
 6<script>
 7function test()
 8{
 9 let suite = InspectorTest.ObjectStore.createSuite("WI.ObjectStore.prototype.addObject");
 10
 11 function testAddObject(name, {options, tests}) {
 12 InspectorTest.ObjectStore.wrapTest(name, async function() {
 13 InspectorTest.ObjectStore.createObjectStore(options);
 14
 15 for (let {value, expected} of tests)
 16 await InspectorTest.ObjectStore.addObject(new InspectorTest.ObjectStore.TestObject(value), expected);
 17 });
 18 }
 19
 20 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.addObject.NoParameters", async function() {
 21 let objectStore = InspectorTest.ObjectStore.createObjectStore();
 22
 23 await InspectorTest.expectException(async function() {
 24 await objectStore.addObject();
 25 await objectStore.addObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2));
 26 });
 27 });
 28
 29 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.addObject.WithoutKeyPathOrAutoIncrement", async function() {
 30 let objectStore = InspectorTest.ObjectStore.createObjectStore();
 31
 32 await InspectorTest.expectException(async function() {
 33 await objectStore.addObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject1));
 34 await objectStore.addObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2));
 35 });
 36 });
 37
 38 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.addObject.KeyPathMissingOnObjectWithoutAutoIncrement", async function() {
 39 const options = {
 40 keyPath: "KeyPathMissingOnObjectWithoutAutoIncrement",
 41 };
 42 let objectStore = InspectorTest.ObjectStore.createObjectStore(options);
 43
 44 await InspectorTest.expectException(async function() {
 45 await objectStore.addObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject1));
 46 await objectStore.addObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2));
 47 });
 48 });
 49
 50 testAddObject("WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithoutAutoIncrement", {
 51 options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement"},
 52 tests: [
 53 {value: {KeyPathSetOnObjectWithoutAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 54 {value: {KeyPathSetOnObjectWithoutAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 55 ],
 56 });
 57
 58 testAddObject("WI.ObjectStore.prototype.addObject.KeyPathMissingOnObjectWithAutoIncrement", {
 59 options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement", autoIncrement: true},
 60 tests: [
 61 {value: InspectorTest.ObjectStore.basicObject1, expected: 1},
 62 {value: InspectorTest.ObjectStore.basicObject2, expected: 2},
 63 ],
 64 });
 65
 66 testAddObject("WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithAutoIncrement", {
 67 options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement", autoIncrement: true},
 68 tests: [
 69 {value: {KeyPathSetOnObjectWithAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 70 {value: {KeyPathSetOnObjectWithAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 71 ],
 72 });
 73
 74 testAddObject("WI.ObjectStore.prototype.addObject.AutoIncrementWithoutKeyPath", {
 75 options: {autoIncrement: true},
 76 tests: [
 77 {value: InspectorTest.ObjectStore.basicObject1, expected: 1},
 78 {value: InspectorTest.ObjectStore.basicObject2, expected: 2},
 79 ],
 80 });
 81
 82 testAddObject("WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithoutAutoIncrement.Sub", {
 83 options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement.Sub"},
 84 tests: [
 85 {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 86 {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 87 ],
 88 });
 89
 90 testAddObject("WI.ObjectStore.prototype.addObject.KeyPathMissingOnObjectWithAutoIncrement.Sub", {
 91 options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement.Sub", autoIncrement: true},
 92 tests: [
 93 {value: InspectorTest.ObjectStore.basicObject1, expected: 1},
 94 {value: InspectorTest.ObjectStore.basicObject2, expected: 2},
 95 ],
 96 });
 97
 98 testAddObject("WI.ObjectStore.prototype.addObject.KeyPathSetOnObjectWithAutoIncrement.Sub", {
 99 options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement.Sub", autoIncrement: true},
 100 tests: [
 101 {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 102 {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 103 ],
 104 });
 105
 106 suite.runTestCasesAndFinish();
 107}
 108</script>
 109</head>
 110<body onload="runTest()">
 111 <p>Tests WI.ObjectStore.prototype.addObject.</p>
 112</body>
 113</html>

LayoutTests/inspector/unit-tests/objectStore/basic-expected.txt

 1Tests basic functionality of WI.ObjectStore.
 2
 3
 4== Running test suite: WI.ObjectStore
 5-- Running test case: WI.ObjectStore.InitiallyNull
 6PASS: The database should initially be null/closed.
 7
 8-- Running test case: WI.ObjectStore.prototype._resolveKeyPath.Exists
 9{"object":{"a":1},"key":["a"],"value":1}
 10[]
 11
 12-- Running test case: WI.ObjectStore.prototype._resolveKeyPath.MissingPart
 13{"object":{"sub.a":0,"a":1,"b":2},"key":"sub.a","value":0}
 14[]
 15
 16-- Running test case: WI.ObjectStore.prototype._resolveKeyPath.MissingWhole
 17{"object":{"a":1,"b":2},"key":"sub.a"}
 18[]
 19

LayoutTests/inspector/unit-tests/objectStore/basic.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../../http/tests/inspector/resources/inspector-test.js"></script>
 5<script src="resources/objectStore-utilities.js"></script>
 6<script>
 7function test()
 8{
 9 let suite = InspectorTest.ObjectStore.createSuite("WI.ObjectStore");
 10
 11 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.InitiallyNull", async function() {
 12 InspectorTest.expectNull(WI.ObjectStore._database, "The database should initially be null/closed.");
 13 });
 14
 15 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype._resolveKeyPath.Exists", async function() {
 16 const options = {
 17 keyPath: "sub.a",
 18 };
 19 let objectStore = InspectorTest.ObjectStore.createObjectStore(options);
 20
 21 const object = {sub: {a: 1}, b: 2};
 22 InspectorTest.log(objectStore._resolveKeyPath(object));
 23 });
 24
 25 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype._resolveKeyPath.MissingPart", async function() {
 26 const options = {
 27 keyPath: "sub.a",
 28 };
 29 let objectStore = InspectorTest.ObjectStore.createObjectStore(options);
 30
 31 const object = {"sub.a": 0, a: 1, b: 2};
 32 InspectorTest.log(objectStore._resolveKeyPath(object));
 33 });
 34
 35 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype._resolveKeyPath.MissingWhole", async function() {
 36 const options = {
 37 keyPath: "sub.a",
 38 };
 39 let objectStore = InspectorTest.ObjectStore.createObjectStore(options);
 40
 41 const object = {a: 1, b: 2};
 42 InspectorTest.log(objectStore._resolveKeyPath(object));
 43 });
 44
 45 suite.runTestCasesAndFinish();
 46}
 47</script>
 48</head>
 49<body onload="runTest()">
 50 <p>Tests basic functionality of WI.ObjectStore.</p>
 51</body>
 52</html>

LayoutTests/inspector/unit-tests/objectStore/delete-expected.txt

 1Tests WI.ObjectStore.prototype.delete.
 2
 3
 4== Running test suite: WI.ObjectStore.prototype.delete
 5-- Running test case: WI.ObjectStore.prototype.delete.NoParameters
 6add: [{"b":2}]
 7PASS: Should produce an exception.
 8TypeError: Not enough arguments
 9[{"b":2}]
 10
 11-- Running test case: WI.ObjectStore.prototype.delete.MissingObject
 12add: [{"b":2}]
 13PASS: Should produce an exception.
 14DataError: Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key.
 15[{"b":2}]
 16
 17-- Running test case: WI.ObjectStore.prototype.delete.Boolean
 18add: [false]
 19add: [false,true]
 20delete: [true]
 21delete: []
 22[]
 23
 24-- Running test case: WI.ObjectStore.prototype.delete.Number
 25add: [11]
 26add: [11,22]
 27delete: [22]
 28delete: []
 29[]
 30
 31-- Running test case: WI.ObjectStore.prototype.delete.String
 32add: ["foo"]
 33add: ["foo","bar"]
 34delete: ["bar"]
 35delete: []
 36[]
 37
 38-- Running test case: WI.ObjectStore.prototype.delete.Array
 39add: [[11]]
 40add: [[11],[22]]
 41delete: [[22]]
 42delete: []
 43[]
 44
 45-- Running test case: WI.ObjectStore.prototype.delete.Null
 46add: [null]
 47delete: []
 48[]
 49
 50-- Running test case: WI.ObjectStore.prototype.delete.Object.WithoutKeyPathOrAutoIncrement
 51PASS: Should produce an exception.
 52DataError: 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.
 53[]
 54
 55-- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathMissingOnObjectWithoutAutoIncrement
 56PASS: Should produce an exception.
 57DataError: Failed to store record in an IDBObjectStore: Evaluating the object store's key path did not yield a value.
 58[]
 59
 60-- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathSetOnObjectWithoutAutoIncrement
 61add: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1}]
 62add: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}]
 63delete: [{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}]
 64delete: []
 65[]
 66
 67-- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathMissingOnObjectWithAutoIncrement
 68add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1}]
 69add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}]
 70delete: [{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}]
 71delete: []
 72[]
 73
 74-- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathSetOnObjectWithAutoIncrement
 75add: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1}]
 76add: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}]
 77delete: [{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}]
 78delete: []
 79[]
 80
 81-- Running test case: WI.ObjectStore.prototype.delete.Object.AutoIncrementWithoutKeyPath
 82add: [{"a":1}]
 83add: [{"a":1},{"b":2}]
 84delete: [{"b":2}]
 85delete: []
 86[]
 87
 88-- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathSetOnObjectWithoutAutoIncrement.Sub
 89add: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1}]
 90add: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}]
 91delete: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}]
 92delete: []
 93[]
 94
 95-- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathMissingOnObjectWithAutoIncrement.Sub
 96add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}}]
 97add: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}]
 98delete: [{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}]
 99delete: []
 100[]
 101
 102-- Running test case: WI.ObjectStore.prototype.delete.Object.KeyPathSetOnObjectWithAutoIncrement.Sub
 103add: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1}]
 104add: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}]
 105delete: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}]
 106delete: []
 107[]
 108

LayoutTests/inspector/unit-tests/objectStore/delete.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../../http/tests/inspector/resources/inspector-test.js"></script>
 5<script src="resources/objectStore-utilities.js"></script>
 6<script>
 7function test()
 8{
 9 let suite = InspectorTest.ObjectStore.createSuite("WI.ObjectStore.prototype.delete");
 10
 11 function testDelete(name, {options, tests}) {
 12 InspectorTest.ObjectStore.wrapTest(name, async function() {
 13 InspectorTest.ObjectStore.createObjectStore(options);
 14
 15 let keys = [];
 16 for (let {value, expected} of tests)
 17 keys.push(await InspectorTest.ObjectStore.add(value, expected));
 18
 19 for (let key of keys)
 20 await InspectorTest.ObjectStore.delete(key);
 21 });
 22 }
 23
 24 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.delete.NoParameters", async function() {
 25 const options = {
 26 autoIncrement: true,
 27 };
 28 let objectStore = InspectorTest.ObjectStore.createObjectStore(options);
 29
 30 await InspectorTest.ObjectStore.add(InspectorTest.ObjectStore.basicObject2, 1);
 31
 32 await InspectorTest.expectException(async () => {
 33 await objectStore.delete();
 34 await objectStore.delete(InspectorTest.ObjectStore.basicObject2);
 35 });
 36 });
 37
 38 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.delete.MissingObject", async function() {
 39 const options = {
 40 autoIncrement: true,
 41 };
 42 let objectStore = InspectorTest.ObjectStore.createObjectStore(options);
 43
 44 await InspectorTest.ObjectStore.add(InspectorTest.ObjectStore.basicObject2, 1);
 45
 46 await InspectorTest.expectException(async () => {
 47 await objectStore.delete(InspectorTest.ObjectStore.basicObject1);
 48 await objectStore.delete(InspectorTest.ObjectStore.basicObject2);
 49 });
 50 });
 51
 52 testDelete("WI.ObjectStore.prototype.delete.Boolean", {
 53 options: {autoIncrement: true},
 54 tests: [
 55 {value: false, expected: 1},
 56 {value: true, expected: 2},
 57 ],
 58 });
 59
 60 testDelete("WI.ObjectStore.prototype.delete.Number", {
 61 options: {autoIncrement: true},
 62 tests: [
 63 {value: 11, expected: 1},
 64 {value: 22, expected: 2},
 65 ],
 66 });
 67
 68 testDelete("WI.ObjectStore.prototype.delete.String", {
 69 options: {autoIncrement: true},
 70 tests: [
 71 {value: "foo", expected: 1},
 72 {value: "bar", expected: 2},
 73 ],
 74 });
 75
 76 testDelete("WI.ObjectStore.prototype.delete.Array", {
 77 options: {autoIncrement: true},
 78 tests: [
 79 {value: [11], expected: 1},
 80 {value: [22], expected: 2},
 81 ],
 82 });
 83
 84 testDelete("WI.ObjectStore.prototype.delete.Null", {
 85 options: {autoIncrement: true},
 86 tests: [
 87 {value: null, expected: 1},
 88 ],
 89 });
 90
 91 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.delete.Object.WithoutKeyPathOrAutoIncrement", async function() {
 92 let objectStore = InspectorTest.ObjectStore.createObjectStore();
 93
 94 await InspectorTest.expectException(async function() {
 95 await objectStore.add(InspectorTest.ObjectStore.basicObject1);
 96 await objectStore.add(InspectorTest.ObjectStore.basicObject2);
 97 });
 98 });
 99
 100 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.delete.Object.KeyPathMissingOnObjectWithoutAutoIncrement", async function() {
 101 const options = {
 102 keyPath: "KeyPathMissingOnObjectWithoutAutoIncrement",
 103 };
 104 let objectStore = InspectorTest.ObjectStore.createObjectStore(options);
 105
 106 await InspectorTest.expectException(async function() {
 107 await objectStore.add(InspectorTest.ObjectStore.basicObject1);
 108 await objectStore.add(InspectorTest.ObjectStore.basicObject2);
 109 });
 110 });
 111
 112 testDelete("WI.ObjectStore.prototype.delete.Object.KeyPathSetOnObjectWithoutAutoIncrement", {
 113 options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement"},
 114 tests: [
 115 {value: {KeyPathSetOnObjectWithoutAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 116 {value: {KeyPathSetOnObjectWithoutAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 117 ],
 118 });
 119
 120 testDelete("WI.ObjectStore.prototype.delete.Object.KeyPathMissingOnObjectWithAutoIncrement", {
 121 options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement", autoIncrement: true},
 122 tests: [
 123 {value: InspectorTest.ObjectStore.basicObject1, expected: 1},
 124 {value: InspectorTest.ObjectStore.basicObject2, expected: 2},
 125 ],
 126 });
 127
 128 testDelete("WI.ObjectStore.prototype.delete.Object.KeyPathSetOnObjectWithAutoIncrement", {
 129 options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement", autoIncrement: true},
 130 tests: [
 131 {value: {KeyPathSetOnObjectWithAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 132 {value: {KeyPathSetOnObjectWithAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 133 ],
 134 });
 135
 136 testDelete("WI.ObjectStore.prototype.delete.Object.AutoIncrementWithoutKeyPath", {
 137 options: {autoIncrement: true},
 138 tests: [
 139 {value: InspectorTest.ObjectStore.basicObject1, expected: 1},
 140 {value: InspectorTest.ObjectStore.basicObject2, expected: 2},
 141 ],
 142 });
 143
 144 testDelete("WI.ObjectStore.prototype.delete.Object.KeyPathSetOnObjectWithoutAutoIncrement.Sub", {
 145 options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement.Sub"},
 146 tests: [
 147 {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 148 {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 149 ],
 150 });
 151
 152 testDelete("WI.ObjectStore.prototype.delete.Object.KeyPathMissingOnObjectWithAutoIncrement.Sub", {
 153 options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement.Sub", autoIncrement: true},
 154 tests: [
 155 {value: InspectorTest.ObjectStore.basicObject1, expected: 1},
 156 {value: InspectorTest.ObjectStore.basicObject2, expected: 2},
 157 ],
 158 });
 159
 160 testDelete("WI.ObjectStore.prototype.delete.Object.KeyPathSetOnObjectWithAutoIncrement.Sub", {
 161 options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement.Sub", autoIncrement: true},
 162 tests: [
 163 {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 164 {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 165 ],
 166 });
 167
 168 suite.runTestCasesAndFinish();
 169}
 170</script>
 171</head>
 172<body onload="runTest()">
 173 <p>Tests WI.ObjectStore.prototype.delete.</p>
 174</body>
 175</html>

LayoutTests/inspector/unit-tests/objectStore/deleteObject-expected.txt

 1Tests WI.ObjectStore.prototype.deleteObject.
 2
 3
 4== Running test suite: WI.ObjectStore.prototype.deleteObject
 5-- Running test case: WI.ObjectStore.prototype.deleteObject.NoParameters
 6add: [{"_object":{"b":2}}]
 7PASS: Should produce an exception.
 8TypeError: undefined is not an object (evaluating 'object[key]')
 9[{"_object":{"b":2}}]
 10
 11-- Running test case: WI.ObjectStore.prototype.deleteObject.MissingObject
 12add: [{"_object":{"b":2}}]
 13PASS: Should produce an exception.
 14DataError: Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key range.
 15[{"_object":{"b":2}}]
 16
 17-- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathMissingOnObjectWithoutAutoIncrement
 18PASS: Should produce an exception.
 19DataError: Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key range.
 20[]
 21
 22-- Running test case: WI.ObjectStore.prototype.deleteObject.WithoutKeyPathOrAutoIncrement
 23PASS: Should produce an exception.
 24DataError: 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.
 25[]
 26
 27-- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathMissingOnObjectWithoutAutoIncrement
 28PASS: Should produce an exception.
 29DataError: Failed to store record in an IDBObjectStore: Evaluating the object store's key path did not yield a value.
 30[]
 31
 32-- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathSetOnObjectWithoutAutoIncrement
 33addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1}]
 34addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}]
 35deleteObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":99,"b":2}]
 36deleteObject: []
 37[]
 38
 39-- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathMissingOnObjectWithAutoIncrement
 40addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1}]
 41addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":1},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}]
 42deleteObject: [{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":2}]
 43deleteObject: []
 44[]
 45
 46-- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathSetOnObjectWithAutoIncrement
 47addObject: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1}]
 48addObject: [{"KeyPathSetOnObjectWithAutoIncrement":42,"a":1},{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}]
 49deleteObject: [{"KeyPathSetOnObjectWithAutoIncrement":99,"b":2}]
 50deleteObject: []
 51[]
 52
 53-- Running test case: WI.ObjectStore.prototype.deleteObject.AutoIncrementWithoutKeyPath
 54addObject: [{"a":1}]
 55addObject: [{"a":1},{"b":2}]
 56deleteObject: [{"b":2}]
 57deleteObject: []
 58[]
 59
 60-- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathSetOnObjectWithoutAutoIncrement.Sub
 61addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1}]
 62addObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}]
 63deleteObject: [{"KeyPathSetOnObjectWithoutAutoIncrement":{"Sub":99},"b":2}]
 64deleteObject: []
 65[]
 66
 67-- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathMissingOnObjectWithAutoIncrement.Sub
 68addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}}]
 69addObject: [{"a":1,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":1}},{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}]
 70deleteObject: [{"b":2,"KeyPathMissingOnObjectWithAutoIncrement":{"Sub":2}}]
 71deleteObject: []
 72[]
 73
 74-- Running test case: WI.ObjectStore.prototype.deleteObject.KeyPathSetOnObjectWithAutoIncrement.Sub
 75addObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1}]
 76addObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":42},"a":1},{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}]
 77deleteObject: [{"KeyPathSetOnObjectWithAutoIncrement":{"Sub":99},"b":2}]
 78deleteObject: []
 79[]
 80

LayoutTests/inspector/unit-tests/objectStore/deleteObject.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../../http/tests/inspector/resources/inspector-test.js"></script>
 5<script src="resources/objectStore-utilities.js"></script>
 6<script>
 7function test()
 8{
 9 let suite = InspectorTest.ObjectStore.createSuite("WI.ObjectStore.prototype.deleteObject");
 10
 11 function testDeleteObject(name, {options, tests}) {
 12 InspectorTest.ObjectStore.wrapTest(name, async function() {
 13 InspectorTest.ObjectStore.createObjectStore(options);
 14
 15 let objects = []
 16 for (let {value, expected} of tests) {
 17 let object = new InspectorTest.ObjectStore.TestObject(value);
 18 await InspectorTest.ObjectStore.addObject(object, expected);
 19 objects.push(object);
 20 }
 21
 22 for (let object of objects)
 23 await InspectorTest.ObjectStore.deleteObject(object);
 24 });
 25 }
 26
 27 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.deleteObject.NoParameters", async function() {
 28 const options = {
 29 autoIncrement: true,
 30 };
 31 let objectStore = InspectorTest.ObjectStore.createObjectStore(options);
 32
 33 await InspectorTest.ObjectStore.add(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2), 1);
 34
 35 await InspectorTest.expectException(async () => {
 36 await objectStore.deleteObject();
 37 await objectStore.deleteObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2));
 38 });
 39 });
 40
 41 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.deleteObject.MissingObject", async function() {
 42 const options = {
 43 autoIncrement: true,
 44 };
 45 let objectStore = InspectorTest.ObjectStore.createObjectStore(options);
 46
 47 await InspectorTest.ObjectStore.add(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2), 1);
 48
 49 await InspectorTest.expectException(async () => {
 50 await objectStore.deleteObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject1));
 51 await objectStore.deleteObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2));
 52 });
 53 });
 54
 55 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.deleteObject.KeyPathMissingOnObjectWithoutAutoIncrement", async function() {
 56 const options = {
 57 keyPath: "KeyPathMissingOnObjectWithoutAutoIncrement",
 58 };
 59 let objectStore = InspectorTest.ObjectStore.createObjectStore(options);
 60
 61 await InspectorTest.expectException(async function() {
 62 await objectStore.deleteObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject1));
 63 await objectStore.deleteObject(new InspectorTest.ObjectStore.TestObject(InspectorTest.ObjectStore.basicObject2));
 64 });
 65 });
 66
 67 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.deleteObject.WithoutKeyPathOrAutoIncrement", async function() {
 68 let objectStore = InspectorTest.ObjectStore.createObjectStore();
 69
 70 await InspectorTest.expectException(async function() {
 71 await objectStore.add(InspectorTest.ObjectStore.basicObject1);
 72 await objectStore.add(InspectorTest.ObjectStore.basicObject2);
 73 });
 74 });
 75
 76 InspectorTest.ObjectStore.wrapTest("WI.ObjectStore.prototype.deleteObject.KeyPathMissingOnObjectWithoutAutoIncrement", async function() {
 77 const options = {
 78 keyPath: "KeyPathMissingOnObjectWithoutAutoIncrement",
 79 };
 80 let objectStore = InspectorTest.ObjectStore.createObjectStore(options);
 81
 82 await InspectorTest.expectException(async function() {
 83 await objectStore.add(InspectorTest.ObjectStore.basicObject1);
 84 await objectStore.add(InspectorTest.ObjectStore.basicObject2);
 85 });
 86 });
 87
 88 testDeleteObject("WI.ObjectStore.prototype.deleteObject.KeyPathSetOnObjectWithoutAutoIncrement", {
 89 options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement"},
 90 tests: [
 91 {value: {KeyPathSetOnObjectWithoutAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 92 {value: {KeyPathSetOnObjectWithoutAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 93 ],
 94 });
 95
 96 testDeleteObject("WI.ObjectStore.prototype.deleteObject.KeyPathMissingOnObjectWithAutoIncrement", {
 97 options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement", autoIncrement: true},
 98 tests: [
 99 {value: InspectorTest.ObjectStore.basicObject1, expected: 1},
 100 {value: InspectorTest.ObjectStore.basicObject2, expected: 2},
 101 ],
 102 });
 103
 104 testDeleteObject("WI.ObjectStore.prototype.deleteObject.KeyPathSetOnObjectWithAutoIncrement", {
 105 options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement", autoIncrement: true},
 106 tests: [
 107 {value: {KeyPathSetOnObjectWithAutoIncrement: 42, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 108 {value: {KeyPathSetOnObjectWithAutoIncrement: 99, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 109 ],
 110 });
 111
 112 testDeleteObject("WI.ObjectStore.prototype.deleteObject.AutoIncrementWithoutKeyPath", {
 113 options: {autoIncrement: true},
 114 tests: [
 115 {value: InspectorTest.ObjectStore.basicObject1, expected: 1},
 116 {value: InspectorTest.ObjectStore.basicObject2, expected: 2},
 117 ],
 118 });
 119
 120 testDeleteObject("WI.ObjectStore.prototype.deleteObject.KeyPathSetOnObjectWithoutAutoIncrement.Sub", {
 121 options: {keyPath: "KeyPathSetOnObjectWithoutAutoIncrement.Sub"},
 122 tests: [
 123 {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 124 {value: {KeyPathSetOnObjectWithoutAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 125 ],
 126 });
 127
 128 testDeleteObject("WI.ObjectStore.prototype.deleteObject.KeyPathMissingOnObjectWithAutoIncrement.Sub", {
 129 options: {keyPath: "KeyPathMissingOnObjectWithAutoIncrement.Sub", autoIncrement: true},
 130 tests: [
 131 {value: InspectorTest.ObjectStore.basicObject1, expected: 1},
 132 {value: InspectorTest.ObjectStore.basicObject2, expected: 2},
 133 ],
 134 });
 135
 136 testDeleteObject("WI.ObjectStore.prototype.deleteObject.KeyPathSetOnObjectWithAutoIncrement.Sub", {
 137 options: {keyPath: "KeyPathSetOnObjectWithAutoIncrement.Sub", autoIncrement: true},
 138 tests: [
 139 {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 42}, ...InspectorTest.ObjectStore.basicObject1}, expected: 42},
 140 {value: {KeyPathSetOnObjectWithAutoIncrement: {Sub: 99}, ...InspectorTest.ObjectStore.basicObject2}, expected: 99},
 141 ],
 142 });
 143
 144 suite.runTestCasesAndFinish();
 145}
 146</script>
 147</head>
 148<body onload="runTest()">
 149 <p>Tests WI.ObjectStore.prototype.deleteObject.</p>
 150</body>
 151</html>

LayoutTests/inspector/unit-tests/objectStore/resources/objectStore-utilities.js

 1TestPage.registerInitializer(() => {
 2 let suite = null;
 3
 4 InspectorTest.ObjectStore = {};
 5
 6 InspectorTest.ObjectStore.TestObject = class TestObject {
 7 constructor(object) {
 8 this._object = object;
 9 }
 10 toJSON() {
 11 return this._object;
 12 }
 13 };
 14
 15 InspectorTest.ObjectStore.basicObject1 = {a: 1};
 16 InspectorTest.ObjectStore.basicObject2 = {b: 2};
 17
 18 InspectorTest.ObjectStore.createSuite = function(name) {
 19 suite = InspectorTest.createAsyncSuite(name);
 20 return suite;
 21 };
 22
 23 InspectorTest.ObjectStore.createObjectStore = function(options = {}) {
 24 WI.ObjectStore.__testObjectStore = new WI.ObjectStore("__testing", options);
 25 return WI.ObjectStore.__testObjectStore;
 26 };
 27
 28 InspectorTest.ObjectStore.add = async function(value, expected) {
 29 let result = await WI.ObjectStore.__testObjectStore.add(value);
 30 InspectorTest.assert(result === expected, `the key of the added item should be ${expected}, but is actually ${result}`);
 31
 32 await InspectorTest.ObjectStore.logValues("add: ");
 33 return result;
 34 };
 35
 36 InspectorTest.ObjectStore.addObject = async function(object, expected) {
 37 let result = await WI.ObjectStore.__testObjectStore.addObject(object);
 38 InspectorTest.assert(result === expected, `the key of the added item should be ${expected}, but is actually ${result}`);
 39
 40 let resolved = WI.ObjectStore.__testObjectStore._resolveKeyPath(object);
 41 InspectorTest.assert(resolved.value === expected, `the resolved keyPath on the object should equal ${expected}, but is actually ${resolved.value}`);
 42
 43 await InspectorTest.ObjectStore.logValues("addObject: ");
 44 return result;
 45 };
 46
 47 InspectorTest.ObjectStore.delete = async function(value) {
 48 let result = await WI.ObjectStore.__testObjectStore.delete(value);
 49 InspectorTest.assert(result === undefined, `delete shouldn't return anything`);
 50
 51 await InspectorTest.ObjectStore.logValues("delete: ");
 52 };
 53
 54 InspectorTest.ObjectStore.deleteObject = async function(object) {
 55 let resolved = WI.ObjectStore.__testObjectStore._resolveKeyPath(object);
 56 InspectorTest.assert(resolved.key in resolved.object, `the resolved keyPath on the object should exist`);
 57
 58 let result = await WI.ObjectStore.__testObjectStore.deleteObject(object);
 59 InspectorTest.assert(result === undefined, `deleteObject shouldn't return anything`);
 60
 61 await InspectorTest.ObjectStore.logValues("deleteObject: ");
 62 };
 63
 64 InspectorTest.ObjectStore.logValues = async function(prefix) {
 65 if (!WI.ObjectStore.__testObjectStore)
 66 return;
 67
 68 prefix = prefix || "";
 69 let results = await WI.ObjectStore.__testObjectStore.getAll();
 70 InspectorTest.log(prefix + JSON.stringify(results));
 71 };
 72
 73 InspectorTest.ObjectStore.wrapTest = function(name, func) {
 74 suite.addTestCase({
 75 name,
 76 async test() {
 77 InspectorTest.assert(!WI.ObjectStore.__testObjectStore, "__testObjectStore should be deleted after each test");
 78
 79 await func();
 80 await InspectorTest.ObjectStore.logValues();
 81
 82 delete WI.ObjectStore.__testObjectStore;
 83
 84 if (WI.ObjectStore._database) {
 85 WI.ObjectStore._database.close();
 86 WI.ObjectStore._database = null;
 87 }
 88
 89 indexedDB.deleteDatabase(WI.ObjectStore._databaseName);
 90 },
 91 });
 92 };
 93});