[inspector] added missing tests

Added tests that I forgot to commit with big debug.js removal.

TBR=dgozman@chromium.org

Bug: none
Change-Id: I518dd254af116d391a2af96a6f6c11da457129a1
Reviewed-on: https://chromium-review.googlesource.com/1086375
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53507}
This commit is contained in:
Alexey Kozyatinskiy 2018-06-04 17:44:45 -07:00 committed by Commit Bot
parent 9758552aa8
commit 954829b037
10 changed files with 682 additions and 0 deletions

View File

@ -0,0 +1,145 @@
Tests for break on exception and stepping.
Running test: testStepThrougA
function a() { #n(); };
function b() { c(); };
Running test: testStepThrougB
function a() { n(); };
function b() { #c(); };
function c() { n(); };
function b() { c(); };
function c() { #n(); };
function d() { x = 1; try { e(); } catch(x) { x = 2; } };
Running test: testStepThrougD
function c() { n(); };
function d() { #x = 1; try { e(); } catch(x) { x = 2; } };
function e() { n(); };
function c() { n(); };
function d() { x = 1; try { #e(); } catch(x) { x = 2; } };
function e() { n(); };
function d() { x = 1; try { e(); } catch(x) { x = 2; } };
function e() { #n(); };
function f() { x = 1; try { g(); } catch(x) { x = 2; } };
function c() { n(); };
function d() { x = 1; try { e(); } catch(x) { #x = 2; } };
function e() { n(); };
function c() { n(); };
function d() { x = 1; try { e(); } catch(x) { x = 2; } #};
function e() { n(); };
Running test: testStepThrougDWithBreakOnAllExceptions
function c() { n(); };
function d() { #x = 1; try { e(); } catch(x) { x = 2; } };
function e() { n(); };
function c() { n(); };
function d() { x = 1; try { #e(); } catch(x) { x = 2; } };
function e() { n(); };
function d() { x = 1; try { e(); } catch(x) { x = 2; } };
function e() { #n(); };
function f() { x = 1; try { g(); } catch(x) { x = 2; } };
paused on exception:
{
className : ReferenceError
description : ReferenceError: n is not defined at e (<anonymous>:6:16) at d (<anonymous>:5:29) at expr.js:1:1
objectId : <objectId>
subtype : error
type : object
uncaught : false
}
function d() { x = 1; try { e(); } catch(x) { x = 2; } };
function e() { #n(); };
function f() { x = 1; try { g(); } catch(x) { x = 2; } };
function c() { n(); };
function d() { x = 1; try { e(); } catch(x) { #x = 2; } };
function e() { n(); };
function c() { n(); };
function d() { x = 1; try { e(); } catch(x) { x = 2; } #};
function e() { n(); };
Running test: testStepThrougF
function e() { n(); };
function f() { #x = 1; try { g(); } catch(x) { x = 2; } };
function g() { h(); };
function e() { n(); };
function f() { x = 1; try { #g(); } catch(x) { x = 2; } };
function g() { h(); };
function f() { x = 1; try { g(); } catch(x) { x = 2; } };
function g() { #h(); };
function h() { x = 1; throw 1; };
function g() { h(); };
function h() { #x = 1; throw 1; };
function g() { h(); };
function h() { x = 1; #throw 1; };
function e() { n(); };
function f() { x = 1; try { g(); } catch(x) { #x = 2; } };
function g() { h(); };
function e() { n(); };
function f() { x = 1; try { g(); } catch(x) { x = 2; } #};
function g() { h(); };
Running test: testStepThrougFWithBreakOnAllExceptions
function e() { n(); };
function f() { #x = 1; try { g(); } catch(x) { x = 2; } };
function g() { h(); };
function e() { n(); };
function f() { x = 1; try { #g(); } catch(x) { x = 2; } };
function g() { h(); };
function f() { x = 1; try { g(); } catch(x) { x = 2; } };
function g() { #h(); };
function h() { x = 1; throw 1; };
function g() { h(); };
function h() { #x = 1; throw 1; };
function g() { h(); };
function h() { x = 1; #throw 1; };
paused on exception:
{
description : 1
type : number
uncaught : false
value : 1
}
function g() { h(); };
function h() { x = 1; #throw 1; };
function e() { n(); };
function f() { x = 1; try { g(); } catch(x) { #x = 2; } };
function g() { h(); };
function e() { n(); };
function f() { x = 1; try { g(); } catch(x) { x = 2; } #};
function g() { h(); };

View File

@ -0,0 +1,69 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start(
'Tests for break on exception and stepping.');
session.setupScriptMap();
Protocol.Debugger.enable();
Protocol.Debugger.setBlackboxPatterns({patterns: ['expr\.js']});
Protocol.Debugger.onPaused(async ({params:{callFrames:[topFrame], data}}) => {
if (data) {
InspectorTest.log('paused on exception:');
InspectorTest.logMessage(data);
}
await session.logSourceLocation(topFrame.location);
Protocol.Debugger.stepInto();
});
contextGroup.addScript(`
function a() { n(); };
function b() { c(); };
function c() { n(); };
function d() { x = 1; try { e(); } catch(x) { x = 2; } };
function e() { n(); };
function f() { x = 1; try { g(); } catch(x) { x = 2; } };
function g() { h(); };
function h() { x = 1; throw 1; };
`);
InspectorTest.runAsyncTestSuite([
async function testStepThrougA() {
Protocol.Debugger.pause();
await Protocol.Runtime.evaluate({expression: 'a()\n//# sourceURL=expr.js'});
},
async function testStepThrougB() {
Protocol.Debugger.pause();
await Protocol.Runtime.evaluate({expression: 'b()\n//# sourceURL=expr.js'});
},
async function testStepThrougD() {
await Protocol.Debugger.setPauseOnExceptions({state: 'uncaught'});
Protocol.Debugger.pause();
await Protocol.Runtime.evaluate({expression: 'd()\n//# sourceURL=expr.js'});
await Protocol.Debugger.setPauseOnExceptions({state: 'none'});
},
async function testStepThrougDWithBreakOnAllExceptions() {
await Protocol.Debugger.setPauseOnExceptions({state: 'all'});
Protocol.Debugger.pause();
await Protocol.Runtime.evaluate({expression: 'd()\n//# sourceURL=expr.js'});
await Protocol.Debugger.setPauseOnExceptions({state: 'none'});
},
async function testStepThrougF() {
await Protocol.Debugger.setPauseOnExceptions({state: 'uncaught'});
Protocol.Debugger.pause();
await Protocol.Runtime.evaluate({expression: 'f()\n//# sourceURL=expr.js'});
await Protocol.Debugger.setPauseOnExceptions({state: 'none'});
},
async function testStepThrougFWithBreakOnAllExceptions() {
await Protocol.Debugger.setPauseOnExceptions({state: 'all'});
Protocol.Debugger.pause();
await Protocol.Runtime.evaluate({expression: 'f()\n//# sourceURL=expr.js'});
await Protocol.Debugger.setPauseOnExceptions({state: 'none'});
}
]);

View File

@ -0,0 +1,91 @@
Break on exceptions from compiler errors.
Running test: testUnexpectedEndOfInput
Runs '+++'
Runtime.evaluate exceptionDetails:
{
columnNumber : 2
exception : {
className : SyntaxError
description : SyntaxError: Unexpected end of input
objectId : <objectId>
subtype : error
type : object
}
exceptionId : <exceptionId>
lineNumber : 0
scriptId : <scriptId>
text : Uncaught
}
Running test: testUnexpectedIdentifier
Runs 'x x'
Runtime.evaluate exceptionDetails:
{
columnNumber : 2
exception : {
className : SyntaxError
description : SyntaxError: Unexpected identifier
objectId : <objectId>
subtype : error
type : object
}
exceptionId : <exceptionId>
lineNumber : 0
scriptId : <scriptId>
text : Uncaught
}
Running test: testEvalUnexpectedEndOfInput
Runs eval('+++')
paused on exception:
{
className : SyntaxError
description : SyntaxError: Unexpected end of input at <anonymous>:1:1
objectId : <objectId>
subtype : error
type : object
uncaught : false
}
Runtime.evaluate exceptionDetails:
{
columnNumber : 2
exception : {
className : SyntaxError
description : SyntaxError: Unexpected end of input at <anonymous>:1:1
objectId : <objectId>
subtype : error
type : object
}
exceptionId : <exceptionId>
lineNumber : 0
scriptId : <scriptId>
text : Uncaught
}
Running test: testEvalUnexpectedIdentifier
Runs eval('x x')
paused on exception:
{
className : SyntaxError
description : SyntaxError: Unexpected identifier at <anonymous>:1:1
objectId : <objectId>
subtype : error
type : object
uncaught : false
}
Runtime.evaluate exceptionDetails:
{
columnNumber : 2
exception : {
className : SyntaxError
description : SyntaxError: Unexpected identifier at <anonymous>:1:1
objectId : <objectId>
subtype : error
type : object
}
exceptionId : <exceptionId>
lineNumber : 0
scriptId : <scriptId>
text : Uncaught
}

View File

@ -0,0 +1,52 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start(
'Break on exceptions from compiler errors.');
Protocol.Debugger.enable();
Protocol.Debugger.setPauseOnExceptions({state: 'all'});
Protocol.Debugger.onPaused(({params:{data}}) => {
InspectorTest.log('paused on exception:');
InspectorTest.logMessage(data);
Protocol.Debugger.resume();
});
InspectorTest.runAsyncTestSuite([
async function testUnexpectedEndOfInput() {
InspectorTest.log(`Runs '+++'`);
let {result:{exceptionDetails}} = await Protocol.Runtime.evaluate({
expression: '+++'
});
InspectorTest.log('Runtime.evaluate exceptionDetails:');
InspectorTest.logMessage(exceptionDetails);
},
async function testUnexpectedIdentifier() {
InspectorTest.log(`Runs 'x x'`);
let {result:{exceptionDetails}} = await Protocol.Runtime.evaluate({
expression: 'x x'
});
InspectorTest.log('Runtime.evaluate exceptionDetails:');
InspectorTest.logMessage(exceptionDetails);
},
async function testEvalUnexpectedEndOfInput() {
InspectorTest.log(`Runs eval('+++')`);
let {result:{exceptionDetails}} = await Protocol.Runtime.evaluate({
expression: `eval('+++')`
});
InspectorTest.log('Runtime.evaluate exceptionDetails:');
InspectorTest.logMessage(exceptionDetails);
},
async function testEvalUnexpectedIdentifier() {
InspectorTest.log(`Runs eval('x x')`);
let {result:{exceptionDetails}} = await Protocol.Runtime.evaluate({
expression: `eval('x x')`
});
InspectorTest.log('Runtime.evaluate exceptionDetails:');
InspectorTest.logMessage(exceptionDetails);
}
]);

View File

@ -0,0 +1,4 @@
Checks that it is possible to disable agent on pause.
set breakpoint, call foo, wait for pause..
disable agent..
call finished

View File

@ -0,0 +1,27 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start(
'Checks that it is possible to disable agent on pause.');
contextGroup.addScript(`
function foo() {
return 42;
}`, 0, 0, 'test.js');
(async function test() {
Protocol.Debugger.enable();
InspectorTest.log('set breakpoint, call foo, wait for pause..');
let {result:{breakpointId}} = await Protocol.Debugger.setBreakpointByUrl({
lineNumber: 2, url: 'test.js'});
const finished = Protocol.Runtime.evaluate({
expression: 'foo()//# sourceURL=expr.js'
});
const {params:{callFrames:[topFrame]}} = await Protocol.Debugger.oncePaused();
InspectorTest.log('disable agent..');
Protocol.Debugger.disable();
await finished;
InspectorTest.log('call finished');
InspectorTest.completeTest();
})();

View File

@ -0,0 +1,8 @@
Checks that it is possbible to remove breakpoint when paused at it.
set breakpoint, call foo, wait for pause..
function foo() {
#return 42;
}
remove breakpoint, call foo again..
call finished without pause

View File

@ -0,0 +1,28 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start(
'Checks that it is possbible to remove breakpoint when paused at it.');
contextGroup.addScript(`
function foo() {
return 42;
}`, 0, 0, 'test.js');
(async function test() {
session.setupScriptMap();
Protocol.Debugger.enable();
InspectorTest.log('set breakpoint, call foo, wait for pause..');
let {result:{breakpointId}} = await Protocol.Debugger.setBreakpointByUrl({
lineNumber: 2, url: 'test.js'});
Protocol.Runtime.evaluate({expression: 'foo()//# sourceURL=expr.js'});
const {params:{callFrames:[topFrame]}} = await Protocol.Debugger.oncePaused();
await session.logSourceLocation(topFrame.location);
InspectorTest.log('remove breakpoint, call foo again..');
Protocol.Debugger.removeBreakpoint({breakpointId});
await Protocol.Debugger.resume();
await Protocol.Runtime.evaluate({expression: 'foo()'});
InspectorTest.log('call finished without pause');
InspectorTest.completeTest();
})();

View File

@ -0,0 +1,169 @@
Tests for stepInto out different places.
Running test: testStepInOutBranch
function a() { #b(false); c(); };
function b(x) { if (x) { c(); }};
function a() { b(false); c(); };
function b(x) { #if (x) { c(); }};
function c() {};
function a() { b(false); c(); };
function b(x) { if (x) { c(); }#};
function c() {};
function a() { b(false); #c(); };
function b(x) { if (x) { c(); }};
function b(x) { if (x) { c(); }};
function c() {#};
a(); b(); c();
function a() { b(false); c(); #};
function b(x) { if (x) { c(); }};
Running test: testStepInOutTree
use stepInto..
function a() { #b(c(d()), d()); c(d()); d(); };
function b(x,y) { c(); };
function c(x) {};
function d() {#};
a(); b(); c(); d();
function a() { b(#c(d()), d()); c(d()); d(); };
function b(x,y) { c(); };
function b(x,y) { c(); };
function c(x) {#};
function d() {};
function a() { b(c(d()), #d()); c(d()); d(); };
function b(x,y) { c(); };
function c(x) {};
function d() {#};
a(); b(); c(); d();
function a() { #b(c(d()), d()); c(d()); d(); };
function b(x,y) { c(); };
function a() { b(c(d()), d()); c(d()); d(); };
function b(x,y) { #c(); };
function c(x) {};
function b(x,y) { c(); };
function c(x) {#};
function d() {};
function a() { b(c(d()), d()); c(d()); d(); };
function b(x,y) { c(); #};
function c(x) {};
function a() { b(c(d()), d()); #c(d()); d(); };
function b(x,y) { c(); };
function c(x) {};
function d() {#};
a(); b(); c(); d();
function a() { b(c(d()), d()); #c(d()); d(); };
function b(x,y) { c(); };
function b(x,y) { c(); };
function c(x) {#};
function d() {};
function a() { b(c(d()), d()); c(d()); #d(); };
function b(x,y) { c(); };
function c(x) {};
function d() {#};
a(); b(); c(); d();
function a() { b(c(d()), d()); c(d()); d(); #};
function b(x,y) { c(); };
use stepOver..
function a() { #b(c(d()), d()); c(d()); d(); };
function b(x,y) { c(); };
function a() { b(c(d()), d()); #c(d()); d(); };
function b(x,y) { c(); };
function a() { b(c(d()), d()); c(d()); #d(); };
function b(x,y) { c(); };
function a() { b(c(d()), d()); c(d()); d(); #};
function b(x,y) { c(); };
use stepOut..
function a() { #b(c(d()), d()); c(d()); d(); };
function b(x,y) { c(); };
Running test: testStepInOutSimple
use stepInto..
function a() { #b(); c(); }
function b() { c(); }
function a() { b(); c(); }
function b() { #c(); }
function c() {}
function b() { c(); }
function c() {#}
a(); b(); c();
function a() { b(); c(); }
function b() { c(); #}
function c() {}
function a() { b(); #c(); }
function b() { c(); }
function b() { c(); }
function c() {#}
a(); b(); c();
function a() { b(); c(); #}
function b() { c(); }
use stepOver..
function a() { #b(); c(); }
function b() { c(); }
function a() { b(); #c(); }
function b() { c(); }
function a() { b(); c(); #}
function b() { c(); }
use stepOut..
function a() { #b(); c(); }
function b() { c(); }

View File

@ -0,0 +1,89 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start(
'Tests for stepInto out different places.');
session.setupScriptMap();
Protocol.Debugger.enable();
let stepAction;
Protocol.Debugger.setBlackboxPatterns({patterns: ['expr\.js']});
Protocol.Debugger.onPaused(async ({params:{callFrames:[topFrame]}}) => {
if (stepAction !== 'resume') {
await session.logSourceLocation(topFrame.location);
}
Protocol.Debugger[stepAction]();
});
InspectorTest.runAsyncTestSuite([
async function testStepInOutBranch() {
contextGroup.addScript(`
function a() { b(false); c(); };
function b(x) { if (x) { c(); }};
function c() {};
a(); b(); c();`);
stepAction = 'stepInto';
Protocol.Debugger.pause();
await Protocol.Runtime.evaluate({expression: 'a()\n//# sourceURL=expr.js'});
stepAction = 'resume';
await Protocol.Runtime.evaluate({expression: ''});
},
async function testStepInOutTree() {
contextGroup.addScript(`
function a() { b(c(d()), d()); c(d()); d(); };
function b(x,y) { c(); };
function c(x) {};
function d() {};
a(); b(); c(); d();`);
stepAction = 'stepInto';
Protocol.Debugger.pause();
InspectorTest.log('use stepInto..');
await Protocol.Runtime.evaluate({expression: 'a()\n//# sourceURL=expr.js'});
stepAction = 'resume';
await Protocol.Runtime.evaluate({expression: ''});
stepAction = 'stepOver';
Protocol.Debugger.pause();
InspectorTest.log('use stepOver..');
await Protocol.Runtime.evaluate({expression: 'a()\n//# sourceURL=expr.js'});
stepAction = 'resume';
await Protocol.Runtime.evaluate({expression: ''});
stepAction = 'stepOut';
Protocol.Debugger.pause();
InspectorTest.log('use stepOut..');
await Protocol.Runtime.evaluate({expression: 'a()\n//# sourceURL=expr.js'});
stepAction = 'resume';
await Protocol.Runtime.evaluate({expression: ''});
},
async function testStepInOutSimple() {
contextGroup.addScript(`
function a() { b(); c(); }
function b() { c(); }
function c() {}
a(); b(); c();`);
stepAction = 'stepInto';
Protocol.Debugger.pause();
InspectorTest.log('use stepInto..');
await Protocol.Runtime.evaluate({expression: 'a()\n//# sourceURL=expr.js'});
stepAction = 'resume';
await Protocol.Runtime.evaluate({expression: ''});
stepAction = 'stepOver';
Protocol.Debugger.pause();
InspectorTest.log('use stepOver..');
await Protocol.Runtime.evaluate({expression: 'a()\n//# sourceURL=expr.js'});
stepAction = 'resume';
await Protocol.Runtime.evaluate({expression: ''});
stepAction = 'stepOut';
Protocol.Debugger.pause();
InspectorTest.log('use stepOut..');
await Protocol.Runtime.evaluate({expression: 'a()\n//# sourceURL=expr.js'});
stepAction = 'resume';
await Protocol.Runtime.evaluate({expression: ''});
}
]);