Skip to content

test: migrate pages handler validation tests to mocks - #2758

Open
dhananjaypai08 wants to merge 1 commit into
ChromeDevTools:mainfrom
dhananjaypai08:test-migrate-pages-handler-validation
Open

dhananjaypai08 wants to merge 1 commit into
ChromeDevTools:mainfrom
dhananjaypai08:test-migrate-pages-handler-validation

Conversation

@dhananjaypai08

Copy link
Copy Markdown

Refs #2639

Summary

  • Move the list_pages handler test and the new_page / navigate_page URL validation tests in tests/tools/pages.test.ts onto createHandlerMocks().
  • Assert the list_pages response flags (setIncludePages, setListThirdPartyDeveloperTools, setListWebMcpTools) and that rejected URLs never call context.newPage or page.pptrPage.goto.
  • Keep the remaining real-browser tests in this file (page close recovery, extensions, dialogs, chrome://newtab/, focus, isolated contexts).

Test plan

  • npm run test tests/tools/pages.test.ts -- --test-name-pattern='list pages$|javascript URL|javascript, data, or vbscript|does not parse|chrome: and chrome-untrusted|chrome-extension: URLs unless'
    • 9/9 passed in ~69ms with PUPPETEER_EXECUTABLE_PATH pointed at a nonexistent binary
  • npm run test tests/tools/pages.test.ts
  • npm run format

@dhananjaypai08
dhananjaypai08 force-pushed the test-migrate-pages-handler-validation branch from d137a5e to 1e9a508 Compare September 23, 2026 23:31
@dhananjaypai08
dhananjaypai08 force-pushed the test-migrate-pages-handler-validation branch from 1e9a508 to aac76f8 Compare September 23, 2026 23:42
@OrKoN
OrKoN self-requested a review September 30, 2026 11:14

@OrKoN OrKoN left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, let's make the following changes:

  1. In tests/tools/pages.test.ts (the --no-javascript-evaluation tests for newPage and navigatePage), rebase on main and pass {javascriptEvaluation: false} directly to createHandlerMocks({javascriptEvaluation: false}) instead of parsing CLI flags. Commit #2861 replaced parseArguments with ConfigParser on main, causing a rebase conflict, and passing the option directly to createHandlerMocks avoids manual argument parsing altogether.

  2. In tests/tools/pages.test.ts, destructure args directly from createHandlerMocks() across the migrated list_pages, newPage, and navigatePage tests instead of repeatedly calling createMockParsedArguments(). createHandlerMocks() already initializes and returns args with default mock options, making the extra createMockParsedArguments() invocations redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants