Web Inspector: Audit: create new IDL type for exposing special functionality in test...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Jan 2019 08:25:33 +0000 (08:25 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Jan 2019 08:25:33 +0000 (08:25 +0000)
commitd562eb9e5794567a982493fe16ec4716064f293a
treea0eabe073bd19070338b7122b6308a79d1d98445
parentbd26daa3f09fe361f92ff0da26e2eb20c6d9c452
Web Inspector: Audit: create new IDL type for exposing special functionality in test context
https://bugs.webkit.org/show_bug.cgi?id=193149
<rdar://problem/46801218>

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

Create a new `AuditAgent` (and various subclasses for different inspection targets)

* inspector/protocol/Audit.json: Added.
Add a `run` command that is a simpler version of `Runtime.evaluate`, except that it expects
a function string instead of an arbitrary JavaScript expression.
Add `setup` and `teardown` commands that create a JavaScript object that will be passed in
to the test as an argument. Keep this object alive so that tests can add to the object and
have later tests use what was added.

* inspector/agents/InspectorAuditAgent.h: Added.
* inspector/agents/InspectorAuditAgent.cpp: Added.
(Inspector::InspectorAuditAgent::InspectorAuditAgent):
(Inspector::InspectorAuditAgent::didCreateFrontendAndBackend):
(Inspector::InspectorAuditAgent::willDestroyFrontendAndBackend):
(Inspector::InspectorAuditAgent::setup):
(Inspector::InspectorAuditAgent::run):
(Inspector::InspectorAuditAgent::teardown):
(Inspector::InspectorAuditAgent::hasActiveAudit):
(Inspector::InspectorAuditAgent::populateAuditObject):

* inspector/agents/JSGlobalObjectAuditAgent.h: Added.
* inspector/agents/JSGlobalObjectAuditAgent.cpp: Added.
(Inspector::JSGlobalObjectAuditAgent::JSGlobalObjectAuditAgent):
(Inspector::JSGlobalObjectAuditAgent::injectedScriptForEval):

* inspector/JSGlobalObjectInspectorController.h:
* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::connectFrontend):
(Inspector::JSGlobalObjectInspectorController::jsAgentContext): Added.
(Inspector::JSGlobalObjectInspectorController::createLazyAgents): Added.

* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute): Added.
(Inspector::InjectedScript::arrayFromVector): Added.
Create a version of `evaluate` that accepts a list of values to be passed in as arguments
to the function that was created by the `eval` of the given `functionString`.

* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.execute): Added.
(InjectedScript.prototype.evaluate):
(InjectedScript.prototype.evaluateOnCallFrame):
(InjectedScript.prototype._evaluateAndWrap):
(InjectedScript.prototype._wrapAndSaveCall): Added.
(InjectedScript.prototype._wrapCall): Added.
(InjectedScript.prototype._evaluateOn):
Refactor the `eval` and `saveResult` logic to allow for more flexibility for other callers.

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources.make:
* JavaScriptCore.xcodeproj/project.pbxproj:
* Sources.txt:
* UnifiedSources-input.xcfilelist:

Source/WebCore:

Tests: inspector/audit/run.html
       inspector/audit/setup.html
       inspector/audit/teardown.html

Create a new `AuditAgent` (and various subclasses for different inspection targets), as well
as `InspectorAuditAccessibilityObject` and `InspectorAuditDOMObject` objects that will
be injected into the test function to allow for more advanced testing.

* inspector/InspectorAuditAccessibilityObject.idl: Added.
* inspector/InspectorAuditAccessibilityObject.h: Added.
(WebCore::InspectorAuditAccessibilityObject::create):
* inspector/InspectorAuditAccessibilityObject.cpp: Added.
(WebCore::InspectorAuditAccessibilityObject::InspectorAuditAccessibilityObject):

* inspector/InspectorAuditDOMObject.idl: Added.
* inspector/InspectorAuditDOMObject.h: Added.
(WebCore::InspectorAuditDOMObject::create):
* inspector/InspectorAuditDOMObject.cpp: Added.
(WebCore::InspectorAuditDOMObject::InspectorAuditDOMObject):

* inspector/agents/page/PageAuditAgent.h: Added.
* inspector/agents/page/PageAuditAgent.cpp: Added.
(WebCore::PageAuditAgent::PageAuditAgent):
(WebCore::PageAuditAgent::injectedScriptForEval):
(WebCore::PageAuditAgent::populateAuditObject):
(WebCore::PageAuditAgent::muteConsole):
(WebCore::PageAuditAgent::unmuteConsole):

* inspector/agents/worker/WorkerAuditAgent.h: Added.
* inspector/agents/worker/WorkerAuditAgent.cpp: Added.
(WebCore::WorkerAuditAgent::WorkerAuditAgent):
(WebCore::WorkerAuditAgent::injectedScriptForEval):

* inspector/InspectorController.cpp:
(WebCore::InspectorController::createLazyAgents):

* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::createLazyAgents):

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Sources.txt:
* UnifiedSources-input.xcfilelist:
* WebCore.xcodeproj/project.pbxproj:

Source/WebInspectorUI:

Add `AuditAgent` getters and plumbing.

