Title: [233655] trunk
Revision
233655
Author
[email protected]
Date
2018-07-09 13:00:32 -0700 (Mon, 09 Jul 2018)

Log Message

REGRESSION: Web Inspector no longer pauses in internal injected scripts like WDFindNodes.js
https://bugs.webkit.org/show_bug.cgi?id=187350
<rdar://problem/41728249>

Reviewed by Matt Baker.

Source/_javascript_Core:

Add a new command that toggles whether or not to blackbox internal scripts.
If blackboxed, the scripts will not be shown to the frontend and the debugger will
not pause in source frames from blackboxed scripts. Sometimes we want to break into
those scripts when debugging Web Inspector, WebDriver, or other WebKit-internal code
that injects scripts.

* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::setPauseForInternalScripts):
(Inspector::InspectorDebuggerAgent::didParseSource):
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/protocol/Debugger.json:

Source/WebInspectorUI:

* UserInterface/Base/Setting.js: Add a new setting to allow pausing in internal scripts.
* UserInterface/Controllers/DebuggerManager.js: Listen to the setting change and toggle
the backend setting accordingly. The default is to not break into internal scripts.

* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createDebugSettingsView):
Expose the new setting in the Debug settings panel.

LayoutTests:

Add a new test to demonstrate a difference in behavior when Debugger.setPauseForInternalScripts(true)
is sent to the backend. There's no way to correctly stringify the current call frame when stepping into
console.log because the injected script was blackboxed at the time that the scripts were parsed.
Instead, the stepping output just shows that the debugger is paused somewhere inside console.log.

* inspector/debugger/pause-for-internal-scripts-expected.txt: Added.
* inspector/debugger/pause-for-internal-scripts.html: Added.
* inspector/debugger/resources/log-pause-location.js:
(TestPage.registerInitializer.window.addSteppingTestCase):
(TestPage.registerInitializer):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (233654 => 233655)


--- trunk/LayoutTests/ChangeLog	2018-07-09 19:33:26 UTC (rev 233654)
+++ trunk/LayoutTests/ChangeLog	2018-07-09 20:00:32 UTC (rev 233655)
@@ -1,3 +1,22 @@
+2018-07-09  Brian Burg  <[email protected]>
+
+        REGRESSION: Web Inspector no longer pauses in internal injected scripts like WDFindNodes.js
+        https://bugs.webkit.org/show_bug.cgi?id=187350
+        <rdar://problem/41728249>
+
+        Reviewed by Matt Baker.
+
+        Add a new test to demonstrate a difference in behavior when Debugger.setPauseForInternalScripts(true)
+        is sent to the backend. There's no way to correctly stringify the current call frame when stepping into
+        console.log because the injected script was blackboxed at the time that the scripts were parsed.
+        Instead, the stepping output just shows that the debugger is paused somewhere inside console.log.
+
+        * inspector/debugger/pause-for-internal-scripts-expected.txt: Added.
+        * inspector/debugger/pause-for-internal-scripts.html: Added.
+        * inspector/debugger/resources/log-pause-location.js:
+        (TestPage.registerInitializer.window.addSteppingTestCase):
+        (TestPage.registerInitializer):
+
 2018-07-09  Truitt Savell  <[email protected]>
 
         Layout Test media/video-background-playback.html is flaky

Added: trunk/LayoutTests/inspector/debugger/pause-for-internal-scripts-expected.txt (0 => 233655)


