Title: [191839] trunk
Revision
191839
Author
[email protected]
Date
2015-10-30 21:58:28 -0700 (Fri, 30 Oct 2015)

Log Message

Web Inspector: Test Debugger.scriptParsed events received after opening inspector frontend
https://bugs.webkit.org/show_bug.cgi?id=150753

Patch by Joseph Pecoraro <[email protected]> on 2015-10-30
Reviewed by Timothy Hatcher.

Source/_javascript_Core:

* parser/Parser.h:
(JSC::Parser<LexerType>::parse):
Only set the directives on the SourceProvider if we were parsing the
entire file (Program or Module), not if we are in function parsing mode.
This was inadvertently clearing the directives stored on the
SourceProvider when the function parse didn't see directives and reset
the values on the source provider.

LayoutTests:

Explicit test for the scriptParsed events we expect to see
when first opening the inspector on an already open page.
We do not expect to see some scripts (built-ins) but do expect
to see all user scripts evaluated on the page.

* inspector/debugger/scriptParsed-expected.txt: Added.
* inspector/debugger/scriptParsed.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (191838 => 191839)


--- trunk/LayoutTests/ChangeLog	2015-10-31 04:03:58 UTC (rev 191838)
+++ trunk/LayoutTests/ChangeLog	2015-10-31 04:58:28 UTC (rev 191839)
@@ -1,3 +1,18 @@
+2015-10-30  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Test Debugger.scriptParsed events received after opening inspector frontend
+        https://bugs.webkit.org/show_bug.cgi?id=150753
+
+        Reviewed by Timothy Hatcher.
+
+        Explicit test for the scriptParsed events we expect to see
+        when first opening the inspector on an already open page.
+        We do not expect to see some scripts (built-ins) but do expect
+        to see all user scripts evaluated on the page.
+
+        * inspector/debugger/scriptParsed-expected.txt: Added.
+        * inspector/debugger/scriptParsed.html: Added.
+
 2015-10-28  Wenson Hsieh  <[email protected]>
 
         Inner height behavior when the keyboard is shown should match on WKWebView and MobileSafari

Added: trunk/LayoutTests/inspector/debugger/scriptParsed-expected.txt (0 => 191839)


--- trunk/LayoutTests/inspector/debugger/scriptParsed-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/scriptParsed-expected.txt	2015-10-31 04:58:28 UTC (rev 191839)
@@ -0,0 +1,15 @@
+Tests for the Debugger.scriptParsed messages the frontend receives when enabling the Debugger domain.
+
+
+== Running test suite: Debugger.scriptParsed.enable
+-- Running test case: EnableDebuggerDomainAndCheckInitialScripts
+Debugger Enabled - Initial Scripts Received
+PASS: Should have received some scriptParsed messages.
+PASS: Should find External Script.
+PASS: Should find Inline Script Tag Script.
+PASS: Should find Inline Attribute Event Listener Script.
+PASS: Should find Eval Script.
+PASS: Should find Inspector InjectedScriptSource Script.
+PASS: Should find Inspector CommandLineAPISource Script.
+PASS: Should not receive any unexpected scripts.
+

Added: trunk/LayoutTests/inspector/debugger/scriptParsed.html (0 => 191839)


