Commit 0634da76 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[DevTools] added Runtime.addBinding test for specific context

R=pfeldman@chromium.org

Bug: chromium:849552
Change-Id: Ib403617014272d1e9091504049ecb650b4b309af
Reviewed-on: https://chromium-review.googlesource.com/1087502Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566021}
parent 2790aeed
Tests that Runtime.installBinding is preserved on navigations and injected before the addScriptOnNewDocument is run.
Tests that Runtime.addBinding is preserved on navigations and injected before the addScriptOnNewDocument is run.
Install binding..
{
id : <number>
......@@ -24,4 +24,82 @@ Navigate to page with console.debug..
payload : payload
}
}
Add binding in iframe..
{
id : <number>
result : {
}
}
Call bindings in iframe..
{
method : Runtime.bindingCalled
params : {
executionContextId : <number>
name : isolateSend
payload : 42
}
}
{
method : Runtime.bindingCalled
params : {
executionContextId : <number>
name : send
payload : 12
}
}
Call send binding in page..
{
method : Runtime.bindingCalled
params : {
executionContextId : <number>
name : send
payload : 12
}
}
{
id : <number>
result : {
result : {
type : undefined
}
}
}
Call isolateSend binding in page..
{
id : <number>
result : {
exceptionDetails : {
columnNumber : 0
exception : {
className : ReferenceError
description : ReferenceError: isolateSend is not defined at <anonymous>:1:1
objectId : <string>
subtype : error
type : object
}
exceptionId : 1
lineNumber : 0
scriptId : <string>
stackTrace : {
callFrames : [
[0] : {
columnNumber : 0
functionName :
lineNumber : 0
scriptId : <string>
url :
}
]
}
text : Uncaught
}
result : {
className : ReferenceError
description : ReferenceError: isolateSend is not defined at <anonymous>:1:1
objectId : <string>
subtype : error
type : object
}
}
}
(async function(testRunner) {
const {page, session, dp} = await testRunner.startBlank(
'Tests that Runtime.installBinding is preserved on navigations and ' +
'Tests that Runtime.addBinding is preserved on navigations and ' +
'injected before the addScriptOnNewDocument is run.');
dp.Runtime.enable();
dp.Page.enable();
......@@ -27,5 +27,36 @@
testRunner.log('Navigate to page with console.debug..');
await dp.Page.navigate({url: testRunner.url('../resources/binding.html')});
testRunner.log(await dp.Runtime.onceBindingCalled());
testRunner.log('Add binding in iframe..');
session.evaluateAsync(`
function appendIframe(url) {
var frame = document.createElement('iframe');
frame.id = 'iframe';
frame.src = url;
document.body.appendChild(frame);
return new Promise(resolve => frame.onload = resolve);
}
appendIframe('${testRunner.url('../resources/binding.html')}')
`);
const {params:{context}} = await dp.Runtime.onceExecutionContextCreated();
testRunner.log(await dp.Runtime.addBinding({
name: 'isolateSend',
executionContextId: context.id
}));
dp.Runtime.onBindingCalled(msg => testRunner.log(msg));
testRunner.log('Call bindings in iframe..');
await dp.Runtime.evaluate({
expression: 'isolateSend(\'42\'), send(\'12\')',
contextId: context.id
});
testRunner.log('Call send binding in page..');
testRunner.log(await dp.Runtime.evaluate({
expression: 'send(\'12\')',
}));
testRunner.log('Call isolateSend binding in page..');
testRunner.log(await dp.Runtime.evaluate({
expression: 'isolateSend(\'12\')',
}));
testRunner.completeTest();
})
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