Commit ec36c513 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[test/inspector] remove any usage of v8::Extension

.. replace all of them with prepared global object template.

+ bonus: wrap inspector related methods with inspector namespace.

BUG=none
R=dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2832723004
Cr-Commit-Position: refs/heads/master@{#44785}
parent dddfcfd0
...@@ -10,11 +10,11 @@ const expression = ` ...@@ -10,11 +10,11 @@ const expression = `
delete Object.prototype.RemoteObject; delete Object.prototype.RemoteObject;
this.RemoteObject = v; this.RemoteObject = v;
detachInspector(); inspector.detachInspector();
setTimeout(function() { setTimeout(function() {
// Attach the inspector again for the sake of establishing a // Attach the inspector again for the sake of establishing a
// communication channel with the frontend test runner. // communication channel with the frontend test runner.
attachInspector(); inspector.attachInspector();
console.log("End of test"); console.log("End of test");
}, 0); }, 0);
}, },
...@@ -23,8 +23,8 @@ const expression = ` ...@@ -23,8 +23,8 @@ const expression = `
// Before the whole script runs, the inspector is already attached. // Before the whole script runs, the inspector is already attached.
// Re-attach the inspector and trigger the console API to make sure that the // Re-attach the inspector and trigger the console API to make sure that the
// injected inspector script runs again (and triggers the above setter). // injected inspector script runs again (and triggers the above setter).
detachInspector(); inspector.detachInspector();
attachInspector(); inspector.attachInspector();
console.log("First inspector activity after attaching inspector"); console.log("First inspector activity after attaching inspector");
console.log("End of test"); console.log("End of test");
`; `;
......
...@@ -6,24 +6,24 @@ InspectorTest.log('Checks that we collect obsolete async tasks with async stacks ...@@ -6,24 +6,24 @@ InspectorTest.log('Checks that we collect obsolete async tasks with async stacks
InspectorTest.addScript(` InspectorTest.addScript(`
function test() { function test() {
setMaxAsyncTaskStacks(128); inspector.setMaxAsyncTaskStacks(128);
var p = Promise.resolve(); var p = Promise.resolve();
dumpAsyncTaskStacksStateForTest(); inspector.dumpAsyncTaskStacksStateForTest();
setMaxAsyncTaskStacks(128); inspector.setMaxAsyncTaskStacks(128);
dumpAsyncTaskStacksStateForTest(); inspector.dumpAsyncTaskStacksStateForTest();
p.then(() => 42).then(() => 239); p.then(() => 42).then(() => 239);
dumpAsyncTaskStacksStateForTest(); inspector.dumpAsyncTaskStacksStateForTest();
setMaxAsyncTaskStacks(128); inspector.setMaxAsyncTaskStacks(128);
dumpAsyncTaskStacksStateForTest(); inspector.dumpAsyncTaskStacksStateForTest();
setTimeout(() => 42, 0); setTimeout(() => 42, 0);
dumpAsyncTaskStacksStateForTest(); inspector.dumpAsyncTaskStacksStateForTest();
setMaxAsyncTaskStacks(128); inspector.setMaxAsyncTaskStacks(128);
dumpAsyncTaskStacksStateForTest(); inspector.dumpAsyncTaskStacksStateForTest();
} }
`); `);
......
Checks that we drop old async call chains. Checks that we drop old async call chains.
Running test: testInfrastructure Running test: testInfrastructure
setMaxAsyncTaskStacks(1024) inspector.setMaxAsyncTaskStacks(1024)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(1024) inspector.setMaxAsyncTaskStacks(1024)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(1024) inspector.setMaxAsyncTaskStacks(1024)
Run expression 'console.trace(42)' with async chain len: 5 Run expression 'console.trace(42)' with async chain len: 5
actual async chain len: 5 actual async chain len: 5
setMaxAsyncTaskStacks(1024) inspector.setMaxAsyncTaskStacks(1024)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(1024) inspector.setMaxAsyncTaskStacks(1024)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(1024) inspector.setMaxAsyncTaskStacks(1024)
Run expression 'console.trace(42)' with async chain len: 5 Run expression 'console.trace(42)' with async chain len: 5
actual async chain len: 5 actual async chain len: 5
Running test: testZeroLimit Running test: testZeroLimit
setMaxAsyncTaskStacks(0) inspector.setMaxAsyncTaskStacks(0)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 0 actual async chain len: 0
setMaxAsyncTaskStacks(0) inspector.setMaxAsyncTaskStacks(0)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 0 actual async chain len: 0
setMaxAsyncTaskStacks(0) inspector.setMaxAsyncTaskStacks(0)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 0 actual async chain len: 0
setMaxAsyncTaskStacks(0) inspector.setMaxAsyncTaskStacks(0)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 0 actual async chain len: 0
Running test: testOneLimit Running test: testOneLimit
setMaxAsyncTaskStacks(1) inspector.setMaxAsyncTaskStacks(1)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 0 actual async chain len: 0
setMaxAsyncTaskStacks(1) inspector.setMaxAsyncTaskStacks(1)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 0 actual async chain len: 0
setMaxAsyncTaskStacks(1) inspector.setMaxAsyncTaskStacks(1)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(1) inspector.setMaxAsyncTaskStacks(1)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 1 actual async chain len: 1
Running test: testTwoLimit Running test: testTwoLimit
setMaxAsyncTaskStacks(2) inspector.setMaxAsyncTaskStacks(2)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 0 actual async chain len: 0
setMaxAsyncTaskStacks(2) inspector.setMaxAsyncTaskStacks(2)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 0 actual async chain len: 0
setMaxAsyncTaskStacks(2) inspector.setMaxAsyncTaskStacks(2)
Run expression 'console.trace(42)' with async chain len: 3 Run expression 'console.trace(42)' with async chain len: 3
actual async chain len: 0 actual async chain len: 0
setMaxAsyncTaskStacks(2) inspector.setMaxAsyncTaskStacks(2)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(2) inspector.setMaxAsyncTaskStacks(2)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(2) inspector.setMaxAsyncTaskStacks(2)
Run expression 'console.trace(42)' with async chain len: 3 Run expression 'console.trace(42)' with async chain len: 3
actual async chain len: 1 actual async chain len: 1
Running test: testMoreThanTwoLimit Running test: testMoreThanTwoLimit
setMaxAsyncTaskStacks(3) inspector.setMaxAsyncTaskStacks(3)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(3) inspector.setMaxAsyncTaskStacks(3)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 0 actual async chain len: 0
setMaxAsyncTaskStacks(3) inspector.setMaxAsyncTaskStacks(3)
Run expression 'console.trace(42)' with async chain len: 3 Run expression 'console.trace(42)' with async chain len: 3
actual async chain len: 0 actual async chain len: 0
setMaxAsyncTaskStacks(3) inspector.setMaxAsyncTaskStacks(3)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(3) inspector.setMaxAsyncTaskStacks(3)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(3) inspector.setMaxAsyncTaskStacks(3)
Run expression 'console.trace(42)' with async chain len: 3 Run expression 'console.trace(42)' with async chain len: 3
actual async chain len: 3 actual async chain len: 3
setMaxAsyncTaskStacks(4) inspector.setMaxAsyncTaskStacks(4)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(4) inspector.setMaxAsyncTaskStacks(4)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(4) inspector.setMaxAsyncTaskStacks(4)
Run expression 'console.trace(42)' with async chain len: 3 Run expression 'console.trace(42)' with async chain len: 3
actual async chain len: 0 actual async chain len: 0
setMaxAsyncTaskStacks(4) inspector.setMaxAsyncTaskStacks(4)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(4) inspector.setMaxAsyncTaskStacks(4)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(4) inspector.setMaxAsyncTaskStacks(4)
Run expression 'console.trace(42)' with async chain len: 3 Run expression 'console.trace(42)' with async chain len: 3
actual async chain len: 3 actual async chain len: 3
setMaxAsyncTaskStacks(5) inspector.setMaxAsyncTaskStacks(5)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(5) inspector.setMaxAsyncTaskStacks(5)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(5) inspector.setMaxAsyncTaskStacks(5)
Run expression 'console.trace(42)' with async chain len: 3 Run expression 'console.trace(42)' with async chain len: 3
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(5) inspector.setMaxAsyncTaskStacks(5)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(5) inspector.setMaxAsyncTaskStacks(5)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(5) inspector.setMaxAsyncTaskStacks(5)
Run expression 'console.trace(42)' with async chain len: 3 Run expression 'console.trace(42)' with async chain len: 3
actual async chain len: 3 actual async chain len: 3
setMaxAsyncTaskStacks(6) inspector.setMaxAsyncTaskStacks(6)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(6) inspector.setMaxAsyncTaskStacks(6)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(6) inspector.setMaxAsyncTaskStacks(6)
Run expression 'console.trace(42)' with async chain len: 3 Run expression 'console.trace(42)' with async chain len: 3
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(6) inspector.setMaxAsyncTaskStacks(6)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(6) inspector.setMaxAsyncTaskStacks(6)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(6) inspector.setMaxAsyncTaskStacks(6)
Run expression 'console.trace(42)' with async chain len: 3 Run expression 'console.trace(42)' with async chain len: 3
actual async chain len: 3 actual async chain len: 3
setMaxAsyncTaskStacks(7) inspector.setMaxAsyncTaskStacks(7)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(7) inspector.setMaxAsyncTaskStacks(7)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(7) inspector.setMaxAsyncTaskStacks(7)
Run expression 'console.trace(42)' with async chain len: 3 Run expression 'console.trace(42)' with async chain len: 3
actual async chain len: 3 actual async chain len: 3
setMaxAsyncTaskStacks(7) inspector.setMaxAsyncTaskStacks(7)
Run expression 'console.trace(42)' with async chain len: 1 Run expression 'console.trace(42)' with async chain len: 1
actual async chain len: 1 actual async chain len: 1
setMaxAsyncTaskStacks(7) inspector.setMaxAsyncTaskStacks(7)
Run expression 'console.trace(42)' with async chain len: 2 Run expression 'console.trace(42)' with async chain len: 2
actual async chain len: 2 actual async chain len: 2
setMaxAsyncTaskStacks(7) inspector.setMaxAsyncTaskStacks(7)
Run expression 'console.trace(42)' with async chain len: 3 Run expression 'console.trace(42)' with async chain len: 3
actual async chain len: 3 actual async chain len: 3
...@@ -165,7 +165,7 @@ function dumpAsyncChainLength(message) { ...@@ -165,7 +165,7 @@ function dumpAsyncChainLength(message) {
} }
async function setMaxAsyncTaskStacks(max) { async function setMaxAsyncTaskStacks(max) {
let expression = `setMaxAsyncTaskStacks(${max})`; let expression = `inspector.setMaxAsyncTaskStacks(${max})`;
InspectorTest.log(expression); InspectorTest.log(expression);
await Protocol.Runtime.evaluate({expression}); await Protocol.Runtime.evaluate({expression});
} }
...@@ -43,13 +43,13 @@ Running test: testDebuggerStatement ...@@ -43,13 +43,13 @@ Running test: testDebuggerStatement
Running test: testSyncDOMBreakpoint Running test: testSyncDOMBreakpoint
> all frames in framework: > all frames in framework:
> mixed, top frame in framework: > mixed, top frame in framework:
syncDOMBreakpoint (framework.js:33:2) syncDOMBreakpoint (framework.js:33:12)
(anonymous) (user.js:0:0) (anonymous) (user.js:0:0)
Running test: testSyncDOMBreakpointWithInlinedUserFrame Running test: testSyncDOMBreakpointWithInlinedUserFrame
> mixed, top frame in framework: > mixed, top frame in framework:
syncDOMBreakpoint (framework.js:33:2) syncDOMBreakpoint (framework.js:33:12)
userFunction (user.js:70:2) userFunction (user.js:70:2)
inlinedWrapper (framework.js:64:4) inlinedWrapper (framework.js:64:4)
syncDOMBreakpointWithInlinedUserFrame (framework.js:67:2) syncDOMBreakpointWithInlinedUserFrame (framework.js:67:2)
......
...@@ -30,7 +30,7 @@ function debuggerStatement() { ...@@ -30,7 +30,7 @@ function debuggerStatement() {
} }
function syncDOMBreakpoint() { function syncDOMBreakpoint() {
breakProgram('', ''); inspector.breakProgram('', '');
} }
function asyncDOMBreakpoint() { function asyncDOMBreakpoint() {
......
...@@ -3,10 +3,10 @@ break reason: framework-break ...@@ -3,10 +3,10 @@ break reason: framework-break
break aux data: { break aux data: {
"data": "data for framework-break" "data": "data for framework-break"
} }
doFrameworkBreak (framework.js:20:2) doFrameworkBreak (framework.js:20:12)
doFrameworkWork (framework.js:15:2) doFrameworkWork (framework.js:15:12)
frameworkCall (framework.js:9:2) frameworkCall (framework.js:9:12)
testFunction (user.js:27:2) testFunction (user.js:27:12)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
break reason: ambiguous break reason: ambiguous
...@@ -25,17 +25,17 @@ break aux data: { ...@@ -25,17 +25,17 @@ break aux data: {
} }
callback (user.js:31:17) callback (user.js:31:17)
doFrameworkWork (framework.js:16:2) doFrameworkWork (framework.js:16:2)
frameworkCall (framework.js:9:2) frameworkCall (framework.js:9:12)
testFunction (user.js:27:2) testFunction (user.js:27:12)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
break reason: user-break break reason: user-break
break aux data: { break aux data: {
"data": "data for user-break" "data": "data for user-break"
} }
callback (user.js:32:2) callback (user.js:32:12)
doFrameworkWork (framework.js:16:2) doFrameworkWork (framework.js:16:2)
frameworkCall (framework.js:9:2) frameworkCall (framework.js:9:12)
testFunction (user.js:27:2) testFunction (user.js:27:12)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
...@@ -6,30 +6,30 @@ InspectorTest.log('Checks nested scheduled break in framework code.'); ...@@ -6,30 +6,30 @@ InspectorTest.log('Checks nested scheduled break in framework code.');
InspectorTest.addScript(` InspectorTest.addScript(`
function frameworkCall(callback) { function frameworkCall(callback) {
callWithScheduledBreak(doFrameworkWork.bind(null, callback), inspector.callWithScheduledBreak(doFrameworkWork.bind(null, callback),
'top-framework-scheduled-break', 'top-framework-scheduled-break',
JSON.stringify({ data: 'data for top-framework-scheduled-break' })); JSON.stringify({ data: 'data for top-framework-scheduled-break' }));
} }
function doFrameworkWork(callback) { function doFrameworkWork(callback) {
callWithScheduledBreak(doFrameworkBreak, 'should-not-be-a-reason', ''); inspector.callWithScheduledBreak(doFrameworkBreak, 'should-not-be-a-reason', '');
callback(); callback();
} }
function doFrameworkBreak() { function doFrameworkBreak() {
breakProgram('framework-break', JSON.stringify({ data: 'data for framework-break' })); inspector.breakProgram('framework-break', JSON.stringify({ data: 'data for framework-break' }));
} }
//# sourceURL=framework.js`, 7, 26); //# sourceURL=framework.js`, 7, 26);
InspectorTest.addScript(` InspectorTest.addScript(`
function testFunction() { function testFunction() {
callWithScheduledBreak(frameworkCall.bind(null, callback), inspector.callWithScheduledBreak(frameworkCall.bind(null, callback),
'top-scheduled-break', ''); 'top-scheduled-break', '');
} }
function callback() { function callback() {
breakProgram('user-break', JSON.stringify({ data: 'data for user-break' })); inspector.breakProgram('user-break', JSON.stringify({ data: 'data for user-break' }));
return 42; return 42;
} }
......
...@@ -67,7 +67,7 @@ testStepFromUser (user.js:31:2) ...@@ -67,7 +67,7 @@ testStepFromUser (user.js:31:2)
Executing resume... Executing resume...
Running test: testStepIntoFromFramework Running test: testStepIntoFromFramework
frameworkBreakAndCall (framework.js:14:2) frameworkBreakAndCall (framework.js:14:12)
testStepFromFramework (user.js:35:2) testStepFromFramework (user.js:35:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
...@@ -80,7 +80,7 @@ testStepFromFramework (user.js:35:2) ...@@ -80,7 +80,7 @@ testStepFromFramework (user.js:35:2)
Executing resume... Executing resume...
Running test: testStepOverFromFramework Running test: testStepOverFromFramework
frameworkBreakAndCall (framework.js:14:2) frameworkBreakAndCall (framework.js:14:12)
testStepFromFramework (user.js:35:2) testStepFromFramework (user.js:35:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
...@@ -91,7 +91,7 @@ testStepFromFramework (user.js:36:0) ...@@ -91,7 +91,7 @@ testStepFromFramework (user.js:36:0)
Executing resume... Executing resume...
Running test: testStepOutFromFramework Running test: testStepOutFromFramework
frameworkBreakAndCall (framework.js:14:2) frameworkBreakAndCall (framework.js:14:12)
testStepFromFramework (user.js:35:2) testStepFromFramework (user.js:35:2)
(anonymous) (expr.js:0:0) (anonymous) (expr.js:0:0)
......
...@@ -11,7 +11,7 @@ function frameworkCall(funcs) { ...@@ -11,7 +11,7 @@ function frameworkCall(funcs) {
} }
function frameworkBreakAndCall(funcs) { function frameworkBreakAndCall(funcs) {
breakProgram('', ''); inspector.breakProgram('', '');
for (var f of funcs) f(); for (var f of funcs) f();
} }
//# sourceURL=framework.js`, //# sourceURL=framework.js`,
......
...@@ -2,7 +2,7 @@ Checks breakProgram,(schedule|cancel)PauseOnNextStatement test API ...@@ -2,7 +2,7 @@ Checks breakProgram,(schedule|cancel)PauseOnNextStatement test API
Running test: testBreakProgram Running test: testBreakProgram
Stack: Stack:
callBreakProgram (:9:2) callBreakProgram (:9:12)
(anonymous) (:0:0) (anonymous) (:0:0)
Other data: Other data:
{ {
......
...@@ -6,7 +6,7 @@ InspectorTest.log("Checks breakProgram,(schedule|cancel)PauseOnNextStatement tes ...@@ -6,7 +6,7 @@ InspectorTest.log("Checks breakProgram,(schedule|cancel)PauseOnNextStatement tes
InspectorTest.addScript(` InspectorTest.addScript(`
function callBreakProgram() { function callBreakProgram() {
breakProgram('reason', JSON.stringify({a: 42})); inspector.breakProgram('reason', JSON.stringify({a: 42}));
} }
function foo() { function foo() {
......
...@@ -2,16 +2,16 @@ Checks that stepping is cleared after breakProgram. ...@@ -2,16 +2,16 @@ Checks that stepping is cleared after breakProgram.
paused at: paused at:
function callBreakProgram() { function callBreakProgram() {
#debugger; #debugger;
breakProgram('reason', ''); inspector.breakProgram('reason', '');
paused at: paused at:
debugger; debugger;
#breakProgram('reason', ''); #inspector.breakProgram('reason', '');
} }
paused at: paused at:
debugger; debugger;
#breakProgram('reason', ''); inspector.#breakProgram('reason', '');
} }
paused at: paused at:
......
...@@ -7,7 +7,7 @@ InspectorTest.log('Checks that stepping is cleared after breakProgram.'); ...@@ -7,7 +7,7 @@ InspectorTest.log('Checks that stepping is cleared after breakProgram.');
InspectorTest.addScript(` InspectorTest.addScript(`
function callBreakProgram() { function callBreakProgram() {
debugger; debugger;
breakProgram('reason', ''); inspector.breakProgram('reason', '');
}`); }`);
InspectorTest.setupScriptMap(); InspectorTest.setupScriptMap();
......
...@@ -7,7 +7,7 @@ checks.'); ...@@ -7,7 +7,7 @@ checks.');
InspectorTest.addScript(` InspectorTest.addScript(`
function testFunction() { function testFunction() {
var array = [ createObjectWithStrictCheck() ]; var array = [ inspector.createObjectWithStrictCheck() ];
debugger; debugger;
} }
//# sourceURL=test.js`); //# sourceURL=test.js`);
......
...@@ -146,11 +146,11 @@ class DisconnectTask : public TaskRunner::Task { ...@@ -146,11 +146,11 @@ class DisconnectTask : public TaskRunner::Task {
class CreateContextGroupTask : public TaskRunner::Task { class CreateContextGroupTask : public TaskRunner::Task {
public: public:
CreateContextGroupTask(InspectorClientImpl* client, CreateContextGroupTask(InspectorClientImpl* client,
v8::ExtensionConfiguration* extensions, TaskRunner::SetupGlobalTasks setup_global_tasks,
v8::base::Semaphore* ready_semaphore, v8::base::Semaphore* ready_semaphore,
int* context_group_id) int* context_group_id)
: client_(client), : client_(client),
extensions_(extensions), setup_global_tasks_(std::move(setup_global_tasks)),
ready_semaphore_(ready_semaphore), ready_semaphore_(ready_semaphore),
context_group_id_(context_group_id) {} context_group_id_(context_group_id) {}
virtual ~CreateContextGroupTask() = default; virtual ~CreateContextGroupTask() = default;
...@@ -159,13 +159,13 @@ class CreateContextGroupTask : public TaskRunner::Task { ...@@ -159,13 +159,13 @@ class CreateContextGroupTask : public TaskRunner::Task {
void Run(v8::Isolate* isolate, void Run(v8::Isolate* isolate,
const v8::Global<v8::Context>& global_context) { const v8::Global<v8::Context>& global_context) {
*context_group_id_ = client_->createContextGroup(extensions_); *context_group_id_ = client_->createContextGroup(setup_global_tasks_);
if (ready_semaphore_) ready_semaphore_->Signal(); if (ready_semaphore_) ready_semaphore_->Signal();
} }
private: private:
InspectorClientImpl* client_; InspectorClientImpl* client_;
v8::ExtensionConfiguration* extensions_; TaskRunner::SetupGlobalTasks setup_global_tasks_;
v8::base::Semaphore* ready_semaphore_; v8::base::Semaphore* ready_semaphore_;
int* context_group_id_; int* context_group_id_;
}; };
...@@ -230,16 +230,17 @@ void InspectorClientImpl::disconnect() { ...@@ -230,16 +230,17 @@ void InspectorClientImpl::disconnect() {
} }
void InspectorClientImpl::scheduleCreateContextGroup( void InspectorClientImpl::scheduleCreateContextGroup(
v8::ExtensionConfiguration* extensions, TaskRunner::SetupGlobalTasks setup_global_tasks,
v8::base::Semaphore* ready_semaphore, int* context_group_id) { v8::base::Semaphore* ready_semaphore, int* context_group_id) {
task_runner_->Append(new CreateContextGroupTask( task_runner_->Append(new CreateContextGroupTask(
this, extensions, ready_semaphore, context_group_id)); this, std::move(setup_global_tasks), ready_semaphore, context_group_id));
} }
int InspectorClientImpl::createContextGroup( int InspectorClientImpl::createContextGroup(
v8::ExtensionConfiguration* extensions) { const TaskRunner::SetupGlobalTasks& setup_global_tasks) {
v8::HandleScope handle_scope(isolate_); v8::HandleScope handle_scope(isolate_);
v8::Local<v8::Context> context = task_runner_->NewContextGroup(); v8::Local<v8::Context> context =
task_runner_->NewContextGroup(setup_global_tasks);
context->SetAlignedPointerInEmbedderData(kInspectorClientIndex, this); context->SetAlignedPointerInEmbedderData(kInspectorClientIndex, this);
int context_group_id = TaskRunner::GetContextGroupId(context); int context_group_id = TaskRunner::GetContextGroupId(context);
v8_inspector::StringView state; v8_inspector::StringView state;
...@@ -371,11 +372,14 @@ class SendMessageToBackendTask : public TaskRunner::Task { ...@@ -371,11 +372,14 @@ class SendMessageToBackendTask : public TaskRunner::Task {
TaskRunner* SendMessageToBackendExtension::backend_task_runner_ = nullptr; TaskRunner* SendMessageToBackendExtension::backend_task_runner_ = nullptr;
v8::Local<v8::FunctionTemplate> void SendMessageToBackendExtension::Run(v8::Isolate* isolate,
SendMessageToBackendExtension::GetNativeFunctionTemplate( v8::Local<v8::ObjectTemplate> global) {
v8::Isolate* isolate, v8::Local<v8::String> name) { global->Set(
return v8::FunctionTemplate::New( v8::String::NewFromUtf8(isolate, "sendMessageToBackend",
isolate, SendMessageToBackendExtension::SendMessageToBackend); v8::NewStringType::kNormal)
.ToLocalChecked(),
v8::FunctionTemplate::New(
isolate, &SendMessageToBackendExtension::SendMessageToBackend));
} }
void SendMessageToBackendExtension::SendMessageToBackend( void SendMessageToBackendExtension::SendMessageToBackend(
......
...@@ -26,9 +26,9 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient { ...@@ -26,9 +26,9 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient {
virtual ~InspectorClientImpl(); virtual ~InspectorClientImpl();
void scheduleReconnect(v8::base::Semaphore* ready_semaphore); void scheduleReconnect(v8::base::Semaphore* ready_semaphore);
void scheduleCreateContextGroup(v8::ExtensionConfiguration* extensions, void scheduleCreateContextGroup(
v8::base::Semaphore* ready_semaphore, TaskRunner::SetupGlobalTasks setup_global_tasks,
int* context_group_id); v8::base::Semaphore* ready_semaphore, int* context_group_id);
static v8_inspector::V8Inspector* InspectorFromContext( static v8_inspector::V8Inspector* InspectorFromContext(
v8::Local<v8::Context> context); v8::Local<v8::Context> context);
...@@ -65,7 +65,8 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient { ...@@ -65,7 +65,8 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient {
friend class DisconnectTask; friend class DisconnectTask;
void disconnect(); void disconnect();
friend class CreateContextGroupTask; friend class CreateContextGroupTask;
int createContextGroup(v8::ExtensionConfiguration* extensions); int createContextGroup(
const TaskRunner::SetupGlobalTasks& setup_global_tasks);
std::unique_ptr<v8_inspector::V8Inspector> inspector_; std::unique_ptr<v8_inspector::V8Inspector> inspector_;
std::unique_ptr<v8_inspector::V8Inspector::Channel> channel_; std::unique_ptr<v8_inspector::V8Inspector::Channel> channel_;
...@@ -86,13 +87,9 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient { ...@@ -86,13 +87,9 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient {
DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl); DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl);
}; };
class SendMessageToBackendExtension : public v8::Extension { class SendMessageToBackendExtension : public TaskRunner::SetupGlobalTask {
public: public:
SendMessageToBackendExtension() void Run(v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> global) override;
: v8::Extension("v8_inspector/frontend",
"native function sendMessageToBackend();") {}
virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Local<v8::String> name);
static void set_backend_task_runner(TaskRunner* task_runner) { static void set_backend_task_runner(TaskRunner* task_runner) {
backend_task_runner_ = task_runner; backend_task_runner_ = task_runner;
......
This diff is collapsed.
...@@ -62,7 +62,7 @@ Object.defineProperty(parentObj, 'propNotNamedProto', { ...@@ -62,7 +62,7 @@ Object.defineProperty(parentObj, 'propNotNamedProto', {
set: function() {} set: function() {}
}); });
var objInheritsGetterProperty = {__proto__: parentObj}; var objInheritsGetterProperty = {__proto__: parentObj};
allowAccessorFormatting(objInheritsGetterProperty); inspector.allowAccessorFormatting(objInheritsGetterProperty);
`); `);
InspectorTest.setupInjectedScriptEnvironment(); InspectorTest.setupInjectedScriptEnvironment();
......
...@@ -32,11 +32,11 @@ v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) { ...@@ -32,11 +32,11 @@ v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) {
} // namespace } // namespace
TaskRunner::TaskRunner(v8::ExtensionConfiguration* extensions, TaskRunner::TaskRunner(TaskRunner::SetupGlobalTasks setup_global_tasks,
bool catch_exceptions, bool catch_exceptions,
v8::base::Semaphore* ready_semaphore) v8::base::Semaphore* ready_semaphore)
: Thread(Options("Task Runner")), : Thread(Options("Task Runner")),
extensions_(extensions), setup_global_tasks_(std::move(setup_global_tasks)),
catch_exceptions_(catch_exceptions), catch_exceptions_(catch_exceptions),
ready_semaphore_(ready_semaphore), ready_semaphore_(ready_semaphore),
isolate_(nullptr), isolate_(nullptr),
...@@ -55,15 +55,20 @@ void TaskRunner::InitializeIsolate() { ...@@ -55,15 +55,20 @@ void TaskRunner::InitializeIsolate() {
isolate_->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped); isolate_->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped);
v8::Isolate::Scope isolate_scope(isolate_); v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_); v8::HandleScope handle_scope(isolate_);
NewContextGroup(); NewContextGroup(setup_global_tasks_);
if (ready_semaphore_) ready_semaphore_->Signal(); if (ready_semaphore_) ready_semaphore_->Signal();
} }
v8::Local<v8::Context> TaskRunner::NewContextGroup() { v8::Local<v8::Context> TaskRunner::NewContextGroup(
const TaskRunner::SetupGlobalTasks& setup_global_tasks) {
v8::Local<v8::ObjectTemplate> global_template = v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate_); v8::ObjectTemplate::New(isolate_);
for (auto it = setup_global_tasks.begin(); it != setup_global_tasks.end();
++it) {
(*it)->Run(isolate_, global_template);
}
v8::Local<v8::Context> context = v8::Local<v8::Context> context =
v8::Context::New(isolate_, extensions_, global_template); v8::Context::New(isolate_, nullptr, global_template);
context->SetAlignedPointerInEmbedderData(kTaskRunnerIndex, this); context->SetAlignedPointerInEmbedderData(kTaskRunnerIndex, this);
intptr_t context_group_id = ++last_context_group_id_; intptr_t context_group_id = ++last_context_group_id_;
// Should be 2-byte aligned. // Should be 2-byte aligned.
......
...@@ -36,7 +36,15 @@ class TaskRunner : public v8::base::Thread { ...@@ -36,7 +36,15 @@ class TaskRunner : public v8::base::Thread {
const v8::Global<v8::Context>& context) = 0; const v8::Global<v8::Context>& context) = 0;
}; };
TaskRunner(v8::ExtensionConfiguration* extensions, bool catch_exceptions, class SetupGlobalTask {
public:
virtual ~SetupGlobalTask() = default;
virtual void Run(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> global) = 0;
};
using SetupGlobalTasks = std::vector<std::unique_ptr<SetupGlobalTask>>;
TaskRunner(SetupGlobalTasks setup_global_tasks, bool catch_exceptions,
v8::base::Semaphore* ready_semaphore); v8::base::Semaphore* ready_semaphore);
virtual ~TaskRunner(); virtual ~TaskRunner();
...@@ -52,7 +60,8 @@ class TaskRunner : public v8::base::Thread { ...@@ -52,7 +60,8 @@ class TaskRunner : public v8::base::Thread {
static TaskRunner* FromContext(v8::Local<v8::Context>); static TaskRunner* FromContext(v8::Local<v8::Context>);
v8::Local<v8::Context> NewContextGroup(); v8::Local<v8::Context> NewContextGroup(
const SetupGlobalTasks& setup_global_tasks);
v8::Local<v8::Context> GetContext(int context_group_id); v8::Local<v8::Context> GetContext(int context_group_id);
static int GetContextGroupId(v8::Local<v8::Context> context); static int GetContextGroupId(v8::Local<v8::Context> context);
...@@ -68,7 +77,7 @@ class TaskRunner : public v8::base::Thread { ...@@ -68,7 +77,7 @@ class TaskRunner : public v8::base::Thread {
void InitializeIsolate(); void InitializeIsolate();
Task* GetNext(bool only_protocol); Task* GetNext(bool only_protocol);
v8::ExtensionConfiguration* extensions_; SetupGlobalTasks setup_global_tasks_;
bool catch_exceptions_; bool catch_exceptions_;
v8::base::Semaphore* ready_semaphore_; v8::base::Semaphore* ready_semaphore_;
......
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