Commit 5ff4d02d authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[inspector] command line api debug and monitor works with bound functions

BUG=chromium:496666
R=dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2391323002
Cr-Commit-Position: refs/heads/master@{#40007}
parent c56222c9
...@@ -139,7 +139,10 @@ class ConsoleHelper { ...@@ -139,7 +139,10 @@ class ConsoleHelper {
v8::MaybeLocal<v8::Function> firstArgAsFunction() { v8::MaybeLocal<v8::Function> firstArgAsFunction() {
if (m_info.Length() < 1 || !m_info[0]->IsFunction()) if (m_info.Length() < 1 || !m_info[0]->IsFunction())
return v8::MaybeLocal<v8::Function>(); return v8::MaybeLocal<v8::Function>();
return m_info[0].As<v8::Function>(); v8::Local<v8::Function> func = m_info[0].As<v8::Function>();
while (func->GetBoundFunction()->IsFunction())
func = func->GetBoundFunction().As<v8::Function>();
return func;
} }
v8::MaybeLocal<v8::Map> privateMap(const char* name) { v8::MaybeLocal<v8::Map> privateMap(const char* name) {
......
Check that debug and monitor methods from Command Line API works with bound function.
debug foo and bar
call foo and bar
paused in foo
paused in boo
undebug foo and bar
call foo and bar
monitor foo and bar
call foo and bar
function foo called
function boo called
unmonitor foo and bar
call foo and bar
monitor and debug bar
call bar
function boo called
paused in boo
undebug bar
call bar
function boo called
debug and unmonitor bar
call bar
paused in boo
\ No newline at end of file
// Copyright 2016 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.
print("Check that debug and monitor methods from Command Line API works with bound function.");
InspectorTest.addScript(`
function foo() {}
function boo() {}
var bar = boo.bind(null);
function testFunction() {
console.log("> debug foo and bar");
debug(foo);
debug(bar);
console.log("> call foo and bar");
foo();
bar();
console.log("> undebug foo and bar");
undebug(foo);
undebug(bar);
console.log("> call foo and bar");
foo();
bar();
console.log("> monitor foo and bar");
monitor(foo);
monitor(bar);
console.log("> call foo and bar");
foo();
bar();
console.log("> unmonitor foo and bar");
unmonitor(foo);
unmonitor(bar);
console.log("> call foo and bar");
foo();
bar();
console.log("> monitor and debug bar");
monitor(bar);
debug(bar);
console.log("> call bar");
bar();
console.log("> undebug bar");
undebug(bar);
console.log("> call bar");
bar();
console.log("> debug and unmonitor bar");
debug(bar);
unmonitor(bar);
console.log("> call bar");
bar();
}`);
Protocol.Runtime.enable();
Protocol.Debugger.enable();
Protocol.Debugger.onPaused(message => {
var functionName = message.params.callFrames[0].functionName;
InspectorTest.log(`paused in ${functionName}`);
Protocol.Debugger.resume();
});
Protocol.Runtime.onConsoleAPICalled(message => InspectorTest.log(message.params.args[0].value));
Protocol.Runtime.evaluate({ expression: "testFunction()", includeCommandLineAPI: true })
.then(InspectorTest.completeTest);
...@@ -36,7 +36,7 @@ InspectorTest.logMessage = function(message) ...@@ -36,7 +36,7 @@ InspectorTest.logMessage = function(message)
if (message.id) if (message.id)
message.id = "<messageId>"; message.id = "<messageId>";
const nonStableFields = new Set(["objectId", "scriptId", "exceptionId", "timestamp", "executionContextId"]); const nonStableFields = new Set(["objectId", "scriptId", "exceptionId", "timestamp", "executionContextId", "callFrameId"]);
var objects = [ message ]; var objects = [ message ];
while (objects.length) { while (objects.length) {
var object = objects.shift(); var object = objects.shift();
......
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