Title: [295152] trunk
Revision
295152
Author
[email protected]
Date
2022-06-02 16:16:52 -0700 (Thu, 02 Jun 2022)

Log Message

Web Inspector: Audit: allow audits to be evaluated as a user gesture
https://bugs.webkit.org/show_bug.cgi?id=200276

Reviewed by Patrick Angle.

This will allow developers to create/run audits that pretend to be a user (e.g. play media, etc.).

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

* Source/_javascript_Core/inspector/protocol/Audit.json:
* Source/WebInspectorUI/UserInterface/Models/AuditTestBase.js:
Increment the current audit version number.

* Source/WebCore/inspector/agents/page/PageAuditAgent.h:
(WebCore::PageAuditAgent::inspectedPage const): Added.
Expose a way for `InspectorAudit*Object` to access the inspected `Page`.

* Source/WebCore/inspector/UserGestureEmulationScope.h: Renamed from Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h.
* Source/WebCore/inspector/UserGestureEmulationScope.cpp: Renamed from Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp.
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
Drive-by: Move this file as it's now used by more than just the `Page*Agent` specializations.

* LayoutTests/inspector/audit/run-dom.html:
* LayoutTests/inspector/audit/run-dom-expected.txt:

* LayoutTests/inspector/model/auditTestCase.html:
* LayoutTests/inspector/model/auditTestCase-expected.txt:
* LayoutTests/inspector/model/auditTestGroup.html:
* LayoutTests/inspector/model/auditTestGroup-expected.txt:
Drive-by: Make it so that these tests no longer need to be updated when the audit version changes.

Canonical link: https://commits.webkit.org/251241@main

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/inspector/audit/run-dom-expected.txt (295151 => 295152)


--- trunk/LayoutTests/inspector/audit/run-dom-expected.txt	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/LayoutTests/inspector/audit/run-dom-expected.txt	2022-06-02 23:16:52 UTC (rev 295152)
@@ -3,54 +3,90 @@
 
 
 == Running test suite: Audit.run.DOM
--- Running test case: Audit.run.DOM.hasEventListeners.noListeners
+-- Running test case: Audit.run.DOM.hasEventListeners.None.General
 Audit setup...
 Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#noListeners"))`...
 Result: false
 Audit teardown...
 
--- Running test case: Audit.run.DOM.hasEventListeners.noListeners.WithArgs
+-- Running test case: Audit.run.DOM.hasEventListeners.None.click
 Audit setup...
-Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#noListeners"), ["FakeEvent"])`...
+Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#noListeners"), "click")`...
 Result: false
 Audit teardown...
 
--- Running test case: Audit.run.DOM.hasEventListeners.attributeListener
+-- Running test case: Audit.run.DOM.hasEventListeners.None.FakeEvent
 Audit setup...
+Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#noListeners"), "FakeEvent")`...
+Result: false
+Audit teardown...
+
+-- Running test case: Audit.run.DOM.hasEventListeners.Attribute.General
+Audit setup...
 Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#attributeListener"))`...
 Result: true
 Audit teardown...
 
--- Running test case: Audit.run.DOM.hasEventListeners.attributeListener.WithArgs
+-- Running test case: Audit.run.DOM.hasEventListeners.Attribute.click
 Audit setup...
-Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#attributeListener"), ["FakeEvent"])`...
+Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#attributeListener"), "click")`...
+Result: true
+Audit teardown...
+
+-- Running test case: Audit.run.DOM.hasEventListeners.Attribute.FakeEvent
+Audit setup...
+Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#attributeListener"), "FakeEvent")`...
 Result: false
 Audit teardown...
 
--- Running test case: Audit.run.DOM.hasEventListeners._javascript_Listener
+-- Running test case: Audit.run.DOM.hasEventListeners._javascript_.General
 Audit setup...
 Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#_javascript_Listener"))`...
 Result: true
 Audit teardown...
 
--- Running test case: Audit.run.DOM.hasEventListeners._javascript_Listener.WithArgs
+-- Running test case: Audit.run.DOM.hasEventListeners._javascript_.click
 Audit setup...
-Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#_javascript_Listener"), ["FakeEvent"])`...
+Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#_javascript_Listener"), "click")`...
+Result: true
+Audit teardown...
+
+-- Running test case: Audit.run.DOM.hasEventListeners._javascript_.FakeEvent
+Audit setup...
+Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#_javascript_Listener"), "FakeEvent")`...
 Result: false
 Audit teardown...
 
--- Running test case: Audit.run.DOM.hasEventListeners.builtinListener
+-- Running test case: Audit.run.DOM.hasEventListeners.Builtin.General
 Audit setup...
 Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#builtinListener"))`...
 Result: false
 Audit teardown...
 
--- Running test case: Audit.run.DOM.hasEventListeners.builtinListener.WithArgs
+-- Running test case: Audit.run.DOM.hasEventListeners.Builtin.play
 Audit setup...
-Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#builtinListener"), ["FakeEvent"])`...
+Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#builtinListener"), "play")`...
 Result: false
 Audit teardown...
 
+-- Running test case: Audit.run.DOM.hasEventListeners.Builtin.FakeEvent
+Audit setup...
+Audit run `WebInspectorAudit.DOM.hasEventListeners(document.querySelector("#builtinListener"), "FakeEvent")`...
+Result: false
+Audit teardown...
+
+-- Running test case: Audit.run.DOM.simulateUserInteraction.UserGesture
+Audit setup...
+Audit run `(() => { let result = undefined; WebInspectorAudit.DOM.simulateUserInteraction(() => { result = internals.isProcessingUserGesture(); }); return result; })()`...
+Result: true
+Audit teardown...
+
+-- Running test case: Audit.run.DOM.simulateUserInteraction.TransientActivation
+Audit setup...
+Audit run `(() => { let result = undefined; WebInspectorAudit.DOM.simulateUserInteraction(() => { result = internals.hasTransientActivation(); }); return result; })()`...
+Result: true
+Audit teardown...
+
 -- Running test case: Audit.run.DOM.InvalidCopiedFunctionCall
 Audit setup...
 Copying WebInspectorAudit to window...
@@ -58,4 +94,7 @@
 Testing copied hasEventListeners...
 PASS: Should produce an exception.
 Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
+Testing copied simulateUserInteraction...
+PASS: Should produce an exception.
+Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
 

Modified: trunk/LayoutTests/inspector/audit/run-dom.html (295151 => 295152)


