Bug 1660332 - [marionette] Port WebDriver:ElementClick to JSWindowActor. r=marionette-reviewers,jdescottes,maja_zf

Differential Revision: https://phabricator.services.mozilla.com/D91006
This commit is contained in:
Henrik Skupin 2020-09-24 19:53:30 +00:00
Родитель 717d9a23ba
Коммит f02816895f
3 изменённых файлов: 43 добавлений и 3 удалений

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

@ -69,6 +69,9 @@ class MarionetteFrameChild extends JSWindowActorChild {
case "MarionetteFrameParent:clearElement":
this.clearElement(data);
break;
case "MarionetteFrameParent:clickElement":
result = await this.clickElement(data);
break;
case "MarionetteFrameParent:findElement":
result = await this.findElement(data);
break;
@ -176,6 +179,20 @@ class MarionetteFrameChild extends JSWindowActorChild {
interaction.clearElement(el);
}
/**
* Click an element.
*/
async clickElement(options = {}) {
const { capabilities, webEl } = options;
const el = this.resolveElement(webEl);
return interaction.clickElement(
el,
capabilities["moz:accessibilityChecks"],
capabilities["moz:webdriverClick"]
);
}
/**
* Find an element in the current browsing context's document using the
* given search strategy.

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

@ -74,6 +74,13 @@ class MarionetteFrameParent extends JSWindowActorParent {
});
}
clickElement(webEl, capabilities) {
return this.sendQuery("MarionetteFrameParent:clickElement", {
webEl,
capabilities,
});
}
findElement(strategy, selector, opts) {
return this.sendQuery("MarionetteFrameParent:findElement", {
strategy,

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

@ -2158,6 +2158,23 @@ GeckoDriver.prototype.clickElement = async function(cmd) {
let id = assert.string(cmd.parameters.id);
let webEl = WebElement.fromUUID(id, this.context);
if (MarionettePrefs.useActors) {
const actor = this.getActor();
const target = await actor.getElementAttribute(webEl, "target");
await navigate.waitForNavigationCompleted(
this,
() => actor.clickElement(webEl, this.capabilities),
{
browsingContext: this.getBrowsingContext(),
// The click might trigger a navigation, so don't count on it.
requireBeforeUnload: false,
loadEventExpected: target !== "_blank",
}
);
return;
}
switch (this.context) {
case Context.Chrome:
let el = this.curBrowser.seenEls.get(webEl);
@ -2169,11 +2186,10 @@ GeckoDriver.prototype.clickElement = async function(cmd) {
await navigate.waitForNavigationCompleted(
this,
async () => {
await this.listener.clickElement(webEl, this.capabilities);
},
() => this.listener.clickElement(webEl, this.capabilities),
{
browsingContext: this.getBrowsingContext(),
// The click might trigger a navigation, so don't count on it.
requireBeforeUnload: false,
loadEventExpected: target !== "_blank",
}