Commit 0e743fb7 authored by Joel Einbinder's avatar Joel Einbinder Committed by Commit Bot

DevTools: Fix flickering scripts with damaged functions

When a script has a function with multiple const declarations for the
same variable, ex:
function hey(){
  const duplicate = 0;
  const duplicate = 1;
}
The script that contains this function will parse correctly, but
when the function `hey` is run a scriptFailedParse event will be
emitted. DevTools only ever expects to get one script parsing
event per scriptId, and this causes flickering of the script in
the Sources panel.

This patch swallows subsequent script parsing events for a script.

Bug: 864296
Change-Id: I55a2e865b665e8fe1283a3dd19e9f152d0982b97
Reviewed-on: https://chromium-review.googlesource.com/1140782
Commit-Queue: Joel Einbinder <einbinder@chromium.org>
Reviewed-by: default avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: default avatarAndrey Lushnikov <lushnikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588901}
parent 69a66495
Tests that FailedToParseScriptSource event is NOT raised after running a damaged part of a script that was already parsed.
Finished running broken code.
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(
`Tests that FailedToParseScriptSource event is NOT raised after running a damaged part of a script that was already parsed.\n`);
await TestRunner.loadModule('sources_test_runner');
await TestRunner.showPanel('sources');
await TestRunner.evaluateInPagePromise(`
function thisIsBroken() {
const duplicated = 1;
const duplicated = 2;
}
`);
TestRunner.debuggerModel.addEventListener(
SDK.DebuggerModel.Events.FailedToParseScriptSource, () => {
TestRunner.addResult('ERROR: Recieved script failed to parse event')
});
await TestRunner.evaluateInPagePromise('thisIsBroken()');
TestRunner.addResult('Finished running broken code.');
TestRunner.completeTest();
})();
...@@ -558,6 +558,8 @@ SDK.DebuggerModel = class extends SDK.SDKModel { ...@@ -558,6 +558,8 @@ SDK.DebuggerModel = class extends SDK.SDKModel {
scriptId, sourceURL, startLine, startColumn, endLine, endColumn, executionContextId, hash, scriptId, sourceURL, startLine, startColumn, endLine, endColumn, executionContextId, hash,
executionContextAuxData, isLiveEdit, sourceMapURL, hasSourceURLComment, hasSyntaxError, length, executionContextAuxData, isLiveEdit, sourceMapURL, hasSourceURLComment, hasSyntaxError, length,
originStackTrace) { originStackTrace) {
if (this._scripts.has(scriptId))
return this._scripts.get(scriptId);
let isContentScript = false; let isContentScript = false;
if (executionContextAuxData && ('isDefault' in executionContextAuxData)) if (executionContextAuxData && ('isDefault' in executionContextAuxData))
isContentScript = !executionContextAuxData['isDefault']; isContentScript = !executionContextAuxData['isDefault'];
......
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