diff --git a/AUTHORS b/AUTHORS index 7c43c60fc1..2a58b0e1c3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -42,6 +42,7 @@ Cloudflare, Inc. <*@cloudflare.com> Julia Computing, Inc. <*@juliacomputing.com> Aaron Bieber +Aaron O'Mullan Abdulla Kamar Adam Kallai Akinori MUSHA @@ -216,4 +217,4 @@ Zhongping Wang 柳荣一 Yanbo Li Gilang Mentari Hamidy -Zeynep Cankara \ No newline at end of file +Zeynep Cankara diff --git a/src/inspector/v8-debugger-script.cc b/src/inspector/v8-debugger-script.cc index 6e54656d40..7a16f9f644 100644 --- a/src/inspector/v8-debugger-script.cc +++ b/src/inspector/v8-debugger-script.cc @@ -174,7 +174,9 @@ class ActualScript : public V8DebuggerScript { result->message = scope.Escape(result->message); return; } - if (preview) return; + // NOP if preview or unchanged source (diffs.empty() in PatchScript) + if (preview || result->script.IsEmpty()) return; + m_hash = String16(); Initialize(scope.Escape(result->script)); } diff --git a/test/inspector/debugger/set-script-source-unchanged-expected.txt b/test/inspector/debugger/set-script-source-unchanged-expected.txt new file mode 100644 index 0000000000..13e3fbcf81 --- /dev/null +++ b/test/inspector/debugger/set-script-source-unchanged-expected.txt @@ -0,0 +1 @@ +Check that setScriptSource does not crash when source is unchanged diff --git a/test/inspector/debugger/set-script-source-unchanged.js b/test/inspector/debugger/set-script-source-unchanged.js new file mode 100644 index 0000000000..bef4d8aaa1 --- /dev/null +++ b/test/inspector/debugger/set-script-source-unchanged.js @@ -0,0 +1,16 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +let {session, contextGroup, Protocol} = + InspectorTest.start('Check that setScriptSource does not crash when source is unchanged'); + +let scriptSource = `function TestExpression() {}`; +contextGroup.addScript(scriptSource); + +(async function test() { + Protocol.Debugger.enable(); + const {params: {scriptId}} = await Protocol.Debugger.onceScriptParsed(); + await Protocol.Debugger.setScriptSource({scriptId, scriptSource}); + InspectorTest.completeTest(); +})();