Bug 1851761 - [bidi] Add `defaultValue` field to the "browsingContext.userPromptOpened" event. r=webdriver-reviewers,whimboo

Differential Revision: https://phabricator.services.mozilla.com/D189633
This commit is contained in:
Alexandra Borovova 2023-10-24 09:07:16 +00:00
Родитель 15aa26cc46
Коммит 5efc971076
4 изменённых файлов: 31 добавлений и 14 удалений

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

@ -210,4 +210,18 @@ modal.Dialog = class {
} }
return this.ui.infoBody.textContent; return this.ui.infoBody.textContent;
} }
/**
* Returns text of the prompt input.
*
* @returns {string}
* Returns string on desktop and Promise on Android.
*/
async getInputText() {
if (lazy.AppInfo.isAndroid) {
const textPromise = await this.window.getInputText();
return textPromise;
}
return this.ui.loginTextbox.value;
}
}; };

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

@ -1679,12 +1679,6 @@
"parameters": ["cdp", "firefox"], "parameters": ["cdp", "firefox"],
"expectations": ["FAIL"] "expectations": ["FAIL"]
}, },
{
"testIdPattern": "[dialog.spec] Page.Events.Dialog should allow accepting prompts",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["firefox", "webDriverBiDi"],
"expectations": ["FAIL"]
},
{ {
"testIdPattern": "[dialog.spec] Page.Events.Dialog should allow accepting prompts", "testIdPattern": "[dialog.spec] Page.Events.Dialog should allow accepting prompts",
"platforms": ["darwin", "linux", "win32"], "platforms": ["darwin", "linux", "win32"],

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

@ -1314,13 +1314,25 @@ class BrowsingContextModule extends Module {
type: lazy.WindowGlobalMessageHandler.type, type: lazy.WindowGlobalMessageHandler.type,
}; };
this.emitEvent( const eventPayload = {
"browsingContext.userPromptOpened",
{
context: contextId, context: contextId,
type: prompt.promptType, type: prompt.promptType,
message: await prompt.getText(), message: await prompt.getText(),
}, };
// Bug 1859814: Since the platform doesn't provide the access to the `defaultValue` of the prompt,
// we use prompt the `value` instead. The `value` is set to `defaultValue` when `defaultValue` is provided.
// This approach doesn't allow us to distinguish between the `defaultValue` being set to an empty string and
// `defaultValue` not set, because `value` is always defaulted to an empty string.
// We should switch to using the actual `defaultValue` when it's available and check for the `null` here.
const defaultValue = await prompt.getInputText();
if (defaultValue) {
eventPayload.defaultValue = defaultValue;
}
this.emitEvent(
"browsingContext.userPromptOpened",
eventPayload,
contextInfo contextInfo
); );
} }

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

@ -2,6 +2,3 @@
[test_subscribe_to_one_context[window\]] [test_subscribe_to_one_context[window\]]
disabled: disabled:
if os == "android": Not supported if os == "android": Not supported
[test_prompt_default_value]
expected: FAIL