--- trunk/LayoutTests/inspector/audit/run-dom.html	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/LayoutTests/inspector/audit/run-dom.html	2022-06-02 23:16:52 UTC (rev 295152)
@@ -8,26 +8,41 @@
 {
     let suite = InspectorTest.Audit.createSuite("Audit.run.DOM");
 
-    function evaluateStringForTest(func, target, args) {
-        return `WebInspectorAudit.DOM.${func}(document.querySelector("#${target}")${args ? ", " + JSON.stringify(args) : ""})`;
+    function evaluateStringForTest(func, args, prefix = "") {
+        switch (func) {
+        case "hasEventListeners":
+            return `${prefix}WebInspectorAudit.DOM.${func}(${args.join(", ")})`;
+
+        case "simulateUserInteraction":
+            return `(() => { let result = undefined; ${prefix}WebInspectorAudit.DOM.${func}(${args.join(", ")}); return result; })()`;
+        }
+
+        return "'FAIL'";
     }
 
     const tests = [
-        { func: "hasEventListeners", target: "noListeners" },
-        { func: "hasEventListeners", target: "noListeners", args: ["FakeEvent"] },
-        { func: "hasEventListeners", target: "attributeListener" },
-        { func: "hasEventListeners", target: "attributeListener", args: ["FakeEvent"] },
-        { func: "hasEventListeners", target: "_javascript_Listener" },
-        { func: "hasEventListeners", target: "_javascript_Listener", args: ["FakeEvent"] },
-        { func: "hasEventListeners", target: "builtinListener" },
-        { func: "hasEventListeners", target: "builtinListener", args: ["FakeEvent"] },
+        { func: "hasEventListeners", name: "None.General", args: [`document.querySelector("#noListeners")`] },
+        { func: "hasEventListeners", name: "None.click", args: [`document.querySelector("#noListeners")`, `"click"`] },
+        { func: "hasEventListeners", name: "None.FakeEvent", args: [`document.querySelector("#noListeners")`, `"FakeEvent"`] },
+        { func: "hasEventListeners", name: "Attribute.General", args: [`document.querySelector("#attributeListener")`] },
+        { func: "hasEventListeners", name: "Attribute.click", args: [`document.querySelector("#attributeListener")`, `"click"`] },
+        { func: "hasEventListeners", name: "Attribute.FakeEvent", args: [`document.querySelector("#attributeListener")`, `"FakeEvent"`] },
+        { func: "hasEventListeners", name: "_javascript_.General", args: [`document.querySelector("#_javascript_Listener")`] },
+        { func: "hasEventListeners", name: "_javascript_.click", args: [`document.querySelector("#_javascript_Listener")`, `"click"`] },
+        { func: "hasEventListeners", name: "_javascript_.FakeEvent", args: [`document.querySelector("#_javascript_Listener")`, `"FakeEvent"`] },
+        { func: "hasEventListeners", name: "Builtin.General", args: [`document.querySelector("#builtinListener")`] },
+        { func: "hasEventListeners", name: "Builtin.play", args: [`document.querySelector("#builtinListener")`, `"play"`] },
+        { func: "hasEventListeners", name: "Builtin.FakeEvent", args: [`document.querySelector("#builtinListener")`, `"FakeEvent"`] },
+
+        { func: "simulateUserInteraction", name: "UserGesture", args: [`() => { result = internals.isProcessingUserGesture(); }`] },
+        { func: "simulateUserInteraction", name: "TransientActivation", args: [`() => { result = internals.hasTransientActivation(); }`] },
     ];
 
-    for (let {func, target, args} of tests) {
+    for (let {func, name, args} of tests) {
         suite.addTestCase({
-            name: "Audit.run.DOM." + func + "." + target + (args ? ".WithArgs" : ""),
+            name: "Audit.run.DOM." + func + (name ? "." + name : ""),
             async test() {
-                let functionString = evaluateStringForTest(func, target, args);
+                let functionString = evaluateStringForTest(func, args);
 
                  await InspectorTest.Audit.setupAudit();
 
@@ -58,10 +73,10 @@
             InspectorTest.assert(!wasThrown, "Should not throw an exception.");
             await InspectorTest.Audit.teardownAudit();
 
-            for (let {func, target, args} of functions.values()) {
+            for (let {func, args} of functions.values()) {
                 InspectorTest.log(`Testing copied ${func}...`);
                 await InspectorTest.expectException(async function() {
-                    await InspectorTest.evaluateInPage("window.Copied" + evaluateStringForTest(func, target, args));
+                    await InspectorTest.evaluateInPage(evaluateStringForTest(func, args, "window.Copied"));
                 });
             }
         },

Modified: trunk/LayoutTests/inspector/model/auditTestCase-expected.txt (295151 => 295152)


--- trunk/LayoutTests/inspector/model/auditTestCase-expected.txt	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/LayoutTests/inspector/model/auditTestCase-expected.txt	2022-06-02 23:16:52 UTC (rev 295152)
@@ -28,7 +28,7 @@
 {
   "type": "test-case",
   "name": "validWithInvalidOptionals test name",
-  "supports": 4,
+  "supports": "<version + 1>",
   "test": "validWithInvalidOptionals test function"
 }
 
@@ -37,7 +37,7 @@
   "type": "test-case",
   "name": "validWithValidOptionals test name",
   "description": "validWithValidOptionals test description",
-  "supports": 2,
+  "supports": "<version + -1>",
   "setup": "validWithValidOptionals test setup",
   "test": "validWithValidOptionals test function"
 }

Modified: trunk/LayoutTests/inspector/model/auditTestCase.html (295151 => 295152)


--- trunk/LayoutTests/inspector/model/auditTestCase.html	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/LayoutTests/inspector/model/auditTestCase.html	2022-06-02 23:16:52 UTC (rev 295152)
@@ -12,7 +12,14 @@
             name,
             async test() {
                 let object = await WI.AuditTestCase.fromPayload(payload);
-                InspectorTest.log(object ? JSON.stringify(object, null, 2) : object);
+
+                function replacer(key, value) {
+                    if (key === "supports")
+                        return `<version + ${value - WI.AuditTestBase.Version}>`;
+
+                    return value;
+                }
+                InspectorTest.log(object ? JSON.stringify(object, replacer, 2) : object);
             },
         });
     }

Modified: trunk/LayoutTests/inspector/model/auditTestGroup-expected.txt (295151 => 295152)


--- trunk/LayoutTests/inspector/model/auditTestGroup-expected.txt	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/LayoutTests/inspector/model/auditTestGroup-expected.txt	2022-06-02 23:16:52 UTC (rev 295152)
@@ -43,12 +43,12 @@
 {
   "type": "test-group",
   "name": "validWithInvalidOptionals group name",
-  "supports": 4,
+  "supports": "<version + 1>",
   "tests": [
     {
       "type": "test-case",
       "name": "validWithInvalidOptionals test name",
-      "supports": 5,
+      "supports": "<version + 2>",
       "test": "validWithInvalidOptionals test function"
     }
   ]
@@ -59,7 +59,7 @@
   "type": "test-group",
   "name": "validWithValidOptionals group name",
   "description": "validWithValidOptionals group description",
-  "supports": 2,
+  "supports": "<version + -1>",
   "setup": "validWithValidOptionals group setup",
   "tests": [
     {
@@ -66,7 +66,7 @@
       "type": "test-case",
       "name": "validWithValidOptionals test name",
       "description": "validWithValidOptionals test description",
-      "supports": 1,
+      "supports": "<version + -2>",
       "setup": "validWithValidOptionals test setup",
       "test": "validWithValidOptionals test function"
     }
@@ -78,7 +78,7 @@
   "type": "test-group",
   "name": "validNested group name",
   "description": "validNested group description",
-  "supports": 2,
+  "supports": "<version + -1>",
   "setup": "validNested group setup",
   "tests": [
     {
@@ -85,7 +85,7 @@
       "type": "test-group",
       "name": "validNested nested group name",
       "description": "validNested nested group description",
-      "supports": 1,
+      "supports": "<version + -2>",
       "setup": "validNested nested group setup",
       "tests": [
         {
@@ -92,7 +92,7 @@
           "type": "test-case",
           "name": "validNested nested test name",
           "description": "validNested nested test description",
-          "supports": 0,
+          "supports": "<version + -3>",
           "setup": "validNested nested test setup",
           "test": "validNested nested test function"
         }
@@ -102,7 +102,7 @@
       "type": "test-case",
       "name": "validNested test name",
       "description": "validNested test description",
-      "supports": -1,
+      "supports": "<version + -4>",
       "setup": "validNested test setup",
       "test": "validNested test function"
     }

Modified: trunk/LayoutTests/inspector/model/auditTestGroup.html (295151 => 295152)


--- trunk/LayoutTests/inspector/model/auditTestGroup.html	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/LayoutTests/inspector/model/auditTestGroup.html	2022-06-02 23:16:52 UTC (rev 295152)
@@ -12,7 +12,14 @@
             name,
             async test() {
                 let object = await WI.AuditTestGroup.fromPayload(payload);
-                InspectorTest.log(object ? JSON.stringify(object, null, 2) : object);
+
+                function replacer(key, value) {
+                    if (key === "supports")
+                        return `<version + ${value - WI.AuditTestBase.Version}>`;
+
+                    return value;
+                }
+                InspectorTest.log(object ? JSON.stringify(object, replacer, 2) : object);
             },
         });
     }

Modified: trunk/Source/_javascript_Core/inspector/protocol/Audit.json (295151 => 295152)


--- trunk/Source/_javascript_Core/inspector/protocol/Audit.json	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/Source/_javascript_Core/inspector/protocol/Audit.json	2022-06-02 23:16:52 UTC (rev 295152)
@@ -1,7 +1,7 @@
 {
     "domain": "Audit",
     "description": "",
-    "version": 3,
+    "version": 4,
     "debuggableTypes": ["itml", "_javascript_", "page", "service-worker", "web-page"],
     "targetTypes": ["itml", "_javascript_", "page", "service-worker", "worker"],
     "commands": [

Modified: trunk/Source/WebCore/Sources.txt (295151 => 295152)


--- trunk/Source/WebCore/Sources.txt	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/Source/WebCore/Sources.txt	2022-06-02 23:16:52 UTC (rev 295152)
@@ -1510,6 +1510,7 @@
 inspector/NetworkResourcesData.cpp
 inspector/PageDebugger.cpp
 inspector/TimelineRecordFactory.cpp
+inspector/UserGestureEmulationScope.cpp
 inspector/WebInjectedScriptHost.cpp
 inspector/WebInjectedScriptManager.cpp
 inspector/WorkerInspectorController.cpp
@@ -1540,7 +1541,6 @@
 inspector/agents/page/PageHeapAgent.cpp
 inspector/agents/page/PageNetworkAgent.cpp
 inspector/agents/page/PageRuntimeAgent.cpp
-inspector/agents/page/UserGestureEmulationScope.cpp
 inspector/agents/worker/ServiceWorkerAgent.cpp
 inspector/agents/worker/WorkerAuditAgent.cpp
 inspector/agents/worker/WorkerConsoleAgent.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (295151 => 295152)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2022-06-02 23:16:52 UTC (rev 295152)
@@ -20559,6 +20559,8 @@
 				91B952221F58A58000931DC2 /* RecordingSwizzleType.h */,
 				7553CFE7108F473F00EA281E /* TimelineRecordFactory.cpp */,
 				7553CFE6108F473F00EA281E /* TimelineRecordFactory.h */,
+				F32BDCD52363AAC90073B6AE /* UserGestureEmulationScope.cpp */,
+				F32BDCD72363AACA0073B6AE /* UserGestureEmulationScope.h */,
 				A5840E22187B8AC200843B10 /* WebInjectedScriptHost.cpp */,
 				A5840E23187B8AC200843B10 /* WebInjectedScriptHost.h */,
 				A584FE2D1864CB8400843B10 /* WebInjectedScriptManager.cpp */,
@@ -27073,8 +27075,6 @@
 				A5CB05211FB51F1700089B97 /* PageNetworkAgent.h */,
 				A5B81CC11FAA44B70037D1E6 /* PageRuntimeAgent.cpp */,
 				A5B81CBF1FAA44B70037D1E6 /* PageRuntimeAgent.h */,
-				F32BDCD52363AAC90073B6AE /* UserGestureEmulationScope.cpp */,
-				F32BDCD72363AACA0073B6AE /* UserGestureEmulationScope.h */,
 			);
 			path = page;
 			sourceTree = "<group>";

Modified: trunk/Source/WebCore/inspector/InspectorAuditDOMObject.cpp (295151 => 295152)


--- trunk/Source/WebCore/inspector/InspectorAuditDOMObject.cpp	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/Source/WebCore/inspector/InspectorAuditDOMObject.cpp	2022-06-02 23:16:52 UTC (rev 295152)
@@ -27,7 +27,10 @@
 #include "config.h"
 #include "InspectorAuditDOMObject.h"
 
+#include "Document.h"
 #include "Node.h"
+#include "UserGestureEmulationScope.h"
+#include "VoidCallback.h"
 #include <wtf/text/AtomString.h>
 #include <wtf/text/WTFString.h>
 
@@ -39,7 +42,7 @@
     if (!m_auditAgent.hasActiveAudit()) \
         return Exception { NotAllowedError, "Cannot be called outside of a Web Inspector Audit"_s };
 
-InspectorAuditDOMObject::InspectorAuditDOMObject(InspectorAuditAgent& auditAgent)
+InspectorAuditDOMObject::InspectorAuditDOMObject(PageAuditAgent& auditAgent)
     : m_auditAgent(auditAgent)
 {
 }
@@ -66,4 +69,14 @@
     return false;
 }
 
+ExceptionOr<void> InspectorAuditDOMObject::simulateUserInteraction(Document& document, Ref<VoidCallback>&& callback)
+{
+    ERROR_IF_NO_ACTIVE_AUDIT();
+
+    UserGestureEmulationScope userGestureScope(m_auditAgent.inspectedPage(), true, &document);
+    callback->handleEvent();
+
+    return { };
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/inspector/InspectorAuditDOMObject.h (295151 => 295152)


--- trunk/Source/WebCore/inspector/InspectorAuditDOMObject.h	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/Source/WebCore/inspector/InspectorAuditDOMObject.h	2022-06-02 23:16:52 UTC (rev 295152)
@@ -26,17 +26,19 @@
 #pragma once
 
 #include "ExceptionOr.h"
-#include <_javascript_Core/InspectorAuditAgent.h>
+#include "PageAuditAgent.h"
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
 
+class Document;
 class Node;
+class VoidCallback;
 
 class InspectorAuditDOMObject : public RefCounted<InspectorAuditDOMObject> {
 public:
-    static Ref<InspectorAuditDOMObject> create(Inspector::InspectorAuditAgent& auditAgent)
+    static Ref<InspectorAuditDOMObject> create(PageAuditAgent& auditAgent)
     {
         return adoptRef(*new InspectorAuditDOMObject(auditAgent));
     }
@@ -43,10 +45,12 @@
 
     ExceptionOr<bool> hasEventListeners(Node&, const String& type);
 
+    ExceptionOr<void> simulateUserInteraction(Document&, Ref<VoidCallback>&&);
+
 private:
-    explicit InspectorAuditDOMObject(Inspector::InspectorAuditAgent&);
+    explicit InspectorAuditDOMObject(PageAuditAgent&);
 
-    Inspector::InspectorAuditAgent& m_auditAgent;
+    PageAuditAgent& m_auditAgent;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/inspector/InspectorAuditDOMObject.idl (295151 => 295152)


--- trunk/Source/WebCore/inspector/InspectorAuditDOMObject.idl	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/Source/WebCore/inspector/InspectorAuditDOMObject.idl	2022-06-02 23:16:52 UTC (rev 295152)
@@ -28,4 +28,6 @@
     LegacyNoInterfaceObject,
 ] interface InspectorAuditDOMObject {
     boolean hasEventListeners(Node node, optional DOMString type);
+
+    [CallWith=CurrentDocument] undefined simulateUserInteraction(VoidCallback callback);
 };

Copied: trunk/Source/WebCore/inspector/UserGestureEmulationScope.cpp (from rev 295151, trunk/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp) (0 => 295152)


--- trunk/Source/WebCore/inspector/UserGestureEmulationScope.cpp	                        (rev 0)
+++ trunk/Source/WebCore/inspector/UserGestureEmulationScope.cpp	2022-06-02 23:16:52 UTC (rev 295152)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2019 Microsoft Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "UserGestureEmulationScope.h"
+
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "Document.h"
+#include "Page.h"
+#include "UserGestureIndicator.h"
+
+namespace WebCore {
+
+UserGestureEmulationScope::UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture, Document* document)
+    : m_pageChromeClient(inspectedPage.chrome().client())
+    , m_gestureIndicator(emulateUserGesture ? std::optional<ProcessingUserGestureState>(ProcessingUserGesture) : std::nullopt, document)
+    , m_emulateUserGesture(emulateUserGesture)
+    , m_userWasInteracting(false)
+{
+    if (m_emulateUserGesture) {
+        m_userWasInteracting = m_pageChromeClient.userIsInteracting();
+        if (!m_userWasInteracting)
+            m_pageChromeClient.setUserIsInteracting(true);
+    }
+}
+
+UserGestureEmulationScope::~UserGestureEmulationScope()
+{
+    if (m_emulateUserGesture && !m_userWasInteracting && m_pageChromeClient.userIsInteracting())
+        m_pageChromeClient.setUserIsInteracting(false);
+}
+
+} // namespace WebCore

Copied: trunk/Source/WebCore/inspector/UserGestureEmulationScope.h (from rev 295151, trunk/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h) (0 => 295152)


--- trunk/Source/WebCore/inspector/UserGestureEmulationScope.h	                        (rev 0)
+++ trunk/Source/WebCore/inspector/UserGestureEmulationScope.h	2022-06-02 23:16:52 UTC (rev 295152)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2019 Microsoft Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "UserGestureIndicator.h"
+
+namespace WebCore {
+
+class ChromeClient;
+class Document;
+class Page;
+
+class UserGestureEmulationScope {
+    WTF_MAKE_NONCOPYABLE(UserGestureEmulationScope);
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    UserGestureEmulationScope(Page&, bool emulateUserGesture, Document* = nullptr);
+    ~UserGestureEmulationScope();
+
+private:
+    ChromeClient& m_pageChromeClient;
+    UserGestureIndicator m_gestureIndicator;
+    bool m_emulateUserGesture;
+    bool m_userWasInteracting;
+};
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/inspector/agents/page/PageAuditAgent.h (295151 => 295152)


--- trunk/Source/WebCore/inspector/agents/page/PageAuditAgent.h	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/Source/WebCore/inspector/agents/page/PageAuditAgent.h	2022-06-02 23:16:52 UTC (rev 295152)
@@ -39,6 +39,8 @@
     PageAuditAgent(PageAgentContext&);
     ~PageAuditAgent();
 
+    Page& inspectedPage() const { return m_inspectedPage; }
+
 private:
     Inspector::InjectedScript injectedScriptForEval(std::optional<Inspector::Protocol::Runtime::ExecutionContextId>&&);
     Inspector::InjectedScript injectedScriptForEval(Inspector::Protocol::ErrorString&, std::optional<Inspector::Protocol::Runtime::ExecutionContextId>&&);

Deleted: trunk/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp (295151 => 295152)


--- trunk/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp	2022-06-02 23:16:52 UTC (rev 295152)
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2019 Microsoft Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * 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.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER OR 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 "UserGestureEmulationScope.h"
-
-#include "Chrome.h"
-#include "ChromeClient.h"
-#include "Document.h"
-#include "Page.h"
-#include "UserGestureIndicator.h"
-
-namespace WebCore {
-
-UserGestureEmulationScope::UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture, Document* document)
-    : m_pageChromeClient(inspectedPage.chrome().client())
-    , m_gestureIndicator(emulateUserGesture ? std::optional<ProcessingUserGestureState>(ProcessingUserGesture) : std::nullopt, document)
-    , m_emulateUserGesture(emulateUserGesture)
-    , m_userWasInteracting(false)
-{
-    if (m_emulateUserGesture) {
-        m_userWasInteracting = m_pageChromeClient.userIsInteracting();
-        if (!m_userWasInteracting)
-            m_pageChromeClient.setUserIsInteracting(true);
-    }
-}
-
-UserGestureEmulationScope::~UserGestureEmulationScope()
-{
-    if (m_emulateUserGesture && !m_userWasInteracting && m_pageChromeClient.userIsInteracting())
-        m_pageChromeClient.setUserIsInteracting(false);
-}
-
-} // namespace WebCore

Deleted: trunk/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h (295151 => 295152)


--- trunk/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h	2022-06-02 23:16:52 UTC (rev 295152)
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2019 Microsoft Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * 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.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER OR 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 "config.h"
-
-#include "UserGestureIndicator.h"
-
-namespace WebCore {
-
-class ChromeClient;
-class Document;
-class Page;
-
-class UserGestureEmulationScope {
-    WTF_MAKE_NONCOPYABLE(UserGestureEmulationScope);
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    UserGestureEmulationScope(Page&, bool emulateUserGesture, Document* = nullptr);
-    ~UserGestureEmulationScope();
-
-private:
-    ChromeClient& m_pageChromeClient;
-    UserGestureIndicator m_gestureIndicator;
-    bool m_emulateUserGesture;
-    bool m_userWasInteracting;
-};
-
-} // namespace WebCore

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestBase.js (295151 => 295152)


--- trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestBase.js	2022-06-02 22:37:10 UTC (rev 295151)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestBase.js	2022-06-02 23:16:52 UTC (rev 295152)
@@ -394,7 +394,7 @@
 };
 
 // Keep this in sync with Inspector::Protocol::Audit::VERSION.
-WI.AuditTestBase.Version = 3;
+WI.AuditTestBase.Version = 4;
 
 WI.AuditTestBase.ObjectGroup = "audit";
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to