Commit 877430d2 authored by Erik Luo's avatar Erik Luo Committed by Commit Bot

[DevTools] fix(bindings): properly detach blackboxed sourcemaps

CompilerScriptMapping assumes that attaching sourcemaps get added to
`_contentScriptsBindings` or `_regularBindings`. Blackboxed sources
were skipped, for some reason, so detaching would throw an error.

In bad cases, navigations will detach sourcemaps, throw errors, and
prevent Console from clearing.

Bug: 888688
Change-Id: I2c460271a868eca9a6d67371d9097cc552f20b56
Reviewed-on: https://chromium-review.googlesource.com/c/1295310Reviewed-by: default avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Commit-Queue: Erik Luo <luoe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601794}
parent 49168a47
Tests that blackboxed sourcemaps properly detach on reload crbug.com/888688
Evaluating script with source map
Message count: 1
Page reloaded.
After reload, Console message count: 0
// 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() {
await TestRunner.loadModule('console_test_runner');
TestRunner.addResult(`Tests that blackboxed sourcemaps properly detach on reload crbug.com/888688`);
var content =
`console.log(1);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZhbC1pbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImV2YWwtaW4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImNvbnNvbGUubG9nKDEpOyJdfQ==`;
TestRunner.addSniffer(Bindings.BlackboxManager.prototype, '_patternChangeFinishedForTests', step1);
var frameworkRegexString = '.*';
Common.settingForTest('skipStackFramesPattern').set('.*');
async function step1() {
TestRunner.addResult('Evaluating script with source map');
await TestRunner.evaluateInPageAnonymously(content);
await new Promise(resolve => TestRunner.addSniffer(Bindings.CompilerScriptMapping.prototype, "_sourceMapAttachedForTest", resolve));
await ConsoleTestRunner.waitForConsoleMessagesPromise(1);
await TestRunner.reloadPagePromise();
TestRunner.addResult(`After reload, Console message count: ${SDK.consoleModel._messages.length}`);
TestRunner.completeTest();
}
})();
...@@ -211,8 +211,10 @@ Bindings.CompilerScriptMapping = class { ...@@ -211,8 +211,10 @@ Bindings.CompilerScriptMapping = class {
const sourceMap = /** @type {!SDK.SourceMap} */ (event.data.sourceMap); const sourceMap = /** @type {!SDK.SourceMap} */ (event.data.sourceMap);
this._removeStubUISourceCode(script); this._removeStubUISourceCode(script);
if (Bindings.blackboxManager.isBlackboxedURL(script.sourceURL, script.isContentScript())) if (Bindings.blackboxManager.isBlackboxedURL(script.sourceURL, script.isContentScript())) {
this._sourceMapAttachedForTest(sourceMap);
return; return;
}
this._populateSourceMapSources(script, sourceMap); this._populateSourceMapSources(script, sourceMap);
this._sourceMapAttachedForTest(sourceMap); this._sourceMapAttachedForTest(sourceMap);
...@@ -228,9 +230,11 @@ Bindings.CompilerScriptMapping = class { ...@@ -228,9 +230,11 @@ Bindings.CompilerScriptMapping = class {
const bindings = script.isContentScript() ? this._contentScriptsBindings : this._regularBindings; const bindings = script.isContentScript() ? this._contentScriptsBindings : this._regularBindings;
for (const sourceURL of sourceMap.sourceURLs()) { for (const sourceURL of sourceMap.sourceURLs()) {
const binding = bindings.get(sourceURL); const binding = bindings.get(sourceURL);
binding.removeSourceMap(sourceMap, frameId); if (binding) {
if (!binding._uiSourceCode) binding.removeSourceMap(sourceMap, frameId);
bindings.delete(sourceURL); if (!binding._uiSourceCode)
bindings.delete(sourceURL);
}
} }
this._debuggerWorkspaceBinding.updateLocations(script); this._debuggerWorkspaceBinding.updateLocations(script);
} }
......
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