Commit 83d7c4d3 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

Report reliable embedderName in scriptParsed/scriptFailedToParse

Currently, only a scriptURL is reported, which can be over-written by
sourceURL comments of the script. This means a script can basically
claim to come from anywhere. This means that DevTools doesn't know the
resource name the embedder provided if there is a sourceURL comment.
This CL adds a `embedderName` field to the scriptParsed and
scriptFailedToParse events that reports the name the embedder
associated with the script.

Bug: chromium:974543
Change-Id: I9863f878f57638174847890d9a3818952b1efc27
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2317310
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69078}
parent 8b694beb
......@@ -572,6 +572,8 @@ domain Debugger
experimental optional integer codeOffset
# The language of the script.
experimental optional Debugger.ScriptLanguage scriptLanguage
# The name the embedder supplied for this script.
experimental optional string embedderName
# Fired when virtual machine parses script. This event is also fired for all known and uncollected
# scripts upon enabling debugger.
......@@ -613,6 +615,8 @@ domain Debugger
experimental optional Debugger.ScriptLanguage scriptLanguage
# If the scriptLanguage is WebASsembly, the source of debug symbols for the module.
experimental optional Debugger.DebugSymbols debugSymbols
# The name the embedder supplied for this script.
experimental optional string embedderName
experimental domain HeapProfiler
depends on Runtime
......
......@@ -1559,6 +1559,7 @@ void V8DebuggerAgentImpl::didParseSource(
bool isModule = script->isModule();
String16 scriptId = script->scriptId();
String16 scriptURL = script->sourceURL();
String16 embedderName = script->embedderName();
String16 scriptLanguage = getScriptLanguage(*script);
Maybe<int> codeOffset;
if (script->getLanguage() == V8DebuggerScript::Language::WebAssembly)
......@@ -1601,7 +1602,7 @@ void V8DebuggerAgentImpl::didParseSource(
scriptRef->hash(), std::move(executionContextAuxDataParam),
std::move(sourceMapURLParam), hasSourceURLParam, isModuleParam,
scriptRef->length(), std::move(stackTrace), std::move(codeOffset),
std::move(scriptLanguage));
std::move(scriptLanguage), embedderName);
return;
}
......@@ -1611,7 +1612,7 @@ void V8DebuggerAgentImpl::didParseSource(
std::move(executionContextAuxDataParam), isLiveEditParam,
std::move(sourceMapURLParam), hasSourceURLParam, isModuleParam, 0,
std::move(stackTrace), std::move(codeOffset), std::move(scriptLanguage),
std::move(debugSymbols));
std::move(debugSymbols), embedderName);
} else {
m_frontend.scriptParsed(
scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(),
......@@ -1620,7 +1621,7 @@ void V8DebuggerAgentImpl::didParseSource(
isLiveEditParam, std::move(sourceMapURLParam), hasSourceURLParam,
isModuleParam, scriptRef->length(), std::move(stackTrace),
std::move(codeOffset), std::move(scriptLanguage),
std::move(debugSymbols));
std::move(debugSymbols), embedderName);
}
std::vector<protocol::DictionaryValue*> potentialBreakpoints;
......
......@@ -94,7 +94,8 @@ class ActualScript : public V8DebuggerScript {
bool isLiveEdit, V8DebuggerAgentImpl* agent,
V8InspectorClient* client)
: V8DebuggerScript(isolate, String16::fromInteger(script->Id()),
GetScriptURL(isolate, script, client)),
GetScriptURL(isolate, script, client),
GetScriptName(isolate, script, client)),
m_agent(agent),
m_isLiveEdit(isLiveEdit) {
Initialize(script);
......@@ -266,6 +267,12 @@ class ActualScript : public V8DebuggerScript {
v8::Local<v8::String> sourceURL;
if (script->SourceURL().ToLocal(&sourceURL) && sourceURL->Length() > 0)
return toProtocolString(isolate, sourceURL);
return GetScriptName(isolate, script, client);
}
static String16 GetScriptName(v8::Isolate* isolate,
v8::Local<v8::debug::Script> script,
V8InspectorClient* client) {
v8::Local<v8::String> v8Name;
if (script->Name().ToLocal(&v8Name) && v8Name->Length() > 0) {
String16 name = toProtocolString(isolate, v8Name);
......@@ -358,8 +365,11 @@ std::unique_ptr<V8DebuggerScript> V8DebuggerScript::Create(
}
V8DebuggerScript::V8DebuggerScript(v8::Isolate* isolate, String16 id,
String16 url)
: m_id(std::move(id)), m_url(std::move(url)), m_isolate(isolate) {}
String16 url, String16 embedderName)
: m_id(std::move(id)),
m_url(std::move(url)),
m_isolate(isolate),
m_embedderName(embedderName) {}
V8DebuggerScript::~V8DebuggerScript() = default;
......
......@@ -56,6 +56,7 @@ class V8DebuggerScript {
const String16& scriptId() const { return m_id; }
bool hasSourceURLComment() const { return m_hasSourceURLComment; }
const String16& sourceURL() const { return m_url; }
const String16& embedderName() const { return m_embedderName; }
virtual const String16& sourceMappingURL() const = 0;
virtual String16 source(size_t pos, size_t len = UINT_MAX) const = 0;
......@@ -98,7 +99,8 @@ class V8DebuggerScript {
virtual bool setBreakpointOnRun(int* id) const = 0;
protected:
V8DebuggerScript(v8::Isolate*, String16 id, String16 url);
V8DebuggerScript(v8::Isolate*, String16 id, String16 url,
String16 embedderName);
virtual v8::Local<v8::debug::Script> script() const = 0;
......@@ -108,6 +110,7 @@ class V8DebuggerScript {
int m_executionContextId = 0;
v8::Isolate* m_isolate;
String16 m_embedderName;
private:
DISALLOW_COPY_AND_ASSIGN(V8DebuggerScript);
......
......@@ -4,6 +4,7 @@ Running test: testLoadedModulesOnDebuggerEnable
{
method : Debugger.scriptParsed
params : {
embedderName : module1.js
endColumn : 1
endLine : 3
executionContextId : <executionContextId>
......@@ -25,6 +26,7 @@ Running test: testScriptEventsWhenDebuggerIsEnabled
{
method : Debugger.scriptParsed
params : {
embedderName : module2.js
endColumn : 1
endLine : 3
executionContextId : <executionContextId>
......@@ -44,6 +46,7 @@ Running test: testScriptEventsWhenDebuggerIsEnabled
{
method : Debugger.scriptFailedToParse
params : {
embedderName : module-with-syntax-error-2.js
endColumn : 1
endLine : 0
executionContextId : <executionContextId>
......
......@@ -2,6 +2,7 @@ getPossibleBreakpoints should not crash during lazy compilation (crbug.com/71533
{
method : Debugger.scriptFailedToParse
params : {
embedderName :
endColumn : 23
endLine : 2
executionContextId : <executionContextId>
......
......@@ -3,6 +3,7 @@ Check script with url:
{
method : Debugger.scriptParsed
params : {
embedderName : prefix://url
endColumn : 16
endLine : 0
executionContextId : <executionContextId>
......@@ -23,6 +24,7 @@ Check script with sourceURL comment:
{
method : Debugger.scriptParsed
params : {
embedderName : prefix://url
endColumn : 37
endLine : 0
executionContextId : <executionContextId>
......@@ -43,6 +45,7 @@ Check script failed to parse:
{
method : Debugger.scriptFailedToParse
params : {
embedderName : prefix://url
endColumn : 15
endLine : 0
executionContextId : <executionContextId>
......@@ -62,6 +65,7 @@ Check script failed to parse with sourceURL comment:
{
method : Debugger.scriptFailedToParse
params : {
embedderName : prefix://url
endColumn : 36
endLine : 0
executionContextId : <executionContextId>
......
......@@ -4,6 +4,7 @@ scriptParsed
scriptSource : function foo1(){}//# sourceURL=oneline.js<nl>
}
{
embedderName :
endColumn : 0
endLine : 1
executionContextId : <executionContextId>
......@@ -24,6 +25,7 @@ scriptParsed
scriptSource : function foo2(){}//# sourceURL=oneline-without-nl.js
}
{
embedderName :
endColumn : 52
endLine : 0
executionContextId : <executionContextId>
......@@ -44,6 +46,7 @@ scriptParsed
scriptSource : function foo3(){}<nl>//# sourceURL=twoline.js<nl>
}
{
embedderName :
endColumn : 0
endLine : 2
executionContextId : <executionContextId>
......@@ -64,6 +67,7 @@ scriptParsed
scriptSource : function foo4(){}<nl><nl>//# sourceURL=threeline.js<nl>
}
{
embedderName :
endColumn : 0
endLine : 3
executionContextId : <executionContextId>
......@@ -84,6 +88,7 @@ scriptParsed
scriptSource : function foo5(){}//# sourceMappingURL=oneline-map<nl>
}
{
embedderName :
endColumn : 0
endLine : 1
executionContextId : <executionContextId>
......@@ -104,6 +109,7 @@ scriptParsed
scriptSource : function foo6(){}//# sourceMappingURL=oneline-without-nl-map
}
{
embedderName :
endColumn : 60
endLine : 0
executionContextId : <executionContextId>
......@@ -124,6 +130,7 @@ scriptParsed
scriptSource : function foo7(){}<nl>//# sourceMappingURL=twoline-map<nl>
}
{
embedderName :
endColumn : 0
endLine : 2
executionContextId : <executionContextId>
......@@ -144,6 +151,7 @@ scriptParsed
scriptSource : function foo8(){}<nl><nl>//# sourceMappingURL=threeline-map<nl>
}
{
embedderName :
endColumn : 0
endLine : 3
executionContextId : <executionContextId>
......@@ -164,6 +172,7 @@ scriptParsed
scriptSource : function foo9(){}//# sourceMappingURL=source-mapping-url-map<nl>//# sourceURL=source-url.js
}
{
embedderName :
endColumn : 27
endLine : 1
executionContextId : <executionContextId>
......@@ -184,6 +193,7 @@ scriptParsed
scriptSource : function foo10(){}//# sourceURL=source-url.js<nl>//# sourceMappingURL=source-mapping-url-map
}
{
embedderName :
endColumn : 43
endLine : 1
executionContextId : <executionContextId>
......@@ -204,6 +214,7 @@ scriptParsed
scriptSource : function foo11(){}<nl>//# sourceURL=end1.js
}
{
embedderName :
endColumn : 21
endLine : 1
executionContextId : <executionContextId>
......@@ -224,6 +235,7 @@ scriptParsed
scriptSource : function foo12(){}<nl>//# sourceURL=end2.js
}
{
embedderName :
endColumn : 22
endLine : 1
executionContextId : <executionContextId>
......@@ -244,6 +256,7 @@ scriptParsed
scriptSource : function foo13(){}
}
{
embedderName :
endColumn : 18
endLine : 0
executionContextId : <executionContextId>
......@@ -264,6 +277,7 @@ scriptParsed
scriptSource : function foo15(){}; eval("function foo14(){}//# sourceURL=eval.js")//# sourceURL=eval-wrapper.js
}
{
embedderName :
endColumn : 96
endLine : 0
executionContextId : <executionContextId>
......@@ -284,6 +298,7 @@ scriptParsed
scriptSource : function foo14(){}//# sourceURL=eval.js
}
{
embedderName :
endColumn : 39
endLine : 0
executionContextId : <executionContextId>
......@@ -304,6 +319,7 @@ scriptParsed
scriptSource : function foo16(){}<nl>
}
{
embedderName :
endColumn : 0
endLine : 1
executionContextId : <executionContextId>
......@@ -324,6 +340,7 @@ scriptParsed
scriptSource : function foo17(){}<nl><nl>
}
{
embedderName :
endColumn : 0
endLine : 2
executionContextId : <executionContextId>
......@@ -344,6 +361,7 @@ scriptParsed
scriptSource : function foo18(){}<nl><nl><nl>
}
{
embedderName :
endColumn : 0
endLine : 3
executionContextId : <executionContextId>
......@@ -364,6 +382,7 @@ scriptParsed
scriptSource : function foo19(){}<nl><nl><nl><nl>
}
{
embedderName :
endColumn : 0
endLine : 4
executionContextId : <executionContextId>
......@@ -384,6 +403,7 @@ scriptParsed
scriptSource : function foo1(){}//# sourceURL=oneline.js<nl>
}
{
embedderName :
endColumn : 0
endLine : 1
executionContextId : <executionContextId>
......@@ -404,6 +424,7 @@ scriptParsed
scriptSource : function foo2(){}//# sourceURL=oneline-without-nl.js
}
{
embedderName :
endColumn : 52
endLine : 0
executionContextId : <executionContextId>
......@@ -424,6 +445,7 @@ scriptParsed
scriptSource : function foo3(){}<nl>//# sourceURL=twoline.js<nl>
}
{
embedderName :
endColumn : 0
endLine : 2
executionContextId : <executionContextId>
......@@ -444,6 +466,7 @@ scriptParsed
scriptSource : function foo4(){}<nl><nl>//# sourceURL=threeline.js<nl>
}
{
embedderName :
endColumn : 0
endLine : 3
executionContextId : <executionContextId>
......@@ -464,6 +487,7 @@ scriptParsed
scriptSource : function foo5(){}//# sourceMappingURL=oneline-map<nl>
}
{
embedderName :
endColumn : 0
endLine : 1
executionContextId : <executionContextId>
......@@ -484,6 +508,7 @@ scriptParsed
scriptSource : function foo6(){}//# sourceMappingURL=oneline-without-nl-map
}
{
embedderName :
endColumn : 60
endLine : 0
executionContextId : <executionContextId>
......@@ -504,6 +529,7 @@ scriptParsed
scriptSource : function foo7(){}<nl>//# sourceMappingURL=twoline-map<nl>
}
{
embedderName :
endColumn : 0
endLine : 2
executionContextId : <executionContextId>
......@@ -524,6 +550,7 @@ scriptParsed
scriptSource : function foo8(){}<nl><nl>//# sourceMappingURL=threeline-map<nl>
}
{
embedderName :
endColumn : 0
endLine : 3
executionContextId : <executionContextId>
......@@ -544,6 +571,7 @@ scriptParsed
scriptSource : function foo9(){}//# sourceMappingURL=source-mapping-url-map<nl>//# sourceURL=source-url.js
}
{
embedderName :
endColumn : 27
endLine : 1
executionContextId : <executionContextId>
......@@ -564,6 +592,7 @@ scriptParsed
scriptSource : function foo10(){}//# sourceURL=source-url.js<nl>//# sourceMappingURL=source-mapping-url-map
}
{
embedderName :
endColumn : 43
endLine : 1
executionContextId : <executionContextId>
......@@ -584,6 +613,7 @@ scriptParsed
scriptSource : function foo11(){}<nl>//# sourceURL=end1.js
}
{
embedderName :
endColumn : 21
endLine : 1
executionContextId : <executionContextId>
......@@ -604,6 +634,7 @@ scriptParsed
scriptSource : function foo12(){}<nl>//# sourceURL=end2.js
}
{
embedderName :
endColumn : 22
endLine : 1
executionContextId : <executionContextId>
......@@ -624,6 +655,7 @@ scriptParsed
scriptSource : function foo13(){}
}
{
embedderName :
endColumn : 18
endLine : 0
executionContextId : <executionContextId>
......@@ -644,6 +676,7 @@ scriptParsed
scriptSource : function foo15(){}; eval("function foo14(){}//# sourceURL=eval.js")//# sourceURL=eval-wrapper.js
}
{
embedderName :
endColumn : 96
endLine : 0
executionContextId : <executionContextId>
......@@ -664,6 +697,7 @@ scriptParsed
scriptSource : function foo14(){}//# sourceURL=eval.js
}
{
embedderName :
endColumn : 39
endLine : 0
executionContextId : <executionContextId>
......@@ -695,6 +729,7 @@ scriptFailedToParse
scriptSource : {a:2:<nl>//# sourceURL=http://a.js
}
{
embedderName :
endColumn : 25
endLine : 1
executionContextId : <executionContextId>
......@@ -714,6 +749,7 @@ scriptFailedToParse
scriptSource : }//# sourceURL=failed.js<nl>//# sourceMappingURL=failed-map
}
{
embedderName :
endColumn : 31
endLine : 1
executionContextId : <executionContextId>
......@@ -733,6 +769,7 @@ scriptParsed
scriptSource : function foo16(){}<nl>
}
{
embedderName :
endColumn : 0
endLine : 1
executionContextId : <executionContextId>
......@@ -753,6 +790,7 @@ scriptParsed
scriptSource : function foo17(){}<nl><nl>
}
{
embedderName :
endColumn : 0
endLine : 2
executionContextId : <executionContextId>
......@@ -773,6 +811,7 @@ scriptParsed
scriptSource : function foo18(){}<nl><nl><nl>
}
{
embedderName :
endColumn : 0
endLine : 3
executionContextId : <executionContextId>
......@@ -793,6 +832,7 @@ scriptParsed
scriptSource : function foo19(){}<nl><nl><nl><nl>
}
{
embedderName :
endColumn : 0
endLine : 4
executionContextId : <executionContextId>
......
......@@ -2,6 +2,7 @@ Debugger.scriptParsed.stackTrace should contain only one frame
{
method : Debugger.scriptParsed
params : {
embedderName :
endColumn : 0
endLine : 0
executionContextId : <executionContextId>
......
......@@ -3,6 +3,7 @@ Runtime.evaluate with valid expression
{
method : Debugger.scriptParsed
params : {
embedderName :
endColumn : 29
endLine : 0
executionContextId : <executionContextId>
......@@ -23,6 +24,7 @@ Runtime.evaluate with syntax error
{
method : Debugger.scriptFailedToParse
params : {
embedderName :
endColumn : 39
endLine : 0
executionContextId : <executionContextId>
......@@ -42,6 +44,7 @@ Runtime.callFunctionOn with valid functionDeclaration
{
method : Debugger.scriptParsed
params : {
embedderName :
endColumn : 18
endLine : 0
executionContextId : <executionContextId>
......@@ -62,6 +65,7 @@ Runtime.callFunctionOn with syntax error
{
method : Debugger.scriptFailedToParse
params : {
embedderName :
endColumn : 3
endLine : 0
executionContextId : <executionContextId>
......@@ -81,6 +85,7 @@ Runtime.compileScript with valid expression
{
method : Debugger.scriptParsed
params : {
embedderName : compile-script.js
endColumn : 4
endLine : 0
executionContextId : <executionContextId>
......@@ -101,6 +106,7 @@ Runtime.compileScript with syntax error
{
method : Debugger.scriptFailedToParse
params : {
embedderName : compile-script-syntax-error.js
endColumn : 1
endLine : 0
executionContextId : <executionContextId>
......@@ -121,6 +127,7 @@ Runtime.evaluate compiled script with stack trace
{
method : Debugger.scriptParsed
params : {
embedderName :
endColumn : 8
endLine : 0
executionContextId : <executionContextId>
......@@ -140,6 +147,7 @@ Runtime.evaluate compiled script with stack trace
{
method : Debugger.scriptParsed
params : {
embedderName :
endColumn : 39
endLine : 4
executionContextId : <executionContextId>
......@@ -170,6 +178,7 @@ Runtime.evaluate compiled script with stack trace
{
method : Debugger.scriptParsed
params : {
embedderName :
endColumn : 4
endLine : 0
executionContextId : <executionContextId>
......@@ -201,6 +210,7 @@ Runtime.evaluate compile script error with stack trace
{
method : Debugger.scriptParsed
params : {
embedderName :
endColumn : 12
endLine : 0
executionContextId : <executionContextId>
......@@ -220,6 +230,7 @@ Runtime.evaluate compile script error with stack trace
{
method : Debugger.scriptParsed
params : {
embedderName :
endColumn : 48
endLine : 4
executionContextId : <executionContextId>
......@@ -250,6 +261,7 @@ Runtime.evaluate compile script error with stack trace
{
method : Debugger.scriptFailedToParse
params : {
embedderName :
endColumn : 3
endLine : 0
executionContextId : <executionContextId>
......
Tests scripts hasing
{
embedderName : foo1.js
endColumn : 1
endLine : 0
executionContextId : <executionContextId>
......@@ -16,6 +17,7 @@ Tests scripts hasing
url : foo1.js
}
{
embedderName : foo2.js
endColumn : 3
endLine : 0
executionContextId : <executionContextId>
......@@ -32,6 +34,7 @@ Tests scripts hasing
url : foo2.js
}
{
embedderName : foo3.js
endColumn : 8106
endLine : 0
executionContextId : <executionContextId>
......
......@@ -2,6 +2,7 @@ Checks basic ES6 modules support.
{
method : Debugger.scriptParsed
params : {
embedderName : module1
endColumn : 17
endLine : 5
executionContextId : <executionContextId>
......@@ -21,6 +22,7 @@ Checks basic ES6 modules support.
{
method : Debugger.scriptParsed
params : {
embedderName : module2
endColumn : 17
endLine : 5
executionContextId : <executionContextId>
......@@ -40,6 +42,7 @@ Checks basic ES6 modules support.
{
method : Debugger.scriptParsed
params : {
embedderName : module3
endColumn : 0
endLine : 11
executionContextId : <executionContextId>
......@@ -201,6 +204,7 @@ console.log(239)
{
method : Debugger.scriptFailedToParse
params : {
embedderName : module4
endColumn : 1
endLine : 0
executionContextId : <executionContextId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment