mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-18 22:35:22 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b396368ba |
@@ -368,6 +368,29 @@ async function waitForGuestActiveElement(client, browserId, elementId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// A wait whose condition never matches must say which condition expired, not blame the host.
|
||||
async function verifyExpiredWaitNamesItsCondition(client, targetUrl) {
|
||||
const created = await callBrowserTool(client, "browser_new_tab", { url: targetUrl });
|
||||
const browserId = created.browserId;
|
||||
assert(typeof browserId === "string", "browser_new_tab returned no browserId for the wait page");
|
||||
try {
|
||||
await callBrowserTool(client, "browser_wait", { browserId, text: "Bridge target" });
|
||||
// The page title is not body text, so this wait expires.
|
||||
const response = await client.callTool({
|
||||
name: "browser_wait",
|
||||
args: { browserId, text: "Desktop browser target", timeoutMs: 1_000 },
|
||||
});
|
||||
const text = response.content?.[0]?.text;
|
||||
assert(
|
||||
response.structuredContent?.ok === false &&
|
||||
text === "Timed out waiting for browser text: Desktop browser target",
|
||||
`browser_wait did not name its expired condition: ${JSON.stringify(response.content)}`,
|
||||
);
|
||||
} finally {
|
||||
await callBrowserTool(client, "browser_close_tab", { browserId });
|
||||
}
|
||||
}
|
||||
|
||||
// A page whose Content Security Policy omits 'unsafe-eval' refuses eval(); the tools must still work.
|
||||
async function verifyEvaluateOnPageWithoutUnsafeEval(client, targetUrl) {
|
||||
const created = await callBrowserTool(client, "browser_new_tab", {
|
||||
@@ -791,6 +814,7 @@ async function runRegression({
|
||||
|
||||
await verifyReactFormFill((name, args) => callBrowserTool(client, name, args), targetUrl);
|
||||
await verifyEvaluateOnPageWithoutUnsafeEval(client, targetUrl);
|
||||
await verifyExpiredWaitNamesItsCondition(client, targetUrl);
|
||||
|
||||
const created = await callBrowserTool(client, "browser_new_tab", { url: targetUrl });
|
||||
const browserId = created.browserId;
|
||||
|
||||
@@ -800,7 +800,8 @@ describe("BrowserToolsBroker", () => {
|
||||
ok: false,
|
||||
error: {
|
||||
code: "browser_timeout",
|
||||
message: "Browser automation timed out after 50ms.",
|
||||
message:
|
||||
"The browser host did not respond within 50ms. Try again or check the browser host.",
|
||||
retryable: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -422,7 +422,7 @@ export class BrowserToolsBroker {
|
||||
browserToolsFailure({
|
||||
requestId: request.requestId,
|
||||
code: "browser_timeout",
|
||||
message: `Browser automation timed out after ${timeoutMs}ms.`,
|
||||
message: `The browser host did not respond within ${timeoutMs}ms. Try again or check the browser host.`,
|
||||
retryable: true,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -481,14 +481,41 @@ const brokerErrorCases = [
|
||||
ok: false,
|
||||
error: {
|
||||
code: "browser_timeout",
|
||||
message: "Browser automation timed out after 15000ms.",
|
||||
message:
|
||||
"The browser host did not respond within 15000ms. Try again or check the browser host.",
|
||||
retryable: true,
|
||||
},
|
||||
},
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "The browser did not respond before the timeout. Try again or check the browser host.",
|
||||
text: "The browser host did not respond within 15000ms. Try again or check the browser host.",
|
||||
},
|
||||
],
|
||||
context: {
|
||||
agentId: "agent-1",
|
||||
cwd: "/repo",
|
||||
workspaceId: "wks_workspace_a",
|
||||
browserId: BROWSER_ID,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "expired wait conditions",
|
||||
toolName: "browser_wait",
|
||||
input: { browserId: BROWSER_ID, text: "Example Domain" },
|
||||
payload: {
|
||||
requestId: "req-wait",
|
||||
ok: false,
|
||||
error: {
|
||||
code: "browser_timeout",
|
||||
message: "Timed out waiting for browser text: Example Domain",
|
||||
retryable: true,
|
||||
},
|
||||
},
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Timed out waiting for browser text: Example Domain",
|
||||
},
|
||||
],
|
||||
context: {
|
||||
@@ -897,7 +924,7 @@ describe("registerBrowserTools", () => {
|
||||
expect(response.content).toEqual([
|
||||
{
|
||||
type: "text",
|
||||
text: 'The browser did not respond before the timeout. Try again or check the browser host.\nHandled browser dialog: dismissed beforeunload "Leave site?".',
|
||||
text: 'Timed out waiting for browser URL: /next\nHandled browser dialog: dismissed beforeunload "Leave site?".',
|
||||
},
|
||||
]);
|
||||
expect(response.structuredContent).toEqual({
|
||||
|
||||
@@ -1039,14 +1039,6 @@ function summarizeBrowserError(
|
||||
switch (error.code) {
|
||||
case "browser_disabled":
|
||||
return "Browser tools are disabled. Enable browser tools on the host, then try again.";
|
||||
case "browser_no_host":
|
||||
return error.message;
|
||||
case "browser_timeout":
|
||||
return "The browser did not respond before the timeout. Try again or check the browser host.";
|
||||
case "screenshot_no_frame":
|
||||
return error.message;
|
||||
case "browser_unsupported":
|
||||
return error.message;
|
||||
case "browser_stale_ref":
|
||||
return "That browser element reference is stale. Take a new browser snapshot and try again.";
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user