--- trunk/LayoutTests/inspector/debugger/scriptParsed.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/scriptParsed.html	2015-10-31 04:58:28 UTC (rev 191839)
@@ -0,0 +1,123 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+// Create a named eval.
+eval("//# sourceURL=eval.js\nfunction foo() { }");
+
+function test()
+{
+    let suite = ProtocolTest.createAsyncSuite("Debugger.scriptParsed.enable");
+
+    ProtocolTest.dumpActivityToSystemConsole = true;
+    ProtocolTest.dumpInspectorProtocolMessages = true;
+
+    // Because InspectorTest output causes scripts to be parsed
+    // this test only checks the scripts the frontend is notified
+    // of when enabling the Debugger domain.
+    //
+    // Scripts we expect to see (in an undefined order)
+    //   - external <script> protocol-test.js
+    //   - inline <script> (this) starting on line 5
+    //   - inline body onload event listener attribute on <body> line below
+    //   - eval source above on line 7
+    //   - inspector internal scripts InjectedScriptSource.js CommandLineAPIModuleSource.js
+
+    let foundExternalScript = false;
+    let foundInlineScriptTagScript = false;
+    let foundInlineAttributeEventListenerScript = false;
+    let foundEvalScript = false;
+    let foundInjectedScriptSourceScript = false;
+    let foundCommandLineAPISourceScript = false;
+    let foundUnexpectedScript = false;
+
+    function isExternalScript(params) {
+        return /inspector\/resources\/protocol-test\.js/.test(params.url);
+    }
+
+    function isInlineScript(params) {
+        return /inspector\/debugger\/scriptParsed\.html$/.test(params.url);
+    }
+
+    function isInlineScriptTagScript(params) {
+        return isInlineScript(params) && params.startLine === 4;
+    }
+
+    function isInlineAttributeEventListenerScript(params) {
+        return isInlineScript(params) && params.startLine >= 100; // Estimate of <body> below.
+    }
+
+    function isEvalScript(params) {
+        return params.hasSourceURL && params.url ="" "eval.js";
+    }
+
+    function isInjectedScriptSourceScript(params) {
+        return params.hasSourceURL && params.url ="" "__WebInspectorInjectedScript__";
+    }
+
+    function isCommandLineAPISourceScript(params) {
+        return params.hasSourceURL && params.url ="" "__WebInspectorCommandLineAPIModuleSource__";
+    }
+
+    suite.addTestCase({
+        name: "EnableDebuggerDomainAndCheckInitialScripts",
+        test: (resolve, reject) => {
+
+            let initialScriptParsedMessages = [];
+            let receivingInitialScripts = true;
+            InspectorProtocol.sendCommand("Debugger.enable", {}, function() {
+                receivingInitialScripts = false;
+
+                ProtocolTest.log("Debugger Enabled - Initial Scripts Received");
+                ProtocolTest.expectThat(initialScriptParsedMessages.length > 0, "Should have received some scriptParsed messages.");
+
+                for (let messageObject of initialScriptParsedMessages) {
+                    let params = messageObject.params;
+                    if (!foundExternalScript && isExternalScript(params))
+                        foundExternalScript = true;
+                    else if (!foundInlineScriptTagScript && isInlineScriptTagScript(params))
+                        foundInlineScriptTagScript = true;
+                    else if (!foundInlineAttributeEventListenerScript && isInlineAttributeEventListenerScript(params))
+                        foundInlineAttributeEventListenerScript = true;
+                    else if (!foundEvalScript && isEvalScript(params))
+                        foundEvalScript = true;
+                    else if (!foundInjectedScriptSourceScript && isInjectedScriptSourceScript(params))
+                        foundInjectedScriptSourceScript = true;
+                    else if (!foundCommandLineAPISourceScript && isCommandLineAPISourceScript(params))
+                        foundCommandLineAPISourceScript = true;
+                    else {
+                        ProtocolTest.log("UNEXPECTED SCRIPT: " + JSON.stringify(messageObject));
+                        foundUnexpectedScript = true;
+                    }
+                }
+
+                ProtocolTest.expectThat(foundExternalScript, "Should find External Script.");
+                ProtocolTest.expectThat(foundInlineScriptTagScript, "Should find Inline Script Tag Script.");
+                ProtocolTest.expectThat(foundInlineAttributeEventListenerScript, "Should find Inline Attribute Event Listener Script.");
+                ProtocolTest.expectThat(foundEvalScript, "Should find Eval Script.");
+                ProtocolTest.expectThat(foundInjectedScriptSourceScript, "Should find Inspector InjectedScriptSource Script.");
+                ProtocolTest.expectThat(foundCommandLineAPISourceScript, "Should find Inspector CommandLineAPISource Script.");
+                ProtocolTest.expectThat(!foundUnexpectedScript, "Should not receive any unexpected scripts.");
+
+                resolve();
+            });
+
+            InspectorProtocol.eventHandler["Debugger.scriptParsed"] = function(messageObject) {
+                // Ignore non-initial load scripts.
+                if (!receivingInitialScripts)
+                    return;
+
+                initialScriptParsedMessages.push(messageObject);
+            };
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()"> <!-- This line number is important -->
+<p>Tests for the Debugger.scriptParsed messages the frontend receives when enabling the Debugger domain.</p>
+</body>
+</html>

Modified: trunk/Source/_javascript_Core/ChangeLog (191838 => 191839)


--- trunk/Source/_javascript_Core/ChangeLog	2015-10-31 04:03:58 UTC (rev 191838)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-10-31 04:58:28 UTC (rev 191839)
@@ -1,3 +1,18 @@
+2015-10-30  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Test Debugger.scriptParsed events received after opening inspector frontend
+        https://bugs.webkit.org/show_bug.cgi?id=150753
+
+        Reviewed by Timothy Hatcher.
+
+        * parser/Parser.h:
+        (JSC::Parser<LexerType>::parse):
+        Only set the directives on the SourceProvider if we were parsing the
+        entire file (Program or Module), not if we are in function parsing mode.
+        This was inadvertently clearing the directives stored on the
+        SourceProvider when the function parse didn't see directives and reset
+        the values on the source provider.
+
 2015-10-30  Benjamin Poulain  <[email protected]>
 
         [JSC] Add lowering for B3's Sub operation with integers

Modified: trunk/Source/_javascript_Core/parser/Parser.h (191838 => 191839)


--- trunk/Source/_javascript_Core/parser/Parser.h	2015-10-31 04:03:58 UTC (rev 191838)
+++ trunk/Source/_javascript_Core/parser/Parser.h	2015-10-31 04:58:28 UTC (rev 191839)
@@ -1330,8 +1330,10 @@
         result->setLoc(m_source->firstLine(), m_lexer->lineNumber(), m_lexer->currentOffset(), m_lexer->currentLineStartOffset());
         result->setEndOffset(m_lexer->currentOffset());
 
-        m_source->provider()->setSourceURLDirective(m_lexer->sourceURL());
-        m_source->provider()->setSourceMappingURLDirective(m_lexer->sourceMappingURL());
+        if (!isFunctionParseMode(parseMode)) {
+            m_source->provider()->setSourceURLDirective(m_lexer->sourceURL());
+            m_source->provider()->setSourceMappingURLDirective(m_lexer->sourceMappingURL());
+        }
     } else {
         // We can never see a syntax error when reparsing a function, since we should have
         // reported the error when parsing the containing program or eval code. So if we're
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to