a11b0d962d
Currently we incorrectly show global object as arrow function receiver. With this CL: - if this is used inside of function we show correct this value, - if this is unused and V8 optimizes it out - we show undefined. Second is known issue which we should address separately. R=dgozman@chromium.org,yangguo@chromium.org Bug: chromium:552753 Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel Change-Id: Iac88a07fe622eb9b2f8af7ecbc4a32a56c8cdfaa Reviewed-on: https://chromium-review.googlesource.com/723840 Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#48839}
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
let {session, contextGroup, Protocol} =
|
|
InspectorTest.start('Checks this in arrow function scope');
|
|
|
|
(async function test() {
|
|
session.setupScriptMap();
|
|
Protocol.Debugger.enable();
|
|
Protocol.Runtime.evaluate({expression: `
|
|
function foo() {
|
|
return () => {
|
|
let a = this;
|
|
(function() {
|
|
let f = () => { debugger; };
|
|
f();
|
|
}).call('a');
|
|
return a;
|
|
};
|
|
}
|
|
function boo() {
|
|
foo.call(1)();
|
|
}
|
|
(() => boo.call({}))();`
|
|
});
|
|
let {params:{callFrames}} = await Protocol.Debugger.oncePaused();
|
|
for (let callFrame of callFrames) {
|
|
await session.logSourceLocation(callFrame.location);
|
|
|
|
InspectorTest.log('This on callFrame:');
|
|
InspectorTest.logMessage(callFrame.this);
|
|
let {result:{result}} = await Protocol.Debugger.evaluateOnCallFrame({
|
|
callFrameId: callFrame.callFrameId,
|
|
expression: 'this'
|
|
});
|
|
InspectorTest.log('This in evaluateOnCallFrame:');
|
|
InspectorTest.logMessage(result);
|
|
|
|
if (callFrame.this.type === 'undefined' || result.type === 'undefined') {
|
|
InspectorTest.log('Values equal: ' + (callFrame.this.type === result.type) + '\n');
|
|
continue;
|
|
}
|
|
|
|
let {result:{result:{value}}} = await Protocol.Runtime.callFunctionOn({
|
|
functionDeclaration: 'function equal(a) { return this === a; }',
|
|
objectId: callFrame.this.objectId,
|
|
arguments: [ result.value ? {value: result.value} : {objectId: result.objectId}],
|
|
returnByValue: true
|
|
});
|
|
InspectorTest.log('Values equal: ' + value + '\n');
|
|
}
|
|
InspectorTest.completeTest();
|
|
})();
|