Skip to content

add tests for request interception #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

karlseguin
Copy link
Contributor

@krichprollsch
Copy link
Member

krichprollsch commented Aug 19, 2025

I'm adding a test with chromedp. I try to fillfull an XHR response for the reviews, but it doesn't work for now.
The script blocks and timeout. I'm trying to understand where the issue is, it could be due to my chromedp usage.

$ cd chromedp
$ go run  ri/main.go -verbose http://127.0.0.1:1234/campfire-commerce/
[...]
INTERCEPT-4 http://127.0.0.1:1234/campfire-commerce/json/reviews.json
2025/08/19 14:58:22 -> {"id":19,"sessionId":"SID-1","method":"Fetch.fulfillRequest","params":{"requestId":"INTERCEPT-4","responseCode":200,"body":"[\"alter review\"]"}}
2025/08/19 14:58:22 -> {"id":20,"sessionId":"SID-1","method":"DOM.getDocument","params":{"pierce":false}}
2025/08/19 14:58:22 <- {"id":18,"result":{},"sessionId":"SID-1"}
2025/08/19 14:58:22 <- {"id":19,"code":-31998,"message":"InvalidCharacter"}
get reviews: context canceled
exit status 1
[...]
DEBUG http : request start . . . . . . . . . . . . . . . . .  [+403.601s]
      method = GET
      url = http://127.0.0.1:1234/campfire-commerce/json/product.json
      source = xhr

* Reusing existing http: connection with host 127.0.0.1
> GET /campfire-commerce/json/product.json HTTP/1.1
Host: 127.0.0.1:1234
Accept: */*
Accept-Encoding: deflate, gzip
Cookie: left=right
User-Agent: Lightpanda/1.0

* Request completely sent off
DEBUG cdp : request intercept . . . . . . . . . . . . . . . . [+403.601s]
      state = fulfilled
      id = 4
      url = http://127.0.0.1:1234/campfire-commerce/json/reviews.json
      status = 200
      body = true

INFO  app : client disconnected . . . . . . . . . . . . . . . [+403.601s]

DEBUG script_event : dispatch event . . . . . . . . . . . . . [+403.601s]
      type = readystatechange
      source = xhr
      method = GET
      url = http://127.0.0.1:1234/campfire-commerce/json/product.json

DEBUG script_event : dispatch progress event . . . . . . . .  [+403.601s]
      type = abort
      source = xhr
      method = GET
      url = http://127.0.0.1:1234/campfire-commerce/json/product.json

DEBUG script_event : dispatch progress event . . . . . . . .  [+403.601s]
      type = loadend
      source = xhr
      method = GET
      url = http://127.0.0.1:1234/campfire-commerce/json/product.json

DEBUG http : error . . . . . . . . . . . . . . . . . . . . .  [+403.601s]
      url = http://127.0.0.1:1234/campfire-commerce/json/product.json
      err = Abort
      source = xhr.OnErr

* closing connection #4
DEBUG browser : remove page . . . . . . . . . . . . . . . . . [+403.602s]

DEBUG app : accepting connection . . . . . . . . . . . . . .  [+403.605s]

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