WebKit Bugzilla
Attachment 358347 Details for
Bug 193149
: Web Inspector: Audit: create new IDL type for exposing special functionality in test context
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193149-20190104132243.patch (text/plain), 91.19 KB, created by
Devin Rousso
on 2019-01-04 12:22:44 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2019-01-04 12:22:44 PST
Size:
91.19 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 94d4d6f959f8a2781a3da217869fc451cc72baa0..432e344f0e4a24cfa934a9af347b60fb0a0f7742 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,57 @@ >+2019-01-04 Devin Rousso <drousso@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ 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. >+ >+ * inspector/agents/InspectorAuditAgent.h: Added. >+ * inspector/agents/InspectorAuditAgent.cpp: Added. >+ (Inspector::InspectorAuditAgent::InspectorAuditAgent): >+ (Inspector::InspectorAuditAgent::didCreateFrontendAndBackend): >+ (Inspector::InspectorAuditAgent::willDestroyFrontendAndBackend): >+ (Inspector::InspectorAuditAgent::run): >+ (Inspector::InspectorAuditAgent::runArguments): >+ >+ * inspector/agents/JSGlobalObjectAuditAgent.h: Added. >+ * inspector/agents/JSGlobalObjectAuditAgent.cpp: Added. >+ (Inspector::JSGlobalObjectAuditAgent::JSGlobalObjectAuditAgent): >+ (Inspector::JSGlobalObjectAuditAgent::injectedScriptForEval): >+ >+ * inspector/JSGlobalObjectInspectorController.cpp: >+ (Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController): >+ >+ * inspector/InjectedScript.h: >+ * inspector/InjectedScript.cpp: >+ (Inspector::InjectedScript::execute): Added. >+ (Inspector::InjectedScript::arrayFromVector): Added. >+ Create a version of `evaluate` that accepts a list of arguemnts 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: >+ > 2019-01-02 Devin Rousso <webkit@devinrousso.com> > > Web Inspector: Implement `queryObjects` Command Line API >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index dc1f8d982cc8394940734728052ad8004df6fa69..ea36f2d68737336eaaeb1a33d7b2cbf2f5fdca1d 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,50 @@ >+2019-01-04 Devin Rousso <drousso@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ Test: inspector/audit/run.html >+ >+ Create a new `AuditAgent` (and various subclasses for different inspection targets), as well >+ as a `InspectorAuditUtilities` object that will be injected into the test function to allow >+ for more advanced testing. >+ >+ * inspector/InspectorAuditUtilities.h: Added. >+ (WebCore::InspectorAuditUtilities::create): >+ * inspector/InspectorAuditUtilities.cpp: Added. >+ (WebCore::InspectorAuditUtilities::InspectorAuditUtilities): >+ * inspector/InspectorAuditUtilities.idl: Added. >+ >+ * inspector/agents/page/PageAuditAgent.h: Added. >+ * inspector/agents/page/PageAuditAgent.cpp: Added. >+ (WebCore::PageAuditAgent::PageAuditAgent): >+ (WebCore::PageAuditAgent::injectedScriptForEval): >+ (WebCore::PageAuditAgent::runArguments): >+ (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::InspectorController): >+ >+ * inspector/WorkerInspectorController.cpp: >+ (WebCore::WorkerInspectorController::WorkerInspectorController): >+ >+ * CMakeLists.txt: >+ * DerivedSources-input.xcfilelist: >+ * DerivedSources-output.xcfilelist: >+ * DerivedSources.make: >+ * Sources.txt: >+ * UnifiedSources-input.xcfilelist: >+ * WebCore.xcodeproj/project.pbxproj: >+ > 2019-01-02 Simon Fraser <simon.fraser@apple.com> > > REGRESSION (r239306): Don't disable font smoothing in transparent layers on macOS Mojave and later >diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index 1ea968ffeb4a36414f735d51088699e1e9886097..aa300c2669503cbbbbbe60c21215bda061616332 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,36 @@ >+2019-01-04 Devin Rousso <drousso@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ Add `AuditAgent` getters and plumbing. >+ >+ * UserInterface/Protocol/Target.js: >+ (WI.Target): >+ (WI.Target.prototype.get AuditAgent): Added. >+ >+ * UserInterface/Models/AuditTestCase.js: >+ (WI.AuditTestCase.prototype.async run): >+ >+ * UserInterface/Base/Main.js: >+ (WI.loaded): >+ * UserInterface/Test/Test.js: >+ (WI.loaded): >+ * UserInterface/Controllers/DebuggerManager.js: >+ (WI.DebuggerManager): >+ (WI.DebuggerManager.prototype._handleAuditManagerTestScheduled): Added. >+ (WI.DebuggerManager.prototype._handleAuditManagerTestCompleted): Added. >+ * UserInterface/Views/DebuggerSidebarPanel.js: >+ (WI.DebuggerSidebarPanel.prototype._handleAuditManagerTestScheduled): Added. >+ (WI.DebuggerSidebarPanel.prototype._handleAuditManagerTestCompleted): Added. >+ (WI.DebuggerSidebarPanel.prototype._updateBreakpointsDisabledBanner): >+ Drive-by: ensure that breakpoints are disabled while running an Audit. >+ >+ * .eslintrc: >+ > 2019-01-02 Nikita Vasilyev <nvasilyev@apple.com> > > Web Inspector: Styles: selection lost when inspector is blurred >diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt >index 79cab0b978bb9c8ebcdcc64ce2c93b09c34953c5..555ac6cabf8f6ed202394ea58c24b03bd512885f 100644 >--- a/Source/JavaScriptCore/CMakeLists.txt >+++ b/Source/JavaScriptCore/CMakeLists.txt >@@ -634,6 +634,7 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS > inspector/ScriptDebugServer.h > > inspector/agents/InspectorAgent.h >+ inspector/agents/InspectorAuditAgent.h > inspector/agents/InspectorConsoleAgent.h > inspector/agents/InspectorDebuggerAgent.h > inspector/agents/InspectorHeapAgent.h >@@ -1063,6 +1064,7 @@ set(JavaScriptCore_INSPECTOR_PROTOCOL_SCRIPTS > > set(JavaScriptCore_INSPECTOR_DOMAINS > ${JAVASCRIPTCORE_DIR}/inspector/protocol/ApplicationCache.json >+ ${JAVASCRIPTCORE_DIR}/inspector/protocol/Audit.json > ${JAVASCRIPTCORE_DIR}/inspector/protocol/CSS.json > ${JAVASCRIPTCORE_DIR}/inspector/protocol/Canvas.json > ${JAVASCRIPTCORE_DIR}/inspector/protocol/Console.json >diff --git a/Source/JavaScriptCore/DerivedSources-input.xcfilelist b/Source/JavaScriptCore/DerivedSources-input.xcfilelist >index 583b1935c547e948e1b8ac78e23e4727af6dda79..20e86fdf50858e604e96e5099563cebb22388184 100644 >--- a/Source/JavaScriptCore/DerivedSources-input.xcfilelist >+++ b/Source/JavaScriptCore/DerivedSources-input.xcfilelist >@@ -76,6 +76,7 @@ $(PROJECT_DIR)/generator/Type.rb > $(PROJECT_DIR)/generator/main.rb > $(PROJECT_DIR)/inspector/InjectedScriptSource.js > $(PROJECT_DIR)/inspector/protocol/ApplicationCache.json >+$(PROJECT_DIR)/inspector/protocol/Audit.json > $(PROJECT_DIR)/inspector/protocol/CSS.json > $(PROJECT_DIR)/inspector/protocol/Canvas.json > $(PROJECT_DIR)/inspector/protocol/Console.json >diff --git a/Source/JavaScriptCore/DerivedSources.make b/Source/JavaScriptCore/DerivedSources.make >index f8435aec78c28d2ce4dafc5ee241771aa6706af8..47d25172e8e5384503ed5c55a8a4d8a2868319b2 100644 >--- a/Source/JavaScriptCore/DerivedSources.make >+++ b/Source/JavaScriptCore/DerivedSources.make >@@ -227,6 +227,7 @@ $(BYTECODE_FILES_PATTERNS): $(wildcard $(JavaScriptCore)/generator/*.rb) $(JavaS > > INSPECTOR_DOMAINS := \ > $(JavaScriptCore)/inspector/protocol/ApplicationCache.json \ >+ $(JavaScriptCore)/inspector/protocol/Audit.json \ > $(JavaScriptCore)/inspector/protocol/CSS.json \ > $(JavaScriptCore)/inspector/protocol/Canvas.json \ > $(JavaScriptCore)/inspector/protocol/Console.json \ >diff --git a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >index f3ef1c42380b3cef2f00fac658e92e9d6e799f03..b641da4b5b1694a86374740b48187ec8f64be165 100644 >--- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >+++ b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >@@ -1243,6 +1243,8 @@ > 8BC064961E1D845C00B2B8CA /* AsyncIteratorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BC064941E1D828B00B2B8CA /* AsyncIteratorPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 90213E3E123A40C200D422F3 /* MemoryStatistics.h in Headers */ = {isa = PBXBuildFile; fileRef = 90213E3C123A40C200D422F3 /* MemoryStatistics.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 9064337DD4B0402BAF34A592 /* JSScriptFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BA93C9590484C5BAD9316EA /* JSScriptFetcher.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 91278D5521DEB82600B57184 /* InspectorAuditAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 91278D5321DEB82500B57184 /* InspectorAuditAgent.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 91278D5821DEDA9600B57184 /* JSGlobalObjectAuditAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 91278D5621DEDA9400B57184 /* JSGlobalObjectAuditAgent.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 93052C350FB792190048FDC3 /* ParserArena.h in Headers */ = {isa = PBXBuildFile; fileRef = 93052C330FB792190048FDC3 /* ParserArena.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 932F5BD30822A1C700736975 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6560A4CF04B3B3E7008AE952 /* CoreFoundation.framework */; }; > 932F5BD60822A1C700736975 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 51F0EC0705C86C9A00E6DF1B /* libobjc.dylib */; }; >@@ -3932,6 +3934,10 @@ > 8BC064951E1D838B00B2B8CA /* AsyncIteratorPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = AsyncIteratorPrototype.js; sourceTree = "<group>"; }; > 90213E3B123A40C200D422F3 /* MemoryStatistics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryStatistics.cpp; sourceTree = "<group>"; }; > 90213E3C123A40C200D422F3 /* MemoryStatistics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryStatistics.h; sourceTree = "<group>"; }; >+ 91278D5221DEB82400B57184 /* InspectorAuditAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorAuditAgent.cpp; sourceTree = "<group>"; }; >+ 91278D5321DEB82500B57184 /* InspectorAuditAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorAuditAgent.h; sourceTree = "<group>"; }; >+ 91278D5621DEDA9400B57184 /* JSGlobalObjectAuditAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObjectAuditAgent.h; sourceTree = "<group>"; }; >+ 91278D5721DEDA9500B57184 /* JSGlobalObjectAuditAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGlobalObjectAuditAgent.cpp; sourceTree = "<group>"; }; > 93052C320FB792190048FDC3 /* ParserArena.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParserArena.cpp; sourceTree = "<group>"; }; > 93052C330FB792190048FDC3 /* ParserArena.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParserArena.h; sourceTree = "<group>"; }; > 930DAD030FB1EB1A0082D205 /* NodeConstructors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeConstructors.h; sourceTree = "<group>"; }; >@@ -7936,6 +7942,8 @@ > children = ( > A5CEEE12187F3BAD00E55C99 /* InspectorAgent.cpp */, > A5CEEE13187F3BAD00E55C99 /* InspectorAgent.h */, >+ 91278D5221DEB82400B57184 /* InspectorAuditAgent.cpp */, >+ 91278D5321DEB82500B57184 /* InspectorAuditAgent.h */, > A5FD007F189B191A00633231 /* InspectorConsoleAgent.cpp */, > A5FD0080189B191A00633231 /* InspectorConsoleAgent.h */, > A57D23E31890CEBF0031C7FA /* InspectorDebuggerAgent.cpp */, >@@ -7948,6 +7956,8 @@ > A55165D11BDEFDBD003B75C1 /* InspectorScriptProfilerAgent.h */, > A555FF3C2159D41E00FCD826 /* InspectorTargetAgent.cpp */, > A555FF3D2159D41E00FCD826 /* InspectorTargetAgent.h */, >+ 91278D5721DEDA9500B57184 /* JSGlobalObjectAuditAgent.cpp */, >+ 91278D5621DEDA9400B57184 /* JSGlobalObjectAuditAgent.h */, > A57D23E71891B0770031C7FA /* JSGlobalObjectDebuggerAgent.cpp */, > A57D23E81891B0770031C7FA /* JSGlobalObjectDebuggerAgent.h */, > A50E4B5F18809DD50068A46D /* JSGlobalObjectRuntimeAgent.cpp */, >@@ -9074,6 +9084,7 @@ > A593CF7F1840362C00BFCE27 /* InspectorAgentBase.h in Headers */, > A593CF87184038CA00BFCE27 /* InspectorAgentRegistry.h in Headers */, > A5EA710E19F6DF810098F5EC /* InspectorAlternateBackendDispatchers.h in Headers */, >+ 91278D5521DEB82600B57184 /* InspectorAuditAgent.h in Headers */, > 996231E918D1804200C03FDA /* InspectorBackendCommands.js in Headers */, > A593CF7D1840360300BFCE27 /* InspectorBackendDispatcher.h in Headers */, > A532438818568335002ED692 /* InspectorBackendDispatchers.h in Headers */, >@@ -9231,6 +9242,7 @@ > 797E07AA1B8FCFB9008400BA /* JSGlobalLexicalEnvironment.h in Headers */, > BC18C4210E16F5CD00B34460 /* JSGlobalObject.h in Headers */, > 996B731D1BDA08EF00331B84 /* JSGlobalObject.lut.h in Headers */, >+ 91278D5821DEDA9600B57184 /* JSGlobalObjectAuditAgent.h in Headers */, > A5C3A1A618C0490200C9593A /* JSGlobalObjectConsoleClient.h in Headers */, > A59455931824744700CC3843 /* JSGlobalObjectDebuggable.h in Headers */, > A57D23EA1891B0770031C7FA /* JSGlobalObjectDebuggerAgent.h in Headers */, >diff --git a/Source/JavaScriptCore/Sources.txt b/Source/JavaScriptCore/Sources.txt >index cba4c4ba6004f930d5ca8563310a6243e36449e5..39c996a387fea91e0ef9580a819684629daf7f23 100644 >--- a/Source/JavaScriptCore/Sources.txt >+++ b/Source/JavaScriptCore/Sources.txt >@@ -577,12 +577,14 @@ inspector/InspectorFrontendDispatchers.cpp > inspector/InspectorProtocolObjects.cpp > > inspector/agents/InspectorAgent.cpp >+inspector/agents/InspectorAuditAgent.cpp > inspector/agents/InspectorConsoleAgent.cpp > inspector/agents/InspectorDebuggerAgent.cpp > inspector/agents/InspectorHeapAgent.cpp > inspector/agents/InspectorRuntimeAgent.cpp > inspector/agents/InspectorScriptProfilerAgent.cpp > inspector/agents/InspectorTargetAgent.cpp >+inspector/agents/JSGlobalObjectAuditAgent.cpp > inspector/agents/JSGlobalObjectDebuggerAgent.cpp > inspector/agents/JSGlobalObjectRuntimeAgent.cpp > >diff --git a/Source/JavaScriptCore/UnifiedSources-input.xcfilelist b/Source/JavaScriptCore/UnifiedSources-input.xcfilelist >index a5a88cb9b397b7baa3bd19609e473acd3d072baa..e630d63d320f73f1615a78d464f55af81cea56ed 100644 >--- a/Source/JavaScriptCore/UnifiedSources-input.xcfilelist >+++ b/Source/JavaScriptCore/UnifiedSources-input.xcfilelist >@@ -544,12 +544,14 @@ $(SRCROOT)/inspector/ScriptCallStack.cpp > $(SRCROOT)/inspector/ScriptCallStackFactory.cpp > $(SRCROOT)/inspector/ScriptDebugServer.cpp > $(SRCROOT)/inspector/agents/InspectorAgent.cpp >+$(SRCROOT)/inspector/agents/InspectorAuditAgent.cpp > $(SRCROOT)/inspector/agents/InspectorConsoleAgent.cpp > $(SRCROOT)/inspector/agents/InspectorDebuggerAgent.cpp > $(SRCROOT)/inspector/agents/InspectorHeapAgent.cpp > $(SRCROOT)/inspector/agents/InspectorRuntimeAgent.cpp > $(SRCROOT)/inspector/agents/InspectorScriptProfilerAgent.cpp > $(SRCROOT)/inspector/agents/InspectorTargetAgent.cpp >+$(SRCROOT)/inspector/agents/JSGlobalObjectAuditAgent.cpp > $(SRCROOT)/inspector/agents/JSGlobalObjectDebuggerAgent.cpp > $(SRCROOT)/inspector/agents/JSGlobalObjectRuntimeAgent.cpp > $(SRCROOT)/inspector/remote/RemoteAutomationTarget.cpp >diff --git a/Source/JavaScriptCore/inspector/InjectedScript.cpp b/Source/JavaScriptCore/inspector/InjectedScript.cpp >index 0a5a6d7648141f4a916fd5d68a801771401713a4..942333154022556f2e262e037379fe45063611df 100644 >--- a/Source/JavaScriptCore/inspector/InjectedScript.cpp >+++ b/Source/JavaScriptCore/inspector/InjectedScript.cpp >@@ -33,9 +33,11 @@ > #include "InjectedScript.h" > > #include "JSCInlines.h" >+#include "JSLock.h" > #include "ScriptFunctionCall.h" > #include "ScriptObject.h" > #include <wtf/JSONValues.h> >+#include <wtf/Vector.h> > #include <wtf/text/WTFString.h> > > namespace Inspector { >@@ -54,6 +56,19 @@ InjectedScript::~InjectedScript() > { > } > >+void InjectedScript::execute(ErrorString& errorString, const String& functionString, ExecuteOptions&& options, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex) >+{ >+ Deprecated::ScriptFunctionCall function(injectedScriptObject(), "execute"_s, inspectorEnvironment()->functionCallHandler()); >+ function.appendArgument(functionString); >+ function.appendArgument(options.objectGroup); >+ function.appendArgument(options.includeCommandLineAPI); >+ function.appendArgument(options.returnByValue); >+ function.appendArgument(options.generatePreview); >+ function.appendArgument(options.saveResult); >+ function.appendArgument(arrayFromVector(WTFMove(options.args))); >+ makeEvalCall(errorString, function, result, wasThrown, savedResultIndex); >+} >+ > void InjectedScript::evaluate(ErrorString& errorString, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex) > { > Deprecated::ScriptFunctionCall function(injectedScriptObject(), "evaluate"_s, inspectorEnvironment()->functionCallHandler()); >@@ -386,5 +401,23 @@ void InjectedScript::releaseObjectGroup(const String& objectGroup) > ASSERT(!hadException); > } > >+JSC::JSValue InjectedScript::arrayFromVector(Vector<JSC::JSValue>&& vector) >+{ >+ JSC::ExecState* execState = scriptState(); >+ if (!execState) >+ return JSC::jsUndefined(); >+ >+ JSC::JSLockHolder lock(execState); >+ >+ JSC::JSArray* array = JSC::constructEmptyArray(execState, nullptr); >+ if (!array) >+ return JSC::jsUndefined(); >+ >+ for (auto& item : vector) >+ array->putDirectIndex(execState, array->length(), item); >+ >+ return array; >+} >+ > } // namespace Inspector > >diff --git a/Source/JavaScriptCore/inspector/InjectedScript.h b/Source/JavaScriptCore/inspector/InjectedScript.h >index f2ba84231d458b521ee842a3672eec0b2873e146..a8db2d2819101d9e5d4e2323182e4a9e93ae2286 100644 >--- a/Source/JavaScriptCore/inspector/InjectedScript.h >+++ b/Source/JavaScriptCore/inspector/InjectedScript.h >@@ -51,6 +51,16 @@ public: > InjectedScript(Deprecated::ScriptObject, InspectorEnvironment*); > virtual ~InjectedScript(); > >+ struct ExecuteOptions { >+ String objectGroup; >+ bool includeCommandLineAPI { false }; >+ bool returnByValue { false }; >+ bool generatePreview { false }; >+ bool saveResult { false }; >+ Vector<JSC::JSValue> args; >+ }; >+ void execute(ErrorString&, const String& functionString, ExecuteOptions&&, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex); >+ > void evaluate(ErrorString&, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex); > void awaitPromise(const String& promiseObjectId, bool returnByValue, bool generatePreview, bool saveResult, AsyncCallCallback&&); > void evaluateOnCallFrame(ErrorString&, JSC::JSValue callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex); >@@ -79,6 +89,8 @@ public: > void releaseObjectGroup(const String& objectGroup); > > private: >+ JSC::JSValue arrayFromVector(Vector<JSC::JSValue>&&); >+ > friend class InjectedScriptModule; > }; > >diff --git a/Source/JavaScriptCore/inspector/InjectedScriptSource.js b/Source/JavaScriptCore/inspector/InjectedScriptSource.js >index 01c1abeb3e540b91af5e3b3ddbf19b3d8e5acd9a..813e9dc8f5d32fa119087f25f8251656c1e87ae8 100644 >--- a/Source/JavaScriptCore/inspector/InjectedScriptSource.js >+++ b/Source/JavaScriptCore/inspector/InjectedScriptSource.js >@@ -103,9 +103,18 @@ let InjectedScript = class InjectedScript > > // InjectedScript C++ API > >- evaluate(expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview, saveResult) >+ execute(functionString, objectGroup, includeCommandLineAPI, returnByValue, generatePreview, saveResult, args) > { >- return this._evaluateAndWrap(InjectedScriptHost.evaluateWithScopeExtension, InjectedScriptHost, expression, objectGroup, false, injectCommandLineAPI, returnByValue, generatePreview, saveResult); >+ return this._wrapAndSaveCall(objectGroup, returnByValue, generatePreview, saveResult, () => { >+ const isEvalOnCallFrame = false; >+ return this._evaluateOn(InjectedScriptHost.evaluateWithScopeExtension, InjectedScriptHost, functionString, isEvalOnCallFrame, includeCommandLineAPI).apply(undefined, args); >+ }); >+ } >+ >+ evaluate(expression, objectGroup, includeCommandLineAPI, returnByValue, generatePreview, saveResult) >+ { >+ const isEvalOnCallFrame = false; >+ return this._evaluateAndWrap(InjectedScriptHost.evaluateWithScopeExtension, InjectedScriptHost, expression, objectGroup, isEvalOnCallFrame, includeCommandLineAPI, returnByValue, generatePreview, saveResult); > } > > awaitPromise(promiseObjectId, returnByValue, generatePreview, saveResult, callback) >@@ -145,12 +154,13 @@ let InjectedScript = class InjectedScript > promiseObject.then(resolve, reject); > } > >- evaluateOnCallFrame(topCallFrame, callFrameId, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview, saveResult) >+ evaluateOnCallFrame(topCallFrame, callFrameId, expression, objectGroup, includeCommandLineAPI, returnByValue, generatePreview, saveResult) > { > let callFrame = this._callFrameForId(topCallFrame, callFrameId); > if (!callFrame) > return "Could not find call frame with given id"; >- return this._evaluateAndWrap(callFrame.evaluateWithScopeExtension, callFrame, expression, objectGroup, true, injectCommandLineAPI, returnByValue, generatePreview, saveResult); >+ const isEvalOnCallFrame = true; >+ return this._evaluateAndWrap(callFrame.evaluateWithScopeExtension, callFrame, expression, objectGroup, isEvalOnCallFrame, includeCommandLineAPI, returnByValue, generatePreview, saveResult); > } > > callFunctionOn(objectId, expression, args, returnByValue, generatePreview) >@@ -501,14 +511,31 @@ let InjectedScript = class InjectedScript > }; > } > >- _evaluateAndWrap(evalFunction, object, expression, objectGroup, isEvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview, saveResult) >+ _evaluateAndWrap(evalFunction, object, expression, objectGroup, isEvalOnCallFrame, includeCommandLineAPI, returnByValue, generatePreview, saveResult) >+ { >+ return this._wrapAndSaveCall(objectGroup, returnByValue, generatePreview, saveResult, () => { >+ return this._evaluateOn(evalFunction, object, expression, isEvalOnCallFrame, includeCommandLineAPI); >+ }); >+ } >+ >+ _wrapAndSaveCall(objectGroup, returnByValue, generatePreview, saveResult, func) >+ { >+ return this._wrapCall(objectGroup, returnByValue, generatePreview, saveResult, () => { >+ let result = func(); >+ if (saveResult) >+ this._saveResult(result); >+ return result; >+ }); >+ } >+ >+ _wrapCall(objectGroup, returnByValue, generatePreview, saveResult, func) > { > try { > this._savedResultIndex = 0; > > let returnObject = { > wasThrown: false, >- result: RemoteObject.create(this._evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI, saveResult), objectGroup, returnByValue, generatePreview) >+ result: RemoteObject.create(func(), objectGroup, returnByValue, generatePreview) > }; > > if (saveResult && this._savedResultIndex) >@@ -520,20 +547,17 @@ let InjectedScript = class InjectedScript > } > } > >- _evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI, saveResult) >+ _evaluateOn(evalFunction, object, expression, isEvalOnCallFrame, includeCommandLineAPI) > { > let commandLineAPI = null; >- if (injectCommandLineAPI) { >+ if (includeCommandLineAPI) { > if (this.CommandLineAPI) > commandLineAPI = new this.CommandLineAPI(this._commandLineAPIImpl, isEvalOnCallFrame ? object : null); > else > commandLineAPI = new BasicCommandLineAPI(isEvalOnCallFrame ? object : null); > } > >- let result = evalFunction.call(object, expression, commandLineAPI); >- if (saveResult) >- this._saveResult(result); >- return result; >+ return evalFunction.call(object, expression, commandLineAPI); > } > > _callFrameForId(topCallFrame, callFrameId) >diff --git a/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp b/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp >index ad45f6f5303ca8dc41ad776a9fc7c8457548d5a1..d80214f814d0fbe47318f8560277dde50850bd0f 100644 >--- a/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp >+++ b/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp >@@ -42,6 +42,7 @@ > #include "InspectorScriptProfilerAgent.h" > #include "JSCInlines.h" > #include "JSGlobalObject.h" >+#include "JSGlobalObjectAuditAgent.h" > #include "JSGlobalObjectConsoleClient.h" > #include "JSGlobalObjectDebuggerAgent.h" > #include "JSGlobalObjectRuntimeAgent.h" >@@ -86,6 +87,7 @@ JSGlobalObjectInspectorController::JSGlobalObjectInspectorController(JSGlobalObj > auto consoleAgent = std::make_unique<InspectorConsoleAgent>(context, heapAgent.get()); > auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(context, consoleAgent.get()); > auto scriptProfilerAgent = std::make_unique<InspectorScriptProfilerAgent>(context); >+ auto auditAgent = std::make_unique<JSGlobalObjectAuditAgent>(context); > > m_inspectorAgent = inspectorAgent.get(); > m_debuggerAgent = debuggerAgent.get(); >@@ -98,6 +100,7 @@ JSGlobalObjectInspectorController::JSGlobalObjectInspectorController(JSGlobalObj > m_agents.append(WTFMove(debuggerAgent)); > m_agents.append(WTFMove(heapAgent)); > m_agents.append(WTFMove(scriptProfilerAgent)); >+ m_agents.append(WTFMove(auditAgent)); > > m_executionStopwatch->start(); > } >diff --git a/Source/JavaScriptCore/inspector/agents/InspectorAuditAgent.cpp b/Source/JavaScriptCore/inspector/agents/InspectorAuditAgent.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..813fea64063da59733e2efc00a803946f337319f >--- /dev/null >+++ b/Source/JavaScriptCore/inspector/agents/InspectorAuditAgent.cpp >@@ -0,0 +1,101 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "InspectorAuditAgent.h" >+ >+#include "InjectedScript.h" >+#include "InjectedScriptManager.h" >+#include "ScriptDebugServer.h" >+#include <wtf/RefPtr.h> >+#include <wtf/Vector.h> >+#include <wtf/text/StringBuilder.h> >+#include <wtf/text/WTFString.h> >+ >+namespace Inspector { >+ >+using namespace JSC; >+ >+InspectorAuditAgent::InspectorAuditAgent(AgentContext& context) >+ : InspectorAgentBase("Audit"_s) >+ , m_backendDispatcher(AuditBackendDispatcher::create(context.backendDispatcher, this)) >+ , m_injectedScriptManager(context.injectedScriptManager) >+ , m_scriptDebugServer(context.environment.scriptDebugServer()) >+{ >+} >+ >+void InspectorAuditAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) >+{ >+} >+ >+void InspectorAuditAgent::willDestroyFrontendAndBackend(DisconnectReason) >+{ >+} >+ >+void InspectorAuditAgent::run(ErrorString& errorString, const String& test, const int* executionContextId, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown) >+{ >+ InjectedScript injectedScript = injectedScriptForEval(errorString, executionContextId); >+ if (injectedScript.hasNoValue()) >+ return; >+ >+ auto arguments = runArguments(executionContextId); >+ >+ StringBuilder argumentStringBuilder; >+ Vector<JSC::JSValue> argumentValues; >+ for (size_t i = 0; i < arguments.size(); ++i) { >+ if (i) >+ argumentStringBuilder.appendLiteral(", "); >+ argumentStringBuilder.append(arguments[i].first); >+ >+ argumentValues.append(arguments[i].second); >+ } >+ String argumentsString = argumentStringBuilder.toString(); >+ >+ String functionString = makeString("(function(", argumentsString, ") { \"use strict\"; return eval(", test, ")(); })"); >+ >+ InjectedScript::ExecuteOptions options; >+ options.objectGroup = "audit"_s; >+ options.includeCommandLineAPI = true; >+ options.args = WTFMove(argumentValues); >+ >+ Optional<int> savedResultIndex; >+ >+ ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = m_scriptDebugServer.pauseOnExceptionsState(); >+ >+ m_scriptDebugServer.setPauseOnExceptionsState(ScriptDebugServer::DontPauseOnExceptions); >+ muteConsole(); >+ >+ injectedScript.execute(errorString, functionString, WTFMove(options), result, wasThrown, savedResultIndex); >+ >+ unmuteConsole(); >+ m_scriptDebugServer.setPauseOnExceptionsState(previousPauseOnExceptionsState); >+} >+ >+Vector<std::pair<String, JSC::JSValue>> InspectorAuditAgent::runArguments(const int* /* executionContextId */) >+{ >+ return { }; >+} >+ >+} // namespace Inspector >diff --git a/Source/JavaScriptCore/inspector/agents/InspectorAuditAgent.h b/Source/JavaScriptCore/inspector/agents/InspectorAuditAgent.h >new file mode 100644 >index 0000000000000000000000000000000000000000..bc1e340b7d946f294a7f2a47b6fe176b9aeccb61 >--- /dev/null >+++ b/Source/JavaScriptCore/inspector/agents/InspectorAuditAgent.h >@@ -0,0 +1,71 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "InspectorAgentBase.h" >+#include "InspectorBackendDispatchers.h" >+#include "JSCInlines.h" >+#include <wtf/FastMalloc.h> >+#include <wtf/Forward.h> >+#include <wtf/Noncopyable.h> >+ >+namespace Inspector { >+ >+class InjectedScript; >+class InjectedScriptManager; >+class ScriptDebugServer; >+typedef String ErrorString; >+ >+class JS_EXPORT_PRIVATE InspectorAuditAgent : public InspectorAgentBase, public AuditBackendDispatcherHandler { >+ WTF_MAKE_NONCOPYABLE(InspectorAuditAgent); >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ virtual ~InspectorAuditAgent() = default; >+ >+ void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) override; >+ void willDestroyFrontendAndBackend(DisconnectReason) override; >+ >+ void run(ErrorString&, const String& test, const int* executionContextId, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown) final; >+ >+protected: >+ explicit InspectorAuditAgent(AgentContext&); >+ >+ InjectedScriptManager& injectedScriptManager() { return m_injectedScriptManager; } >+ >+ virtual InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) = 0; >+ >+ virtual Vector<std::pair<String, JSC::JSValue>> runArguments(const int* executionContextId); >+ >+ virtual void muteConsole() { }; >+ virtual void unmuteConsole() { }; >+ >+private: >+ RefPtr<AuditBackendDispatcher> m_backendDispatcher; >+ InjectedScriptManager& m_injectedScriptManager; >+ ScriptDebugServer& m_scriptDebugServer; >+}; >+ >+} // namespace Inspector >diff --git a/Source/JavaScriptCore/inspector/agents/JSGlobalObjectAuditAgent.cpp b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectAuditAgent.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..86e767ba0daff17f532d075daf655c7dcd613d58 >--- /dev/null >+++ b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectAuditAgent.cpp >@@ -0,0 +1,62 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "JSGlobalObjectAuditAgent.h" >+ >+#include "InjectedScript.h" >+#include "InjectedScriptManager.h" >+#include "JSCInlines.h" >+#include "JSGlobalObject.h" >+#include <wtf/Ref.h> >+#include <wtf/RefPtr.h> >+#include <wtf/text/WTFString.h> >+ >+using namespace JSC; >+ >+namespace Inspector { >+ >+JSGlobalObjectAuditAgent::JSGlobalObjectAuditAgent(JSAgentContext& context) >+ : InspectorAuditAgent(context) >+ , m_globalObject(context.inspectedGlobalObject) >+{ >+} >+ >+InjectedScript JSGlobalObjectAuditAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId) >+{ >+ if (executionContextId) { >+ errorString = "Execution context id is not supported for JSContexts as there is only one execution context."_s; >+ return InjectedScript(); >+ } >+ >+ JSC::ExecState* scriptState = m_globalObject.globalExec(); >+ InjectedScript injectedScript = injectedScriptManager().injectedScriptFor(scriptState); >+ if (injectedScript.hasNoValue()) >+ errorString = "Internal error: main world execution context not found."_s; >+ >+ return injectedScript; >+} >+ >+} // namespace Inspector >diff --git a/Source/JavaScriptCore/inspector/agents/JSGlobalObjectAuditAgent.h b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectAuditAgent.h >new file mode 100644 >index 0000000000000000000000000000000000000000..c1cad323690d7bab6e2f56019b4eba8197b4481c >--- /dev/null >+++ b/Source/JavaScriptCore/inspector/agents/JSGlobalObjectAuditAgent.h >@@ -0,0 +1,48 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "InspectorAuditAgent.h" >+ >+namespace JSC { >+class JSGlobalObject; >+} >+ >+namespace Inspector { >+ >+class JSGlobalObjectAuditAgent final : public InspectorAuditAgent { >+ WTF_MAKE_NONCOPYABLE(JSGlobalObjectAuditAgent); >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ explicit JSGlobalObjectAuditAgent(JSAgentContext&); >+ >+private: >+ InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override; >+ >+ JSC::JSGlobalObject& m_globalObject; >+}; >+ >+} // namespace Inspector >diff --git a/Source/JavaScriptCore/inspector/protocol/Audit.json b/Source/JavaScriptCore/inspector/protocol/Audit.json >new file mode 100644 >index 0000000000000000000000000000000000000000..8175a7dd2fcee52035f4a9481ba69174f208cc78 >--- /dev/null >+++ b/Source/JavaScriptCore/inspector/protocol/Audit.json >@@ -0,0 +1,18 @@ >+{ >+ "domain": "Audit", >+ "description": "", >+ "commands": [ >+ { >+ "name": "run", >+ "description": "Parses and evaluates the given test string and sends back the result.", >+ "parameters": [ >+ { "name": "test", "type": "string", "description": "Test string to parse and evaluate." }, >+ { "name": "contextId", "$ref": "Runtime.ExecutionContextId", "optional": true, "description": "Specifies in which isolated context to run the test. Each content script lives in an isolated context and this parameter may be used to specify one of those contexts. If the parameter is omitted or 0 the evaluation will be performed in the context of the inspected page." } >+ ], >+ "returns": [ >+ { "name": "result", "$ref": "Runtime.RemoteObject", "description": "Evaluation result." }, >+ { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." } >+ ] >+ } >+ ] >+} >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 9c51418af76624841ebbf5c6589f250df85f1d50..04c2c382b5769a79f04e997c26144cc1fcd335ae 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -884,6 +884,7 @@ set(WebCore_NON_SVG_IDL_FILES > html/canvas/WebMetalTextureDescriptor.idl > > inspector/CommandLineAPIHost.idl >+ inspector/InspectorAuditUtilities.idl > inspector/InspectorFrontendHost.idl > > loader/appcache/DOMApplicationCache.idl >diff --git a/Source/WebCore/DerivedSources-input.xcfilelist b/Source/WebCore/DerivedSources-input.xcfilelist >index 90b25fa1e53185a10d30ae5ef1d34f5ae8cc475f..a586104b52936b92e2e0c299ef7a00ef5f314d57 100644 >--- a/Source/WebCore/DerivedSources-input.xcfilelist >+++ b/Source/WebCore/DerivedSources-input.xcfilelist >@@ -808,6 +808,7 @@ $(PROJECT_DIR)/html/track/VideoTrack.idl > $(PROJECT_DIR)/html/track/VideoTrackList.idl > $(PROJECT_DIR)/inspector/CommandLineAPIHost.idl > $(PROJECT_DIR)/inspector/CommandLineAPIModuleSource.js >+$(PROJECT_DIR)/inspector/InspectorAuditUtilities.idl > $(PROJECT_DIR)/inspector/InspectorFrontendHost.idl > $(PROJECT_DIR)/inspector/InspectorOverlayPage.css > $(PROJECT_DIR)/inspector/InspectorOverlayPage.html >diff --git a/Source/WebCore/DerivedSources-output.xcfilelist b/Source/WebCore/DerivedSources-output.xcfilelist >index dfbb88b0c675c70c10cc27ce8a26fa148ce67cc8..a4293521d0b6bf37a466f0ee5e6f249b123cc433 100644 >--- a/Source/WebCore/DerivedSources-output.xcfilelist >+++ b/Source/WebCore/DerivedSources-output.xcfilelist >@@ -814,6 +814,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageSmoothingQuality.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageSmoothingQuality.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInputEvent.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInputEvent.h >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorAuditUtilities.cpp >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorAuditUtilities.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorFrontendHost.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorFrontendHost.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInternalSettings.cpp >diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make >index e948b702f37a566e550a5ebe56e602fcb7922f8f..5d9f54f36636039d7c20d8d580acebf4aa7f98b5 100644 >--- a/Source/WebCore/DerivedSources.make >+++ b/Source/WebCore/DerivedSources.make >@@ -835,6 +835,7 @@ JS_BINDING_IDLS = \ > $(WebCore)/html/track/VideoTrack.idl \ > $(WebCore)/html/track/VideoTrackList.idl \ > $(WebCore)/inspector/CommandLineAPIHost.idl \ >+ $(WebCore)/inspector/InspectorAuditUtilities.idl \ > $(WebCore)/inspector/InspectorFrontendHost.idl \ > $(WebCore)/loader/appcache/DOMApplicationCache.idl \ > $(WebCore)/page/BarProp.idl \ >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index e7d934ad27f1bfa91231e1d86df0b7419d838b90..b171a4d6e1f78bf1c5a5cc5181f99a2a8d826735 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -1216,6 +1216,7 @@ inspector/CommandLineAPIHost.cpp > inspector/CommandLineAPIModule.cpp > inspector/DOMEditor.cpp > inspector/DOMPatchSupport.cpp >+inspector/InspectorAuditUtilities.cpp > inspector/InspectorCanvas.cpp > inspector/InspectorClient.cpp > inspector/InspectorController.cpp >@@ -1256,6 +1257,7 @@ inspector/agents/WebConsoleAgent.cpp > inspector/agents/WebDebuggerAgent.cpp > inspector/agents/WebHeapAgent.cpp > >+inspector/agents/page/PageAuditAgent.cpp > inspector/agents/page/PageConsoleAgent.cpp > inspector/agents/page/PageDebuggerAgent.cpp > inspector/agents/page/PageHeapAgent.cpp >@@ -1263,6 +1265,7 @@ inspector/agents/page/PageNetworkAgent.cpp > inspector/agents/page/PageRuntimeAgent.cpp > > inspector/agents/worker/ServiceWorkerAgent.cpp >+inspector/agents/worker/WorkerAuditAgent.cpp > inspector/agents/worker/WorkerConsoleAgent.cpp > inspector/agents/worker/WorkerDebuggerAgent.cpp > inspector/agents/worker/WorkerNetworkAgent.cpp >@@ -2815,6 +2818,7 @@ JSImageBitmapRenderingContextSettings.cpp > JSImageData.cpp > JSImageSmoothingQuality.cpp > JSInputEvent.cpp >+JSInspectorAuditUtilities.cpp > JSInspectorFrontendHost.cpp > JSIntersectionObserver.cpp > JSIntersectionObserverCallback.cpp >diff --git a/Source/WebCore/UnifiedSources-input.xcfilelist b/Source/WebCore/UnifiedSources-input.xcfilelist >index dfc2a3c29529a4146448ec8c3b5bcee081411730..375d6d7467d170a7c298acca6cfb23a9f7e62c53 100644 >--- a/Source/WebCore/UnifiedSources-input.xcfilelist >+++ b/Source/WebCore/UnifiedSources-input.xcfilelist >@@ -391,6 +391,7 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageBitmapRenderingContextSettin > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageData.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageSmoothingQuality.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInputEvent.cpp >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorAuditUtilities.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorFrontendHost.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIntersectionObserver.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIntersectionObserverCallback.cpp >@@ -2173,6 +2174,7 @@ $(SRCROOT)/inspector/CommandLineAPIHost.cpp > $(SRCROOT)/inspector/CommandLineAPIModule.cpp > $(SRCROOT)/inspector/DOMEditor.cpp > $(SRCROOT)/inspector/DOMPatchSupport.cpp >+$(SRCROOT)/inspector/InspectorAuditUtilities.cpp > $(SRCROOT)/inspector/InspectorCanvas.cpp > $(SRCROOT)/inspector/InspectorClient.cpp > $(SRCROOT)/inspector/InspectorController.cpp >@@ -2211,12 +2213,14 @@ $(SRCROOT)/inspector/agents/InspectorWorkerAgent.cpp > $(SRCROOT)/inspector/agents/WebConsoleAgent.cpp > $(SRCROOT)/inspector/agents/WebDebuggerAgent.cpp > $(SRCROOT)/inspector/agents/WebHeapAgent.cpp >+$(SRCROOT)/inspector/agents/page/PageAuditAgent.cpp > $(SRCROOT)/inspector/agents/page/PageConsoleAgent.cpp > $(SRCROOT)/inspector/agents/page/PageDebuggerAgent.cpp > $(SRCROOT)/inspector/agents/page/PageHeapAgent.cpp > $(SRCROOT)/inspector/agents/page/PageNetworkAgent.cpp > $(SRCROOT)/inspector/agents/page/PageRuntimeAgent.cpp > $(SRCROOT)/inspector/agents/worker/ServiceWorkerAgent.cpp >+$(SRCROOT)/inspector/agents/worker/WorkerAuditAgent.cpp > $(SRCROOT)/inspector/agents/worker/WorkerConsoleAgent.cpp > $(SRCROOT)/inspector/agents/worker/WorkerDebuggerAgent.cpp > $(SRCROOT)/inspector/agents/worker/WorkerNetworkAgent.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index de452c062a6ba26f47327077fc1f99acfcfd8ceb..2cfecec40d6978be454b680310e9f7913248206f 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -2576,6 +2576,10 @@ > 9001774012E0347800648462 /* OESStandardDerivatives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9001773D12E0347800648462 /* OESStandardDerivatives.cpp */; }; > 9001774112E0347800648462 /* OESStandardDerivatives.h in Headers */ = {isa = PBXBuildFile; fileRef = 9001773E12E0347800648462 /* OESStandardDerivatives.h */; }; > 9001788112E0370700648462 /* JSOESStandardDerivatives.h in Headers */ = {isa = PBXBuildFile; fileRef = 9001787F12E0370700648462 /* JSOESStandardDerivatives.h */; }; >+ 91278D5E21DEDAD600B57184 /* PageAuditAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 91278D5C21DEDAD500B57184 /* PageAuditAgent.h */; }; >+ 91278D6221DEDAF000B57184 /* WorkerAuditAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 91278D6021DEDAF000B57184 /* WorkerAuditAgent.h */; }; >+ 91278D6D21DEDC8000B57184 /* InspectorAuditUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 91278D6A21DEDC7E00B57184 /* InspectorAuditUtilities.h */; }; >+ 91278D6D21DEDC8000B57185 /* JSInspectorAuditUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 91278D6A21DEDC7E00B57185 /* JSInspectorAuditUtilities.h */; }; > 91B8F0B521953D65000C2B00 /* CertificateInfoBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 91B8F0B321953D65000C2B00 /* CertificateInfoBase.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 91B952241F58A58F00931DC2 /* RecordingSwizzleTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 91B952221F58A58000931DC2 /* RecordingSwizzleTypes.h */; }; > 91C9F2F91AE3BEB00095B61C /* AXTextStateChangeIntent.h in Headers */ = {isa = PBXBuildFile; fileRef = 91C9F2F81AE3BE240095B61C /* AXTextStateChangeIntent.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -10348,6 +10352,14 @@ > 9001773F12E0347800648462 /* OESStandardDerivatives.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OESStandardDerivatives.idl; sourceTree = "<group>"; }; > 9001787E12E0370700648462 /* JSOESStandardDerivatives.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSOESStandardDerivatives.cpp; sourceTree = "<group>"; }; > 9001787F12E0370700648462 /* JSOESStandardDerivatives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSOESStandardDerivatives.h; sourceTree = "<group>"; }; >+ 91278D5A21DEDAD500B57184 /* PageAuditAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageAuditAgent.cpp; sourceTree = "<group>"; }; >+ 91278D5C21DEDAD500B57184 /* PageAuditAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageAuditAgent.h; sourceTree = "<group>"; }; >+ 91278D5F21DEDAEF00B57184 /* WorkerAuditAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerAuditAgent.cpp; sourceTree = "<group>"; }; >+ 91278D6021DEDAF000B57184 /* WorkerAuditAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerAuditAgent.h; sourceTree = "<group>"; }; >+ 91278D6A21DEDC7E00B57184 /* InspectorAuditUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorAuditUtilities.h; sourceTree = "<group>"; }; >+ 91278D6B21DEDC7F00B57184 /* InspectorAuditUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorAuditUtilities.cpp; sourceTree = "<group>"; }; >+ 91278D6A21DEDC7E00B57185 /* JSInspectorAuditUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInspectorAuditUtilities.h; sourceTree = "<group>"; }; >+ 91278D6B21DEDC7F00B57185 /* JSInspectorAuditUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInspectorAuditUtilities.cpp; sourceTree = "<group>"; }; > 91B8F0B321953D65000C2B00 /* CertificateInfoBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CertificateInfoBase.h; sourceTree = "<group>"; }; > 91B952221F58A58000931DC2 /* RecordingSwizzleTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RecordingSwizzleTypes.h; sourceTree = "<group>"; }; > 91C9F2F81AE3BE240095B61C /* AXTextStateChangeIntent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AXTextStateChangeIntent.h; sourceTree = "<group>"; }; >@@ -16767,6 +16779,8 @@ > A584FE2518637DAB00843B10 /* CommandLineAPIModuleSource.h */, > A584FE391864E2D800843B10 /* JSCommandLineAPIHost.cpp */, > A584FE3A1864E2D800843B10 /* JSCommandLineAPIHost.h */, >+ 91278D6B21DEDC7F00B57185 /* JSInspectorAuditUtilities.cpp */, >+ 91278D6A21DEDC7E00B57185 /* JSInspectorAuditUtilities.h */, > 7A0E771C10C00DB100A0276E /* JSInspectorFrontendHost.cpp */, > 7A0E771D10C00DB100A0276E /* JSInspectorFrontendHost.h */, > ); >@@ -16787,6 +16801,8 @@ > 7AABA25814BC613300AA9A11 /* DOMEditor.h */, > 7A54881614E432A1006AE05A /* DOMPatchSupport.cpp */, > 7A54881514E432A1006AE05A /* DOMPatchSupport.h */, >+ 91278D6B21DEDC7F00B57184 /* InspectorAuditUtilities.cpp */, >+ 91278D6A21DEDC7E00B57184 /* InspectorAuditUtilities.h */, > 6A22E8721F1042C400F546C3 /* InspectorCanvas.cpp */, > 6A22E86F1F10418600F546C3 /* InspectorCanvas.h */, > 7A1F2B51126C61B20006A7E6 /* InspectorClient.cpp */, >@@ -22171,6 +22187,8 @@ > A5B81CB91FAA44820037D1E6 /* page */ = { > isa = PBXGroup; > children = ( >+ 91278D5A21DEDAD500B57184 /* PageAuditAgent.cpp */, >+ 91278D5C21DEDAD500B57184 /* PageAuditAgent.h */, > A5B81CC01FAA44B70037D1E6 /* PageConsoleAgent.cpp */, > A5B81CBB1FAA44B70037D1E6 /* PageConsoleAgent.h */, > A5B81CBD1FAA44B70037D1E6 /* PageDebuggerAgent.cpp */, >@@ -22190,6 +22208,8 @@ > children = ( > A581ED121FB288C900CED4EC /* ServiceWorkerAgent.cpp */, > A581ED101FB288C800CED4EC /* ServiceWorkerAgent.h */, >+ 91278D5F21DEDAEF00B57184 /* WorkerAuditAgent.cpp */, >+ 91278D6021DEDAF000B57184 /* WorkerAuditAgent.h */, > A5B81CCB1FAA44DA0037D1E6 /* WorkerConsoleAgent.cpp */, > A5B81CCA1FAA44DA0037D1E6 /* WorkerConsoleAgent.h */, > A5B81CC81FAA44DA0037D1E6 /* WorkerDebuggerAgent.cpp */, >@@ -29208,6 +29228,7 @@ > 93309DF0099E64920056E581 /* InsertParagraphSeparatorCommand.h in Headers */, > 93309DF2099E64920056E581 /* InsertTextCommand.h in Headers */, > A5B81CA71FAA44620037D1E6 /* InspectorApplicationCacheAgent.h in Headers */, >+ 91278D6D21DEDC8000B57184 /* InspectorAuditUtilities.h in Headers */, > 6A22E8701F10418600F546C3 /* InspectorCanvas.h in Headers */, > A5B81CA81FAA44620037D1E6 /* InspectorCanvasAgent.h in Headers */, > 1C81B95C0E97330800266E07 /* InspectorClient.h in Headers */, >@@ -29640,6 +29661,7 @@ > A77979290D6B9E64003851B9 /* JSImageData.h in Headers */, > 7C193C011F5E11050088F3E6 /* JSImageSmoothingQuality.h in Headers */, > A86629D309DA2B48009633A6 /* JSInputEvent.h in Headers */, >+ 91278D6D21DEDC8000B57185 /* JSInspectorAuditUtilities.h in Headers */, > 7A0E771F10C00DB100A0276E /* JSInspectorFrontendHost.h in Headers */, > 0F4710E61DB700C7002DCEC3 /* JSIntersectionObserver.h in Headers */, > 0F8B45761DC41DBA00443C3F /* JSIntersectionObserverCallback.h in Headers */, >@@ -30460,6 +30482,7 @@ > 1A0D57370A5C77FE007EDD4C /* OverflowEvent.h in Headers */, > 3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */, > 65A21468097A329100B9050A /* Page.h in Headers */, >+ 91278D5E21DEDAD600B57184 /* PageAuditAgent.h in Headers */, > 1477E7770BF4134A00152872 /* PageCache.h in Headers */, > CD5E5B5F1A15CE54000C609E /* PageConfiguration.h in Headers */, > A5B81CC21FAA44BC0037D1E6 /* PageConsoleAgent.h in Headers */, >@@ -31880,6 +31903,7 @@ > A14832C6187F668F00DA63A6 /* WKViewPrivate.h in Headers */, > 379919971200DDF400EA041C /* WOFFFileFormat.h in Headers */, > 2E4346460F546A8200B0F1BA /* Worker.h in Headers */, >+ 91278D6221DEDAF000B57184 /* WorkerAuditAgent.h in Headers */, > 41A7D3531F438D16008988DE /* WorkerCacheStorageConnection.h in Headers */, > A5B81CCD1FAA44DE0037D1E6 /* WorkerConsoleAgent.h in Headers */, > A55639D11C6F09E300806D8E /* WorkerConsoleClient.h in Headers */, >diff --git a/Source/WebCore/inspector/InspectorAuditUtilities.cpp b/Source/WebCore/inspector/InspectorAuditUtilities.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..6acb337df205259892e99de181db45dad567edf3 >--- /dev/null >+++ b/Source/WebCore/inspector/InspectorAuditUtilities.cpp >@@ -0,0 +1,36 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+ >+#include "config.h" >+#include "InspectorAuditUtilities.h" >+ >+namespace WebCore { >+ >+InspectorAuditUtilities::InspectorAuditUtilities() >+{ >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/inspector/InspectorAuditUtilities.h b/Source/WebCore/inspector/InspectorAuditUtilities.h >new file mode 100644 >index 0000000000000000000000000000000000000000..14118fc5aed10434bcc1f81c8c3e89846258570a >--- /dev/null >+++ b/Source/WebCore/inspector/InspectorAuditUtilities.h >@@ -0,0 +1,44 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/Ref.h> >+#include <wtf/RefCounted.h> >+ >+namespace WebCore { >+ >+class InspectorAuditUtilities : public RefCounted<InspectorAuditUtilities> { >+public: >+ static Ref<InspectorAuditUtilities> create() >+ { >+ return adoptRef(*new InspectorAuditUtilities()); >+ } >+ >+private: >+ InspectorAuditUtilities(); >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebCore/inspector/InspectorAuditUtilities.idl b/Source/WebCore/inspector/InspectorAuditUtilities.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..cde158604b9583e642cea8e6e0178abffcbfa952 >--- /dev/null >+++ b/Source/WebCore/inspector/InspectorAuditUtilities.idl >@@ -0,0 +1,31 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+[ >+ ImplementationLacksVTable, >+ JSGenerateToJSObject, >+ NoInterfaceObject, >+] interface InspectorAuditUtilities { >+}; >diff --git a/Source/WebCore/inspector/InspectorController.cpp b/Source/WebCore/inspector/InspectorController.cpp >index 44aa81b2a9bace32f4d871740bd103d1a888e7c4..945070d62a52c5d4af3c914df1237e23a2b94efa 100644 >--- a/Source/WebCore/inspector/InspectorController.cpp >+++ b/Source/WebCore/inspector/InspectorController.cpp >@@ -60,6 +60,7 @@ > #include "JSDOMWindowCustom.h" > #include "JSExecState.h" > #include "Page.h" >+#include "PageAuditAgent.h" > #include "PageConsoleAgent.h" > #include "PageDebuggerAgent.h" > #include "PageHeapAgent.h" >@@ -148,6 +149,8 @@ InspectorController::InspectorController(Page& page, InspectorClient* inspectorC > m_instrumentingAgents->setInspectorCanvasAgent(canvasAgentPtr.get()); > m_agents.append(WTFMove(canvasAgentPtr)); > >+ m_agents.append(std::make_unique<PageAuditAgent>(pageContext)); >+ > ASSERT(m_injectedScriptManager->commandLineAPIHost()); > if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost()) > commandLineAPIHost->init(m_inspectorAgent, consoleAgent, m_domAgent, domStorageAgent, databaseAgent); >diff --git a/Source/WebCore/inspector/WorkerInspectorController.cpp b/Source/WebCore/inspector/WorkerInspectorController.cpp >index d2c023fccc00b0e25a2ad4bd2630dc73c1a5f64f..8581a579ea1d6c16e7fcfcfa7d183a1a73977f9f 100644 >--- a/Source/WebCore/inspector/WorkerInspectorController.cpp >+++ b/Source/WebCore/inspector/WorkerInspectorController.cpp >@@ -32,6 +32,7 @@ > #include "WebHeapAgent.h" > #include "WebInjectedScriptHost.h" > #include "WebInjectedScriptManager.h" >+#include "WorkerAuditAgent.h" > #include "WorkerConsoleAgent.h" > #include "WorkerDebuggerAgent.h" > #include "WorkerGlobalScope.h" >@@ -77,6 +78,7 @@ WorkerInspectorController::WorkerInspectorController(WorkerGlobalScope& workerGl > m_agents.append(std::make_unique<WorkerDebuggerAgent>(workerContext)); > m_agents.append(WTFMove(consoleAgent)); > m_agents.append(WTFMove(heapAgent)); >+ m_agents.append(std::make_unique<WorkerAuditAgent>(workerContext)); > > if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost()) > commandLineAPIHost->init(nullptr, m_instrumentingAgents->webConsoleAgent(), nullptr, nullptr, nullptr); >diff --git a/Source/WebCore/inspector/agents/page/PageAuditAgent.cpp b/Source/WebCore/inspector/agents/page/PageAuditAgent.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..e89946c2a686dae62eda917c5e2c24986f4939da >--- /dev/null >+++ b/Source/WebCore/inspector/agents/page/PageAuditAgent.cpp >@@ -0,0 +1,112 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "PageAuditAgent.h" >+ >+#include "InspectorAuditUtilities.h" >+#include "JSInspectorAuditUtilities.h" >+#include "Page.h" >+#include "PageConsoleClient.h" >+#include <JavaScriptCore/CallFrame.h> >+#include <JavaScriptCore/InjectedScript.h> >+#include <JavaScriptCore/InjectedScriptManager.h> >+#include <JavaScriptCore/JSLock.h> >+#include <wtf/Ref.h> >+#include <wtf/RefPtr.h> >+#include <wtf/Vector.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+using namespace Inspector; >+ >+PageAuditAgent::PageAuditAgent(PageAgentContext& context) >+ : InspectorAuditAgent(context) >+ , m_inspectedPage(context.inspectedPage) >+{ >+} >+ >+InjectedScript PageAuditAgent::injectedScriptForEval(const int* executionContextId) >+{ >+ if (executionContextId) >+ return injectedScriptManager().injectedScriptForId(*executionContextId); >+ >+ JSC::ExecState* scriptState = mainWorldExecState(&m_inspectedPage.mainFrame()); >+ return injectedScriptManager().injectedScriptFor(scriptState); >+} >+ >+InjectedScript PageAuditAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId) >+{ >+ InjectedScript injectedScript = injectedScriptForEval(executionContextId); >+ if (injectedScript.hasNoValue()) { >+ if (executionContextId) >+ errorString = "Internal error: main world execution context not found."_s; >+ else >+ errorString = "Execution context with given id not found."_s; >+ } >+ return injectedScript; >+} >+ >+Vector<std::pair<String, JSC::JSValue>> PageAuditAgent::runArguments(const int* executionContextId) >+{ >+ auto arguments = InspectorAuditAgent::runArguments(executionContextId); >+ >+ InjectedScript injectedScript = injectedScriptForEval(executionContextId); >+ if (!injectedScript.hasNoValue()) { >+ if (JSC::ExecState* execState = injectedScript.scriptState()) { >+ if (auto* globalObject = JSC::jsCast<JSDOMGlobalObject*>(execState->lexicalGlobalObject())) { >+ JSC::JSValue inspectorAuditUtilities; >+ >+ { >+ JSC::JSLockHolder lock(execState); >+ >+ inspectorAuditUtilities = toJSNewlyCreated(execState, globalObject, InspectorAuditUtilities::create()); >+ } >+ >+ if (inspectorAuditUtilities) >+ arguments.append(std::make_pair("AUDIT"_s, WTFMove(inspectorAuditUtilities))); >+ } >+ } >+ } >+ >+ return arguments; >+} >+ >+void PageAuditAgent::muteConsole() >+{ >+ InspectorAuditAgent::muteConsole(); >+ >+ PageConsoleClient::mute(); >+} >+ >+void PageAuditAgent::unmuteConsole() >+{ >+ PageConsoleClient::unmute(); >+ >+ InspectorAuditAgent::unmuteConsole(); >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/inspector/agents/page/PageAuditAgent.h b/Source/WebCore/inspector/agents/page/PageAuditAgent.h >new file mode 100644 >index 0000000000000000000000000000000000000000..08a0b7cd1246f48ecca691f1a22bbb383ca88984 >--- /dev/null >+++ b/Source/WebCore/inspector/agents/page/PageAuditAgent.h >@@ -0,0 +1,53 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "InspectorWebAgentBase.h" >+#include <JavaScriptCore/InspectorAuditAgent.h> >+ >+namespace WebCore { >+ >+class Page; >+ >+class PageAuditAgent final : public Inspector::InspectorAuditAgent { >+ WTF_MAKE_NONCOPYABLE(PageAuditAgent); >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ explicit PageAuditAgent(PageAgentContext&); >+ >+private: >+ Inspector::InjectedScript injectedScriptForEval(const int* executionContextId); >+ Inspector::InjectedScript injectedScriptForEval(Inspector::ErrorString&, const int* executionContextId) override; >+ >+ Vector<std::pair<String, JSC::JSValue>> runArguments(const int* executionContextId) override; >+ >+ void muteConsole() override; >+ void unmuteConsole() override; >+ >+ Page& m_inspectedPage; >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebCore/inspector/agents/worker/WorkerAuditAgent.cpp b/Source/WebCore/inspector/agents/worker/WorkerAuditAgent.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..854c24553ba991b32fd7a82308d0b56456911a92 >--- /dev/null >+++ b/Source/WebCore/inspector/agents/worker/WorkerAuditAgent.cpp >@@ -0,0 +1,59 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "WorkerAuditAgent.h" >+ >+#include "WorkerGlobalScope.h" >+#include <JavaScriptCore/InjectedScript.h> >+#include <JavaScriptCore/InjectedScriptManager.h> >+#include <JavaScriptCore/JSCInlines.h> >+#include <wtf/Ref.h> >+#include <wtf/RefPtr.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+using namespace Inspector; >+ >+WorkerAuditAgent::WorkerAuditAgent(WorkerAgentContext& context) >+ : InspectorAuditAgent(context) >+ , m_workerGlobalScope(context.workerGlobalScope) >+{ >+ ASSERT(context.workerGlobalScope.isContextThread()); >+} >+ >+InjectedScript WorkerAuditAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId) >+{ >+ if (executionContextId) { >+ errorString = "Execution context id is not supported for workers as there is only one execution context."_s; >+ return InjectedScript(); >+ } >+ >+ JSC::ExecState* scriptState = execStateFromWorkerGlobalScope(m_workerGlobalScope); >+ return injectedScriptManager().injectedScriptFor(scriptState); >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/inspector/agents/worker/WorkerAuditAgent.h b/Source/WebCore/inspector/agents/worker/WorkerAuditAgent.h >new file mode 100644 >index 0000000000000000000000000000000000000000..1b8d9ff7594154e6cc94c63c42e39288da3e27e3 >--- /dev/null >+++ b/Source/WebCore/inspector/agents/worker/WorkerAuditAgent.h >@@ -0,0 +1,47 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "InspectorWebAgentBase.h" >+#include <JavaScriptCore/InspectorAuditAgent.h> >+ >+namespace WebCore { >+ >+class WorkerGlobalScope; >+ >+class WorkerAuditAgent final : public Inspector::InspectorAuditAgent { >+ WTF_MAKE_NONCOPYABLE(WorkerAuditAgent); >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ explicit WorkerAuditAgent(WorkerAgentContext&); >+ >+private: >+ Inspector::InjectedScript injectedScriptForEval(Inspector::ErrorString&, const int* executionContextId) override; >+ >+ WorkerGlobalScope& m_workerGlobalScope; >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebInspectorUI/.eslintrc b/Source/WebInspectorUI/.eslintrc >index 75ea80baeb61d40064d9db5bea7e91c4f4dec0dd..a8c04ddc0627ac05842fd2b00d83fd5631bda40a 100644 >--- a/Source/WebInspectorUI/.eslintrc >+++ b/Source/WebInspectorUI/.eslintrc >@@ -35,6 +35,7 @@ > }, > "globals": { > // Agents >+ "AuditAgent": true, > "ApplicationCacheAgent": true, > "CSSAgent": true, > "CanvasAgent": true, >diff --git a/Source/WebInspectorUI/UserInterface/Base/Main.js b/Source/WebInspectorUI/UserInterface/Base/Main.js >index 251cef7c43434448ba6c972ea27faa0cca7884b6..81b06dd502e8ae5793ca26cc1745f07fc2eb3e6a 100644 >--- a/Source/WebInspectorUI/UserInterface/Base/Main.js >+++ b/Source/WebInspectorUI/UserInterface/Base/Main.js >@@ -114,12 +114,12 @@ WI.loaded = function() > WI.memoryManager = new WI.MemoryManager, > WI.applicationCacheManager = new WI.ApplicationCacheManager, > WI.timelineManager = new WI.TimelineManager, >+ WI.auditManager = new WI.AuditManager, > WI.debuggerManager = new WI.DebuggerManager, > WI.layerTreeManager = new WI.LayerTreeManager, > WI.workerManager = new WI.WorkerManager, > WI.domDebuggerManager = new WI.DOMDebuggerManager, > WI.canvasManager = new WI.CanvasManager, >- WI.auditManager = new WI.AuditManager, > ]; > > // Register for events. >diff --git a/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js b/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js >index e994556128d000e794398582e8222413271b4284..7f84554706ebce668c36d38a0b95874cad36271b 100644 >--- a/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js >+++ b/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js >@@ -41,6 +41,9 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object > WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingWillStart, this._timelineCapturingWillStart, this); > WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._timelineCapturingStopped, this); > >+ WI.auditManager.addEventListener(WI.AuditManager.Event.TestScheduled, this._handleAuditManagerTestScheduled, this); >+ WI.auditManager.addEventListener(WI.AuditManager.Event.TestCompleted, this._handleAuditManagerTestCompleted, this); >+ > WI.targetManager.addEventListener(WI.TargetManager.Event.TargetRemoved, this._targetRemoved, this); > > WI.settings.pauseForInternalScripts.addEventListener(WI.Setting.Event.Changed, this._pauseForInternalScriptsDidChange, this); >@@ -1144,6 +1147,19 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object > this._stopDisablingBreakpointsTemporarily(); > } > >+ _handleAuditManagerTestScheduled(event) >+ { >+ this._startDisablingBreakpointsTemporarily(); >+ >+ if (this.paused) >+ this.resume(); >+ } >+ >+ _handleAuditManagerTestCompleted(event) >+ { >+ this._stopDisablingBreakpointsTemporarily(); >+ } >+ > _targetRemoved(event) > { > let wasPaused = this.paused; >diff --git a/Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js b/Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js >index a6daef2582bc4e9463c2eb453b15f93a3c7048c8..8dda87f318271d66ab1ec3cabe45ada7523fff96 100644 >--- a/Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js >+++ b/Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js >@@ -106,12 +106,6 @@ WI.AuditTestCase = class AuditTestCase extends WI.AuditTestBase > data.errors.push(value); > } > >- let evaluateArguments = { >- expression: `(function() { "use strict"; return eval(${this._test})(); })()`, >- objectGroup: "audit", >- doNotPauseOnExceptionsAndMuteConsole: true, >- }; >- > async function parseResponse(response) { > let remoteObject = WI.RemoteObject.fromPayload(response.result, WI.mainTarget); > if (response.wasThrown || (remoteObject.type === "object" && remoteObject.subtype === "error")) >@@ -232,9 +226,21 @@ WI.AuditTestCase = class AuditTestCase extends WI.AuditTestBase > addError(WI.UIString("Return value is not an object, string, or boolean")); > } > >+ let agentCommandFunction = null; >+ let agentCommandArguments = {}; >+ if (window.AuditAgent) { >+ agentCommandFunction = AuditAgent.run; >+ agentCommandArguments.test = this._test; >+ } else { >+ agentCommandFunction = RuntimeAgent.evaluate; >+ agentCommandArguments.expression = `(function() { "use strict"; return eval(${this._test})(); })()`; >+ agentCommandArguments.objectGroup = "audit"; >+ agentCommandArguments.doNotPauseOnExceptionsAndMuteConsole = true; >+ } >+ > try { > metadata.startTimestamp = new Date; >- let response = await RuntimeAgent.evaluate.invoke(evaluateArguments); >+ let response = await agentCommandFunction.invoke(agentCommandArguments); > metadata.endTimestamp = new Date; > > if (response.result.type === "object" && response.result.className === "Promise") { >diff --git a/Source/WebInspectorUI/UserInterface/Protocol/Target.js b/Source/WebInspectorUI/UserInterface/Protocol/Target.js >index dc7995267621b2a6856921c7544ba80c3e88fc22..eb5aa0f085149de7428cdea6fa4e09cdf43b0823 100644 >--- a/Source/WebInspectorUI/UserInterface/Protocol/Target.js >+++ b/Source/WebInspectorUI/UserInterface/Protocol/Target.js >@@ -52,9 +52,10 @@ WI.Target = class Target extends WI.Object > this._connection.target = this; > > // Agents we always expect in every target. >- console.assert(this.RuntimeAgent); >- console.assert(this.DebuggerAgent); >+ console.assert(this.AuditAgent); > console.assert(this.ConsoleAgent); >+ console.assert(this.DebuggerAgent); >+ console.assert(this.RuntimeAgent); > } > > // Target >@@ -109,6 +110,7 @@ WI.Target = class Target extends WI.Object > > // Agents > >+ get AuditAgent() { return this._agents.Audit; } > get ApplicationCacheAgent() { return this._agents.ApplicationCache; } > get CSSAgent() { return this._agents.CSS; } > get CanvasAgent() { return this._agents.Canvas; } >diff --git a/Source/WebInspectorUI/UserInterface/Test/Test.js b/Source/WebInspectorUI/UserInterface/Test/Test.js >index f8adde814a31199222b807081ba3dacaeb27b5de..195fbc21222239dda5037848fbf2435249ed7907 100644 >--- a/Source/WebInspectorUI/UserInterface/Test/Test.js >+++ b/Source/WebInspectorUI/UserInterface/Test/Test.js >@@ -57,12 +57,12 @@ WI.loaded = function() > WI.heapManager = new WI.HeapManager, > WI.memoryManager = new WI.MemoryManager, > WI.timelineManager = new WI.TimelineManager, >+ WI.auditManager = new WI.AuditManager, > WI.debuggerManager = new WI.DebuggerManager, > WI.layerTreeManager = new WI.LayerTreeManager, > WI.workerManager = new WI.WorkerManager, > WI.domDebuggerManager = new WI.DOMDebuggerManager, > WI.canvasManager = new WI.CanvasManager, >- WI.auditManager = new WI.AuditManager, > ]; > > // Register for events. >diff --git a/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js b/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js >index 90ab86d2af47e623491f0914596d4bbe66b49e67..aaddb34c6ca01ec78bae892910ab197c8a6e78f6 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js >+++ b/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js >@@ -58,15 +58,25 @@ WI.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WI.NavigationSideba > WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingWillStart, this._timelineCapturingWillStart, this); > WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._timelineCapturingStopped, this); > >+ WI.auditManager.addEventListener(WI.AuditManager.Event.TestScheduled, this._handleAuditManagerTestScheduled, this); >+ WI.auditManager.addEventListener(WI.AuditManager.Event.TestCompleted, this._handleAuditManagerTestCompleted, this); >+ > WI.targetManager.addEventListener(WI.TargetManager.Event.TargetAdded, this._targetAdded, this); > WI.targetManager.addEventListener(WI.TargetManager.Event.TargetRemoved, this._targetRemoved, this); > > this._timelineRecordingWarningElement = document.createElement("div"); > this._timelineRecordingWarningElement.classList.add("warning-banner"); > this._timelineRecordingWarningElement.append(WI.UIString("Debugger disabled during Timeline recording"), " "); >- let stopRecordingLink = this._timelineRecordingWarningElement.appendChild(document.createElement("a")); >- stopRecordingLink.textContent = WI.UIString("Stop recording"); >- stopRecordingLink.addEventListener("click", () => { WI.timelineManager.stopCapturing(); }); >+ let timelineStopRecordingLink = this._timelineRecordingWarningElement.appendChild(document.createElement("a")); >+ timelineStopRecordingLink.textContent = WI.UIString("Stop recording"); >+ timelineStopRecordingLink.addEventListener("click", () => { WI.timelineManager.stopCapturing(); }); >+ >+ this._auditTestRecordingWarningElement = document.createElement("div"); >+ this._auditTestRecordingWarningElement.classList.add("warning-banner"); >+ this._auditTestRecordingWarningElement.append(WI.UIString("Debugger disabled during Audit"), " "); >+ let auditStopRecordingLink = this._auditTestRecordingWarningElement.appendChild(document.createElement("a")); >+ auditStopRecordingLink.textContent = WI.UIString("Stop Audit"); >+ auditStopRecordingLink.addEventListener("click", () => { WI.auditManager.stop(); }); > > this._breakpointsDisabledWarningElement = document.createElement("div"); > this._breakpointsDisabledWarningElement.classList.add("warning-banner"); >@@ -638,12 +648,31 @@ WI.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WI.NavigationSideba > this._updateBreakpointsDisabledBanner(); > } > >+ _handleAuditManagerTestScheduled(event) >+ { >+ this._debuggerBreakpointsButtonItem.enabled = false; >+ this._debuggerPauseResumeButtonItem.enabled = false; >+ >+ this.contentView.element.insertBefore(this._auditTestRecordingWarningElement, this.contentView.element.firstChild); >+ this._updateBreakpointsDisabledBanner(); >+ } >+ >+ _handleAuditManagerTestCompleted(event) >+ { >+ this._debuggerBreakpointsButtonItem.enabled = true; >+ this._debuggerPauseResumeButtonItem.enabled = true; >+ >+ this._auditTestRecordingWarningElement.remove(); >+ this._updateBreakpointsDisabledBanner(); >+ } >+ > _updateBreakpointsDisabledBanner() > { > let breakpointsEnabled = WI.debuggerManager.breakpointsEnabled; > let timelineWarningShowing = !!this._timelineRecordingWarningElement.parentElement; >+ let auditWarningShowing = !!this._auditTestRecordingWarningElement.parentElement; > >- if (!breakpointsEnabled && !timelineWarningShowing) >+ if (!breakpointsEnabled && !timelineWarningShowing && !auditWarningShowing) > this.contentView.element.insertBefore(this._breakpointsDisabledWarningElement, this.contentView.element.firstChild); > else > this._breakpointsDisabledWarningElement.remove(); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 886d5a5c429faa558c4540a3f66d1c4dd3e4c393..d35c1f97c4539cc79ac05b4d04fe2f565219fc86 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2019-01-04 Devin Rousso <drousso@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ * inspector/audit/run.html: Added. >+ * inspector/audit/run-expected.txt: Added. >+ > 2019-01-02 Simon Fraser <simon.fraser@apple.com> > > REGRESSION (r239306): Don't disable font smoothing in transparent layers on macOS Mojave and later >diff --git a/LayoutTests/inspector/audit/run-expected.txt b/LayoutTests/inspector/audit/run-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..a0a955239861fc40a6e00944ed4f52901dda10f0 >--- /dev/null >+++ b/LayoutTests/inspector/audit/run-expected.txt >@@ -0,0 +1,13 @@ >+Testing audits involving DOM attributes. >+ >+ >+== Running test suite: Audit.run >+-- Running test case: Audit.run.Valid >+PASS: Run should send back 42. >+ >+-- Running test case: Audit.run.Valid.InjectedObject >+PASS: The injected AUDIT should be an instance of InspectorAuditUtilities. >+ >+-- Running test case: Audit.run.Invalid >+TypeError: eval(42) is not a function. (In 'eval(42)()', 'eval(42)' is 42) >+ >diff --git a/LayoutTests/inspector/audit/run.html b/LayoutTests/inspector/audit/run.html >new file mode 100644 >index 0000000000000000000000000000000000000000..906bfcc892cd5a7c767d4edd1d8c1c14660b7c19 >--- /dev/null >+++ b/LayoutTests/inspector/audit/run.html >@@ -0,0 +1,54 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../http/tests/inspector/resources/inspector-test.js"></script> >+<script> >+ >+function test() >+{ >+ let suite = InspectorTest.createAsyncSuite("Audit.run"); >+ >+ suite.addTestCase({ >+ name: "Audit.run.Valid", >+ description: "Check that Audit.run is able to respond with a RemoteObject.", >+ async test() { >+ const functionString = `function() { return 42; }`; >+ let {result, wasThrown} = await AuditAgent.run(functionString); >+ InspectorTest.assert(!wasThrown); >+ InspectorTest.expectEqual(result.value, 42, "Run should send back 42."); >+ }, >+ }); >+ >+ suite.addTestCase({ >+ name: "Audit.run.Valid.InjectedObject", >+ description: "Check that an InspectorAuditUtilities object is injected into the function that is executed.", >+ async test() { >+ const functionString = `function() { return AUDIT; }`; >+ let {result, wasThrown} = await AuditAgent.run(functionString); >+ InspectorTest.assert(!wasThrown); >+ InspectorTest.expectEqual(result.description, "InspectorAuditUtilities", "The injected AUDIT should be an instance of InspectorAuditUtilities."); >+ }, >+ }); >+ >+ suite.addTestCase({ >+ name: "Audit.run.Invalid", >+ description: "Check that an error is thrown when trying to execute a non-function.", >+ async test() { >+ const functionString = `42`; >+ let {result, wasThrown} = await AuditAgent.run(functionString); >+ InspectorTest.assert(wasThrown); >+ InspectorTest.log(result.description); >+ }, >+ }); >+ >+ suite.runTestCasesAndFinish(); >+} >+</script> >+</head> >+<body onload="runTest()"> >+ <p>Testing audits involving DOM attributes.</p> >+ <div id="id1" class="class2 class3"></div> >+ <div id="id2" class="class3 class1"></div> >+ <div id="id3" class="class1 class2"></div> >+</body> >+</html>
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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193149
:
358347
|
358357
|
358359
|
358375
|
358380
|
358394
|
358400
|
358409
|
358422
|
358462
|
358467
|
358843
|
359007
|
359118
|
359120
|
359124
|
359132
|
359139