Web Inspector: Audit: don't keep the injected sub-objects alive between runs
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Jan 2019 00:13:28 +0000 (00:13 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Jan 2019 00:13:28 +0000 (00:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193594
<rdar://problem/47398091>

Reviewed by Joseph Pecoraro.

Rather than save the `InspectorAuditAccessibilityObject` and `InspectorAuditDOMObject`
between individual `Audit.setup` invocations, we should only keep them alive so long as the
injected `WebInspectorAudit` object is alive (e.g. from `Audit.setup` to `Audit.teardown`).

This change fixes inspector/audit/run-accessibility.html.

* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
(WebCore::PageAuditAgent::populateAuditObject):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240188 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/agents/page/PageAuditAgent.cpp
Source/WebCore/inspector/agents/page/PageAuditAgent.h

index c3a928c..fe9a500 100644 (file)
@@ -1,3 +1,21 @@
+2019-01-18  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Audit: don't keep the injected sub-objects alive between runs
+        https://bugs.webkit.org/show_bug.cgi?id=193594
+        <rdar://problem/47398091>
+
+        Reviewed by Joseph Pecoraro.
+
+        Rather than save the `InspectorAuditAccessibilityObject` and `InspectorAuditDOMObject`
+        between individual `Audit.setup` invocations, we should only keep them alive so long as the
+        injected `WebInspectorAudit` object is alive (e.g. from `Audit.setup` to `Audit.teardown`).
+
+        This change fixes inspector/audit/run-accessibility.html.
+
+        * inspector/agents/page/PageAuditAgent.h:
+        * inspector/agents/page/PageAuditAgent.cpp:
+        (WebCore::PageAuditAgent::populateAuditObject):
+
 2019-01-18  Daniel Bates  <dabates@apple.com>
 
         Another attempt to fix the iOS build following <https://trac.webkit.org/changeset/240174>
index 9172b6c..141ec08 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "PageAuditAgent.h"
 
+#include "InspectorAuditAccessibilityObject.h"
+#include "InspectorAuditDOMObject.h"
 #include "JSInspectorAuditAccessibilityObject.h"
 #include "JSInspectorAuditDOMObject.h"
 #include "Page.h"
@@ -81,15 +83,11 @@ void PageAuditAgent::populateAuditObject(JSC::ExecState* execState, JSC::Strong<
     if (auto* globalObject = JSC::jsCast<JSDOMGlobalObject*>(execState->lexicalGlobalObject())) {
         JSC::JSLockHolder lock(execState);
 
-#define ADD_AUDIT_OBJECT(name) \
-        if (!m_audit##name##Object) \
-            m_audit##name##Object = InspectorAudit##name##Object::create(*this); \
-        if (JSC::JSValue inspectorAudit##name##Object = toJS(execState, globalObject, *m_audit##name##Object)) \
-            auditObject->putDirect(execState->vm(), JSC::Identifier::fromString(execState, "" #name ""), inspectorAudit##name##Object);
+        if (JSC::JSValue jsInspectorAuditAccessibilityObject = toJSNewlyCreated(execState, globalObject, InspectorAuditAccessibilityObject::create(*this))) \
+            auditObject->putDirect(execState->vm(), JSC::Identifier::fromString(execState, "Accessibility"), jsInspectorAuditAccessibilityObject);
 
-        ADD_AUDIT_OBJECT(Accessibility);
-        ADD_AUDIT_OBJECT(DOM);
-#undef ADD_AUDIT_OBJECT
+        if (JSC::JSValue jsInspectorAuditDOMObject = toJSNewlyCreated(execState, globalObject, InspectorAuditDOMObject::create(*this))) \
+            auditObject->putDirect(execState->vm(), JSC::Identifier::fromString(execState, "DOM"), jsInspectorAuditDOMObject);
     }
 }
 
index b96768f..ac46f4f 100644 (file)
@@ -25,8 +25,6 @@
 
 #pragma once
 
-#include "InspectorAuditAccessibilityObject.h"
-#include "InspectorAuditDOMObject.h"
 #include "InspectorWebAgentBase.h"
 #include <JavaScriptCore/InspectorAuditAgent.h>
 
@@ -50,8 +48,6 @@ private:
     void unmuteConsole() override;
 
     Page& m_inspectedPage;
-    RefPtr<InspectorAuditAccessibilityObject> m_auditAccessibilityObject;
-    RefPtr<InspectorAuditDOMObject> m_auditDOMObject;
 };
 
 } // namespace WebCore