feat: support allowedUrlPattern & blockedUrlPattern Options#2037
feat: support allowedUrlPattern & blockedUrlPattern Options#2037nattallius wants to merge 11 commits into
Conversation
b5eca0f to
788efce
Compare
f537e11 to
998d4be
Compare
| }, | ||
| { | ||
| blockedUrlPattern: [server.getRoute('/blocked.html')], | ||
| executablePath: process.env.CHROME_M149_EXECUTABLE_PATH, |
There was a problem hiding this comment.
block list should not need M149, right?
There was a problem hiding this comment.
No, it also fails if runs against stable
703ef62 to
eab8536
Compare
| }, | ||
| { | ||
| blockedUrlPattern: [server.getRoute('/blocked.html')], | ||
| executablePath: process.env.CHROME_M149_EXECUTABLE_PATH, |
There was a problem hiding this comment.
blocklist should not need M149?
b90f3a7 to
57c0f95
Compare
57c0f95 to
6f1034f
Compare
Lightning00Blade
left a comment
There was a problem hiding this comment.
LGTM with some small comment and questions.
| }); | ||
| } | ||
|
|
||
| const chromePath = _installChrome('149.0.7827.14'); |
There was a problem hiding this comment.
Do we need this this is already stable https://chromestatus.com/roadmap
And that is the version pinned by Puppeteer.
| await page.emulateNetworkConditions(networkCondition); | ||
| newSettings.networkConditions = options.networkConditions; | ||
| // Skip network emulation if blocklist/allowlist is configured, as it is rejected by Puppeteer. | ||
| if (!this.#options.hasNetworkBlockOrAllowlist) { |
There was a problem hiding this comment.
Should we throw if we try to set emulation? Reason is I try to emulate network conditions and this just silently ignores it, an LLM most likely will be confused.
| await fetch(url); | ||
| return 'SUCCESS'; | ||
| } catch (err) { | ||
| return err instanceof Error ? err.message : String(err); |
There was a problem hiding this comment.
Nit: We can just return true or false as the message may change.
|
|
||
| it( | ||
| 'blocks URLs not in allowlist', | ||
| {skip: 'Requires Chrome 149 or greater'}, |
There was a problem hiding this comment.
Is this also still needed?
| [ | ||
| 'node', | ||
| 'main.js', | ||
| '--blocked-url-pattern=https://a.com/*', |
There was a problem hiding this comment.
Can you double check if '--blocked-url-pattern', '<pattern-1>', <pattern-2> works? I think that is also valid CLI args.
| function: `async () => { | ||
| try { | ||
| await fetch("${blockedUrl}"); | ||
| return 'SUCCESS'; |
There was a problem hiding this comment.
Same here. we can use true/false.
| ); | ||
| }, | ||
| { | ||
| blockedUrlPattern: [server.getRoute('/blocked.html')], |
There was a problem hiding this comment.
This was confusingly at the end we should move it to the start, some where easier to find.
| }, | ||
| { | ||
| allowedUrlPattern: [server.getRoute('/allowed.html')], | ||
| executablePath: process.env.CHROME_M149_EXECUTABLE_PATH, |
No description provided.