Commit 7bbea08f authored by dgozman's avatar dgozman Committed by Commit bot

[inspector] Refactor protocol-test.js

This refactoring makes it easier to write advanced tests and
gives full control over what's happening to the test code.
It also forces description for every test.

BUG=none

Review-Url: https://codereview.chromium.org/2891213002
Cr-Commit-Position: refs/heads/master@{#45412}
parent 47702c53
Tests that destroying context from inside of console.log does not crash
{
type : string
value : First inspector activity after attaching inspector
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that destroying context from inside of console.log does not crash');
const expression = `
Object.defineProperty(Object.prototype, 'RemoteObject', {
configurable: true,
......
Tests how let and const interact with command line api
first "let a = 1;" result: wasThrown = false
second "let a = 1;" result: wasThrown = true
exception message: Uncaught SyntaxError: Identifier 'a' has already been declared
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start('Tests how let and const interact with command line api');
Protocol.Runtime.evaluate({ expression: "let a = 42;" }).then(step2);
function step2(response)
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log("Tests that \"console.profileEnd()\" does not cause crash. (webkit:105759)");
let {session, contextGroup, Protocol} = InspectorTest.start("Tests that \"console.profileEnd()\" does not cause crash. (webkit:105759)");
InspectorTest.addScript(`
contextGroup.addScript(`
function collectProfiles()
{
console.profile();
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log("Tests that console.profile/profileEnd will record CPU profile when inspector front-end is connected.");
let {session, contextGroup, Protocol} = InspectorTest.start("Tests that console.profile/profileEnd will record CPU profile when inspector front-end is connected.");
InspectorTest.addScript(`
contextGroup.addScript(`
function collectProfiles()
{
console.profile("outer");
......
......@@ -50,7 +50,7 @@ var f = (function outer() {
f()()();
`;
InspectorTest.log("Test collecting code coverage data with Profiler.collectCoverage.");
let {session, contextGroup, Protocol} = InspectorTest.start("Test collecting code coverage data with Profiler.collectCoverage.");
function ClearAndGC() {
return Protocol.Runtime.evaluate({ expression: "fib = g = f = h = is_optimized = 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.
InspectorTest.log("Test that profiling can only be started when Profiler was enabled and that Profiler.disable command will stop recording all profiles.");
let {session, contextGroup, Protocol} = InspectorTest.start("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();
......@@ -31,7 +31,7 @@ function allowConsoleProfiles()
}
function didFailToStartWhenDisabled(messageObject)
{
if (!InspectorTest.expectedError("didFailToStartWhenDisabled", messageObject))
if (!expectedError("didFailToStartWhenDisabled", messageObject))
return;
allowConsoleProfiles();
Protocol.Profiler.enable();
......@@ -39,21 +39,21 @@ function didFailToStartWhenDisabled(messageObject)
}
function didStartFrontendProfile(messageObject)
{
if (!InspectorTest.expectedSuccess("didStartFrontendProfile", messageObject))
if (!expectedSuccess("didStartFrontendProfile", messageObject))
return;
Protocol.Runtime.evaluate({expression: "console.profile('p1');"}).then(didStartConsoleProfile);
}
function didStartConsoleProfile(messageObject)
{
if (!InspectorTest.expectedSuccess("didStartConsoleProfile", messageObject))
if (!expectedSuccess("didStartConsoleProfile", messageObject))
return;
Protocol.Profiler.disable().then(didDisableProfiler);
}
function didDisableProfiler(messageObject)
{
if (!InspectorTest.expectedSuccess("didDisableProfiler", messageObject))
if (!expectedSuccess("didDisableProfiler", messageObject))
return;
Protocol.Profiler.enable();
Protocol.Profiler.stop().then(didStopFrontendProfile);
......@@ -61,7 +61,7 @@ function didDisableProfiler(messageObject)
function didStopFrontendProfile(messageObject)
{
if (!InspectorTest.expectedError("no front-end initiated profiles found", messageObject))
if (!expectedError("no front-end initiated profiles found", messageObject))
return;
disallowConsoleProfiles();
Protocol.Runtime.evaluate({expression: "console.profileEnd();"}).then(didStopConsoleProfile);
......@@ -69,7 +69,21 @@ function didStopFrontendProfile(messageObject)
function didStopConsoleProfile(messageObject)
{
if (!InspectorTest.expectedSuccess("didStopConsoleProfile", messageObject))
if (!expectedSuccess("didStopConsoleProfile", messageObject))
return;
InspectorTest.completeTest();
}
function checkExpectation(fail, name, messageObject)
{
if (fail === !!messageObject.error) {
InspectorTest.log("PASS: " + name);
return true;
}
InspectorTest.log("FAIL: " + name + ": " + JSON.stringify(messageObject));
InspectorTest.completeTest();
return false;
}
var expectedSuccess = checkExpectation.bind(null, false);
var expectedError = checkExpectation.bind(null, true);
......@@ -2,47 +2,61 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
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.");
let {session, contextGroup, Protocol} = InspectorTest.start("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);
function didStartFrontendProfile(messageObject)
{
if (!InspectorTest.expectedSuccess("startFrontendProfile", messageObject))
if (!expectedSuccess("startFrontendProfile", messageObject))
return;
Protocol.Runtime.evaluate({expression: "console.profile('Profile 1');"}).then(didStartConsoleProfile);
}
function didStartConsoleProfile(messageObject)
{
if (!InspectorTest.expectedSuccess("startConsoleProfile", messageObject))
if (!expectedSuccess("startConsoleProfile", messageObject))
return;
Protocol.Runtime.evaluate({expression: "console.profileEnd('Profile 1');"}).then(didStopConsoleProfile);
}
function didStopConsoleProfile(messageObject)
{
if (!InspectorTest.expectedSuccess("stopConsoleProfile", messageObject))
if (!expectedSuccess("stopConsoleProfile", messageObject))
return;
Protocol.Profiler.stop().then(didStopFrontendProfile);
}
function didStopFrontendProfile(messageObject)
{
if (!InspectorTest.expectedSuccess("stoppedFrontendProfile", messageObject))
if (!expectedSuccess("stoppedFrontendProfile", messageObject))
return;
Protocol.Profiler.start().then(didStartFrontendProfile2);
}
function didStartFrontendProfile2(messageObject)
{
if (!InspectorTest.expectedSuccess("startFrontendProfileSecondTime", messageObject))
if (!expectedSuccess("startFrontendProfileSecondTime", messageObject))
return;
Protocol.Profiler.stop().then(didStopFrontendProfile2);
}
function didStopFrontendProfile2(messageObject)
{
InspectorTest.expectedSuccess("stopFrontendProfileSecondTime", messageObject)
expectedSuccess("stopFrontendProfileSecondTime", messageObject)
InspectorTest.completeTest();
}
function checkExpectation(fail, name, messageObject)
{
if (fail === !!messageObject.error) {
InspectorTest.log("PASS: " + name);
return true;
}
InspectorTest.log("FAIL: " + name + ": " + JSON.stringify(messageObject));
InspectorTest.completeTest();
return false;
}
var expectedSuccess = checkExpectation.bind(null, false);
var expectedError = checkExpectation.bind(null, true);
......@@ -2,11 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log("Test that profiler doesn't crash when we call stop without preceeding start.");
let {session, contextGroup, Protocol} = InspectorTest.start("Test that profiler doesn't crash when we call stop without preceeding start.");
Protocol.Profiler.stop().then(didStopProfile);
function didStopProfile(messageObject)
{
InspectorTest.expectedError("ProfileAgent.stop", messageObject);
expectedError("ProfileAgent.stop", messageObject);
InspectorTest.completeTest();
}
function checkExpectation(fail, name, messageObject)
{
if (fail === !!messageObject.error) {
InspectorTest.log("PASS: " + name);
return true;
}
InspectorTest.log("FAIL: " + name + ": " + JSON.stringify(messageObject));
InspectorTest.completeTest();
return false;
}
var expectedSuccess = checkExpectation.bind(null, false);
var expectedError = checkExpectation.bind(null, true);
Tests that accessing no longer valid call frames returns an error
Paused on 'debugger;'
resume
restartFrame
......
......@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.addScript(`
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that accessing no longer valid call frames returns an error');
contextGroup.addScript(`
function testFunction()
{
debugger;
......
......@@ -4,7 +4,7 @@
// Flags: --validate-asm --allow-natives-syntax
InspectorTest.log(
let {session, contextGroup, Protocol} = InspectorTest.start(
'This test runs asm.js which calls back to JS. Before executing (after ' +
'the script is parsed) we set breakpoints in the asm.js code.');
......@@ -50,7 +50,7 @@ InspectorTest.runTestSuite([
function addScript(next) {
afterScriptParsedCallback = next;
InspectorTest.addScript(testFunction.toString());
contextGroup.addScript(testFunction.toString());
},
function runTestFunction(next) {
......
......@@ -4,7 +4,7 @@
// Flags: --validate-asm --allow-natives-syntax
InspectorTest.log(
let {session, contextGroup, Protocol} = InspectorTest.start(
'This test runs asm.js which calls back to JS. JS triggers a break, on ' +
'pause we set breakpoints in the asm.js code.');
......@@ -53,7 +53,7 @@ InspectorTest.runTestSuite([
function addScript(next) {
afterScriptParsedCallback = next;
InspectorTest.addScript(testFunction.toString());
contextGroup.addScript(testFunction.toString());
},
function runTestFunction(next) {
......
Tests that asm-js scripts produce correct stack
Paused on 'debugger;'
Number of frames: 5
- [0] {"functionName":"call_debugger","function_lineNumber":13,"function_columnNumber":24,"lineNumber":14,"columnNumber":4}
......
......@@ -4,6 +4,8 @@
// Flags: --validate-asm
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that asm-js scripts produce correct stack');
function testFunction() {
function generateAsmJs(stdlib, foreign, heap) {
'use asm';
......@@ -25,7 +27,7 @@ function testFunction() {
fun();
}
InspectorTest.addScript(testFunction.toString());
contextGroup.addScript(testFunction.toString());
Protocol.Debugger.enable();
Protocol.Debugger.oncePaused().then(handleDebuggerPaused);
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log("setTimeout(console.count, 0) doesn't crash with enabled async stacks.")
let {session, contextGroup, Protocol} = InspectorTest.start("setTimeout(console.count, 0) doesn't crash with enabled async stacks.")
Protocol.Debugger.enable();
Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 1 });
Protocol.Runtime.evaluate({ expression: "setTimeout(console.count, 0)" });
InspectorTest.completeTestAfterPendingTimeouts();
InspectorTest.waitForPendingTasks().then(InspectorTest.completeTest);
......@@ -4,9 +4,9 @@
// Flags: --harmony-async-iteration
InspectorTest.log('Checks that async chains for for-await-of are correct.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that async chains for for-await-of are correct.');
InspectorTest.addScript(`
contextGroup.addScript(`
function Debugger(value) {
debugger;
......@@ -128,10 +128,10 @@ async function CaughtThrowOnBreak() {
}
//# sourceURL=test.js`, 9, 26);
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
InspectorTest.logCallFrames(message.params.callFrames);
InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace);
session.logCallFrames(message.params.callFrames);
session.logAsyncStackTrace(message.params.asyncStackTrace);
InspectorTest.log('');
Protocol.Debugger.resume();
});
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks async instrumentation enabled in the middle.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks async instrumentation enabled in the middle.');
InspectorTest.addScript(`
contextGroup.addScript(`
function foo() {
// asyncTaskStarted
debugger;
......@@ -24,15 +24,15 @@ function test() {
//# sourceURL=test.js`, 7, 26);
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
if (enableOnPause-- === 0)
Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 });
InspectorTest.logCallFrames(message.params.callFrames);
session.logCallFrames(message.params.callFrames);
var asyncStackTrace = message.params.asyncStackTrace;
while (asyncStackTrace) {
InspectorTest.log(`-- ${asyncStackTrace.description} --`);
InspectorTest.logCallFrames(asyncStackTrace.callFrames);
session.logCallFrames(asyncStackTrace.callFrames);
asyncStackTrace = asyncStackTrace.parent;
}
InspectorTest.log('');
......
......@@ -3,9 +3,9 @@
// found in the LICENSE file.
// Flags: --expose-gc
InspectorTest.log('Checks async stack for late .then handlers with gc');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks async stack for late .then handlers with gc');
InspectorTest.addScript(`
contextGroup.addScript(`
function foo1() {
gc();
debugger;
......@@ -27,13 +27,13 @@ function test() {
}
//# sourceURL=test.js`, 8, 26);
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
InspectorTest.logCallFrames(message.params.callFrames);
session.logCallFrames(message.params.callFrames);
var asyncStackTrace = message.params.asyncStackTrace;
while (asyncStackTrace) {
InspectorTest.log(`-- ${asyncStackTrace.description} --`);
InspectorTest.logCallFrames(asyncStackTrace.callFrames);
session.logCallFrames(asyncStackTrace.callFrames);
asyncStackTrace = asyncStackTrace.parent;
}
InspectorTest.log('');
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks that async stack contains setTimeout');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that async stack contains setTimeout');
InspectorTest.addScript(`
contextGroup.addScript(`
var resolveCallback;
function foo1() {
function inner1() {
......@@ -29,13 +29,13 @@ function foo3() {
}
//# sourceURL=test.js`, 7, 26);
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
InspectorTest.logCallFrames(message.params.callFrames);
session.logCallFrames(message.params.callFrames);
var asyncStackTrace = message.params.asyncStackTrace;
while (asyncStackTrace) {
InspectorTest.log(`-- ${asyncStackTrace.description} --`);
InspectorTest.logCallFrames(asyncStackTrace.callFrames);
session.logCallFrames(asyncStackTrace.callFrames);
asyncStackTrace = asyncStackTrace.parent;
}
InspectorTest.log('');
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks that async stacks works for async/await');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that async stacks works for async/await');
InspectorTest.addScript(`
contextGroup.addScript(`
async function foo1() {
debugger;
return Promise.resolve();
......@@ -25,10 +25,10 @@ async function test() {
}
//# sourceURL=test.js`, 7, 26);
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
InspectorTest.logCallFrames(message.params.callFrames);
InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace);
session.logCallFrames(message.params.callFrames);
session.logAsyncStackTrace(message.params.asyncStackTrace);
InspectorTest.log('');
Protocol.Debugger.resume();
});
......
......@@ -3,9 +3,9 @@
// found in the LICENSE file.
// TODO(kozyatinskiy): fix this test.
InspectorTest.log('Checks created frame for async call chain');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks created frame for async call chain');
InspectorTest.addScript(
contextGroup.addScript(
`
function foo1() {
debugger;
......@@ -77,10 +77,10 @@ function setTimeouts() {
//# sourceURL=test.js`,
8, 4);
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
InspectorTest.logCallFrames(message.params.callFrames);
InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace);
session.logCallFrames(message.params.callFrames);
session.logAsyncStackTrace(message.params.asyncStackTrace);
InspectorTest.log('');
Protocol.Debugger.resume();
});
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks that async chains for promises are correct.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that async chains for promises are correct.');
InspectorTest.addScript(`
contextGroup.addScript(`
function foo1() {
debugger;
}
......@@ -219,10 +219,10 @@ function reject() {
//# sourceURL=test.js`, 7, 26);
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
InspectorTest.logCallFrames(message.params.callFrames);
InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace);
session.logCallFrames(message.params.callFrames);
session.logAsyncStackTrace(message.params.asyncStackTrace);
InspectorTest.log('');
Protocol.Debugger.resume();
});
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log("Check that inspector correctly change break on exception state.");
let {session, contextGroup, Protocol} = InspectorTest.start("Check that inspector correctly change break on exception state.");
InspectorTest.addScript(`
contextGroup.addScript(`
function scheduleUncaughtException()
{
setTimeout(throwUncaughtException, 0);
......
Tests that function location in call frames is correct
Paused on 'debugger;'
Top frame location: {"scriptId":"42","lineNumber":3,"columnNumber":4}
Top frame functionLocation: {"scriptId":"42","lineNumber":0,"columnNumber":21}
......@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.addScript(
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that function location in call frames is correct');
contextGroup.addScript(
`function testFunction()
{
var a = 2;
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Async caught exception prediction and blackboxing.');
let {session, contextGroup, Protocol} = InspectorTest.start('Async caught exception prediction and blackboxing.');
InspectorTest.addScript(`
contextGroup.addScript(`
function constructorThrow() {
return new Promise((resolve, reject) =>
Promise.resolve().then(() =>
......@@ -18,7 +18,7 @@ function dotCatch(producer) {
}
//# sourceURL=framework.js`);
InspectorTest.setupScriptMap();
session.setupScriptMap();
(async function test() {
Protocol.Debugger.enable();
Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']});
......@@ -33,6 +33,6 @@ InspectorTest.setupScriptMap();
async function waitPauseAndDumpLocation() {
var message = await Protocol.Debugger.oncePaused();
InspectorTest.log('paused at:');
InspectorTest.logSourceLocation(message.params.callFrames[0].location);
session.logSourceLocation(message.params.callFrames[0].location);
return message;
}
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log("Check that inspector correctly passes caught/uncaught information.");
let {session, contextGroup, Protocol} = InspectorTest.start("Check that inspector correctly passes caught/uncaught information.");
InspectorTest.addScript(
contextGroup.addScript(
`function throwCaught() { try { throw new Error(); } catch (_) {} }
function throwUncaught() { throw new Error(); }
function schedule(f) { setTimeout(f, 0); }
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks that we collect obsolete async tasks with async stacks.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that we collect obsolete async tasks with async stacks.');
InspectorTest.addScript(`
contextGroup.addScript(`
function test() {
inspector.setMaxAsyncTaskStacks(128);
var p = Promise.resolve();
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks that we drop old async call chains.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that we drop old async call chains.');
Protocol.Debugger.enable();
Protocol.Runtime.enable();
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log("Check that debug and monitor methods from Command Line API works with bound function.");
let {session, contextGroup, Protocol} = InspectorTest.start("Check that debug and monitor methods from Command Line API works with bound function.");
InspectorTest.addScript(`
contextGroup.addScript(`
function foo() {}
function boo() {}
var bar = boo.bind(null);
......
Tests Debugger.continueToLocation
Paused on debugger statement
Paused after continueToLocation
Stopped on line 8, expected 8, requested 8, (0-based numbers).
......@@ -28,4 +29,3 @@ Paused after continueToLocation
Stopped on line 17, expected 17, requested 17, (0-based numbers).
Control parameter 'step' calculation result: 6, expected: 6
SUCCESS
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Check that continue-to-location works with different strategies.');
let {session, contextGroup, Protocol} = InspectorTest.start('Check that continue-to-location works with different strategies.');
InspectorTest.addScript(`
contextGroup.addScript(`
async function asyncFact(n) {
if (n == 0) return 1;
let r = n * await asyncFact(n - 1);
......@@ -30,7 +30,7 @@ function topLevel() {
//# sourceURL=test.js`, 7, 26);
InspectorTest.setupScriptMap();
session.setupScriptMap();
InspectorTest.runAsyncTestSuite([
async function testAwaitAny() {
Protocol.Debugger.enable();
......@@ -132,8 +132,8 @@ InspectorTest.runAsyncTestSuite([
async function pausedAndDumpStack() {
let message = await Protocol.Debugger.oncePaused();
InspectorTest.logCallFrames(message.params.callFrames);
InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace);
session.logCallFrames(message.params.callFrames);
session.logAsyncStackTrace(message.params.asyncStackTrace);
InspectorTest.log('');
return message;
}
......@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.addScript(
let {session, contextGroup, Protocol} = InspectorTest.start('Tests Debugger.continueToLocation');
contextGroup.addScript(
`function statementsExample()
{
var self = arguments.callee;
......
......@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Check destroying agent inside of breakProgram');
let {session, contextGroup, Protocol} = InspectorTest.start('Check destroying agent inside of breakProgram');
(async function test(){
await Protocol.Debugger.enable();
Protocol.Runtime.evaluate({expression: 'inspector.breakProgram(\'\', \'{}\')'});
await Protocol.Debugger.oncePaused();
InspectorTest.session.disconnect();
utils.quit();
session.disconnect();
InspectorTest.quitImmediately();
})();
......@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Check that stepInto at then end of the script go to next user script instead InjectedScriptSource.js.');
let {session, contextGroup, Protocol} = InspectorTest.start('Check that stepInto at then end of the script go to next user script instead InjectedScriptSource.js.');
(async function test() {
InspectorTest.setupScriptMap();
session.setupScriptMap();
await Protocol.Debugger.enable();
Protocol.Runtime.evaluate({expression: '(function boo() { setTimeout(() => 239, 0); debugger; })()\n'});
await waitPauseAndDumpLocation();
......@@ -22,6 +22,6 @@ InspectorTest.log('Check that stepInto at then end of the script go to next user
async function waitPauseAndDumpLocation() {
var message = await Protocol.Debugger.oncePaused();
InspectorTest.log('paused at:');
InspectorTest.logSourceLocation(message.params.callFrames[0].location);
session.logSourceLocation(message.params.callFrames[0].location);
return message;
}
......@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Debugger.scriptParsed and Debugger.scriptFailedToParse with ES6 module');
let {session, contextGroup, Protocol} = InspectorTest.start('Debugger.scriptParsed and Debugger.scriptFailedToParse with ES6 module');
let moduleSource = `
export function foo() {
return 42;
}`;
InspectorTest.addModule(moduleSource, 'module1.js');
InspectorTest.addModule('}', 'module-with-syntax-error-1.js');
contextGroup.addModule(moduleSource, 'module1.js');
contextGroup.addModule('}', 'module-with-syntax-error-1.js');
Protocol.Debugger.onScriptParsed(InspectorTest.logMessage);
Protocol.Debugger.onScriptFailedToParse(InspectorTest.logMessage);
......@@ -21,8 +21,8 @@ InspectorTest.runTestSuite([
},
function testScriptEventsWhenDebuggerIsEnabled(next) {
InspectorTest.addModule(moduleSource, 'module2.js');
InspectorTest.addModule('}', 'module-with-syntax-error-2.js');
InspectorTest.waitPendingTasks().then(next);
contextGroup.addModule(moduleSource, 'module2.js');
contextGroup.addModule('}', 'module-with-syntax-error-2.js');
InspectorTest.waitForPendingTasks().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.
InspectorTest.log('Checks that Debugger.setScriptSource doesn\'t crash with modules');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that Debugger.setScriptSource doesn\'t crash with modules');
var module1 = `
export function foo() {
......@@ -25,9 +25,9 @@ Protocol.Debugger.onScriptParsed(message => {
module1Id = message.params.scriptId;
});
Protocol.Debugger.enable()
.then(() => InspectorTest.addModule(module1, 'module1'))
.then(() => InspectorTest.addModule(module2, 'module2'))
.then(() => InspectorTest.waitPendingTasks())
.then(() => contextGroup.addModule(module1, 'module1'))
.then(() => contextGroup.addModule(module2, 'module2'))
.then(() => InspectorTest.waitForPendingTasks())
.then(() => Protocol.Debugger.setScriptSource({ scriptId: module1Id, scriptSource: editedModule1 }))
.then(InspectorTest.logMessage)
.then(InspectorTest.completeTest);
Tests that variables introduced in eval scopes are accessible
{
id : <messageId>
result : {
......
......@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.addScript(
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that variables introduced in eval scopes are accessible');
contextGroup.addScript(
`function testNonEmptyEvalScope() {
eval("'use strict'; var hest = 420; debugger;");
}
......
......@@ -3,9 +3,9 @@
// found in the LICENSE file.
// Flags: --allow-natives-syntax
InspectorTest.log('Checks that breaks in framework code correctly processed.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that breaks in framework code correctly processed.');
InspectorTest.addScript(`
contextGroup.addScript(`
function frameworkAssert() {
console.assert(false);
}
......@@ -69,7 +69,7 @@ function syncDOMBreakpointWithInlinedUserFrame() {
//# sourceURL=framework.js`, 8, 26);
InspectorTest.addScript(`
contextGroup.addScript(`
function throwUserException() {
throw new Error();
}
......@@ -80,9 +80,9 @@ function userFunction() {
//# sourceURL=user.js`, 64, 26)
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
InspectorTest.logCallFrames(message.params.callFrames);
session.logCallFrames(message.params.callFrames);
InspectorTest.log('');
Protocol.Debugger.resume();
});
......@@ -188,16 +188,16 @@ InspectorTest.runTestSuite([
},
function testAsyncDOMBreakpoint(next) {
InspectorTest.contextGroup.schedulePauseOnNextStatement('', '');
contextGroup.schedulePauseOnNextStatement('', '');
InspectorTest.log('> all frames in framework:');
Protocol.Runtime
.evaluate(
{expression: 'asyncDOMBreakpoint()//# sourceURL=framework.js'})
.then(() => InspectorTest.contextGroup.cancelPauseOnNextStatement())
.then(() => contextGroup.cancelPauseOnNextStatement())
.then(
() => Protocol.Runtime.evaluate(
{expression: '42//# sourceURL=user.js'}))
.then(() => InspectorTest.contextGroup.schedulePauseOnNextStatement('', ''))
.then(() => contextGroup.schedulePauseOnNextStatement('', ''))
.then(
() => Protocol.Runtime.evaluate(
{expression: 'asyncDOMBreakpoint()//# sourceURL=user.js'}))
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks nested scheduled break in framework code.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks nested scheduled break in framework code.');
InspectorTest.addScript(`
contextGroup.addScript(`
function frameworkCall(callback) {
inspector.callWithScheduledBreak(doFrameworkWork.bind(null, callback),
'top-framework-scheduled-break',
......@@ -22,7 +22,7 @@ function doFrameworkBreak() {
//# sourceURL=framework.js`, 7, 26);
InspectorTest.addScript(`
contextGroup.addScript(`
function testFunction() {
inspector.callWithScheduledBreak(frameworkCall.bind(null, callback),
'top-scheduled-break', '');
......@@ -35,11 +35,11 @@ function callback() {
//# sourceURL=user.js`, 25, 26);
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
InspectorTest.log('break reason: ' + message.params.reason);
InspectorTest.log('break aux data: ' + JSON.stringify(message.params.data || {}, null, ' '));
InspectorTest.logCallFrames(message.params.callFrames);
session.logCallFrames(message.params.callFrames);
InspectorTest.log('');
Protocol.Debugger.resume();
});
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks framework debugging with blackboxed ranges.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks framework debugging with blackboxed ranges.');
InspectorTest.addScript(
contextGroup.addScript(
`
function foo() {
return boo();
......@@ -18,9 +18,9 @@ function testFunction() {
//# sourceURL=test.js`,
7, 26);
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
InspectorTest.logCallFrames(message.params.callFrames);
session.logCallFrames(message.params.callFrames);
InspectorTest.log('');
Protocol.Debugger.stepInto();
});
......@@ -64,7 +64,7 @@ var testSuite = [
];
function testPositions(positions) {
InspectorTest.contextGroup.schedulePauseOnNextStatement('', '');
contextGroup.schedulePauseOnNextStatement('', '');
return Protocol.Debugger
.setBlackboxedRanges({scriptId: scriptId, positions: positions})
.then(InspectorTest.logMessage)
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks stepping with blackboxed frames on stack');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks stepping with blackboxed frames on stack');
InspectorTest.addScript(
contextGroup.addScript(
`
function frameworkCall(funcs) {
for (var f of funcs) f();
......@@ -17,7 +17,7 @@ function frameworkBreakAndCall(funcs) {
//# sourceURL=framework.js`,
8, 4);
InspectorTest.addScript(
contextGroup.addScript(
`
function userFoo() {
return 1;
......@@ -37,7 +37,7 @@ function testStepFromFramework() {
//# sourceURL=user.js`,
21, 4);
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.enable()
.then(
......@@ -47,7 +47,7 @@ Protocol.Debugger.enable()
var testSuite = [
function testStepIntoFromUser(next) {
InspectorTest.contextGroup.schedulePauseOnNextStatement('', '');
contextGroup.schedulePauseOnNextStatement('', '');
test('testStepFromUser()', [
'print', // before testStepFromUser call
'stepInto', 'stepInto', 'print', // userFoo
......@@ -57,7 +57,7 @@ var testSuite = [
},
function testStepOverFromUser(next) {
InspectorTest.contextGroup.schedulePauseOnNextStatement('', '');
contextGroup.schedulePauseOnNextStatement('', '');
test('testStepFromUser()', [
'print', // before testStepFromUser call
'stepInto', 'stepInto', 'print', // userFoo
......@@ -67,7 +67,7 @@ var testSuite = [
},
function testStepOutFromUser(next) {
InspectorTest.contextGroup.schedulePauseOnNextStatement('', '');
contextGroup.schedulePauseOnNextStatement('', '');
test('testStepFromUser()', [
'print', // before testStepFromUser call
'stepInto', 'stepInto', 'print', // userFoo
......@@ -101,7 +101,7 @@ function test(entryExpression, actions) {
Protocol.Debugger.onPaused(message => {
var action = actions.shift() || 'resume';
if (action === 'print') {
InspectorTest.logCallFrames(message.params.callFrames);
session.logCallFrames(message.params.callFrames);
InspectorTest.log('');
action = actions.shift() || 'resume';
}
......
Tests possible breakpoints in array literal
{
id : <messageId>
result : {
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start('Tests possible breakpoints in array literal');
Protocol.Debugger.enable();
Protocol.Debugger.onceScriptParsed().then(message => message.params.scriptId)
......@@ -9,4 +11,4 @@ Protocol.Debugger.onceScriptParsed().then(message => message.params.scriptId)
.then(InspectorTest.logMessage)
.then(InspectorTest.completeTest);
InspectorTest.addScript("() => []");
contextGroup.addScript("() => []");
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('getPossibleBreakpoints should not crash during lazy compilation (crbug.com/715334)');
let {session, contextGroup, Protocol} = InspectorTest.start('getPossibleBreakpoints should not crash during lazy compilation (crbug.com/715334)');
InspectorTest.addScript(`
contextGroup.addScript(`
function test() { continue; }
//# sourceURL=test.js`);
......
......@@ -4,10 +4,10 @@
// Flags: --turbo
InspectorTest.log('Checks Debugger.getPossibleBreakpoints');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks Debugger.getPossibleBreakpoints');
var source = utils.read('test/inspector/debugger/resources/break-locations.js');
InspectorTest.addScript(source);
contextGroup.addScript(source);
Protocol.Debugger.onceScriptParsed()
.then(message => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber : 0, scriptId: message.params.scriptId }}))
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks Debugger.getPossibleBreakpoints with ignoreNestedFunctions');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks Debugger.getPossibleBreakpoints with ignoreNestedFunctions');
var source = `
function test() {
......@@ -17,7 +17,7 @@ function test() {
nested2();
}
//# sourceURL=test.js`;
InspectorTest.addScript(source);
contextGroup.addScript(source);
var scriptId;
Protocol.Debugger.onceScriptParsed().then(message => {
......@@ -25,7 +25,7 @@ Protocol.Debugger.onceScriptParsed().then(message => {
scriptId = message.params.scriptId;
}).then(() => InspectorTest.runTestSuite(tests));
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(dumpBreakLocationInSourceAndResume);
Protocol.Debugger.enable();
......@@ -103,7 +103,7 @@ function dumpAllLocations(message) {
}
function dumpBreakLocationInSourceAndResume(message) {
InspectorTest.logCallFrames([ message.params.callFrames[0] ]);
session.logCallFrames([ message.params.callFrames[0] ]);
var location = message.params.callFrames[0].location;
var sourceLines = source.split('\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.
InspectorTest.log('Test for Debugger.getPossibleBreakpoints');
let {session, contextGroup, Protocol} = InspectorTest.start('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 };
InspectorTest.addScript(source, origin.line_offset, origin.column_offset, origin.name);
contextGroup.addScript(source, origin.line_offset, origin.column_offset, origin.name);
return promise;
}
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log("Checks breakProgram,(schedule|cancel)PauseOnNextStatement test API");
let {session, contextGroup, Protocol} = InspectorTest.start("Checks breakProgram,(schedule|cancel)PauseOnNextStatement test API");
InspectorTest.addScript(`
contextGroup.addScript(`
function callBreakProgram() {
inspector.breakProgram('reason', JSON.stringify({a: 42}));
}
......@@ -13,10 +13,10 @@ function foo() {
return 42;
}`, 7, 26);
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
InspectorTest.log('Stack:');
InspectorTest.logCallFrames(message.params.callFrames);
session.logCallFrames(message.params.callFrames);
delete message.params.callFrames;
InspectorTest.log('Other data:');
InspectorTest.logMessage(message);
......@@ -33,17 +33,17 @@ InspectorTest.runTestSuite([
},
function testSchedulePauseOnNextStatement(next) {
InspectorTest.contextGroup.schedulePauseOnNextStatement('reason', JSON.stringify({a: 42}));
contextGroup.schedulePauseOnNextStatement('reason', JSON.stringify({a: 42}));
Protocol.Runtime.evaluate({ expression: 'foo()//# sourceURL=expr1.js'})
.then(() => Protocol.Runtime.evaluate({
expression: 'foo()//# sourceURL=expr2.js'}))
.then(() => InspectorTest.contextGroup.cancelPauseOnNextStatement())
.then(() => contextGroup.cancelPauseOnNextStatement())
.then(next);
},
function testCancelPauseOnNextStatement(next) {
InspectorTest.contextGroup.schedulePauseOnNextStatement('reason', JSON.stringify({a: 42}));
InspectorTest.contextGroup.cancelPauseOnNextStatement();
contextGroup.schedulePauseOnNextStatement('reason', JSON.stringify({a: 42}));
contextGroup.cancelPauseOnNextStatement();
Protocol.Runtime.evaluate({ expression: 'foo()'})
.then(next);
}
......
// 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.
// TODO(kozyatinskiy): fix or remove it later.
InspectorTest.log('Checks that we trim async call chains correctly.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that we trim async call chains correctly.');
Protocol.Debugger.enable();
InspectorTest.log('set async chain depth to 8');
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log("Check internal properties reported in object preview.");
let {session, contextGroup, Protocol} = InspectorTest.start("Check internal properties reported in object preview.");
Protocol.Debugger.enable();
Protocol.Runtime.enable();
......
......@@ -4,9 +4,9 @@
// Flags: --max-old-space-size=8
InspectorTest.log('Check pause on OOM');
let {session, contextGroup, Protocol} = InspectorTest.start('Check pause on OOM');
InspectorTest.addScript(`
contextGroup.addScript(`
var arr = [];
var stop = false;
function generateGarbage() {
......
......@@ -3,95 +3,99 @@
// found in the LICENSE file.
InspectorTest.log('Checks Debugger.pause');
let contextGroup1 = new InspectorTest.ContextGroup();
let session1 = contextGroup1.connect();
let Protocol1 = session1.Protocol;
InspectorTest.setupScriptMap();
Protocol.Debugger.enable();
session1.setupScriptMap();
Protocol1.Debugger.enable();
InspectorTest.runAsyncTestSuite([
async function testPause() {
Protocol.Debugger.pause();
Protocol.Runtime.evaluate({expression: 'var a = 42;'});
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
Protocol1.Debugger.pause();
Protocol1.Runtime.evaluate({expression: 'var a = 42;'});
await waitPauseAndDumpLocation(session1);
await Protocol1.Debugger.resume();
},
async function testSkipFrameworks() {
Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']});
Protocol.Debugger.pause();
Protocol.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework.js'});
Protocol.Runtime.evaluate({expression: 'var a = 239;'});
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
Protocol1.Debugger.setBlackboxPatterns({patterns: ['framework\.js']});
Protocol1.Debugger.pause();
Protocol1.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework.js'});
Protocol1.Runtime.evaluate({expression: 'var a = 239;'});
await waitPauseAndDumpLocation(session1);
await Protocol1.Debugger.resume();
},
async function testSkipOtherContext1() {
let contextGroup = InspectorTest.createContextGroup();
let session = InspectorTest.createSession(contextGroup);
session.Protocol.Debugger.enable({});
Protocol.Debugger.pause();
Protocol.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework.js'});
session.Protocol.Runtime.evaluate({expression: 'var a = 239;'});
Protocol.Runtime.evaluate({expression: 'var a = 1;'});
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
await session.Protocol.Debugger.disable({});
let contextGroup2 = new InspectorTest.ContextGroup();
let session2 = contextGroup2.connect();
let Protocol2 = session2.Protocol;
Protocol2.Debugger.enable({});
Protocol1.Debugger.pause();
Protocol1.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework.js'});
Protocol2.Runtime.evaluate({expression: 'var a = 239;'});
Protocol1.Runtime.evaluate({expression: 'var a = 1;'});
await waitPauseAndDumpLocation(session1);
await Protocol1.Debugger.resume();
await Protocol2.Debugger.disable({});
},
async function testSkipOtherContext2() {
let contextGroup = InspectorTest.createContextGroup();
let session = InspectorTest.createSession(contextGroup);
InspectorTest.setupScriptMap(session);
session.Protocol.Debugger.enable({});
session.Protocol.Debugger.pause({});
Protocol.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework.js'});
session.Protocol.Runtime.evaluate({expression: 'var a = 239;'});
Protocol.Runtime.evaluate({expression: 'var a = 1;'});
await waitPauseAndDumpLocation(session);
let contextGroup2 = new InspectorTest.ContextGroup();
let session2 = contextGroup2.connect();
let Protocol2 = session2.Protocol;
session2.setupScriptMap();
Protocol2.Debugger.enable({});
Protocol2.Debugger.pause({});
Protocol1.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework.js'});
Protocol2.Runtime.evaluate({expression: 'var a = 239;'});
Protocol1.Runtime.evaluate({expression: 'var a = 1;'});
await waitPauseAndDumpLocation(session2);
// should not resume pause from different context group id.
Protocol.Debugger.resume();
session.Protocol.Debugger.stepOver({});
await waitPauseAndDumpLocation(session);
await session.Protocol.Debugger.resume({});
await session.Protocol.Debugger.disable({});
Protocol1.Debugger.resume();
Protocol2.Debugger.stepOver({});
await waitPauseAndDumpLocation(session2);
await Protocol2.Debugger.resume({});
await Protocol2.Debugger.disable({});
},
async function testWithNativeBreakpoint() {
InspectorTest.contextGroup.schedulePauseOnNextStatement('', '');
await Protocol.Debugger.pause();
InspectorTest.contextGroup.cancelPauseOnNextStatement();
Protocol.Runtime.evaluate({expression: 'var a = 42;'});
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
contextGroup1.schedulePauseOnNextStatement('', '');
await Protocol1.Debugger.pause();
contextGroup1.cancelPauseOnNextStatement();
Protocol1.Runtime.evaluate({expression: 'var a = 42;'});
await waitPauseAndDumpLocation(session1);
await Protocol1.Debugger.resume();
await Protocol.Debugger.pause();
InspectorTest.contextGroup.schedulePauseOnNextStatement('', '');
InspectorTest.contextGroup.cancelPauseOnNextStatement();
Protocol.Runtime.evaluate({expression: 'var a = 42;'});
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
await Protocol1.Debugger.pause();
contextGroup1.schedulePauseOnNextStatement('', '');
contextGroup1.cancelPauseOnNextStatement();
Protocol1.Runtime.evaluate({expression: 'var a = 42;'});
await waitPauseAndDumpLocation(session1);
await Protocol1.Debugger.resume();
InspectorTest.contextGroup.schedulePauseOnNextStatement('', '');
InspectorTest.contextGroup.cancelPauseOnNextStatement();
await Protocol.Debugger.pause();
Protocol.Runtime.evaluate({expression: 'var a = 42;'});
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
contextGroup1.schedulePauseOnNextStatement('', '');
contextGroup1.cancelPauseOnNextStatement();
await Protocol1.Debugger.pause();
Protocol1.Runtime.evaluate({expression: 'var a = 42;'});
await waitPauseAndDumpLocation(session1);
await Protocol1.Debugger.resume();
},
async function testDisableBreaksShouldCancelPause() {
await Protocol.Debugger.pause();
await Protocol.Debugger.setBreakpointsActive({active: false});
Protocol.Runtime.evaluate({expression: 'var a = 42;'})
.then(() => Protocol.Debugger.setBreakpointsActive({active: true}))
.then(() => Protocol.Runtime.evaluate({expression: 'debugger'}));
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
await Protocol1.Debugger.pause();
await Protocol1.Debugger.setBreakpointsActive({active: false});
Protocol1.Runtime.evaluate({expression: 'var a = 42;'})
.then(() => Protocol1.Debugger.setBreakpointsActive({active: true}))
.then(() => Protocol1.Runtime.evaluate({expression: 'debugger'}));
await waitPauseAndDumpLocation(session1);
await Protocol1.Debugger.resume();
}
]);
async function waitPauseAndDumpLocation(session) {
session = session || InspectorTest.session;
var message = await session.Protocol.Debugger.oncePaused();
InspectorTest.log('paused at:');
await InspectorTest.logSourceLocation(message.params.callFrames[0].location, session);
await session.logSourceLocation(message.params.callFrames[0].location);
return message;
}
Tests how async promise chains behave when reaching the limit of stacks
Checks correctness of promise chains when limit hit
inspector.setMaxAsyncTaskStacks(3)
Run expression 'console.trace()' with async chain len: 3
......
// 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.
// TODO(kozyatinskiy): fix or remove it later.
let {session, contextGroup, Protocol} = InspectorTest.start('Tests how async promise chains behave when reaching the limit of stacks');
(async function test(){
InspectorTest.log('Checks correctness of promise chains when limit hit');
await Protocol.Runtime.enable();
......
Tests that double numbers are parsed and serialized correctly on different locales
This test verifies that we correctly parse doubles with non-US locale
{
a : 0.5
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that double numbers are parsed and serialized correctly on different locales');
(async function() {
InspectorTest.log('This test verifies that we correctly parse doubles with non-US locale');
utils.setlocale("fr_CA.UTF-8");
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks that debugger agent uses source content to restore breakpoints.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that debugger agent uses source content to restore breakpoints.');
Protocol.Debugger.enable();
InspectorTest.runTestSuite([
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Return break locations within function');
let {session, contextGroup, Protocol} = InspectorTest.start('Return break locations within function');
InspectorTest.addScript(`
contextGroup.addScript(`
function fib(x) {
if (x < 0) return;
if (x === 0) return 1;
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks Debugger.scheduleStepIntoAsync with setTimeout.');
InspectorTest.setupScriptMap();
let {session, contextGroup, Protocol} = InspectorTest.start('Checks Debugger.scheduleStepIntoAsync with setTimeout.');
session.setupScriptMap();
Protocol.Debugger.enable();
InspectorTest.runAsyncTestSuite([
async function testSetTimeout() {
......@@ -42,7 +42,7 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
await InspectorTest.waitPendingTasks();
await InspectorTest.waitForPendingTasks();
},
async function testSetTimeoutWithoutJS() {
......@@ -70,6 +70,6 @@ InspectorTest.runAsyncTestSuite([
async function waitPauseAndDumpLocation() {
var message = await Protocol.Debugger.oncePaused();
InspectorTest.log('paused at:');
await InspectorTest.logSourceLocation(message.params.callFrames[0].location);
await session.logSourceLocation(message.params.callFrames[0].location);
return message;
}
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks Debugger.scheduleStepIntoAsync.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks Debugger.scheduleStepIntoAsync.');
InspectorTest.addScript(`
contextGroup.addScript(`
function testNoScheduledTask() {
debugger;
return 42;
......@@ -47,7 +47,7 @@ function testBlackboxedCreatePromise() {
}
//# sourceURL=test.js`);
InspectorTest.addScript(`
contextGroup.addScript(`
function createPromise() {
return Promise.resolve().then(v => v * 3).then(v => v * 4);
......@@ -55,7 +55,7 @@ function createPromise() {
//# sourceURL=framework.js`)
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.enable();
InspectorTest.runAsyncTestSuite([
......@@ -154,6 +154,6 @@ InspectorTest.runAsyncTestSuite([
async function waitPauseAndDumpLocation() {
var message = await Protocol.Debugger.oncePaused();
InspectorTest.log('paused at:');
InspectorTest.logSourceLocation(message.params.callFrames[0].location);
session.logSourceLocation(message.params.callFrames[0].location);
return message;
}
Tests that scopes do not report variables with empty names
{
id : <messageId>
result : {
......
......@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.addScript(
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that scopes do not report variables with empty names');
contextGroup.addScript(
`function testFunction()
{
for (var a of [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.
InspectorTest.log('Checks that we report correct endLine, endColumn and source for scripts.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that we report correct endLine, endColumn and source for scripts.');
var sources = [
'',
......@@ -27,7 +27,7 @@ var sources = [
(async function test() {
Protocol.Debugger.enable();
for (let source of sources) {
InspectorTest.addScript(source);
contextGroup.addScript(source);
var message = await Protocol.Debugger.onceScriptParsed();
var inspectorSource = (await Protocol.Debugger.getScriptSource({ scriptId: message.params.scriptId })).result.scriptSource;
var lines = source.split('\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.
InspectorTest.log("Checks that inspector correctly process compiled scripts");
let {session, contextGroup, Protocol} = InspectorTest.start("Checks that inspector correctly process compiled scripts");
function addScripts() {
// sourceURL in the same line
......
......@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log("Checks that inspector reports script compiled in Runtime.evaluate, " +
let {session, contextGroup, Protocol} = InspectorTest.start("Checks that inspector reports script compiled in Runtime.evaluate, " +
"Runtime.callFunctionOn and Runtime.compileScript");
InspectorTest.addScript(`
contextGroup.addScript(`
function fooTop() {
eval(\`
function foo() {
......@@ -15,7 +15,7 @@ function fooTop() {
}
//# sourceURL=top-frame.js`, 8, 26);
InspectorTest.addScript(`
contextGroup.addScript(`
function fooTopFail() {
eval(\`
function fooFail() {
......
Tests scripts hasing
Hash received: 1C6D2E82E4E4F1BA4CB5762843D429DC872EBA18
Hash received: EBF1ECD351E7A3294CB5762843D429DC872EBA18
Hash received: 86A31E7131896CF01BA837945C2894385F369F24
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start('Tests scripts hasing');
var hashes = new Set(["1C6D2E82E4E4F1BA4CB5762843D429DC872EBA18",
"EBF1ECD351E7A3294CB5762843D429DC872EBA18",
"86A31E7131896CF01BA837945C2894385F369F24"]);
......
......@@ -4,9 +4,9 @@
// TODO(kozyatinskiy): fix or remove it later with new stack traces it's almost
// imposible to hit limit.
InspectorTest.log('Checks that we report not more then maxDepth call chains.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that we report not more then maxDepth call chains.');
InspectorTest.addScript(`
contextGroup.addScript(`
function promisesChain(num) {
var p = Promise.resolve();
for (var i = 0; i < num - 1; ++i) {
......
Tests blackboxing by patterns
Pattern parser error: Uncaught SyntaxError: Invalid regular expression: /(foo([)/: Unterminated character class
Paused in
(...):1
......
......@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.addScript(
let {session, contextGroup, Protocol} = InspectorTest.start('Tests blackboxing by patterns');
contextGroup.addScript(
`function bar()
{
return 42;
}`);
InspectorTest.addScript(
contextGroup.addScript(
`function foo()
{
var a = bar();
......@@ -16,7 +18,7 @@ InspectorTest.addScript(
}
//# sourceURL=foo.js`);
InspectorTest.addScript(
contextGroup.addScript(
`function qwe()
{
var a = foo();
......@@ -24,7 +26,7 @@ InspectorTest.addScript(
}
//# sourceURL=qwe.js`);
InspectorTest.addScript(
contextGroup.addScript(
`function baz()
{
var a = qwe();
......
Tests that setting breakpoint before enabling debugger produces an error
setBreakpointByUrl error: undefined
setBreakpoint error: {
"code": -32602,
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that setting breakpoint before enabling debugger produces an error');
Protocol.Debugger.setBreakpointByUrl({ url: "http://example.com", lineNumber: 10 }).then(didSetBreakpointByUrlBeforeEnable);
function didSetBreakpointByUrlBeforeEnable(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.
InspectorTest.log('Check that setScriptSource completes correctly when an exception is thrown.');
let {session, contextGroup, Protocol} = InspectorTest.start('Check that setScriptSource completes correctly when an exception is thrown.');
Protocol.Debugger.enable();
......@@ -18,6 +18,6 @@ InspectorTest.runTestSuite([
.then(message => Protocol.Debugger.setScriptSource({ scriptId: message.params.scriptId, scriptSource: 'a # b' }))
.then(InspectorTest.logMessage)
.then(next);
InspectorTest.addScript('function foo() {}');
contextGroup.addScript('function foo() {}');
}
]);
Tests Debugger.setScriptSource
Function evaluate: {"type":"number","value":6,"description":"6"}
PASS, result value: 6
Function evaluate: {"type":"number","value":8,"description":"8"}
......@@ -5,4 +6,3 @@ PASS, result value: 8
Has error reported: PASS
Reported error is a compile error: PASS
PASS, result value: 1
......@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.addScript(
let {session, contextGroup, Protocol} = InspectorTest.start('Tests Debugger.setScriptSource');
contextGroup.addScript(
`function TestExpression(a, b) {
return a + b;
}`);
......
Tests side-effect-free evaluation
Paused on 'debugger;'
f() returns 1
g() returns 2
......
......@@ -3,8 +3,9 @@
// found in the LICENSE file.
// Flags: --ignition --turbo
let {session, contextGroup, Protocol} = InspectorTest.start('Tests side-effect-free evaluation');
InspectorTest.addScript(`
contextGroup.addScript(`
function testFunction()
{
var o = 0;
......
......@@ -2,18 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log(
let {session, contextGroup, Protocol} = InspectorTest.start(
'Checks that stepInto nested arrow function doesn\'t produce crash.');
InspectorTest.setupScriptMap();
InspectorTest.addScript(`
session.setupScriptMap();
contextGroup.addScript(`
const rec = (x) => (y) =>
rec();
//# sourceURL=test.js`);
Protocol.Debugger.onPaused(message => {
InspectorTest.log("paused");
InspectorTest.logCallFrames(message.params.callFrames);
session.logCallFrames(message.params.callFrames);
Protocol.Debugger.stepInto();
})
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Debugger breaks in next script after stepOut from previous one.');
let {session, contextGroup, Protocol} = InspectorTest.start('Debugger breaks in next script after stepOut from previous one.');
InspectorTest.addScript(`
contextGroup.addScript(`
function test() {
setTimeout('var a = 1;//# sourceURL=timeout1.js', 0);
setTimeout(foo, 0);
......@@ -13,16 +13,16 @@ function test() {
}
//# sourceURL=foo.js`, 7, 26);
InspectorTest.addScript(`
contextGroup.addScript(`
function foo() {
return 42;
}
//# sourceURL=timeout2.js`)
InspectorTest.setupScriptMap();
session.setupScriptMap();
var stepAction;
Protocol.Debugger.onPaused(message => {
InspectorTest.logCallFrames(message.params.callFrames);
session.logCallFrames(message.params.callFrames);
InspectorTest.log('');
Protocol.Debugger[stepAction]();
});
......@@ -31,21 +31,21 @@ InspectorTest.runTestSuite([
function testStepOut(next) {
stepAction = 'stepOut';
Protocol.Runtime.evaluate({ expression: 'test()' })
.then(() => InspectorTest.waitPendingTasks())
.then(() => InspectorTest.waitForPendingTasks())
.then(next);
},
function testStepOver(next) {
stepAction = 'stepOver';
Protocol.Runtime.evaluate({ expression: 'test()' })
.then(() => InspectorTest.waitPendingTasks())
.then(() => InspectorTest.waitForPendingTasks())
.then(next);
},
function testStepInto(next) {
stepAction = 'stepInto';
Protocol.Runtime.evaluate({ expression: 'test()' })
.then(() => InspectorTest.waitPendingTasks())
.then(() => InspectorTest.waitForPendingTasks())
.then(next);
}
]);
......@@ -4,9 +4,9 @@
// Flags: --turbo
InspectorTest.log('Checks possible break locations.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks possible break locations.');
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.onPaused(message => {
var frames = message.params.callFrames;
if (frames.length === 1) {
......@@ -15,11 +15,11 @@ Protocol.Debugger.onPaused(message => {
}
var scriptId = frames[0].location.scriptId;
InspectorTest.log('break at:');
InspectorTest.logSourceLocation(frames[0].location)
session.logSourceLocation(frames[0].location)
.then(() => Protocol.Debugger.stepInto());
});
InspectorTest.loadScript('test/inspector/debugger/resources/break-locations.js');
contextGroup.loadScript('test/inspector/debugger/resources/break-locations.js');
Protocol.Debugger.enable();
Protocol.Runtime.evaluate({ expression: 'Object.keys(this).filter(name => name.indexOf(\'test\') === 0)', returnByValue: true })
......
......@@ -6,9 +6,9 @@
// of async generator we should break at next instruction of resumed generator
// instead of next scheduled microtask.
InspectorTest.log('StepOut from return position of async function.');
let {session, contextGroup, Protocol} = InspectorTest.start('StepOut from return position of async function.');
InspectorTest.addScript(`
contextGroup.addScript(`
async function testFunction() {
async function foo() {
var p = Promise.resolve();
......@@ -21,7 +21,7 @@ InspectorTest.addScript(`
}
`);
InspectorTest.setupScriptMap();
session.setupScriptMap();
Protocol.Debugger.enable();
InspectorTest.runAsyncTestSuite([
async function testStepInto() {
......@@ -68,5 +68,5 @@ InspectorTest.runAsyncTestSuite([
]);
function logPauseLocation(message) {
return InspectorTest.logSourceLocation(message.params.callFrames[0].location);
return session.logSourceLocation(message.params.callFrames[0].location);
}
......@@ -4,29 +4,33 @@
InspectorTest.log('Checks stepping with more then one context group.');
var contextGroup1 = new InspectorTest.ContextGroup();
var session1 = contextGroup1.connect();
session1.setupScriptMap();
let contextGroup2 = new InspectorTest.ContextGroup();
let session2 = contextGroup2.connect();
session2.setupScriptMap();
(async function test() {
InspectorTest.setupScriptMap();
await Protocol.Debugger.enable();
let contextGroup = InspectorTest.createContextGroup();
let session = InspectorTest.createSession(contextGroup);
InspectorTest.setupScriptMap(session);
await session.Protocol.Debugger.enable({});
Protocol.Runtime.evaluate({expression: 'debugger'});
session.Protocol.Runtime.evaluate({expression: 'setTimeout(() => { debugger }, 0)'});
Protocol.Runtime.evaluate({expression: 'setTimeout(() => 42, 0)'});
await waitPauseAndDumpLocation(InspectorTest.session);
Protocol.Debugger.stepOver();
await Protocol.Debugger.oncePaused();
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation(InspectorTest.session);
await session.Protocol.Debugger.disable({});
await Protocol.Debugger.disable();
await session1.Protocol.Debugger.enable();
await session2.Protocol.Debugger.enable({});
session1.Protocol.Runtime.evaluate({expression: 'debugger'});
session2.Protocol.Runtime.evaluate({expression: 'setTimeout(() => { debugger }, 0)'});
session1.Protocol.Runtime.evaluate({expression: 'setTimeout(() => 42, 0)'});
await waitPauseAndDumpLocation(session1);
session1.Protocol.Debugger.stepOver();
await session1.Protocol.Debugger.oncePaused();
session1.Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation(session1);
await session2.Protocol.Debugger.disable({});
await session1.Protocol.Debugger.disable();
InspectorTest.completeTest();
})();
async function waitPauseAndDumpLocation(session) {
var message = await session.Protocol.Debugger.oncePaused();
InspectorTest.log('paused at:');
await InspectorTest.logSourceLocation(message.params.callFrames[0].location, session);
await session.logSourceLocation(message.params.callFrames[0].location);
return message;
}
Tests that stepping over caught exception will pause when asked for
testFunction:9
testFunction:11
testFunction:9
......
......@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.addScript(
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that stepping over caught exception will pause when asked for');
contextGroup.addScript(
`function testFunction()
{
function foo()
......
Embedding script 'function c(f, ...args) { return f(...args); }'
Tests that stepping works on snapshotted function
paused
}
#debugger;
......@@ -31,3 +32,4 @@ paused
paused
test(#)
......@@ -6,9 +6,10 @@
// Flags: --embed 'function c(f, ...args) { return f(...args); }'
InspectorTest.setupScriptMap();
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that stepping works on snapshotted function');
session.setupScriptMap();
InspectorTest.addScript(`
contextGroup.addScript(`
function test() {
function f(x) {
return x * 2;
......@@ -21,7 +22,7 @@ function test() {
Protocol.Debugger.onPaused(message => {
InspectorTest.log("paused");
var frames = message.params.callFrames;
InspectorTest.logSourceLocation(frames[0].location);
session.logSourceLocation(frames[0].location);
Protocol.Debugger.stepInto();
})
......
Tests that stepping works after calling getPossibleBreakpoints
-- call boo:
(top)
(top)
......
......@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.addScript(`
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that stepping works after calling getPossibleBreakpoints');
contextGroup.addScript(`
function boo() {}
boo();
function foo() {}
......
......@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log('Checks that stepping is cleared after breakProgram.');
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that stepping is cleared after breakProgram.');
InspectorTest.addScript(`
contextGroup.addScript(`
function callBreakProgram() {
debugger;
inspector.breakProgram('reason', '');
}`);
InspectorTest.setupScriptMap();
session.setupScriptMap();
(async function test() {
Protocol.Debugger.enable();
Protocol.Runtime.evaluate({expression: 'callBreakProgram();'});
......@@ -29,6 +29,6 @@ InspectorTest.setupScriptMap();
async function waitPauseAndDumpLocation() {
var message = await Protocol.Debugger.oncePaused();
InspectorTest.log('paused at:');
InspectorTest.logSourceLocation(message.params.callFrames[0].location);
session.logSourceLocation(message.params.callFrames[0].location);
return message;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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