abacd4c115
This adds support for injecting binding into contexts other than main based on the context name (AKA isolated world name in Blink terms). This would simplify a common use case for addBinding in Puppeteer and other automation tools that use addBinding to expose a back-channel for extension code running in an isolated world by making bindings available to such code at an early stage and in a race-free manner (currently, we can only inject a binding into specific context after the creation of the context has been reported to the client, which typically introduces a race with other evals the client may be running in the context). Change-Id: I66454954491a47a0c9aa4864f0aace4da2e67d3a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2440984 Reviewed-by: Simon Zünd <szuend@chromium.org> Reviewed-by: Pavel Feldman <pfeldman@chromium.org> Commit-Queue: Andrey Kosyakov <caseq@chromium.org> Cr-Commit-Position: refs/heads/master@{#70266}
207 lines
4.3 KiB
Plaintext
207 lines
4.3 KiB
Plaintext
Test for Runtime.addBinding.
|
|
|
|
Running test: testBasic
|
|
|
|
Add binding inside session1..
|
|
Call binding..
|
|
binding called in session1
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : send
|
|
payload : payload
|
|
}
|
|
}
|
|
|
|
Add binding inside session2..
|
|
Call binding..
|
|
binding called in session1
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : send
|
|
payload : payload
|
|
}
|
|
}
|
|
binding called in session2
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : send
|
|
payload : payload
|
|
}
|
|
}
|
|
|
|
Disable agent inside session1..
|
|
Call binding..
|
|
binding called in session1
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : send
|
|
payload : payload
|
|
}
|
|
}
|
|
binding called in session2
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : send
|
|
payload : payload
|
|
}
|
|
}
|
|
|
|
Disable agent inside session2..
|
|
Call binding..
|
|
binding called in session1
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : send
|
|
payload : payload
|
|
}
|
|
}
|
|
binding called in session2
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : send
|
|
payload : payload
|
|
}
|
|
}
|
|
|
|
Enable agent inside session1..
|
|
Call binding..
|
|
binding called in session1
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : send
|
|
payload : payload
|
|
}
|
|
}
|
|
binding called in session2
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : send
|
|
payload : payload
|
|
}
|
|
}
|
|
|
|
Running test: testReconnect
|
|
|
|
Add binding inside session..
|
|
Reconnect..
|
|
binding called in session1
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : send
|
|
payload : payload
|
|
}
|
|
}
|
|
|
|
Running test: testBindingOverrides
|
|
|
|
Add send function on global object..
|
|
Add binding inside session..
|
|
Call binding..
|
|
binding called in session1
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : send
|
|
payload : payload
|
|
}
|
|
}
|
|
|
|
Running test: testRemoveBinding
|
|
|
|
Add binding inside session..
|
|
Call binding..
|
|
binding called in session1
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : send
|
|
payload : payload
|
|
}
|
|
}
|
|
Remove binding inside session..
|
|
Call binding..
|
|
|
|
Running test: testAddBindingToContextById
|
|
Call binding in default context (binding should NOT be exposed)
|
|
Call binding in target context (binding should be exposed)
|
|
binding called in session1
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : frobnicate
|
|
payload : message
|
|
}
|
|
}
|
|
Call binding in newly created context (binding should NOT be exposed)
|
|
|
|
Running test: testAddBindingToContextByName
|
|
Call binding in default context (binding should NOT be exposed)
|
|
Call binding in Foo (binding should be exposed)
|
|
binding called in session1
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : frobnicate
|
|
payload : message
|
|
}
|
|
}
|
|
Call binding in Bar (binding should NOT be exposed)
|
|
Call binding in newly-created Foo (binding should be exposed)
|
|
binding called in session1
|
|
{
|
|
method : Runtime.bindingCalled
|
|
params : {
|
|
executionContextId : <executionContextId>
|
|
name : frobnicate
|
|
payload : message
|
|
}
|
|
}
|
|
Call binding in newly-created Bazz (binding should NOT be exposed)
|
|
|
|
Running test: testErrors
|
|
{
|
|
error : {
|
|
code : -32602
|
|
message : Invalid executionContextName
|
|
}
|
|
id : <messageId>
|
|
}
|
|
{
|
|
error : {
|
|
code : -32602
|
|
message : executionContextName is mutually exclusive with executionContextId
|
|
}
|
|
id : <messageId>
|
|
}
|
|
{
|
|
error : {
|
|
code : -32602
|
|
message : Cannot find execution context with given executionContextId
|
|
}
|
|
id : <messageId>
|
|
}
|