Web Inspector: Audit: save imported audits across WebInspector sessions
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Nov 2018 01:18:07 +0000 (01:18 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Nov 2018 01:18:07 +0000 (01:18 +0000)
commit675f8c9376338b60f54eed54f7eac06bbc17707d
treeb35ab7e1f72b22be4f64fbf01335532b02417d4b
parent28fb1b25248664414cc7e28e699c26a476549ac9
Web Inspector: Audit: save imported audits across WebInspector sessions
https://bugs.webkit.org/show_bug.cgi?id=190858
<rdar://problem/45527625>

Reviewed by Brian Burg.

Source/WebInspectorUI:

* UserInterface/Base/ObjectStore.js: Added.
(WI.ObjectStore):
(WI.ObjectStore.supported):
(WI.ObjectStore._open):
(WI.ObjectStore.get _databaseName):
(WI.ObjectStore.prototype.associateObject):
(WI.ObjectStore.prototype.async getAll):
(WI.ObjectStore.prototype.async add):
(WI.ObjectStore.prototype.async addObject):
(WI.ObjectStore.prototype.async delete):
(WI.ObjectStore.prototype.async deleteObject):
(WI.ObjectStore.prototype._resolveKeyPath):
(WI.ObjectStore.prototype.async _operation.listener):
(WI.ObjectStore.prototype.async _operation):
Wrapper for a global `IndexedDB` instance for all of WebInspector (per level). Instances of
`WI.ObjectStore` are able to control a given `IDBObjectStore` using a promise-based API.

*NOTE*: due to the constraint that `IDBObjectStore`s are only able to be created when the
owner `IndexedDB` is "upgrade"d, all `WI.ObjectStore` must be declared before the database
is opened for the first time. Additionally, any time a new `WI.ObjectStore` is added, the
`version` needs to be incremented to ensure that the "upgrade" event fires.

To use any of the `*Object` functions, one must implement a `toJSON` on the object provided.
This is so that `WI.ObjectStore` is able to add the resulting identifier value to the owner
object while storing its `toJSON` value in the IndexedDB (e.g. for objects that have cycles).

* UserInterface/Controllers/AuditManager.js:
(WI.AuditManager.prototype.import):
(WI.AuditManager.prototype.loadStoredTests): Added.
(WI.AuditManager.prototype.removeTest): Added.
(WI.AuditManager.prototype._addTest):

* UserInterface/Views/AuditTabContentView.js:
(WI.AuditTabContentView.prototype.initialLayout): Added.
Attempt to load stored audits when the Audit tab is first shown (lazy-load).

* UserInterface/Views/AuditNavigationSidebarPanel.js:
(WI.AuditNavigationSidebarPanel.prototype.initialLayout):
(WI.AuditNavigationSidebarPanel.prototype._handleAuditTestRemoved): Added.

* UserInterface/Views/AuditTreeElement.js:
(WI.AuditTreeElement.prototype.ondelete):
Only allow top-level audits to be deleted, as that is what matches the `WI.ObjectStore`.

* UserInterface/Main.html:
* UserInterface/Test.html:

LayoutTests:

* inspector/unit-tests/objectStore/add-expected.txt: Added.
* inspector/unit-tests/objectStore/add.html: Added.
* inspector/unit-tests/objectStore/addObject-expected.txt: Added.
* inspector/unit-tests/objectStore/addObject.html: Added.
* inspector/unit-tests/objectStore/basic-expected.txt: Added.
* inspector/unit-tests/objectStore/basic.html: Added.
* inspector/unit-tests/objectStore/delete-expected.txt: Added.
* inspector/unit-tests/objectStore/delete.html: Added.
* inspector/unit-tests/objectStore/deleteObject-expected.txt: Added.
* inspector/unit-tests/objectStore/deleteObject.html: Added.
* inspector/unit-tests/objectStore/resources/objectStore-utilities.js: Added.
(TestPage.registerInitializer.InspectorTest.ObjectStore.TestObject):
(TestPage.registerInitializer.InspectorTest.ObjectStore.TestObject.prototype.toJSON):
(TestPage.registerInitializer.InspectorTest.ObjectStore.createSuite):
(TestPage.registerInitializer.InspectorTest.ObjectStore.createObjectStore):
(TestPage.registerInitializer.InspectorTest.ObjectStore.add):
(TestPage.registerInitializer.InspectorTest.ObjectStore.addObject):
(TestPage.registerInitializer.InspectorTest.ObjectStore.delete):
(TestPage.registerInitializer.InspectorTest.ObjectStore.deleteObject):
(TestPage.registerInitializer.InspectorTest.ObjectStore.logValues):
(TestPage.registerInitializer.InspectorTest.ObjectStore.wrapTest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237665 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/unit-tests/objectStore/add-expected.txt [new file with mode: 0644]
LayoutTests/inspector/unit-tests/objectStore/add.html [new file with mode: 0644]
LayoutTests/inspector/unit-tests/objectStore/addObject-expected.txt [new file with mode: 0644]
LayoutTests/inspector/unit-tests/objectStore/addObject.html [new file with mode: 0644]
LayoutTests/inspector/unit-tests/objectStore/basic-expected.txt [new file with mode: 0644]
LayoutTests/inspector/unit-tests/objectStore/basic.html [new file with mode: 0644]
LayoutTests/inspector/unit-tests/objectStore/delete-expected.txt [new file with mode: 0644]
LayoutTests/inspector/unit-tests/objectStore/delete.html [new file with mode: 0644]
LayoutTests/inspector/unit-tests/objectStore/deleteObject-expected.txt [new file with mode: 0644]
LayoutTests/inspector/unit-tests/objectStore/deleteObject.html [new file with mode: 0644]
LayoutTests/inspector/unit-tests/objectStore/resources/objectStore-utilities.js [new file with mode: 0644]
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/ObjectStore.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js
Source/WebInspectorUI/UserInterface/Main.html
Source/WebInspectorUI/UserInterface/Test.html
Source/WebInspectorUI/UserInterface/Views/AuditNavigationSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/AuditTabContentView.js
Source/WebInspectorUI/UserInterface/Views/AuditTreeElement.js