* UserInterface/Protocol/Target.js:
(WI.Target.prototype.get AuditAgent): Added.

* UserInterface/Models/AuditTestCase.js:
(WI.AuditTestCase.prototype.async run):

* UserInterface/Controllers/AuditManager.js:
(WI.AuditManager.prototype.async start):

* .eslintrc:

LayoutTests:

* inspector/audit/resources/audit-utilities.js:
(TestPage.registerInitializer.InspectorTest.Audit.setupAudit): Added.
(TestPage.registerInitializer.InspectorTest.Audit.teardownAudit): Added.

* inspector/audit/run.html: Added.
* inspector/audit/run-expected.txt: Added.
* inspector/audit/setup.html: Added.
* inspector/audit/setup-expected.txt: Added.
* inspector/audit/teardown.html: Added.
* inspector/audit/teardown-expected.txt: Added.

* inspector/canvas/create-context-2d-expected.txt:
* inspector/canvas/create-context-bitmaprenderer-expected.txt:
* inspector/canvas/create-context-webgl-expected.txt:
* inspector/canvas/create-context-webgl2-expected.txt:
* inspector/canvas/create-context-webmetal-expected.txt:
* inspector/canvas/recording-2d-expected.txt:
* inspector/canvas/recording-webgl-expected.txt:
* inspector/canvas/recording-webgl-snapshots-expected.txt:
* inspector/model/remote-object-expected.txt:
* inspector/model/stack-trace-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239976 268f45cc-cd09-0410-ab3c-d52691b4dbfc
60 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/audit/resources/audit-utilities.js
LayoutTests/inspector/audit/run-expected.txt [new file with mode: 0644]
LayoutTests/inspector/audit/run.html [new file with mode: 0644]
LayoutTests/inspector/audit/setup-expected.txt [new file with mode: 0644]
LayoutTests/inspector/audit/setup.html [new file with mode: 0644]
LayoutTests/inspector/audit/teardown-expected.txt [new file with mode: 0644]
LayoutTests/inspector/audit/teardown.html [new file with mode: 0644]
LayoutTests/inspector/canvas/create-context-2d-expected.txt
LayoutTests/inspector/canvas/create-context-bitmaprenderer-expected.txt
LayoutTests/inspector/canvas/create-context-webgl-expected.txt
LayoutTests/inspector/canvas/create-context-webgl2-expected.txt
LayoutTests/inspector/canvas/create-context-webmetal-expected.txt
LayoutTests/inspector/canvas/recording-2d-expected.txt
LayoutTests/inspector/canvas/recording-webgl-expected.txt
LayoutTests/inspector/canvas/recording-webgl-snapshots-expected.txt
LayoutTests/inspector/model/remote-object-expected.txt
LayoutTests/inspector/model/stack-trace-expected.txt
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/DerivedSources-input.xcfilelist
Source/JavaScriptCore/DerivedSources.make
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/Sources.txt
Source/JavaScriptCore/UnifiedSources-input.xcfilelist
Source/JavaScriptCore/inspector/InjectedScript.cpp
Source/JavaScriptCore/inspector/InjectedScript.h
Source/JavaScriptCore/inspector/InjectedScriptSource.js
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h
Source/JavaScriptCore/inspector/agents/InspectorAuditAgent.cpp [new file with mode: 0644]
Source/JavaScriptCore/inspector/agents/InspectorAuditAgent.h [new file with mode: 0644]
Source/JavaScriptCore/inspector/agents/JSGlobalObjectAuditAgent.cpp [new file with mode: 0644]
Source/JavaScriptCore/inspector/agents/JSGlobalObjectAuditAgent.h [new file with mode: 0644]
Source/JavaScriptCore/inspector/protocol/Audit.json [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources-input.xcfilelist
Source/WebCore/DerivedSources-output.xcfilelist
Source/WebCore/DerivedSources.make
Source/WebCore/Sources.txt
Source/WebCore/UnifiedSources-input.xcfilelist
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/inspector/InspectorAuditAccessibilityObject.cpp [new file with mode: 0644]
Source/WebCore/inspector/InspectorAuditAccessibilityObject.h [new file with mode: 0644]
Source/WebCore/inspector/InspectorAuditAccessibilityObject.idl [new file with mode: 0644]
Source/WebCore/inspector/InspectorAuditDOMObject.cpp [new file with mode: 0644]
Source/WebCore/inspector/InspectorAuditDOMObject.h [new file with mode: 0644]
Source/WebCore/inspector/InspectorAuditDOMObject.idl [new file with mode: 0644]
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/WorkerInspectorController.cpp
Source/WebCore/inspector/agents/page/PageAuditAgent.cpp [new file with mode: 0644]
Source/WebCore/inspector/agents/page/PageAuditAgent.h [new file with mode: 0644]
Source/WebCore/inspector/agents/worker/WorkerAuditAgent.cpp [new file with mode: 0644]
Source/WebCore/inspector/agents/worker/WorkerAuditAgent.h [new file with mode: 0644]
Source/WebInspectorUI/.eslintrc
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js
Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js
Source/WebInspectorUI/UserInterface/Protocol/Target.js