зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1770740 - [bidi] Implement "script.disown" command r=webdriver-reviewers,Sasha,whimboo
Depends on D155522 Differential Revision: https://phabricator.services.mozilla.com/D155634
This commit is contained in:
Родитель
32963370f6
Коммит
584c2ea03d
|
@ -169,6 +169,52 @@ class ScriptModule extends Module {
|
|||
return this.#buildReturnValue(evaluationResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* The script.disown command disowns the given handles. This does not
|
||||
* guarantee the handled object will be garbage collected, as there can be
|
||||
* other handles or strong ECMAScript references.
|
||||
*
|
||||
* @param {Object=} options
|
||||
* @param {Array<string>} handles
|
||||
* Array of handle ids to disown.
|
||||
* @param {Object} target
|
||||
* The target owning the handles, which either matches the definition for
|
||||
* a RealmTarget or for ContextTarget.
|
||||
*/
|
||||
async disown(options = {}) {
|
||||
// TODO: Bug 1778976. Remove once command is fully supported.
|
||||
this.assertExperimentalCommandsEnabled("script.disown");
|
||||
|
||||
const { handles, target = {} } = options;
|
||||
|
||||
lazy.assert.array(
|
||||
handles,
|
||||
`Expected "handles" to be an array, got ${handles}`
|
||||
);
|
||||
handles.forEach(handle => {
|
||||
lazy.assert.string(
|
||||
handle,
|
||||
`Expected "handles" to be an array of strings, got ${handle}`
|
||||
);
|
||||
});
|
||||
|
||||
const { contextId, realmId, sandbox } = this.#assertTarget(target);
|
||||
const context = this.#getContextFromTarget({ contextId, realmId, sandbox });
|
||||
await this.messageHandler.forwardCommand({
|
||||
moduleName: "script",
|
||||
commandName: "disownHandles",
|
||||
destination: {
|
||||
type: lazy.WindowGlobalMessageHandler.type,
|
||||
id: context.id,
|
||||
},
|
||||
params: {
|
||||
handles,
|
||||
realmId,
|
||||
sandbox,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate a provided expression in the provided target, which is either a
|
||||
* realm or a browsing context.
|
||||
|
|
|
@ -209,6 +209,8 @@ class ScriptModule extends Module {
|
|||
* The arguments to pass to the function call.
|
||||
* @param {string} functionDeclaration
|
||||
* The body of the function to call.
|
||||
* @param {string=} realmId [not supported]
|
||||
* The id of the realm.
|
||||
* @param {OwnershipModel} resultOwnership
|
||||
* The ownership model to use for the results of this evaluation.
|
||||
* @param {string=} sandbox
|
||||
|
@ -252,6 +254,26 @@ class ScriptModule extends Module {
|
|||
return this.#buildReturnValue(rv, realm, awaitPromise, resultOwnership);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the provided handles from the realm corresponding to the provided
|
||||
* sandbox name.
|
||||
*
|
||||
* @param {Object=} options
|
||||
* @param {Array<string>} handles
|
||||
* Array of handle ids to disown.
|
||||
* @param {string=} realmId [not supported]
|
||||
* The id of the realm.
|
||||
* @param {string=} sandbox
|
||||
* The name of the sandbox.
|
||||
*/
|
||||
disownHandles(options) {
|
||||
const { handles, sandbox: sandboxName = null } = options;
|
||||
const realm = this.#getRealmFromSandboxName(sandboxName);
|
||||
for (const handle of handles) {
|
||||
realm.removeObjectHandle(handle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate a provided expression in the current window global.
|
||||
*
|
||||
|
@ -261,6 +283,8 @@ class ScriptModule extends Module {
|
|||
* expression to resolve, if this return value is a Promise.
|
||||
* @param {string} expression
|
||||
* The expression to evaluate.
|
||||
* @param {string=} realmId [not supported]
|
||||
* The id of the realm.
|
||||
* @param {OwnershipModel} resultOwnership
|
||||
* The ownership model to use for the results of this evaluation.
|
||||
* @param {string=} sandbox
|
||||
|
|
Загрузка…
Ссылка в новой задаче