Changes
diff --git a/mcp/firefox-rdp/src/page_scripts.py b/mcp/firefox-rdp/src/page_scripts.py
index 4b6b910..b1af543 100644
--- a/mcp/firefox-rdp/src/page_scripts.py
+++ b/mcp/firefox-rdp/src/page_scripts.py
@@ -20,7 +20,7 @@ def _wrapped(body: str) -> str:
def _wrappedAsync(body: str) -> str:
return (
- "(async () => { try { " + body
+ "await (async () => { try { " + body
+ " } catch (error) { return JSON.stringify({ok:false,error:{"
+ "code:'javascript_error',message:String(error && "
+ "error.message || error)}}); } })()"
diff --git a/mcp/firefox-rdp/tests/manual_firefox_smoke.py b/mcp/firefox-rdp/tests/manual_firefox_smoke.py
index beb5233..09eb7c6 100644
--- a/mcp/firefox-rdp/tests/manual_firefox_smoke.py
+++ b/mcp/firefox-rdp/tests/manual_firefox_smoke.py
@@ -156,6 +156,15 @@ async def runSmoke(firefox_binary: str) -> dict[str, object]:
actor_id = await waitForTab(rdp, interaction_url)
browser = BrowserSession(config, rdp)
await browser.selectTab(tab_id=actor_id)
+ javascript = await browser.runJavaScript(
+ "document.title",
+ config.request_timeout_ms,
+ )
+ if javascript != {
+ "result": "Interaction fixture",
+ "result_type": "string",
+ }:
+ raise AssertionError("JavaScript result did not match the title.")
webdriver = await rdp.evaluateJson(
browser.selected_tab.console_actor_id,
"(() => JSON.stringify({ok:true,value:{webdriver:"
@@ -236,6 +245,7 @@ async def runSmoke(firefox_binary: str) -> dict[str, object]:
raise AssertionError("File assignment submitted the fixture form.")
return {
"navigator_webdriver": False,
+ "ran_javascript": True,
"filled_and_typed": True,
"pressed_key": True,
"clicked": True,
diff --git a/mcp/firefox-rdp/tests/test_page_scripts.py b/mcp/firefox-rdp/tests/test_page_scripts.py
index 5a6e7a5..a4725c1 100644
--- a/mcp/firefox-rdp/tests/test_page_scripts.py
+++ b/mcp/firefox-rdp/tests/test_page_scripts.py
@@ -80,6 +80,7 @@ class PageScriptsTest(unittest.TestCase):
self.assertIn("const result = await operation();", script)
self.assertIn("result_type:resultType", script)
self.assertIn("code:'javascript_error'", script)
+ self.assertTrue(script.startswith("await (async () =>"))
if __name__ == "__main__":