Title: [276276] trunk/Tools
Revision
276276
Author
[email protected]
Date
2021-04-19 16:03:26 -0700 (Mon, 19 Apr 2021)

Log Message

Can't use Web Inspector on web views made by TestWebKitAPI
https://bugs.webkit.org/show_bug.cgi?id=147073
<rdar://problem/76708379>

Reviewed by Devin Rousso.

It is necessary to spin a nested run loop at the point in the test where you would
like to remote inspect a WebView. Messages from the remote connection are dispatched
through UIProcess, so if lldb has paused UIProcess, WebInspectorUI will not be able to
get any data from the inspected WebView.

* TestWebKitAPI/DebugUtilities.h: Added.
Add macros to wait for a remote inspector to attach or detach, then drop into
the debugger when it has done so.

* TestWebKitAPI/PlatformUtilities.h: Add missing `#pragma once`.
* TestWebKitAPI/WTFStringUtilities.h: Force the build to fail noisily if we have
attempted to redefine WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING. Force the correct
ordering between "WTFStringUtilities.h" and <wtf/text/StringConcatenate.h>.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (276275 => 276276)


--- trunk/Tools/ChangeLog	2021-04-19 22:20:53 UTC (rev 276275)
+++ trunk/Tools/ChangeLog	2021-04-19 23:03:26 UTC (rev 276276)
@@ -1,3 +1,25 @@
+2021-04-19  BJ Burg  <[email protected]>
+
+        Can't use Web Inspector on web views made by TestWebKitAPI
+        https://bugs.webkit.org/show_bug.cgi?id=147073
+        <rdar://problem/76708379>
+
+        Reviewed by Devin Rousso.
+
+        It is necessary to spin a nested run loop at the point in the test where you would
+        like to remote inspect a WebView. Messages from the remote connection are dispatched
+        through UIProcess, so if lldb has paused UIProcess, WebInspectorUI will not be able to
+        get any data from the inspected WebView.
+
+        * TestWebKitAPI/DebugUtilities.h: Added.
+        Add macros to wait for a remote inspector to attach or detach, then drop into
+        the debugger when it has done so.
+
+        * TestWebKitAPI/PlatformUtilities.h: Add missing `#pragma once`.
+        * TestWebKitAPI/WTFStringUtilities.h: Force the build to fail noisily if we have
+        attempted to redefine WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING. Force the correct
+        ordering between "WTFStringUtilities.h" and <wtf/text/StringConcatenate.h>.
+
 2021-04-19  Wenson Hsieh  <[email protected]>
 
         Rename FloatQuad::isEmpty() to boundingBoxIsEmpty() and reimplement isEmpty()

Added: trunk/Tools/TestWebKitAPI/DebugUtilities.h (0 => 276276)


--- trunk/Tools/TestWebKitAPI/DebugUtilities.h	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/DebugUtilities.h	2021-04-19 23:03:26 UTC (rev 276276)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2021 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
+
+#if PLATFORM(COCOA)
+
+#include "WTFStringUtilities.h"
+#include <WebKit/WKWebViewPrivate.h>
+#include <wtf/DebugUtilities.h>
+
+#define WAIT_FOR_INSPECTOR_TO_ATTACH(webView) \
+do { \
+    WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, "Spinning a nested run loop until an inspector attaches to the WebView. Remote inspect the process (PID: %d) to continue.", getCurrentProcessID()); \
+    do { \
+        TestWebKitAPI::Util::sleep(1); \
+        if ([webView _isBeingInspected]) \
+            break; \
+    } while (1); \
+    WTFBreakpointTrap(); \
+} while (0)
+
+#define WAIT_FOR_INSPECTOR_TO_DETACH(webView) \
+do { \
+    WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, "Spinning a nested run loop until no inspectors are attached to the WebView. Close all local and remote inspectors for the process (PID: %d) to continue.", getCurrentProcessID()); \
+    do { \
+        TestWebKitAPI::Util::sleep(1); \
+        if (![webView _isBeingInspected]) \
+            break; \
+    } while (1); \
+    WTFBreakpointTrap(); \
+} while (0)
+
+#endif // PLATFORM(COCOA)

Modified: trunk/Tools/TestWebKitAPI/PlatformUtilities.h (276275 => 276276)


--- trunk/Tools/TestWebKitAPI/PlatformUtilities.h	2021-04-19 22:20:53 UTC (rev 276275)
+++ trunk/Tools/TestWebKitAPI/PlatformUtilities.h	2021-04-19 23:03:26 UTC (rev 276276)
@@ -23,6 +23,8 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#pragma once
+
 #ifndef PlatformUtilities_h
 #define PlatformUtilities_h
 

Modified: trunk/Tools/TestWebKitAPI/WTFStringUtilities.h (276275 => 276276)


--- trunk/Tools/TestWebKitAPI/WTFStringUtilities.h	2021-04-19 22:20:53 UTC (rev 276275)
+++ trunk/Tools/TestWebKitAPI/WTFStringUtilities.h	2021-04-19 23:03:26 UTC (rev 276276)
@@ -30,9 +30,12 @@
 
 #pragma once
 
+#ifdef WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING
+#error "WTFStringUtilities.h must be included before <wtf/StringConcatenate.h>"
+#else
 #define WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING() (++wtfStringCopyCount)
-
 extern int wtfStringCopyCount;
+#endif
 
 #include <wtf/Assertions.h>
 #include <wtf/text/CString.h>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to