Closed sadym-chromium closed 2 years ago
Yes, I was assuming we'd have something like script.call[FunctionOn]
.
For arguments, we could indeed allow a serialization like {objectId: <object id string>}
to refer to an object on the remote end. The question is whether to allow type
and value
fields. The advantage of that would be allowing the exact same object from a response to be used in an argument. The disadvantage is that it's unclear what to do if there's a mismatch (e.g. if you pass in type: "object"
but once you lookup the object id get a map
).
I think I favour minimisng the amount of validation having a schema like:
Argument = (
RemoteValueArgument //
ValueArgument
)
RemoteValueArgument = {
objectId: text
}
ValueArgument = {
type: text,
value: Argument
}
The Browser Testing and Tools Working Group just discussed Sending data from the local end (client) to the remote end (browser)
.
Merged in #142
As a BiDi user, I want to be able to invoke some custom function with some custom arguments on the page context. For example, I want to be able to invoke
(text) => {this.innerHtml=text}
with customthis
andtext
.It can be done:
script.evaluate
command by adding optional parametersthisObject
andargument
. It can be quite ugly, asexpression
changes meaning from expression to be evaluated and returned as a result to expression to return a function which will be invoked with the given params and each result will be returned to user.script.invoke
with anexpression
string returning function to be invoked,thisObject
andargument
.I'm inclined to go with the second way.
There is another open question:
{a: 1}
, andRemoteObject
return by e.g.script.evaluate
.For primitive type it is logical to use the
remote value
serialisation. But for non-primitive it's enough to have onlyobjectId
, even without type. Should we send{type: 'object', objectId: 'SOME_OBJECT_ID'}
, or we don'r requiretype
?For non-primitive objects I want to use as an argument, if I want to pass some new object as an argument, which was not presented in BiDi yet (like
{a: 1}
), I want to use be able to use BiDi serialisation protocol. But it requires making anobjectId
optional.UPD:
As discussed, command
script.callFunction
would be more readable.