The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.
JavaScript agent-skillsai-agentautomationbrowserbrowser-automationclaude-codecodexhermes-agentskillsskills-sh
docs(ego-browser): state that waitForFunction resolves to true
Joway@MacMini4afcddf59291
diff --git a/package/ego-browser/skill-body/SKILL.md b/package/ego-browser/skill-body/SKILL.mdindex f330a10..756bc8e 100644--- a/package/ego-browser/skill-body/SKILL.md+++ b/package/ego-browser/skill-body/SKILL.md@@ -281,12 +281,13 @@ matches in the top document before searching frames.`waitForLoadState()` defaults to `load`. `waitForFunction()` follows thePlaywright argument order; pass `undefined` before options when there is no Page-argument:+argument. Unlike Playwright, it resolves to `true`, not the predicate's value:```jsawait page.waitForFunction(() => window.appReady, undefined, {timeout: 10_000,});+const ready = await page.evaluate(() => window.appReady);``````jsdiff --git a/package/ego-browser/src/page-model.test.mjs b/package/ego-browser/src/page-model.test.mjsindex 738ae90..4a6bc40 100644--- a/package/ego-browser/src/page-model.test.mjs+++ b/package/ego-browser/src/page-model.test.mjs@@ -10,6 +10,7 @@ import {} from "node:fs/promises";import { tmpdir } from "node:os";import { dirname, join } from "node:path";+import { runInNewContext } from "node:vm";import { NativeOperationGate } from "../dist/src/native-gate.js";import {@@ -1358,6 +1359,45 @@ test("Page.waitForFunction polls one Page with one JSON argument", async () => {});});+test("Page.waitForFunction resolves to true, not the predicate's value", async () => {+ await withFixture(async (fixture) => {+ const baseCdp = fixture.services.cdp;+ const task = taskForRound(fixture, "round-a", {+ // Run the real probe, because the shared fixture answers it with a+ // canned `matched` and would not exercise the coercion.+ async cdp(method, params, sessionId, timeoutMs) {+ if (+ method === "Runtime.evaluate" &&+ params.expression.includes("__egoWaitForFunction")+ ) {+ const value = await runInNewContext(params.expression, {+ location: { href: "https://example.test/wait" },+ document: { title: "wait" },+ });+ return { result: { type: "object", value } };+ }+ return baseCdp(method, params, sessionId, timeoutMs);+ },+ });+ const page = await openTestPage(task, "https://example.test/wait");++ for (const predicate of [+ () => "loaded",+ () => ({ status: "ok" }),+ () => 42,+ async () => "loaded",+ "'loaded'",+ "({ status: 'ok' })",+ ]) {+ assert.equal(await page.waitForFunction(predicate), true);+ }+ await assert.rejects(+ () => page.waitForFunction(() => 0, undefined, { timeout: 60 }),+ /page\.waitForFunction timed out after 60ms/,+ );+ });+});+test("Page.waitForFunction validates input and reports its timeout", async () => {await withFixture(async (fixture) => {const task = taskForRound(fixture, "round-a");diff --git a/package/ego-browser/src/page-model.ts b/package/ego-browser/src/page-model.tsindex b364ec9..db7f59d 100644--- a/package/ego-browser/src/page-model.ts+++ b/package/ego-browser/src/page-model.ts@@ -2282,7 +2282,11 @@ class Page {return this.#evaluate(expression, hasArgument, argument, true);}- /** Wait until a Page expression returns a truthy value. */+ /**+ * Wait until a Page expression returns a truthy value. Resolves to `true`,+ * not that value, and throws on timeout; read Page state afterwards with+ * `page.evaluate()`.+ */async waitForFunction(expression: string | ((argument: any) => unknown | Promise<unknown>),argument?: unknown,diff --git a/package/ego-browser/src/public-api-schema.test.mjs b/package/ego-browser/src/public-api-schema.test.mjsindex c95ab5b..7840e40 100644--- a/package/ego-browser/src/public-api-schema.test.mjs+++ b/package/ego-browser/src/public-api-schema.test.mjs@@ -51,6 +51,14 @@ test("the public API schema contains the v2 entry points and object methods", ()assert.equal(names.has("Page.scrollBy"), false);});+test("Page.waitForFunction documents what it resolves to", () => {+ const { summary } = PUBLIC_API_SCHEMA.find(+ (entry) => entry.name === "Page.waitForFunction",+ );+ assert.match(summary, /resolves? to true, not (that|the predicate's) value/i);+ assert.match(summary, /page\.evaluate\(\)/);+});+test("schema-driven option validation rejects unknown and invalid fields", () => {validatePublicApiOptions("taskSpace", { profileId: "Profile 2" });validatePublicApiOptions("Page.click", {diff --git a/package/ego-browser/src/public-api-schema.ts b/package/ego-browser/src/public-api-schema.tsindex f5ee9b9..6bb7184 100644--- a/package/ego-browser/src/public-api-schema.ts+++ b/package/ego-browser/src/public-api-schema.ts@@ -371,7 +371,8 @@ export const PUBLIC_API_SCHEMA: readonly PublicApiEntry[] = [name: "Page.waitForFunction",signature:"await page.waitForFunction(fnOrString, argument?, { timeout?, polling? })",- summary: "Wait until a Page function or expression returns a truthy value.",+ summary:+ "Wait until a Page function or expression returns a truthy value; resolves to true, not that value, and throws on timeout. Read Page state afterwards with page.evaluate().",options: {timeout,polling: option(