Commit b8b5e2f2 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[DevTools] fixed highlighting of expression with spread operator

On pause when we get expression for popover we by mistake include
spread operator when we should not.

R=einbinder@chromium.org

Bug: chromium:797296
Change-Id: I9a5eaa5df045874ec82056081e01e4c4a308ae87
Reviewed-on: https://chromium-review.googlesource.com/1041276
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: default avatarJoel Einbinder <einbinder@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583246}
parent 5175155c
Tests popver for spread operator.
Request popover for array:
Array(3)
Request popover for object:
Object
// 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 popver for spread operator.\n`);
await TestRunner.loadModule('sources_test_runner');
await TestRunner.showPanel('sources');
await SourcesTestRunner.startDebuggerTestPromise(/* quiet */ true);
TestRunner.evaluateInPageAnonymously(`
let arr = [1,2,3];
console.log(...arr);
let obj = {a:1};
console.log({...obj});
debugger;
//# sourceURL=test.js`);
await new Promise(resolve => UI.context.addFlavorChangeListener(SDK.DebuggerModel.CallFrame, resolve));
const sourceFrame = await SourcesTestRunner.showScriptSourcePromise('test.js');
TestRunner.addResult('Request popover for array:');
const {description: arr} = await SourcesTestRunner.objectForPopover(sourceFrame, 2, 16);
TestRunner.addResult(arr);
TestRunner.addResult('Request popover for object:');
const {description: obj} = await SourcesTestRunner.objectForPopover(sourceFrame, 4, 17);
TestRunner.addResult(obj);
SourcesTestRunner.completeDebuggerTest();
})();
...@@ -472,6 +472,8 @@ Sources.DebuggerPlugin = class extends Sources.UISourceCodeFrame.Plugin { ...@@ -472,6 +472,8 @@ Sources.DebuggerPlugin = class extends Sources.UISourceCodeFrame.Plugin {
const tokenBefore = this._textEditor.tokenAtTextPosition(editorLineNumber, startHighlight - 2); const tokenBefore = this._textEditor.tokenAtTextPosition(editorLineNumber, startHighlight - 2);
if (!tokenBefore || !tokenBefore.type) if (!tokenBefore || !tokenBefore.type)
return null; return null;
if (tokenBefore.type === 'js-meta')
break;
startHighlight = tokenBefore.startColumn; startHighlight = tokenBefore.startColumn;
} }
} }
......
...@@ -447,6 +447,14 @@ SourcesTestRunner.waitForScriptSource = function(scriptName, callback) { ...@@ -447,6 +447,14 @@ SourcesTestRunner.waitForScriptSource = function(scriptName, callback) {
SourcesTestRunner.waitForScriptSource.bind(SourcesTestRunner, scriptName, callback)); SourcesTestRunner.waitForScriptSource.bind(SourcesTestRunner, scriptName, callback));
}; };
SourcesTestRunner.objectForPopover = function(sourceFrame, lineNumber, columnNumber) {
const debuggerPlugin = SourcesTestRunner.debuggerPlugin(sourceFrame);
const {x, y} = debuggerPlugin._textEditor.cursorPositionToCoordinates(lineNumber, columnNumber);
const promise = TestRunner.addSnifferPromise(ObjectUI.ObjectPopoverHelper, 'buildObjectPopover');
debuggerPlugin._getPopoverRequest({x, y}).show(new UI.GlassPane());
return promise;
};
SourcesTestRunner.setBreakpoint = function(sourceFrame, lineNumber, condition, enabled) { SourcesTestRunner.setBreakpoint = function(sourceFrame, lineNumber, condition, enabled) {
const debuggerPlugin = SourcesTestRunner.debuggerPlugin(sourceFrame); const debuggerPlugin = SourcesTestRunner.debuggerPlugin(sourceFrame);
if (!debuggerPlugin._muted) if (!debuggerPlugin._muted)
......
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