--- trunk/LayoutTests/inspector/debugger/pause-for-internal-scripts-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/pause-for-internal-scripts-expected.txt	2018-07-09 20:00:32 UTC (rev 233655)
@@ -0,0 +1,127 @@
+CONSOLE MESSAGE: line 9: [object Window]
+CONSOLE MESSAGE: line 10: [object Console]
+CONSOLE MESSAGE: line 11: string
+CONSOLE MESSAGE: line 9: [object Window]
+CONSOLE MESSAGE: line 10: [object Console]
+CONSOLE MESSAGE: line 11: string
+Checking whether console.log can be stepped into or not, depending on the value of WI.settings.pauseForInternalScripts.
+
+
+== Running test suite: Debugger.setPauseForInternalScripts
+-- Running test setup.
+-- Running test case: Debugger.setPauseForInternalScripts.Disabled
+_expression_: setTimeout(entryConsoleLog)
+STEPS: over, in, in, in, resume
+PAUSED (debugger-statement)
+PAUSE AT entryConsoleLog:8:5
+      4    <script src=""
+      5    <script>
+      6    function entryConsoleLog() {
+ ->   7        |debugger;
+      8        console.log(window);
+      9        console.log(console);
+     10        console.log("string");
+
+ACTION: step-over
+PAUSE AT entryConsoleLog:9:5
+      5    <script>
+      6    function entryConsoleLog() {
+      7        debugger;
+ ->   8        |console.log(window);
+      9        console.log(console);
+     10        console.log("string");
+     11    }
+
+ACTION: step-in
+PAUSE AT entryConsoleLog:10:5
+      6    function entryConsoleLog() {
+      7        debugger;
+      8        console.log(window);
+ ->   9        |console.log(console);
+     10        console.log("string");
+     11    }
+     12    
+
+ACTION: step-in
+PAUSE AT entryConsoleLog:11:5
+      7        debugger;
+      8        console.log(window);
+      9        console.log(console);
+ ->  10        |console.log("string");
+     11    }
+     12    
+     13    // ---------
+
+ACTION: step-in
+PAUSE AT entryConsoleLog:12:2
+      8        console.log(window);
+      9        console.log(console);
+     10        console.log("string");
+ ->  11    }|
+     12    
+     13    // ---------
+     14    
+
+ACTION: resume
+RESUMED
+PASS: Should have used all steps.
+-- Running test setup.
+
+-- Running test case: Debugger.setPauseForInternalScripts.Enabled
+_expression_: setTimeout(entryConsoleLog)
+STEPS: over, in, in, in, resume
+PAUSED (debugger-statement)
+PAUSE AT entryConsoleLog:8:5
+      4    <script src=""
+      5    <script>
+      6    function entryConsoleLog() {
+ ->   7        |debugger;
+      8        console.log(window);
+      9        console.log(console);
+     10        console.log("string");
+
+ACTION: step-over
+PAUSE AT entryConsoleLog:9:5
+      5    <script>
+      6    function entryConsoleLog() {
+      7        debugger;
+ ->   8        |console.log(window);
+      9        console.log(console);
+     10        console.log("string");
+     11    }
+
+ACTION: step-in
+PAUSE AT entryConsoleLog:9:16
+      5    <script>
+      6    function entryConsoleLog() {
+      7        debugger;
+ ->   8        console.log|(window);
+      9        console.log(console);
+     10        console.log("string");
+     11    }
+
+ACTION: step-in
+PAUSE AT entryConsoleLog:9:16
+      5    <script>
+      6    function entryConsoleLog() {
+      7        debugger;
+ ->   8        console.log|(window);
+      9        console.log(console);
+     10        console.log("string");
+     11    }
+
+ACTION: step-in
+PAUSE AT entryConsoleLog:9:16
+      5    <script>
+      6    function entryConsoleLog() {
+      7        debugger;
+ ->   8        console.log|(window);
+      9        console.log(console);
+     10        console.log("string");
+     11    }
+
+ACTION: resume
+RESUMED
+PASS: Should have used all steps.
+-- Running test teardown.
+

Added: trunk/LayoutTests/inspector/debugger/pause-for-internal-scripts.html (0 => 233655)


--- trunk/LayoutTests/inspector/debugger/pause-for-internal-scripts.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/pause-for-internal-scripts.html	2018-07-09 20:00:32 UTC (rev 233655)
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+function entryConsoleLog() {
+    debugger;
+    console.log(window);
+    console.log(console);
+    console.log("string");
+}
+
+// ---------
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Debugger.setPauseForInternalScripts");
+
+    window.initializeSteppingTestSuite(suite);
+
+    addSteppingTestCase({
+        name: "Debugger.setPauseForInternalScripts.Disabled",
+        description: "Should not be able to step into console.log statements which use the Internal InjectedScript.",
+        _expression_: "setTimeout(entryConsoleLog)",
+        // Call out directly to the backend since there is no other way to wait on the command result if changing via the setting.
+        setup: async () => { return DebuggerAgent.setPauseForInternalScripts(false); },
+        steps: [
+            "over",
+                "in", // console.log(window)
+                "in", // console.log(console)
+                "in", // console.log("string")
+            "resume",
+        ]
+    });
+
+    addSteppingTestCase({
+        name: "Debugger.setPauseForInternalScripts.Enabled",
+        description: "Should be able to step over console.log statements which use the Internal InjectedScript.",
+        _expression_: "setTimeout(entryConsoleLog)",
+        // Call out directly to the backend since there is no other way to wait on the command result if changing via the setting.
+        setup: async () => { return DebuggerAgent.setPauseForInternalScripts(true); },
+        teardown: async () => { return DebuggerAgent.setPauseForInternalScripts(false); },
+        steps: [
+            "over",
+                "in", // console.log(window)
+                "in", // [Somewhere inside console.log(window)]
+                "in", // [Somewhere inside console.log(window)]
+            "resume",
+        ]
+    });
+
+    loadMainPageContent().then(() => {
+        suite.runTestCasesAndFinish();
+    });
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Checking whether console.log can be stepped into or not, depending on the value of WI.settings.pauseForInternalScripts.</p>
+</body>
+</html>

Modified: trunk/LayoutTests/inspector/debugger/resources/log-pause-location.js (233654 => 233655)


--- trunk/LayoutTests/inspector/debugger/resources/log-pause-location.js	2018-07-09 19:33:26 UTC (rev 233654)
+++ trunk/LayoutTests/inspector/debugger/resources/log-pause-location.js	2018-07-09 20:00:32 UTC (rev 233655)
@@ -163,9 +163,9 @@
         });
     }
 
