haikuwebkit/LayoutTests/inspector/debugger/sourceURLs.html

208 lines
6.7 KiB
HTML
Raw Permalink Normal View History

Web Inspector: JavaScriptCore should parse sourceURL and sourceMappingURL directives https://bugs.webkit.org/show_bug.cgi?id=150096 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * inspector/ContentSearchUtilities.cpp: (Inspector::ContentSearchUtilities::scriptCommentPattern): Deleted. (Inspector::ContentSearchUtilities::findScriptSourceURL): Deleted. (Inspector::ContentSearchUtilities::findScriptSourceMapURL): Deleted. * inspector/ContentSearchUtilities.h: No longer need to search script content. * inspector/ScriptDebugServer.cpp: (Inspector::ScriptDebugServer::dispatchDidParseSource): Carry over the sourceURL and sourceMappingURL from the SourceProvider. * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::sourceMapURLForScript): (Inspector::InspectorDebuggerAgent::didParseSource): No longer do content searching. * parser/Lexer.cpp: (JSC::Lexer<T>::setCode): (JSC::Lexer<T>::skipWhitespace): (JSC::Lexer<T>::parseCommentDirective): (JSC::Lexer<T>::parseCommentDirectiveValue): (JSC::Lexer<T>::consume): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::sourceURL): (JSC::Lexer::sourceMappingURL): (JSC::Lexer::sourceProvider): Deleted. Give lexer the ability to detect script comment directives. This just consumes characters in single line comments and ultimately sets the sourceURL or sourceMappingURL found. * parser/Parser.h: (JSC::Parser<LexerType>::parse): * parser/SourceProvider.h: (JSC::SourceProvider::url): (JSC::SourceProvider::sourceURL): (JSC::SourceProvider::sourceMappingURL): (JSC::SourceProvider::setSourceURL): (JSC::SourceProvider::setSourceMappingURL): After parsing a script, update the Source Provider with the value of directives that may have been found in the script. Source/WebInspectorUI: * UserInterface/Test/InspectorProtocol.js: (InspectorProtocol._sendMessage): (InspectorProtocol.dispatchMessageFromBackend): This is only used for tests, so avoid console.log and just dump directly to the system console. LayoutTests: * inspector/debugger/sourceURLs-expected.txt: Added. * inspector/debugger/sourceURLs.html: Added. sourceURL and sourceMappingURL detection. Canonical link: https://commits.webkit.org/168521@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-10-20 20:48:49 +00:00
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/protocol-test.js"></script>
<script>
function test()
{
let suite = ProtocolTest.createAsyncSuite("Debugger.scriptParsed.sourceURL-directives");
// Because InspectorTest output causes scripts to be parsed
// we cannot check sourceURL per evaluation easily. Instead
// just run a bunch of tests for valid and invalid directives
// and check that the output only includes the valid results.
let expressions = [];
let sourceURLExpectations = [];
let sourceMappingURLExpectations = [];
function addInvalidTestCase(args) {
let {expression} = args;
expressions.push(expression);
}
function addValidTestCase(args) {
let {expression, expected} = args;
expressions.push(expression);
sourceURLExpectations.push(expected);
sourceMappingURLExpectations.push(expected);
}
suite.addTestCase({
name: "TestExpressionsForSourceURL",
Web Inspector: DebuggerManager.Event.Resumed introduces test flakiness https://bugs.webkit.org/show_bug.cgi?id=161951 <rdar://problem/28295767> Reviewed by Brian Burg. Source/JavaScriptCore: This removes an ambiguity in the protocol when stepping through JavaScript. Previously, when paused and issuing a Debugger.step* command the frontend would always receive a Debugger.resumed event and then, maybe, a Debugger.paused event indicating we paused again (after stepping). However, this ambiguity means that the frontend needs to wait for a short period of time to determine if we really resumed or not. And even still that decision may be incorrect if the step takes a sufficiently long period of time. The new approach removes this ambiguity. Now, in response to a Debugger.step* command the backend MUST send a single Debugger.paused event or Debugger.resumed event. Now the frontend knows that the next Debugger event it receives after issuing the step command is the result (stepped and paused, or stepped and resumed). To make resuming consistent in all cases, a Debugger.resume command will always respond with a Debugger.resumed event. Finally, Debugger.continueToLocation is treated like a "big step" in cases where we can resolve the location. If we can't resolve the location it is treated as a resume, maintaining the old behavior. * inspector/agents/InspectorDebuggerAgent.h: * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::stepOver): (Inspector::InspectorDebuggerAgent::stepInto): (Inspector::InspectorDebuggerAgent::stepOut): (Inspector::InspectorDebuggerAgent::willStepAndMayBecomeIdle): (Inspector::InspectorDebuggerAgent::didBecomeIdleAfterStepping): When stepping register a VM exit observer so that we can issue a Debugger.resumed event if the step caused us to exit the VM. (Inspector::InspectorDebuggerAgent::resume): Set a flag to issue a Debugger.resumed event once we break out of the nested run loop. (Inspector::InspectorDebuggerAgent::didPause): We are issuing Debugger.paused so clear the state to indicate that we no longer need to issue Debugger.resumed event, we have paused. (Inspector::InspectorDebuggerAgent::didContinue): Only issue the Debugger.resumed event if needed (explicitly asked to resume). (Inspector::InspectorDebuggerAgent::continueToLocation): (Inspector::InspectorDebuggerAgent::clearDebuggerBreakpointState): All places that do continueProgram should be audited. In error cases, if we are paused and continue we should remember to send Debugger.resumed. * inspector/protocol/Debugger.json: Clarify in the protocol description the contract of these methods. Source/WebCore: Covered by existing tests that would ASSERT otherwise. * inspector/InspectorClient.cpp: (WebCore::InspectorClient::doDispatchMessageOnFrontendPage): When paused on an exception in the inspected page and evaluating commands in the inspector frontend page (which evaluates JavaScript) we ASSERT when entering the Global DOM VM with an existing exception. This makes it so when we evaluate JavaScript in the frontend we suspend / ignore the state of the VM for the inspected page, and restore it when we return from the inspector. Source/WebInspectorUI: * UserInterface/Controllers/DebuggerManager.js: (WebInspector.DebuggerManager.prototype.debuggerDidResume): Now, Debugger.resumed events really mean the debugger resumed, so act immediately instead of guessing. We must still guess in legacy backends. * UserInterface/Test/Test.js: When the inspector frontend encounters an issue, log it. * UserInterface/Views/DebuggerSidebarPanel.js: (WebInspector.DebuggerSidebarPanel.prototype._debuggerDidPause): (WebInspector.DebuggerSidebarPanel.prototype._debuggerActiveCallFrameDidChange): Always enable the step out button. I don't think it makes sense to disable it sometimes, and if there are issues with this we should solve the issues instead of hiding them. LayoutTests: Rewrite tests to be more deterministic. For tests that relied on a Resumed event to happen after a short amount of time, instead have the test dispatch an event when it is appropriate to continue. Take this opportunity to rewrite some tests using new style and best practices. * inspector/debugger/break-in-constructor-before-super.html: * inspector/debugger/break-on-exception-throw-in-promise.html: * inspector/debugger/break-on-exception.html: * inspector/debugger/break-on-uncaught-exception-throw-in-promise.html: * inspector/debugger/break-on-uncaught-exception.html: * inspector/debugger/breakpoint-syntax-error-top-level.html: * inspector/debugger/command-line-api-exception-expected.txt: * inspector/debugger/command-line-api-exception-nested-catch.html: * inspector/debugger/command-line-api-exception.html: * inspector/debugger/csp-exceptions.html: * inspector/debugger/didSampleProbe-multiple-probes.html: * inspector/debugger/evaluateOnCallFrame-CommandLineAPI.html: * inspector/debugger/evaluateOnCallFrame-errors.html: * inspector/debugger/pause-reason-expected.txt: * inspector/debugger/pause-reason.html: * inspector/debugger/paused-scopes-expected.txt: * inspector/debugger/paused-scopes.html: * inspector/debugger/resources/exceptions.js: * inspector/debugger/scriptParsed.html: * inspector/debugger/sourceURL-repeated-identical-executions.html: * inspector/debugger/sourceURLs.html: * inspector/debugger/stepping/stepping-pause-in-inner-step-to-parent.html: Canonical link: https://commits.webkit.org/182248@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208523 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-10 06:07:07 +00:00
test(resolve, reject) {
Web Inspector: JavaScriptCore should parse sourceURL and sourceMappingURL directives https://bugs.webkit.org/show_bug.cgi?id=150096 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * inspector/ContentSearchUtilities.cpp: (Inspector::ContentSearchUtilities::scriptCommentPattern): Deleted. (Inspector::ContentSearchUtilities::findScriptSourceURL): Deleted. (Inspector::ContentSearchUtilities::findScriptSourceMapURL): Deleted. * inspector/ContentSearchUtilities.h: No longer need to search script content. * inspector/ScriptDebugServer.cpp: (Inspector::ScriptDebugServer::dispatchDidParseSource): Carry over the sourceURL and sourceMappingURL from the SourceProvider. * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::sourceMapURLForScript): (Inspector::InspectorDebuggerAgent::didParseSource): No longer do content searching. * parser/Lexer.cpp: (JSC::Lexer<T>::setCode): (JSC::Lexer<T>::skipWhitespace): (JSC::Lexer<T>::parseCommentDirective): (JSC::Lexer<T>::parseCommentDirectiveValue): (JSC::Lexer<T>::consume): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::sourceURL): (JSC::Lexer::sourceMappingURL): (JSC::Lexer::sourceProvider): Deleted. Give lexer the ability to detect script comment directives. This just consumes characters in single line comments and ultimately sets the sourceURL or sourceMappingURL found. * parser/Parser.h: (JSC::Parser<LexerType>::parse): * parser/SourceProvider.h: (JSC::SourceProvider::url): (JSC::SourceProvider::sourceURL): (JSC::SourceProvider::sourceMappingURL): (JSC::SourceProvider::setSourceURL): (JSC::SourceProvider::setSourceMappingURL): After parsing a script, update the Source Provider with the value of directives that may have been found in the script. Source/WebInspectorUI: * UserInterface/Test/InspectorProtocol.js: (InspectorProtocol._sendMessage): (InspectorProtocol.dispatchMessageFromBackend): This is only used for tests, so avoid console.log and just dump directly to the system console. LayoutTests: * inspector/debugger/sourceURLs-expected.txt: Added. * inspector/debugger/sourceURLs.html: Added. sourceURL and sourceMappingURL detection. Canonical link: https://commits.webkit.org/168521@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-10-20 20:48:49 +00:00
for (let expression of expressions)
ProtocolTest.evaluateInPage(expression);
InspectorProtocol.eventHandler["Debugger.scriptParsed"] = function(messageObject) {
// Ignore named inspector internal scripts.
if (messageObject.params.sourceURL && messageObject.params.sourceURL.startsWith("__InjectedScript_"))
Web Inspector: JavaScriptCore should parse sourceURL and sourceMappingURL directives https://bugs.webkit.org/show_bug.cgi?id=150096 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * inspector/ContentSearchUtilities.cpp: (Inspector::ContentSearchUtilities::scriptCommentPattern): Deleted. (Inspector::ContentSearchUtilities::findScriptSourceURL): Deleted. (Inspector::ContentSearchUtilities::findScriptSourceMapURL): Deleted. * inspector/ContentSearchUtilities.h: No longer need to search script content. * inspector/ScriptDebugServer.cpp: (Inspector::ScriptDebugServer::dispatchDidParseSource): Carry over the sourceURL and sourceMappingURL from the SourceProvider. * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::sourceMapURLForScript): (Inspector::InspectorDebuggerAgent::didParseSource): No longer do content searching. * parser/Lexer.cpp: (JSC::Lexer<T>::setCode): (JSC::Lexer<T>::skipWhitespace): (JSC::Lexer<T>::parseCommentDirective): (JSC::Lexer<T>::parseCommentDirectiveValue): (JSC::Lexer<T>::consume): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::sourceURL): (JSC::Lexer::sourceMappingURL): (JSC::Lexer::sourceProvider): Deleted. Give lexer the ability to detect script comment directives. This just consumes characters in single line comments and ultimately sets the sourceURL or sourceMappingURL found. * parser/Parser.h: (JSC::Parser<LexerType>::parse): * parser/SourceProvider.h: (JSC::SourceProvider::url): (JSC::SourceProvider::sourceURL): (JSC::SourceProvider::sourceMappingURL): (JSC::SourceProvider::setSourceURL): (JSC::SourceProvider::setSourceMappingURL): After parsing a script, update the Source Provider with the value of directives that may have been found in the script. Source/WebInspectorUI: * UserInterface/Test/InspectorProtocol.js: (InspectorProtocol._sendMessage): (InspectorProtocol.dispatchMessageFromBackend): This is only used for tests, so avoid console.log and just dump directly to the system console. LayoutTests: * inspector/debugger/sourceURLs-expected.txt: Added. * inspector/debugger/sourceURLs.html: Added. sourceURL and sourceMappingURL detection. Canonical link: https://commits.webkit.org/168521@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-10-20 20:48:49 +00:00
return;
// Has a sourceURL, must be one of the valid ones.
Web Inspector: sourceMappingURL not used when sourceURL is set https://bugs.webkit.org/show_bug.cgi?id=156021 <rdar://problem/25438417> Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-04-15 Reviewed by Timothy Hatcher. Source/JavaScriptCore: Clean up Debugger.sourceParsed to separately include: - url ("resource URL", "source url" in JSC APIs) - sourceURL - //# sourceURL directive By always having the resource URL the Web Inspector frontend can better match this Script to a Resource of the same URL, and decide to use the sourceURL if it is available when appropriate. * inspector/protocol/Debugger.json: * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::setBreakpointByUrl): (Inspector::InspectorDebuggerAgent::didParseSource): Send the new sourceParsed parameters. Source/WebInspectorUI: Previously Debugger.sourceParsed only providing the sourceURL, and wiping out the resourceURL, meant that a Script from a Resource that set a sourceURL directive would fail to be associated with its Resource. This would result in duplicated tree elements in the Resources Sidebar, one for the Resource, and one for the Script. With the Script getting ultimately getting the SourceMap resources. However, since the frontend prefers Resources over Scripts when possible, an error that generated from the script would point to a location in the Resource, not following source maps. By always providing the resource URL in Debugger.sourceParsed, a Script can better be associated with its Resource. The result is now a single shared tree element in the Resources Sidebar, and the Resource getting the SourceMap resources. Now the script error goes through the Resource to its SourceMap resources as we would expect. * UserInterface/Protocol/DebuggerObserver.js: (WebInspector.DebuggerObserver): (WebInspector.DebuggerObserver.prototype.scriptParsed): We now have to handle two different signatures of scriptParsed. One for legacy, and one for non-legacy. Cache that value early on, since scriptParsed happens a lot. * UserInterface/Protocol/InspectorBackend.js: (InspectorBackend.Agent.prototype.hasEventParameter): Runtime check a protocol event to see if it has a parameter. This is used to check if Debugger.sourceParsed is legacy or not based on if it has the legacy "hasSourceURL" parameter. * UserInterface/Models/Script.js: (WebInspector.Script): (WebInspector.Script.prototype.get sourceURL): Treat sourceURL and url separately. (WebInspector.Script.prototype.get displayName): Handle both the url and sourceURL in displayName. * UserInterface/Controllers/DebuggerManager.js: (WebInspector.DebuggerManager.prototype.get knownNonResourceScripts): (WebInspector.DebuggerManager.prototype.debuggerDidPause): (WebInspector.DebuggerManager.prototype.scriptDidParse): * UserInterface/Protocol/RemoteObject.js: (WebInspector.RemoteObject.prototype.findFunctionSourceCodeLocation): Update code that checks the sourceURL to explicitly use sourceURL. * UserInterface/Controllers/SourceMapManager.js: (WebInspector.SourceMapManager.prototype.downloadSourceMap): For legacy backends, or in case we get a resource that has an incomplete baseURL, attempt to get an absolute URL based on the main resource. * UserInterface/Views/DebuggerSidebarPanel.js: (WebInspector.DebuggerSidebarPanel.prototype._addScript): * UserInterface/Views/ResourceSidebarPanel.js: (WebInspector.ResourceSidebarPanel.prototype._scriptWasAdded): Ignore scripts without a url or sourceURL. LayoutTests: * inspector/debugger/scriptParsed.html: * inspector/debugger/search-scripts.html: * inspector/debugger/setBreakpointByUrl-sourceURL.html: * inspector/debugger/sourceURLs.html: Update tests that need to handle sourceURL separately. * inspector/model/resources/relationship-named.js: Added. * inspector/model/resources/relationship-normal.js: Added. * inspector/model/script-resource-relationship-expected.txt: Added. * inspector/model/script-resource-relationship.html: Added. Tests for Script and Resource relationships. Canonical link: https://commits.webkit.org/174740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199602 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-04-15 19:01:39 +00:00
if (messageObject.params.sourceURL) {
let sourceURL = messageObject.params.sourceURL;
Web Inspector: JavaScriptCore should parse sourceURL and sourceMappingURL directives https://bugs.webkit.org/show_bug.cgi?id=150096 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * inspector/ContentSearchUtilities.cpp: (Inspector::ContentSearchUtilities::scriptCommentPattern): Deleted. (Inspector::ContentSearchUtilities::findScriptSourceURL): Deleted. (Inspector::ContentSearchUtilities::findScriptSourceMapURL): Deleted. * inspector/ContentSearchUtilities.h: No longer need to search script content. * inspector/ScriptDebugServer.cpp: (Inspector::ScriptDebugServer::dispatchDidParseSource): Carry over the sourceURL and sourceMappingURL from the SourceProvider. * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::sourceMapURLForScript): (Inspector::InspectorDebuggerAgent::didParseSource): No longer do content searching. * parser/Lexer.cpp: (JSC::Lexer<T>::setCode): (JSC::Lexer<T>::skipWhitespace): (JSC::Lexer<T>::parseCommentDirective): (JSC::Lexer<T>::parseCommentDirectiveValue): (JSC::Lexer<T>::consume): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::sourceURL): (JSC::Lexer::sourceMappingURL): (JSC::Lexer::sourceProvider): Deleted. Give lexer the ability to detect script comment directives. This just consumes characters in single line comments and ultimately sets the sourceURL or sourceMappingURL found. * parser/Parser.h: (JSC::Parser<LexerType>::parse): * parser/SourceProvider.h: (JSC::SourceProvider::url): (JSC::SourceProvider::sourceURL): (JSC::SourceProvider::sourceMappingURL): (JSC::SourceProvider::setSourceURL): (JSC::SourceProvider::setSourceMappingURL): After parsing a script, update the Source Provider with the value of directives that may have been found in the script. Source/WebInspectorUI: * UserInterface/Test/InspectorProtocol.js: (InspectorProtocol._sendMessage): (InspectorProtocol.dispatchMessageFromBackend): This is only used for tests, so avoid console.log and just dump directly to the system console. LayoutTests: * inspector/debugger/sourceURLs-expected.txt: Added. * inspector/debugger/sourceURLs.html: Added. sourceURL and sourceMappingURL detection. Canonical link: https://commits.webkit.org/168521@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-10-20 20:48:49 +00:00
ProtocolTest.log(`Found Script with sourceURL '${sourceURL}'`);
ProtocolTest.assert(sourceURLExpectations[0] === sourceURL, "Did not expect to see sourceURL: " + sourceURL);
sourceURLExpectations.shift();
if (!sourceURLExpectations.length)
resolve();
}
}
}
});
suite.addTestCase({
name: "TestExpressionsForSourceMappingURL",
Web Inspector: DebuggerManager.Event.Resumed introduces test flakiness https://bugs.webkit.org/show_bug.cgi?id=161951 <rdar://problem/28295767> Reviewed by Brian Burg. Source/JavaScriptCore: This removes an ambiguity in the protocol when stepping through JavaScript. Previously, when paused and issuing a Debugger.step* command the frontend would always receive a Debugger.resumed event and then, maybe, a Debugger.paused event indicating we paused again (after stepping). However, this ambiguity means that the frontend needs to wait for a short period of time to determine if we really resumed or not. And even still that decision may be incorrect if the step takes a sufficiently long period of time. The new approach removes this ambiguity. Now, in response to a Debugger.step* command the backend MUST send a single Debugger.paused event or Debugger.resumed event. Now the frontend knows that the next Debugger event it receives after issuing the step command is the result (stepped and paused, or stepped and resumed). To make resuming consistent in all cases, a Debugger.resume command will always respond with a Debugger.resumed event. Finally, Debugger.continueToLocation is treated like a "big step" in cases where we can resolve the location. If we can't resolve the location it is treated as a resume, maintaining the old behavior. * inspector/agents/InspectorDebuggerAgent.h: * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::stepOver): (Inspector::InspectorDebuggerAgent::stepInto): (Inspector::InspectorDebuggerAgent::stepOut): (Inspector::InspectorDebuggerAgent::willStepAndMayBecomeIdle): (Inspector::InspectorDebuggerAgent::didBecomeIdleAfterStepping): When stepping register a VM exit observer so that we can issue a Debugger.resumed event if the step caused us to exit the VM. (Inspector::InspectorDebuggerAgent::resume): Set a flag to issue a Debugger.resumed event once we break out of the nested run loop. (Inspector::InspectorDebuggerAgent::didPause): We are issuing Debugger.paused so clear the state to indicate that we no longer need to issue Debugger.resumed event, we have paused. (Inspector::InspectorDebuggerAgent::didContinue): Only issue the Debugger.resumed event if needed (explicitly asked to resume). (Inspector::InspectorDebuggerAgent::continueToLocation): (Inspector::InspectorDebuggerAgent::clearDebuggerBreakpointState): All places that do continueProgram should be audited. In error cases, if we are paused and continue we should remember to send Debugger.resumed. * inspector/protocol/Debugger.json: Clarify in the protocol description the contract of these methods. Source/WebCore: Covered by existing tests that would ASSERT otherwise. * inspector/InspectorClient.cpp: (WebCore::InspectorClient::doDispatchMessageOnFrontendPage): When paused on an exception in the inspected page and evaluating commands in the inspector frontend page (which evaluates JavaScript) we ASSERT when entering the Global DOM VM with an existing exception. This makes it so when we evaluate JavaScript in the frontend we suspend / ignore the state of the VM for the inspected page, and restore it when we return from the inspector. Source/WebInspectorUI: * UserInterface/Controllers/DebuggerManager.js: (WebInspector.DebuggerManager.prototype.debuggerDidResume): Now, Debugger.resumed events really mean the debugger resumed, so act immediately instead of guessing. We must still guess in legacy backends. * UserInterface/Test/Test.js: When the inspector frontend encounters an issue, log it. * UserInterface/Views/DebuggerSidebarPanel.js: (WebInspector.DebuggerSidebarPanel.prototype._debuggerDidPause): (WebInspector.DebuggerSidebarPanel.prototype._debuggerActiveCallFrameDidChange): Always enable the step out button. I don't think it makes sense to disable it sometimes, and if there are issues with this we should solve the issues instead of hiding them. LayoutTests: Rewrite tests to be more deterministic. For tests that relied on a Resumed event to happen after a short amount of time, instead have the test dispatch an event when it is appropriate to continue. Take this opportunity to rewrite some tests using new style and best practices. * inspector/debugger/break-in-constructor-before-super.html: * inspector/debugger/break-on-exception-throw-in-promise.html: * inspector/debugger/break-on-exception.html: * inspector/debugger/break-on-uncaught-exception-throw-in-promise.html: * inspector/debugger/break-on-uncaught-exception.html: * inspector/debugger/breakpoint-syntax-error-top-level.html: * inspector/debugger/command-line-api-exception-expected.txt: * inspector/debugger/command-line-api-exception-nested-catch.html: * inspector/debugger/command-line-api-exception.html: * inspector/debugger/csp-exceptions.html: * inspector/debugger/didSampleProbe-multiple-probes.html: * inspector/debugger/evaluateOnCallFrame-CommandLineAPI.html: * inspector/debugger/evaluateOnCallFrame-errors.html: * inspector/debugger/pause-reason-expected.txt: * inspector/debugger/pause-reason.html: * inspector/debugger/paused-scopes-expected.txt: * inspector/debugger/paused-scopes.html: * inspector/debugger/resources/exceptions.js: * inspector/debugger/scriptParsed.html: * inspector/debugger/sourceURL-repeated-identical-executions.html: * inspector/debugger/sourceURLs.html: * inspector/debugger/stepping/stepping-pause-in-inner-step-to-parent.html: Canonical link: https://commits.webkit.org/182248@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208523 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-10 06:07:07 +00:00
test(resolve, reject) {
Web Inspector: JavaScriptCore should parse sourceURL and sourceMappingURL directives https://bugs.webkit.org/show_bug.cgi?id=150096 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * inspector/ContentSearchUtilities.cpp: (Inspector::ContentSearchUtilities::scriptCommentPattern): Deleted. (Inspector::ContentSearchUtilities::findScriptSourceURL): Deleted. (Inspector::ContentSearchUtilities::findScriptSourceMapURL): Deleted. * inspector/ContentSearchUtilities.h: No longer need to search script content. * inspector/ScriptDebugServer.cpp: (Inspector::ScriptDebugServer::dispatchDidParseSource): Carry over the sourceURL and sourceMappingURL from the SourceProvider. * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::sourceMapURLForScript): (Inspector::InspectorDebuggerAgent::didParseSource): No longer do content searching. * parser/Lexer.cpp: (JSC::Lexer<T>::setCode): (JSC::Lexer<T>::skipWhitespace): (JSC::Lexer<T>::parseCommentDirective): (JSC::Lexer<T>::parseCommentDirectiveValue): (JSC::Lexer<T>::consume): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::sourceURL): (JSC::Lexer::sourceMappingURL): (JSC::Lexer::sourceProvider): Deleted. Give lexer the ability to detect script comment directives. This just consumes characters in single line comments and ultimately sets the sourceURL or sourceMappingURL found. * parser/Parser.h: (JSC::Parser<LexerType>::parse): * parser/SourceProvider.h: (JSC::SourceProvider::url): (JSC::SourceProvider::sourceURL): (JSC::SourceProvider::sourceMappingURL): (JSC::SourceProvider::setSourceURL): (JSC::SourceProvider::setSourceMappingURL): After parsing a script, update the Source Provider with the value of directives that may have been found in the script. Source/WebInspectorUI: * UserInterface/Test/InspectorProtocol.js: (InspectorProtocol._sendMessage): (InspectorProtocol.dispatchMessageFromBackend): This is only used for tests, so avoid console.log and just dump directly to the system console. LayoutTests: * inspector/debugger/sourceURLs-expected.txt: Added. * inspector/debugger/sourceURLs.html: Added. sourceURL and sourceMappingURL detection. Canonical link: https://commits.webkit.org/168521@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-10-20 20:48:49 +00:00
// Rewrite the "sourceURL" to "sourceMappingURL" in the original expressions.
for (let expression of expressions)
ProtocolTest.evaluateInPage(expression.replace(/sourceURL/g, "sourceMappingURL"));
InspectorProtocol.eventHandler["Debugger.scriptParsed"] = function(messageObject) {
// Has a sourceMapURL, must be one of the valid ones.
if (messageObject.params.sourceMapURL) {
let sourceMappingURL = messageObject.params.sourceMapURL;
ProtocolTest.log(`Found Script with sourceMappingURL '${sourceMappingURL}'`);
ProtocolTest.assert(sourceMappingURLExpectations[0] === sourceMappingURL, "Did not expect to see sourceMappingURL: " + sourceMappingURL);
sourceMappingURLExpectations.shift();
if (!sourceMappingURLExpectations.length)
resolve();
}
}
}
});
// ------
addInvalidTestCase({
description: "Evaluation without a SourceURL.",
expression: "eval('1')",
});
addInvalidTestCase({
description: "SourceURL missing '#'.",
expression: "eval('// sourceURL=invalid.js')",
});
addInvalidTestCase({
description: "SourceURL missing space after '#'.",
expression: "eval('//#sourceURL=invalid.js')",
});
addInvalidTestCase({
description: "SourceURL with space before '#'.",
expression: "eval('// #sourceURL=invalid.js')",
});
addInvalidTestCase({
description: "SourceURL with multiple spaces after '#'.",
expression: "eval('//# sourceURL=invalid.js')",
});
addInvalidTestCase({
description: "SourceURL with space between name and '='.",
expression: "eval('//# sourceURL =invalid.js')",
});
addInvalidTestCase({
description: "SourceURL with quotes in value.",
expression: "eval('//# sourceURL=\\\'invalid.js\\\'')",
});
addInvalidTestCase({
description: "SourceURL value must be a single non-whitespace enclosed value.",
expression: "eval('//# sourceURL=invalid.js a')",
});
addInvalidTestCase({
description: "Unknown directive.",
expression: "eval('//# unknown=invalid.js')",
});
addInvalidTestCase({
description: "Missing parts.",
expression: "eval('//#')",
});
addInvalidTestCase({
description: "Missing parts.",
expression: "eval('//# ')",
});
addInvalidTestCase({
description: "Missing parts.",
expression: "eval('//# source')",
});
addInvalidTestCase({
description: "Missing parts.",
expression: "eval('//# sourceURL=')",
});
// ------
addValidTestCase({
description: "SourceURL basic form.",
expression: "eval('//# sourceURL=test1.js')",
expected: "test1.js",
});
addValidTestCase({
description: "SourceURL extra leading whitespace.",
expression: "eval('//# sourceURL= test2.js')",
expected: "test2.js",
});
addValidTestCase({
description: "SourceURL extra trailing whitespace.",
expression: "eval('//# sourceURL=test3.js ')",
expected: "test3.js",
});
addValidTestCase({
description: "SourceURL extra leading and trailing whitespace.",
expression: "eval('//# sourceURL= test4.js ')",
expected: "test4.js",
});
addValidTestCase({
description: "SourceURL with tabs.",
expression: "eval('//#\\tsourceURL=test5.js')",
expected: "test5.js",
});
addValidTestCase({
description: "SourceURLs not at the start of a line.",
expression: "eval('1 //# sourceURL=test6.js')",
expected: "test6.js",
});
addValidTestCase({
description: "SourceURL with deprecated '@' instead of '#'.",
expression: "eval('//@ sourceURL=test7.js ')",
expected: "test7.js",
});
addValidTestCase({
description: "SourceURLs not on the first line.",
expression: "eval('\\n\\n//# sourceURL=test8.js')",
expected: "test8.js",
});
addValidTestCase({
description: "Multiple SourceURLs will return the second.",
expression: "eval('//# sourceURL=first.js\\n//# sourceURL=second.js')",
expected: "second.js",
Web Inspector: JavaScriptCore should parse sourceURL and sourceMappingURL directives https://bugs.webkit.org/show_bug.cgi?id=150096 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * inspector/ContentSearchUtilities.cpp: (Inspector::ContentSearchUtilities::scriptCommentPattern): Deleted. (Inspector::ContentSearchUtilities::findScriptSourceURL): Deleted. (Inspector::ContentSearchUtilities::findScriptSourceMapURL): Deleted. * inspector/ContentSearchUtilities.h: No longer need to search script content. * inspector/ScriptDebugServer.cpp: (Inspector::ScriptDebugServer::dispatchDidParseSource): Carry over the sourceURL and sourceMappingURL from the SourceProvider. * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::sourceMapURLForScript): (Inspector::InspectorDebuggerAgent::didParseSource): No longer do content searching. * parser/Lexer.cpp: (JSC::Lexer<T>::setCode): (JSC::Lexer<T>::skipWhitespace): (JSC::Lexer<T>::parseCommentDirective): (JSC::Lexer<T>::parseCommentDirectiveValue): (JSC::Lexer<T>::consume): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::sourceURL): (JSC::Lexer::sourceMappingURL): (JSC::Lexer::sourceProvider): Deleted. Give lexer the ability to detect script comment directives. This just consumes characters in single line comments and ultimately sets the sourceURL or sourceMappingURL found. * parser/Parser.h: (JSC::Parser<LexerType>::parse): * parser/SourceProvider.h: (JSC::SourceProvider::url): (JSC::SourceProvider::sourceURL): (JSC::SourceProvider::sourceMappingURL): (JSC::SourceProvider::setSourceURL): (JSC::SourceProvider::setSourceMappingURL): After parsing a script, update the Source Provider with the value of directives that may have been found in the script. Source/WebInspectorUI: * UserInterface/Test/InspectorProtocol.js: (InspectorProtocol._sendMessage): (InspectorProtocol.dispatchMessageFromBackend): This is only used for tests, so avoid console.log and just dump directly to the system console. LayoutTests: * inspector/debugger/sourceURLs-expected.txt: Added. * inspector/debugger/sourceURLs.html: Added. sourceURL and sourceMappingURL detection. Canonical link: https://commits.webkit.org/168521@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-10-20 20:48:49 +00:00
});
InspectorProtocol.sendCommand("Debugger.enable", {});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests for the Debugger.scriptParsed sourceURL and sourceMappingURL comment directive parsing.</p>
</body>
</html>