diff --git a/remote/shared/Prompt.sys.mjs b/remote/shared/Prompt.sys.mjs index b4e038736f33..dcdc254ebc04 100644 --- a/remote/shared/Prompt.sys.mjs +++ b/remote/shared/Prompt.sys.mjs @@ -210,4 +210,18 @@ modal.Dialog = class { } 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; + } }; diff --git a/remote/test/puppeteer/test/TestExpectations.json b/remote/test/puppeteer/test/TestExpectations.json index 14a664e66282..9b97705818df 100644 --- a/remote/test/puppeteer/test/TestExpectations.json +++ b/remote/test/puppeteer/test/TestExpectations.json @@ -1679,12 +1679,6 @@ "parameters": ["cdp", "firefox"], "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", "platforms": ["darwin", "linux", "win32"], diff --git a/remote/webdriver-bidi/modules/root/browsingContext.sys.mjs b/remote/webdriver-bidi/modules/root/browsingContext.sys.mjs index 41cb9e528e13..7ed847594d01 100644 --- a/remote/webdriver-bidi/modules/root/browsingContext.sys.mjs +++ b/remote/webdriver-bidi/modules/root/browsingContext.sys.mjs @@ -1314,13 +1314,25 @@ class BrowsingContextModule extends Module { type: lazy.WindowGlobalMessageHandler.type, }; + const eventPayload = { + context: contextId, + type: prompt.promptType, + 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", - { - context: contextId, - type: prompt.promptType, - message: await prompt.getText(), - }, + eventPayload, contextInfo ); } diff --git a/testing/web-platform/meta/webdriver/tests/bidi/browsing_context/user_prompt_opened/user_prompt_opened.py.ini b/testing/web-platform/meta/webdriver/tests/bidi/browsing_context/user_prompt_opened/user_prompt_opened.py.ini index e9cfdd1054fb..338198800c67 100644 --- a/testing/web-platform/meta/webdriver/tests/bidi/browsing_context/user_prompt_opened/user_prompt_opened.py.ini +++ b/testing/web-platform/meta/webdriver/tests/bidi/browsing_context/user_prompt_opened/user_prompt_opened.py.ini @@ -2,6 +2,3 @@ [test_subscribe_to_one_context[window\]] disabled: if os == "android": Not supported - - [test_prompt_default_value] - expected: FAIL