Bug 1777460 - [bidi] Support "this" parameter for "script.callFunction" command r=webdriver-reviewers,whimboo

Depends on D150823

Differential Revision: https://phabricator.services.mozilla.com/D150824
This commit is contained in:
Julian Descottes 2022-07-12 16:19:32 +00:00
Родитель b7742d679e
Коммит 481846b3e9
4 изменённых файлов: 11 добавлений и 26 удалений

Просмотреть файл

@ -139,7 +139,7 @@ class ScriptModule extends Module {
* The target for the evaluation, which either matches the definition for
* a RealmTarget or for ContextTarget.
* @param {RemoteValue=} this
* The value of the this keyword for the function call. [unsupported]
* The value of the this keyword for the function call.
*
* @returns {ScriptEvaluateResult}
*
@ -180,12 +180,6 @@ class ScriptModule extends Module {
);
}
if (thisParameter != null) {
throw new lazy.error.UnsupportedOperationError(
`"this" parameter is not supported yet`
);
}
const { contextId, realmId, sandbox } = this.#assertTarget(target);
const realm = this.#getRealmInfoFromTarget({ contextId, realmId, sandbox });
const evaluationResult = await this.messageHandler.forwardCommand({
@ -199,6 +193,7 @@ class ScriptModule extends Module {
awaitPromise,
commandArguments,
functionDeclaration,
thisParameter,
},
});

Просмотреть файл

@ -183,6 +183,8 @@ class ScriptModule extends Module {
* The arguments to pass to the function call.
* @param {string} functionDeclaration
* The body of the function to call.
* @param {RemoteValue=} thisParameter
* The value of the this keyword for the function call.
*
* @return {Object}
* - evaluationStatus {EvaluationStatus} One of "normal", "throw".
@ -196,18 +198,24 @@ class ScriptModule extends Module {
awaitPromise,
commandArguments = null,
functionDeclaration,
thisParameter = null,
} = options;
const deserializedArguments =
commandArguments != null
? commandArguments.map(a => lazy.deserialize(a))
: [];
const expression = `(${functionDeclaration}).apply(null, __bidi_args)`;
const deserializedThis =
thisParameter != null ? lazy.deserialize(thisParameter) : null;
const expression = `(${functionDeclaration}).apply(__bidi_this, __bidi_args)`;
const rv = this.#global.executeInGlobalWithBindings(
expression,
{
__bidi_args: this.#cloneAsDebuggerObject(deserializedArguments),
__bidi_this: this.#cloneAsDebuggerObject(deserializedThis),
},
{
url: this.messageHandler.window.document.baseURI,

Просмотреть файл

@ -8,9 +8,6 @@
[test_default_arguments]
expected: FAIL
[test_this]
expected: FAIL
[test_default_this]
expected: FAIL

Просмотреть файл

@ -1,18 +1,3 @@
[invalid.py]
[test_params_realm_unknown]
expected: FAIL
[test_params_this_invalid_type[False\]]
expected: FAIL
[test_params_this_invalid_type[SOME_STRING\]]
expected: FAIL
[test_params_this_invalid_type[42\]]
expected: FAIL
[test_params_this_invalid_type[this3\]]
expected: FAIL
[test_params_this_invalid_type[this4\]]
expected: FAIL