Commit 9fa30d92 authored by Erik Luo's avatar Erik Luo Committed by Commit Bot

DevTools: breakpoints without uilocation should update decoration

When editing a breakpoint (disable, edit condition), we trigger
BreakpointRemoved, BreakpointAdded by resetting live UILocations.
Un-evaluated Snippets and Filesystem scripts may have a
'defaultUILocation' but no live UILocation, so edits will not
update the decoration.

This CL resets the defaultUILocation to trigger decoration
update.

Bug: 899369
Change-Id: I4474d39c5fd25f14588e0488ce9b284aa453988e
Reviewed-on: https://chromium-review.googlesource.com/c/1303096
Commit-Queue: Erik Luo <luoe@chromium.org>
Reviewed-by: default avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604103}
parent d239fd5a
Tests that breakpoints can be edited in snippets before execution.
Snippet content:
var x = 0;
breakpoint at 0
breakpoint at 0 disabled
// 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 breakpoints can be edited in snippets before execution.\n`);
await TestRunner.loadModule('sources_test_runner');
await TestRunner.showPanel('sources');
const uiSourceCode1 = await Snippets.project.createFile('s1', null, '');
uiSourceCode1.setContent('var x = 0;\n');
TestRunner.addResult('Snippet content:');
TestRunner.addResult(await uiSourceCode1.requestContent());
let sourceFrame = await SourcesTestRunner.showScriptSourcePromise("Script%20snippet%20%231");
await SourcesTestRunner.waitUntilDebuggerPluginLoaded(sourceFrame);
SourcesTestRunner.toggleBreakpoint(sourceFrame, 0, true);
await SourcesTestRunner.waitDebuggerPluginDecorations();
SourcesTestRunner.dumpDebuggerPluginBreakpoints(sourceFrame);
SourcesTestRunner.toggleBreakpoint(sourceFrame, 0, true);
await SourcesTestRunner.waitDebuggerPluginDecorations();
SourcesTestRunner.dumpDebuggerPluginBreakpoints(sourceFrame);
TestRunner.completeTest();
})();
...@@ -439,6 +439,10 @@ Bindings.BreakpointManager.Breakpoint = class { ...@@ -439,6 +439,10 @@ Bindings.BreakpointManager.Breakpoint = class {
} }
_updateBreakpoint() { _updateBreakpoint() {
if (this._uiLocations.size === 0 && this._defaultUILocation)
this._breakpointManager._uiLocationRemoved(this, this._defaultUILocation);
if (this._uiLocations.size === 0 && this._defaultUILocation && !this._isRemoved)
this._breakpointManager._uiLocationAdded(this, this._defaultUILocation);
const modelBreakpoints = this._modelBreakpoints.valuesArray(); const modelBreakpoints = this._modelBreakpoints.valuesArray();
for (let i = 0; i < modelBreakpoints.length; ++i) for (let i = 0; i < modelBreakpoints.length; ++i)
modelBreakpoints[i]._scheduleUpdateInDebugger(); modelBreakpoints[i]._scheduleUpdateInDebugger();
......
...@@ -698,17 +698,17 @@ SourcesTestRunner.evaluateOnCurrentCallFrame = function(code) { ...@@ -698,17 +698,17 @@ SourcesTestRunner.evaluateOnCurrentCallFrame = function(code) {
return TestRunner.debuggerModel.evaluateOnSelectedCallFrame({expression: code, objectGroup: 'console'}); return TestRunner.debuggerModel.evaluateOnSelectedCallFrame({expression: code, objectGroup: 'console'});
}; };
SourcesTestRunner.waitDebuggerPluginBreakpoints = function(sourceFrame) { SourcesTestRunner.waitDebuggerPluginDecorations = function(sourceFrame) {
return waitUpdate().then(checkIfReady); return TestRunner.addSnifferPromise(Sources.DebuggerPlugin.prototype, '_breakpointDecorationsUpdatedForTest');
};
async function waitUpdate() { SourcesTestRunner.waitDebuggerPluginBreakpoints = function(sourceFrame) {
await TestRunner.addSnifferPromise(Sources.DebuggerPlugin.prototype, '_breakpointDecorationsUpdatedForTest'); return SourcesTestRunner.waitDebuggerPluginDecorations().then(checkIfReady);
}
function checkIfReady() { function checkIfReady() {
for (const {breakpoint} of Bindings.breakpointManager.allBreakpointLocations()) { for (const {breakpoint} of Bindings.breakpointManager.allBreakpointLocations()) {
if (breakpoint._uiLocations.size === 0 && breakpoint.enabled()) if (breakpoint._uiLocations.size === 0 && breakpoint.enabled())
return waitUpdate().then(checkIfReady); return SourcesTestRunner.waitDebuggerPluginDecorations().then(checkIfReady);
} }
return Promise.resolve(); return Promise.resolve();
......
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