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