Commit 9c385f04 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[inspector] added reconnect method for tests

This method enables test of agent::restore methods.
Bonus: forbid setCustomObjectFormatterEnabled on disabled agent.

BUG=none
R=dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2713023004
Cr-Commit-Position: refs/heads/master@{#43502}
parent 4e600299
......@@ -521,6 +521,7 @@ Response V8RuntimeAgentImpl::runIfWaitingForDebugger() {
Response V8RuntimeAgentImpl::setCustomObjectFormatterEnabled(bool enabled) {
m_state->setBoolean(V8RuntimeAgentImplState::customObjectFormatterEnabled,
enabled);
if (!m_enabled) return Response::Error("Runtime agent is not enabled");
m_session->setCustomObjectFormatterEnabled(enabled);
return Response::OK();
}
......@@ -678,6 +679,7 @@ Response V8RuntimeAgentImpl::disable() {
m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, false);
m_inspector->disableStackCapturingIfNeeded();
m_session->discardInjectedScripts();
m_session->setCustomObjectFormatterEnabled(false);
reset();
m_inspector->client()->endEnsureAllContextsInGroup(
m_session->contextGroupId());
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests checks that console.memory property can be set in strict mode (crbug.com/468611).")
InspectorTest.log("Tests checks that console.memory property can be set in strict mode (crbug.com/468611).")
Protocol.Runtime.evaluate({ expression: "\"use strict\"\nconsole.memory = {};undefined" }).then(dumpResult);
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests that \"console.profileEnd()\" does not cause crash. (webkit:105759)");
InspectorTest.log("Tests that \"console.profileEnd()\" does not cause crash. (webkit:105759)");
InspectorTest.addScript(`
function collectProfiles()
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests that console.profile/profileEnd will record CPU profile when inspector front-end is connected.");
InspectorTest.log("Tests that console.profile/profileEnd will record CPU profile when inspector front-end is connected.");
InspectorTest.addScript(`
function collectProfiles()
......
......@@ -14,7 +14,7 @@ function fib(x) {
fib(5);
`;
print("Test collecting code coverage data with Profiler.collectCoverage.");
InspectorTest.log("Test collecting code coverage data with Profiler.collectCoverage.");
function ClearAndGC() {
return Protocol.Runtime.evaluate({ expression: "fib = null;" })
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Test that profiling can only be started when Profiler was enabled and that Profiler.disable command will stop recording all profiles.");
InspectorTest.log("Test that profiling can only be started when Profiler was enabled and that Profiler.disable command will stop recording all profiles.");
Protocol.Profiler.start().then(didFailToStartWhenDisabled);
disallowConsoleProfiles();
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Test that profiler is able to record a profile. Also it tests that profiler returns an error when it unable to find the profile.");
InspectorTest.log("Test that profiler is able to record a profile. Also it tests that profiler returns an error when it unable to find the profile.");
Protocol.Profiler.enable();
Protocol.Profiler.start().then(didStartFrontendProfile);
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Test that profiler doesn't crash when we call stop without preceeding start.");
InspectorTest.log("Test that profiler doesn't crash when we call stop without preceeding start.");
Protocol.Profiler.stop().then(didStopProfile);
function didStopProfile(messageObject)
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("setTimeout(console.count, 0) doesn't crash with enabled async stacks.")
InspectorTest.log("setTimeout(console.count, 0) doesn't crash with enabled async stacks.")
Protocol.Debugger.enable();
Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 1 });
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks async instrumentation enabled in the middle.');
InspectorTest.log('Checks async instrumentation enabled in the middle.');
InspectorTest.addScript(`
function foo() {
......
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
// Flags: --expose-gc
print('Checks async stack for late .then handlers with gc');
InspectorTest.log('Checks async stack for late .then handlers with gc');
InspectorTest.addScript(`
function foo1() {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks that async stack contains setTimeout');
InspectorTest.log('Checks that async stack contains setTimeout');
InspectorTest.addScript(`
var resolveCallback;
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks that async stacks works for async/await');
InspectorTest.log('Checks that async stacks works for async/await');
InspectorTest.addScript(`
async function foo1() {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks created frame for async call chain');
InspectorTest.log('Checks created frame for async call chain');
InspectorTest.addScript(
`
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks that async chains for promises are correct.');
InspectorTest.log('Checks that async chains for promises are correct.');
InspectorTest.addScript(`
function foo1() {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks that async stacks works good with different limits');
InspectorTest.log('Checks that async stacks works good with different limits');
InspectorTest.addScript(`
var resolveTest;
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Check that inspector correctly change break on exception state.");
InspectorTest.log("Check that inspector correctly change break on exception state.");
InspectorTest.addScript(`
function scheduleUncaughtException()
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Check that inspector correctly passes caught/uncaught information.");
InspectorTest.log("Check that inspector correctly passes caught/uncaught information.");
InspectorTest.addScript(
`function throwCaught() { try { throw new Error(); } catch (_) {} }
......
......@@ -2,7 +2,7 @@
// 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.log("Check that debug and monitor methods from Command Line API works with bound function.");
InspectorTest.addScript(`
function foo() {}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Check that stepInto at then end of the script go to next user script instead InjectedScriptSource.js.");
InspectorTest.log("Check that stepInto at then end of the script go to next user script instead InjectedScriptSource.js.");
InspectorTest.addScript(
`function foo()
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Debugger.scriptParsed and Debugger.scriptFailedToParse with ES6 module');
InspectorTest.log('Debugger.scriptParsed and Debugger.scriptFailedToParse with ES6 module');
let moduleSource = `
export function foo() {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks that Debugger.setScriptSource doesn\'t crash with modules');
InspectorTest.log('Checks that Debugger.setScriptSource doesn\'t crash with modules');
var module1 = `
export function foo() {
......
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
// Flags: --allow-natives-syntax
print('Checks that breaks in framework code correctly processed.');
InspectorTest.log('Checks that breaks in framework code correctly processed.');
InspectorTest.addScript(`
function frameworkAssert() {
......@@ -188,16 +188,16 @@ InspectorTest.runTestSuite([
},
function testAsyncDOMBreakpoint(next) {
schedulePauseOnNextStatement('', '');
utils.schedulePauseOnNextStatement('', '');
InspectorTest.log('> all frames in framework:');
Protocol.Runtime
.evaluate(
{expression: 'asyncDOMBreakpoint()//# sourceURL=framework.js'})
.then(() => cancelPauseOnNextStatement())
.then(() => utils.cancelPauseOnNextStatement())
.then(
() => Protocol.Runtime.evaluate(
{expression: '42//# sourceURL=user.js'}))
.then(() => schedulePauseOnNextStatement('', ''))
.then(() => utils.schedulePauseOnNextStatement('', ''))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'asyncDOMBreakpoint()//# sourceURL=user.js'}))
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks nested scheduled break in framework code.');
InspectorTest.log('Checks nested scheduled break in framework code.');
InspectorTest.addScript(`
function frameworkCall(callback) {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks framework debugging with blackboxed ranges.');
InspectorTest.log('Checks framework debugging with blackboxed ranges.');
InspectorTest.addScript(
`
......@@ -64,7 +64,7 @@ var testSuite = [
];
function testPositions(positions) {
schedulePauseOnNextStatement('', '');
utils.schedulePauseOnNextStatement('', '');
return Protocol.Debugger
.setBlackboxedRanges({scriptId: scriptId, positions: positions})
.then(InspectorTest.logMessage)
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks stepping with blackboxed frames on stack');
InspectorTest.log('Checks stepping with blackboxed frames on stack');
InspectorTest.addScript(
`
......@@ -47,7 +47,7 @@ Protocol.Debugger.enable()
var testSuite = [
function testStepIntoFromUser(next) {
schedulePauseOnNextStatement('', '');
utils.schedulePauseOnNextStatement('', '');
test('testStepFromUser()', [
'print', // before testStepFromUser call
'stepInto', 'stepInto', 'print', // userFoo
......@@ -57,7 +57,7 @@ var testSuite = [
},
function testStepOverFromUser(next) {
schedulePauseOnNextStatement('', '');
utils.schedulePauseOnNextStatement('', '');
test('testStepFromUser()', [
'print', // before testStepFromUser call
'stepInto', 'stepInto', 'print', // userFoo
......@@ -67,7 +67,7 @@ var testSuite = [
},
function testStepOutFromUser(next) {
schedulePauseOnNextStatement('', '');
utils.schedulePauseOnNextStatement('', '');
test('testStepFromUser()', [
'print', // before testStepFromUser call
'stepInto', 'stepInto', 'print', // userFoo
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks Debugger.getPossibleBreakpoints');
InspectorTest.log('Checks Debugger.getPossibleBreakpoints');
var source = read('test/inspector/debugger/resources/break-locations.js');
var source = utils.read('test/inspector/debugger/resources/break-locations.js');
InspectorTest.addScript(source);
Protocol.Debugger.onceScriptParsed()
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks Debugger.getPossibleBreakpoints with ignoreNestedFunctions');
InspectorTest.log('Checks Debugger.getPossibleBreakpoints with ignoreNestedFunctions');
var source = `
function test() {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Test for Debugger.getPossibleBreakpoints');
InspectorTest.log('Test for Debugger.getPossibleBreakpoints');
Protocol.Runtime.enable();
Protocol.Debugger.enable();
......@@ -153,7 +153,7 @@ function foo6() { Promise.resolve().then(() => 42) }`;
function compileScript(source, origin) {
var promise = Protocol.Debugger.onceScriptParsed().then(message => message.params.scriptId);
if (!origin) origin = { name: '', line_offset: 0, column_offset: 0 };
compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column_offset, false);
utils.compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column_offset, false);
return promise;
}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Checks breakProgram,(schedule|cancel)PauseOnNextStatement test API");
InspectorTest.log("Checks breakProgram,(schedule|cancel)PauseOnNextStatement test API");
InspectorTest.addScript(`
function callBreakProgram() {
......@@ -33,17 +33,17 @@ InspectorTest.runTestSuite([
},
function testSchedulePauseOnNextStatement(next) {
schedulePauseOnNextStatement('reason', JSON.stringify({a: 42}));
utils.schedulePauseOnNextStatement('reason', JSON.stringify({a: 42}));
Protocol.Runtime.evaluate({ expression: 'foo()//# sourceURL=expr1.js'})
.then(() => Protocol.Runtime.evaluate({
expression: 'foo()//# sourceURL=expr2.js'}))
.then(() => cancelPauseOnNextStatement())
.then(() => utils.cancelPauseOnNextStatement())
.then(next);
},
function testCancelPauseOnNextStatement(next) {
schedulePauseOnNextStatement('reason', JSON.stringify({a: 42}));
cancelPauseOnNextStatement();
utils.schedulePauseOnNextStatement('reason', JSON.stringify({a: 42}));
utils.cancelPauseOnNextStatement();
Protocol.Runtime.evaluate({ expression: 'foo()'})
.then(next);
}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Check internal properties reported in object preview.");
InspectorTest.log("Check internal properties reported in object preview.");
Protocol.Debugger.enable();
Protocol.Runtime.enable();
......
......@@ -4,7 +4,7 @@
// Flags: --max-old-space-size=4
print('Check pause on OOM');
InspectorTest.log('Check pause on OOM');
InspectorTest.addScript(`
var arr = [];
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks that debugger agent uses source content to restore breakpoints.');
InspectorTest.log('Checks that debugger agent uses source content to restore breakpoints.');
Protocol.Debugger.enable();
InspectorTest.runTestSuite([
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Checks that inspector correctly process compiled scripts");
InspectorTest.log("Checks that inspector correctly process compiled scripts");
function addScripts() {
// sourceURL in the same line
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Checks that inspector reports script compiled in Runtime.evaluate," +
InspectorTest.log("Checks that inspector reports script compiled in Runtime.evaluate," +
"Runtime.callFunctionOn and Runtime.compileScript");
Promise.prototype.thenLog = function log(message) {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Check that setScriptSource completes correctly when an exception is thrown.');
InspectorTest.log('Check that setScriptSource completes correctly when an exception is thrown.');
Protocol.Debugger.enable();
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Debugger breaks in next script after stepOut from previous one.');
InspectorTest.log('Debugger breaks in next script after stepOut from previous one.');
InspectorTest.addScript(`
function test() {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks possible break locations.');
InspectorTest.log('Checks possible break locations.');
InspectorTest.setupScriptMap();
Protocol.Debugger.onPaused(message => {
......
......@@ -4,8 +4,8 @@
// Flags: --expose-wasm
load('test/mjsunit/wasm/wasm-constants.js');
load('test/mjsunit/wasm/wasm-module-builder.js');
utils.load('test/mjsunit/wasm/wasm-constants.js');
utils.load('test/mjsunit/wasm/wasm-module-builder.js');
var builder = new WasmModuleBuilder();
......
......@@ -4,8 +4,8 @@
// Flags: --expose-wasm
load('test/mjsunit/wasm/wasm-constants.js');
load('test/mjsunit/wasm/wasm-module-builder.js');
utils.load('test/mjsunit/wasm/wasm-constants.js');
utils.load('test/mjsunit/wasm/wasm-module-builder.js');
// Add two empty functions. Both should be registered as individual scripts at
// module creation time.
......
......@@ -4,8 +4,8 @@
// Flags: --expose-wasm
load('test/mjsunit/wasm/wasm-constants.js');
load('test/mjsunit/wasm/wasm-module-builder.js');
utils.load('test/mjsunit/wasm/wasm-constants.js');
utils.load('test/mjsunit/wasm/wasm-module-builder.js');
var builder = new WasmModuleBuilder();
......
......@@ -4,8 +4,8 @@
// Flags: --expose-wasm
load('test/mjsunit/wasm/wasm-constants.js');
load('test/mjsunit/wasm/wasm-module-builder.js');
utils.load('test/mjsunit/wasm/wasm-constants.js');
utils.load('test/mjsunit/wasm/wasm-module-builder.js');
var builder = new WasmModuleBuilder();
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
load('test/mjsunit/wasm/wasm-constants.js');
load('test/mjsunit/wasm/wasm-module-builder.js');
utils.load('test/mjsunit/wasm/wasm-constants.js');
utils.load('test/mjsunit/wasm/wasm-module-builder.js');
var builder = new WasmModuleBuilder();
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks that takeHeapSnapshot uses empty accessing_context for access \
InspectorTest.log('Checks that takeHeapSnapshot uses empty accessing_context for access \
checks.');
InspectorTest.addScript(`
......
......@@ -108,6 +108,22 @@ class ConnectTask : public TaskRunner::Task {
v8::base::Semaphore* ready_semaphore_;
};
class DisconnectTask : public TaskRunner::Task {
public:
explicit DisconnectTask(InspectorClientImpl* client) : client_(client) {}
virtual ~DisconnectTask() = default;
bool is_inspector_task() final { return true; }
void Run(v8::Isolate* isolate,
const v8::Global<v8::Context>& global_context) {
client_->disconnect();
}
private:
InspectorClientImpl* client_;
};
InspectorClientImpl::InspectorClientImpl(TaskRunner* task_runner,
FrontendChannel* frontend_channel,
v8::base::Semaphore* ready_semaphore)
......@@ -125,7 +141,9 @@ void InspectorClientImpl::connect(v8::Local<v8::Context> context) {
channel_.reset(new ChannelImpl(frontend_channel_));
inspector_ = v8_inspector::V8Inspector::create(isolate_, this);
session_ = inspector_->connect(1, channel_.get(), v8_inspector::StringView());
v8_inspector::StringView state =
state_ ? state_->string() : v8_inspector::StringView();
session_ = inspector_->connect(1, channel_.get(), state);
context->SetAlignedPointerInEmbedderData(kInspectorClientIndex, this);
inspector_->contextCreated(
......@@ -133,6 +151,17 @@ void InspectorClientImpl::connect(v8::Local<v8::Context> context) {
context_.Reset(isolate_, context);
}
void InspectorClientImpl::scheduleReconnect(
v8::base::Semaphore* ready_semaphore) {
task_runner_->Append(new DisconnectTask(this));
task_runner_->Append(new ConnectTask(this, ready_semaphore));
}
void InspectorClientImpl::disconnect() {
state_ = session_->stateJSON();
session_.reset();
}
v8::Local<v8::Context> InspectorClientImpl::ensureDefaultContextInGroup(int) {
CHECK(isolate_);
return context_.Get(isolate_);
......
......@@ -25,6 +25,8 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient {
v8::base::Semaphore* ready_semaphore);
virtual ~InspectorClientImpl();
void scheduleReconnect(v8::base::Semaphore* ready_semaphore);
static v8_inspector::V8Inspector* InspectorFromContext(
v8::Local<v8::Context> context);
static v8_inspector::V8InspectorSession* SessionFromContext(
......@@ -46,10 +48,13 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient {
friend class ConnectTask;
void connect(v8::Local<v8::Context> context);
friend class DisconnectTask;
void disconnect();
std::unique_ptr<v8_inspector::V8Inspector> inspector_;
std::unique_ptr<v8_inspector::V8InspectorSession> session_;
std::unique_ptr<v8_inspector::V8Inspector::Channel> channel_;
std::unique_ptr<v8_inspector::StringBuffer> state_;
v8::Isolate* isolate_;
v8::Global<v8::Context> context_;
......
......@@ -58,7 +58,8 @@ class UtilsExtension : public v8::Extension {
"native function compileAndRunWithOrigin();"
"native function setCurrentTimeMSForTest();"
"native function schedulePauseOnNextStatement();"
"native function cancelPauseOnNextStatement();") {}
"native function cancelPauseOnNextStatement();"
"native function reconnect();") {}
virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Local<v8::String> name) {
v8::Local<v8::Context> context = isolate->GetCurrentContext();
......@@ -120,6 +121,12 @@ class UtilsExtension : public v8::Extension {
.FromJust()) {
return v8::FunctionTemplate::New(
isolate, UtilsExtension::CancelPauseOnNextStatement);
} else if (name->Equals(context,
v8::String::NewFromUtf8(isolate, "reconnect",
v8::NewStringType::kNormal)
.ToLocalChecked())
.FromJust()) {
return v8::FunctionTemplate::New(isolate, UtilsExtension::Reconnect);
}
return v8::Local<v8::FunctionTemplate>();
}
......@@ -275,6 +282,16 @@ class UtilsExtension : public v8::Extension {
}
inspector_client_->session()->cancelPauseOnNextStatement();
}
static void Reconnect(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() != 0) {
fprintf(stderr, "Internal error: reconnect().");
Exit();
}
v8::base::Semaphore ready_semaphore(0);
inspector_client_->scheduleReconnect(&ready_semaphore);
ready_semaphore.Wait();
}
};
TaskRunner* UtilsExtension::backend_runner_ = nullptr;
......
......@@ -30,7 +30,31 @@ Protocol = new Proxy({}, {
}
});
InspectorTest.log = print.bind(null);
var utils = {};
(function setupUtils() {
utils.load = load;
this.load = null;
utils.read = read;
this.read = null;
utils.compileAndRunWithOrigin = compileAndRunWithOrigin;
this.compileAndRunWithOrigin = null;
utils.quit = quit;
this.quit = null;
utils.print = print;
this.print = null;
utils.setlocale = setlocale;
this.setlocale = null;
utils.setCurrentTimeMSForTest = setCurrentTimeMSForTest;
this.setCurrentTimeMSForTest = null;
utils.schedulePauseOnNextStatement = schedulePauseOnNextStatement;
this.schedulePauseOnNextStatement = null;
utils.cancelPauseOnNextStatement = cancelPauseOnNextStatement;
this.cancelPauseOnNextStatement = null;
utils.reconnect = reconnect;
this.reconnect = null;
})();
InspectorTest.log = utils.print.bind(null);
InspectorTest.logMessage = function(originalMessage)
{
......@@ -38,7 +62,8 @@ InspectorTest.logMessage = function(originalMessage)
if (message.id)
message.id = "<messageId>";
const nonStableFields = new Set(["objectId", "scriptId", "exceptionId", "timestamp", "executionContextId", "callFrameId", "breakpointId"]);
const nonStableFields = new Set(["objectId", "scriptId", "exceptionId", "timestamp",
"executionContextId", "callFrameId", "breakpointId", "bindRemoteObjectFunctionId", "formatterObjectId" ]);
var objects = [ message ];
while (objects.length) {
var object = objects.shift();
......@@ -154,10 +179,7 @@ InspectorTest.logAsyncStackTrace = function(asyncStackTrace)
}
}
InspectorTest.completeTest = function()
{
Protocol.Debugger.disable().then(() => quit());
}
InspectorTest.completeTest = () => Protocol.Debugger.disable().then(() => utils.quit());
InspectorTest.completeTestAfterPendingTimeouts = function()
{
......@@ -169,9 +191,9 @@ InspectorTest.waitPendingTasks = function()
return Protocol.Runtime.evaluate({ expression: "new Promise(r => setTimeout(r, 0))//# sourceURL=wait-pending-tasks.js", awaitPromise: true });
}
InspectorTest.addScript = (string, lineOffset, columnOffset) => compileAndRunWithOrigin(string, "", lineOffset || 0, columnOffset || 0, false);
InspectorTest.addScriptWithUrl = (string, url) => compileAndRunWithOrigin(string, url, 0, 0, false);
InspectorTest.addModule = (string, url, lineOffset, columnOffset) => compileAndRunWithOrigin(string, url, lineOffset || 0, columnOffset || 0, true);
InspectorTest.addScript = (string, lineOffset, columnOffset) => utils.compileAndRunWithOrigin(string, "", lineOffset || 0, columnOffset || 0, false);
InspectorTest.addScriptWithUrl = (string, url) => utils.compileAndRunWithOrigin(string, url, 0, 0, false);
InspectorTest.addModule = (string, url, lineOffset, columnOffset) => utils.compileAndRunWithOrigin(string, url, lineOffset || 0, columnOffset || 0, true);
InspectorTest.startDumpingProtocolMessages = function()
{
......@@ -181,7 +203,7 @@ InspectorTest.startDumpingProtocolMessages = function()
InspectorTest.sendRawCommand = function(requestId, command, handler)
{
if (InspectorTest._dumpInspectorProtocolMessages)
print("frontend: " + command);
utils.print("frontend: " + command);
InspectorTest._dispatchTable.set(requestId, handler);
sendMessageToBackend(command);
}
......@@ -245,7 +267,7 @@ InspectorTest._waitForEventPromise = function(eventName)
InspectorTest._dispatchMessage = function(messageObject)
{
if (InspectorTest._dumpInspectorProtocolMessages)
print("backend: " + JSON.stringify(messageObject));
utils.print("backend: " + JSON.stringify(messageObject));
try {
var messageId = messageObject["id"];
if (typeof messageId === "number") {
......@@ -271,5 +293,5 @@ InspectorTest._dispatchMessage = function(messageObject)
}
InspectorTest.loadScript = function(fileName) {
InspectorTest.addScript(read(fileName));
InspectorTest.addScript(utils.read(fileName));
}
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
// Flags: --expose_gc
print("Tests that Runtime.awaitPromise works.");
InspectorTest.log("Tests that Runtime.awaitPromise works.");
InspectorTest.addScript(
`
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests that Runtime.callFunctionOn works with awaitPromise flag.");
InspectorTest.log("Tests that Runtime.callFunctionOn works with awaitPromise flag.");
InspectorTest.runTestSuite([
function testArguments(next)
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests that CommandLineAPI is presented only while evaluation.");
InspectorTest.log("Tests that CommandLineAPI is presented only while evaluation.");
InspectorTest.addScript(
`
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Check that console.log is reported through Console domain as well.");
InspectorTest.log("Check that console.log is reported through Console domain as well.");
var expectedMessages = 4;
var messages = [];
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Checks that console.assert works and points to correct call frame.");
InspectorTest.log("Checks that console.assert works and points to correct call frame.");
InspectorTest.addScript(`
function testFunction() {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests checks that deprecation messages for console.")
InspectorTest.log("Tests checks that deprecation messages for console.")
Protocol.Runtime.onConsoleAPICalled(messageAdded);
Protocol.Runtime.enable();
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Check that console.log doesn't run microtasks.");
InspectorTest.log("Check that console.log doesn't run microtasks.");
InspectorTest.addScript(
`
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks that console message storage doesn\'t exceed limits');
InspectorTest.log('Checks that console message storage doesn\'t exceed limits');
InspectorTest.addScript(`
function generateEmptyMessages(n) {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks console methods');
InspectorTest.log('Checks console methods');
InspectorTest.addScript(`
function testFunction() {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks format of console.timeEnd output');
InspectorTest.log('Checks format of console.timeEnd output');
Protocol.Runtime.enable();
Protocol.Runtime.onConsoleAPICalled(message => {
......@@ -34,12 +34,12 @@ InspectorTest.runTestSuite([
]);
function checkInterval(time) {
setCurrentTimeMSForTest(0.0);
utils.setCurrentTimeMSForTest(0.0);
return Protocol.Runtime.evaluate({
expression: `console.log('js: ' + ${time} + 'ms')`})
.then(() => Protocol.Runtime.evaluate({
expression: 'console.time(\'timeEnd\')'}))
.then(() => setCurrentTimeMSForTest(time))
.then(() => utils.setCurrentTimeMSForTest(time))
.then(() => Protocol.Runtime.evaluate({
expression: 'console.timeEnd(\'timeEnd\')'}));
}
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks basic ES6 modules support.');
InspectorTest.log('Checks basic ES6 modules support.');
var module1 = `
export function foo() {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Test that Runtime.evaluate correctly process errors during wrapping \
InspectorTest.log("Test that Runtime.evaluate correctly process errors during wrapping \
async result.");
var evaluateArguments = {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests that Runtime.evaluate works with awaitPromise flag.");
InspectorTest.log("Tests that Runtime.evaluate works with awaitPromise flag.");
InspectorTest.addScript(`
function createPromiseAndScheduleResolve()
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests that Runtime.evaluate works with an empty stack");
InspectorTest.log("Tests that Runtime.evaluate works with an empty stack");
InspectorTest.addScript("var text = [48116210, 34460128, 1406661984071834]");
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests that DevTools doesn't crash on Runtime.evaluate with contextId equals 0.");
InspectorTest.log("Tests that DevTools doesn't crash on Runtime.evaluate with contextId equals 0.");
Protocol.Runtime.evaluate({ "contextId": 0, "expression": "" })
.then(message => InspectorTest.logMessage(message))
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests that Runtime.evaluate will generate correct previews.");
InspectorTest.log("Tests that Runtime.evaluate will generate correct previews.");
InspectorTest.addScript(
`
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Check that exceptionThrown is supported by test runner.")
InspectorTest.log("Check that exceptionThrown is supported by test runner.")
Protocol.Runtime.enable();
Protocol.Runtime.onExceptionThrown(message => InspectorTest.logMessage(message));
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Check that while Runtime.getProperties call on proxy object no user defined trap will be executed.");
InspectorTest.log("Check that while Runtime.getProperties call on proxy object no user defined trap will be executed.");
InspectorTest.addScript(`
var self = this;
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks internal [[Entries]] in Runtime.getProperties output');
InspectorTest.log('Checks internal [[Entries]] in Runtime.getProperties output');
Protocol.Runtime.enable();
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print('Checks internal properties in Runtime.getProperties output');
InspectorTest.log('Checks internal properties in Runtime.getProperties output');
InspectorTest.addScript(`
function* foo() {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Test that descriptions for arrays, maps, and sets include the correct length or size.")
InspectorTest.log("Test that descriptions for arrays, maps, and sets include the correct length or size.")
Promise.all([
testExpression("new Set()"),
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests that property defined on console.__proto__ doesn't observable on other Objects.");
InspectorTest.log("Tests that property defined on console.__proto__ doesn't observable on other Objects.");
InspectorTest.addScript(`
function testFunction()
......
......@@ -13,27 +13,27 @@ InspectorTest.runTestSuite([
function consoleTimeWithCommaAsSeparator(next) {
InspectorTest.log("set locale to fr_CA.UTF-8 (has comma as separator)");
setlocale("fr_CA.UTF-8");
setCurrentTimeMSForTest(0.0);
utils.setlocale("fr_CA.UTF-8");
utils.setCurrentTimeMSForTest(0.0);
Protocol.Runtime.evaluate({ expression: "console.time(\"a\");"})
.then(() => setCurrentTimeMSForTest(0.001))
.then(() => utils.setCurrentTimeMSForTest(0.001))
.then(() => Protocol.Runtime.evaluate({ expression: "console.timeEnd(\"a\");"}))
.then(next);
},
function consoleLogWithCommaAsSeparator(next) {
InspectorTest.log("set locale to fr_CA.UTF-8 (has comma as separator)");
setlocale("fr_CA.UTF-8");
utils.setlocale("fr_CA.UTF-8");
Protocol.Runtime.evaluate({ expression: "console.log(239) "}).then(next);
},
function consoleTimeWithCommaAfterConsoleLog(next) {
InspectorTest.log("set locale to fr_CA.UTF-8 (has comma as separator)");
setlocale("fr_CA.UTF-8");
utils.setlocale("fr_CA.UTF-8");
Protocol.Runtime.evaluate({ expression: "console.log(239) "})
.then(() => setCurrentTimeMSForTest(0.0))
.then(() => utils.setCurrentTimeMSForTest(0.0))
.then(() => Protocol.Runtime.evaluate({ expression: "console.time(\"a\");"}))
.then(() => setCurrentTimeMSForTest(0.001))
.then(() => utils.setCurrentTimeMSForTest(0.001))
.then(() => Protocol.Runtime.evaluate({ expression: "console.timeEnd(\"a\");"}))
.then(next);
}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Tests that Runtime.compileScript and Runtime.runScript work with awaitPromise flag.");
InspectorTest.log("Tests that Runtime.compileScript and Runtime.runScript work with awaitPromise flag.");
InspectorTest.runTestSuite([
function testRunAndCompileWithoutAgentEnable(next)
......
Checks that Runtime agent correctly restore its state.
Running test: testExecutionContextsNotificationsOnRestore
{
method : Runtime.executionContextCreated
params : {
context : {
id : 1
name :
origin :
}
}
}
will reconnect..
{
method : Runtime.executionContextsCleared
params : {
}
}
{
method : Runtime.executionContextCreated
params : {
context : {
id : 1
name :
origin :
}
}
}
Running test: testConsoleAPICalledAfterRestore
will reconnect..
{
method : Runtime.consoleAPICalled
params : {
args : [
[0] : {
description : 42
type : number
value : 42
}
]
executionContextId : <executionContextId>
stackTrace : {
callFrames : [
[0] : {
columnNumber : 8
functionName :
lineNumber : 0
scriptId : <scriptId>
url :
}
]
}
timestamp : <timestamp>
type : log
}
}
Running test: testSetCustomObjectFormatterEnabled
will reconnect..
will reconnect..
{
method : Runtime.consoleAPICalled
params : {
args : [
[0] : {
className : Object
customPreview : {
bindRemoteObjectFunctionId : <bindRemoteObjectFunctionId>
formatterObjectId : <formatterObjectId>
hasBody : true
header : ["span",{},"Header formatted ",42]
}
description : Object
objectId : <objectId>
preview : {
description : Object
overflow : false
properties : [
[0] : {
name : name
type : number
value : 42
}
]
type : object
}
type : object
}
]
executionContextId : <executionContextId>
stackTrace : {
callFrames : [
[0] : {
columnNumber : 8
functionName :
lineNumber : 0
scriptId : <scriptId>
url :
}
]
}
timestamp : <timestamp>
type : log
}
}
{
id : <messageId>
result : {
result : {
type : undefined
}
}
}
// Copyright 2017 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.v8
InspectorTest.log('Checks that Runtime agent correctly restore its state.');
InspectorTest.addScript(`
var formatter = {
header: function(x)
{
return ["span", {}, "Header formatted ", x.name];
},
hasBody: function(x)
{
return true;
},
body: function(x)
{
return ["span", {}, "Body formatted ", x.name]
}
};
devtoolsFormatters = [ formatter ];
//# sourceURL=test.js`)
InspectorTest.runTestSuite([
function testExecutionContextsNotificationsOnRestore(next) {
Protocol.Runtime.onExecutionContextsCleared(InspectorTest.logMessage);
Protocol.Runtime.onExecutionContextCreated(InspectorTest.logMessage);
Protocol.Runtime.onExecutionContextDestroyed(InspectorTest.logMessage);
Protocol.Runtime.enable()
.then(reconnect)
.then(Protocol.Runtime.disable)
.then(() => {
Protocol.Runtime.onExecutionContextsCleared(null);
Protocol.Runtime.onExecutionContextCreated(null);
Protocol.Runtime.onExecutionContextDestroyed(null);
next()
});
},
function testConsoleAPICalledAfterRestore(next) {
Protocol.Runtime.onConsoleAPICalled(InspectorTest.logMessage);
Protocol.Runtime.enable()
.then(reconnect)
.then(() => Protocol.Runtime.evaluate({ expression: 'console.log(42);' }))
.then(Protocol.Runtime.disable)
.then(() => {
Protocol.Runtime.onConsoleAPICalled(null);
next();
});
},
function testSetCustomObjectFormatterEnabled(next) {
Protocol.Runtime.onConsoleAPICalled(InspectorTest.logMessage);
// cleanup console message storage
reconnect();
Protocol.Runtime.enable()
.then(() => Protocol.Runtime.setCustomObjectFormatterEnabled({ enabled: true }))
.then(reconnect)
.then(() => Protocol.Runtime.evaluate({ expression: 'console.log({ name: 42 })'}))
.then(InspectorTest.logMessage)
.then(Protocol.Runtime.disable)
.then(() => {
Protocol.Runtime.onConsoleAPICalled(null);
next();
});
},
]);
function reconnect() {
InspectorTest.logMessage('will reconnect..');
utils.reconnect();
}
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
print("Test that Runtime.getProperties doesn't truncate set and map entries in internalProperties.")
InspectorTest.log("Test that Runtime.getProperties doesn't truncate set and map entries in internalProperties.")
InspectorTest.addScript(`
function createSet(size) {
......
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