-    window.addSteppingTestCase = function({name, description, _expression_, steps, pauseOnAllException}) {
+    window.addSteppingTestCase = function({name, description, _expression_, steps, pauseOnAllException, setup, teardown}) {
         suite.addTestCase({
-            name, description,
+            name, description, setup, teardown,
             test(resolve, reject) {
                 // Setup.
                 currentSteps = steps;

Modified: trunk/Source/_javascript_Core/ChangeLog (233654 => 233655)


--- trunk/Source/_javascript_Core/ChangeLog	2018-07-09 19:33:26 UTC (rev 233654)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-07-09 20:00:32 UTC (rev 233655)
@@ -1,3 +1,23 @@
+2018-07-09  Brian Burg  <[email protected]>
+
+        REGRESSION: Web Inspector no longer pauses in internal injected scripts like WDFindNodes.js
+        https://bugs.webkit.org/show_bug.cgi?id=187350
+        <rdar://problem/41728249>
+
+        Reviewed by Matt Baker.
+
+        Add a new command that toggles whether or not to blackbox internal scripts.
+        If blackboxed, the scripts will not be shown to the frontend and the debugger will
+        not pause in source frames from blackboxed scripts. Sometimes we want to break into
+        those scripts when debugging Web Inspector, WebDriver, or other WebKit-internal code
+        that injects scripts.
+
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::setPauseForInternalScripts):
+        (Inspector::InspectorDebuggerAgent::didParseSource):
+        * inspector/agents/InspectorDebuggerAgent.h:
+        * inspector/protocol/Debugger.json:
+
 2018-07-09  Yusuke Suzuki  <[email protected]>
 
         [JSC] Make some data members of UnlinkedCodeBlock private

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (233654 => 233655)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2018-07-09 19:33:26 UTC (rev 233654)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2018-07-09 20:00:32 UTC (rev 233655)
@@ -884,6 +884,17 @@
     return script.sourceMappingURL;
 }
 
+void InspectorDebuggerAgent::setPauseForInternalScripts(ErrorString&, bool shouldPause)
+{
+    if (shouldPause == m_pauseForInternalScripts)
+        return;
+
+    m_pauseForInternalScripts = shouldPause;
+
+    if (m_pauseForInternalScripts)
+        m_scriptDebugServer.clearBlacklist();
+}
+
 static bool isWebKitInjectedScript(const String& sourceURL)
 {
     return sourceURL.startsWith("__InjectedScript_") && sourceURL.endsWith(".js");
@@ -905,7 +916,7 @@
 
     m_scripts.set(sourceID, script);
 
-    if (hasSourceURL && isWebKitInjectedScript(sourceURL))
+    if (hasSourceURL && isWebKitInjectedScript(sourceURL) && !m_pauseForInternalScripts)
         m_scriptDebugServer.addToBlacklist(sourceID);
 
     String scriptURLForBreakpoints = hasSourceURL ? script.sourceURL : script.url;

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h (233654 => 233655)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h	2018-07-09 19:33:26 UTC (rev 233654)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h	2018-07-09 20:00:32 UTC (rev 233655)
@@ -61,6 +61,7 @@
 
     void enable(ErrorString&) final;
     void disable(ErrorString&) final;
+    void setPauseForInternalScripts(ErrorString&, bool shouldPause) final;
     void setAsyncStackTraceDepth(ErrorString&, int depth) final;
     void setBreakpointsActive(ErrorString&, bool active) final;
     void setBreakpointByUrl(ErrorString&, int lineNumber, const String* optionalURL, const String* optionalURLRegex, const int* optionalColumnNumber, const JSON::Object* options, Protocol::Debugger::BreakpointId*, RefPtr<JSON::ArrayOf<Protocol::Debugger::Location>>& locations) final;
@@ -197,6 +198,7 @@
     bool m_hasExceptionValue { false };
     bool m_didPauseStopwatch { false };
     bool m_pauseOnAssertionFailures { false };
+    bool m_pauseForInternalScripts { false };
     bool m_registeredIdleCallback { false };
     int m_asyncStackTraceDepth { 0 };
 };

Modified: trunk/Source/_javascript_Core/inspector/protocol/Debugger.json (233654 => 233655)


--- trunk/Source/_javascript_Core/inspector/protocol/Debugger.json	2018-07-09 19:33:26 UTC (rev 233654)
+++ trunk/Source/_javascript_Core/inspector/protocol/Debugger.json	2018-07-09 20:00:32 UTC (rev 233655)
@@ -263,6 +263,13 @@
             ]
         },
         {
+            "name": "setPauseForInternalScripts",
+            "description": "Change whether to pause in the debugger for internal scripts. The default value is false.",
+            "parameters": [
+                { "name": "shouldPause", "type": "boolean" }
+            ]
+        },
+        {
             "name": "evaluateOnCallFrame",
             "description": "Evaluates _expression_ on a given call frame.",
             "parameters": [

Modified: trunk/Source/WebInspectorUI/ChangeLog (233654 => 233655)


--- trunk/Source/WebInspectorUI/ChangeLog	2018-07-09 19:33:26 UTC (rev 233654)
+++ trunk/Source/WebInspectorUI/ChangeLog	2018-07-09 20:00:32 UTC (rev 233655)
@@ -1,3 +1,19 @@
+2018-07-09  Brian Burg  <[email protected]>
+
+        REGRESSION: Web Inspector no longer pauses in internal injected scripts like WDFindNodes.js
+        https://bugs.webkit.org/show_bug.cgi?id=187350
+        <rdar://problem/41728249>
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Base/Setting.js: Add a new setting to allow pausing in internal scripts.
+        * UserInterface/Controllers/DebuggerManager.js: Listen to the setting change and toggle
+        the backend setting accordingly. The default is to not break into internal scripts.
+
+        * UserInterface/Views/SettingsTabContentView.js:
+        (WI.SettingsTabContentView.prototype._createDebugSettingsView):
+        Expose the new setting in the Debug settings panel.
+
 2018-07-06  Nikita Vasilyev  <[email protected]>
 
         Web Inspector: Dark Mode: resource search field has white text on white background

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js (233654 => 233655)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js	2018-07-09 19:33:26 UTC (rev 233654)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js	2018-07-09 20:00:32 UTC (rev 233655)
@@ -103,10 +103,6 @@
 };
 
 WI.settings = {
-    autoLogProtocolMessages: new WI.Setting("auto-collect-protocol-messages", false),
-    autoLogTimeStats: new WI.Setting("auto-collect-time-stats", false),
-    enableUncaughtExceptionReporter: new WI.Setting("enable-uncaught-exception-reporter", true),
-    enableLayoutFlashing: new WI.Setting("enable-layout-flashing", false),
     enableLineWrapping: new WI.Setting("enable-line-wrapping", false),
     indentUnit: new WI.Setting("indent-unit", 4),
     tabSize: new WI.Setting("tab-size", 4),
@@ -116,7 +112,6 @@
     clearLogOnNavigate: new WI.Setting("clear-log-on-navigate", true),
     clearNetworkOnNavigate: new WI.Setting("clear-network-on-navigate", true),
     zoomFactor: new WI.Setting("zoom-factor", 1),
-    layoutDirection: new WI.Setting("layout-direction-override", "system"),
     showScopeChainOnPause: new WI.Setting("show-scope-chain-sidebar", true),
     showImageGrid: new WI.Setting("show-image-grid", false),
     showCanvasPath: new WI.Setting("show-canvas-path", false),
@@ -131,4 +126,12 @@
     experimentalEnableNewTabBar: new WI.Setting("experimental-enable-new-tab-bar", false),
     experimentalEnableAccessibilityAuditTab: new WI.Setting("experimental-enable-accessibility-audit-tab", false),
     experimentalRecordingHasVisualEffect: new WI.Setting("experimental-recording-has-visual-effect", false),
+
+    // DebugUI
+    autoLogProtocolMessages: new WI.Setting("auto-collect-protocol-messages", false),
+    autoLogTimeStats: new WI.Setting("auto-collect-time-stats", false),
+    enableUncaughtExceptionReporter: new WI.Setting("enable-uncaught-exception-reporter", true),
+    enableLayoutFlashing: new WI.Setting("enable-layout-flashing", false),
+    layoutDirection: new WI.Setting("layout-direction-override", "system"),
+    pauseForInternalScripts: new WI.Setting("pause-for-internal-scripts", false),
 };

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (233654 => 233655)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js	2018-07-09 19:33:26 UTC (rev 233654)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js	2018-07-09 20:00:32 UTC (rev 233655)
@@ -99,6 +99,14 @@
         if (DebuggerAgent.setAsyncStackTraceDepth)
             DebuggerAgent.setAsyncStackTraceDepth(this._asyncStackTraceDepthSetting.value);
 
+        // COMPATIBILITY (iOS 12): DebuggerAgent.setPauseForInternalScripts did not exist yet.
+        if (DebuggerAgent.setPauseForInternalScripts) {
+            let updateBackendSetting = () => { DebuggerAgent.setPauseForInternalScripts(WI.settings.pauseForInternalScripts.value); };
+            WI.settings.pauseForInternalScripts.addEventListener(WI.Setting.Event.Changed, updateBackendSetting);
+
+            updateBackendSetting();
+        }
+
         this._ignoreBreakpointDisplayLocationDidChangeEvent = false;
 
         function restoreBreakpointsSoon() {

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js (233654 => 233655)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js	2018-07-09 19:33:26 UTC (rev 233654)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js	2018-07-09 20:00:32 UTC (rev 233655)
@@ -310,6 +310,8 @@
 
         this._debugSettingsView.addSeparator();
 
+        this._debugSettingsView.addSetting(WI.unlocalizedString("Debugging:"), WI.settings.pauseForInternalScripts, WI.unlocalizedString("Pause in WebKit-internal scripts"));
+
         this._debugSettingsView.addSetting(WI.unlocalizedString("Uncaught Exception Reporter:"), WI.settings.enableUncaughtExceptionReporter, WI.unlocalizedString("Enabled"));
 
         this._debugSettingsView.addSeparator();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to