Uh oh!
There was an error while loading. Please reload this page.
[WIP] Service worker support - #391
Conversation
| attr_reader :cookies | ||
| def initialize(target_id, browser, proxy: nil) | ||
| def initialize(target_id, browser, proxy: nil, type: "page") |
There was a problem hiding this comment.
Do you want me to use Page or create another class for workers?
| @@ -355,13 +356,21 @@ def subscribe | |||
| end | |||
| def prepare_page | |||
There was a problem hiding this comment.
Should I keep everything in this method or split out the worker preparation into a different method?
| connection(**options) | ||
| end | ||
| def build_page(**options) |
There was a problem hiding this comment.
Should I just alias_method this to build?
| sleep(NEW_WINDOW_WAIT) if window? | ||
| end | ||
| def connection(**options) |
There was a problem hiding this comment.
Not sure what the proper naming would be for this if it can be both a page and a worker.
| def page | ||
| @page ||= build_page | ||
| connection if page? |
There was a problem hiding this comment.
Initially I had this return nil if it was a worker because other parts of the code were causing failures otherwise, but not sure what the impact of this is.
There was a problem hiding this comment.
Just an image I came up with on Figma, no particular attachment to it if you'd like something else. I tried a SVG but it didn't work with the createImageBitmap code.
| let canvas = document.getElementById('canvas'); | ||
| let context = canvas.getContext('2d'); | ||
| let imageBitmap = event.data.data; | ||
| context.drawImage(imageBitmap, 0, 0); |
There was a problem hiding this comment.
Drawn to the canvas so the page isn't blank.
| page.go_to("/ferrum/service_worker") | ||
| browser.network.wait_for_idle | ||
| traffic = browser.targets.values.map { _1.network.traffic }.flatten |
There was a problem hiding this comment.
Should the worker bubble up its traffic to its parent page?
route
commented
Aug 24, 2023
I'm now on the road but I'll check your implementation this weekend, I hope by that time I'll be home. |
johncoates-st
commented
Aug 24, 2023
Okay, sounds great! |
route
commented
Sep 11, 2023
@johncoates-st let me first finish new headless mode for Ferrum, as there are architecture changes for the gem since frames don't work like they were. So we might need some changes here as well. |
johncoates-st
commented
Sep 14, 2023
@route Okay, sounds good. What kind of timeline are you thinking for that new headless mode getting merged? |
route
commented
Sep 14, 2023
@johncoates-st it's merged, so I'm fully yours ;) I'll start playing with it today. |
johncoates-st
commented
Sep 14, 2023
@route Great! Looking forward to your feedback |
route
commented
Sep 16, 2023
I think first of all we should address |
route
commented
Jan 6, 2024
The support for flatten mode and auto-attach landed to the main branch. Could you please rebase and now we can continue on service workers. To answer your questions I think it makes more sense not to derive from the Page class. |
johncoates-st
commented
Jan 8, 2024
@route That's great! Okay sounds good, I'll rebase. |
jpheos
commented
Dec 9, 2024
thanks for your work @johncoates-st |
mtomov
commented
Feb 26, 2025
Hi @johncoates-st, thanks for your work on this. Would you have time to look at the changes needed to get this out? Thank you! |
Implementation of:
Hey @route, this is a follow up to our conversation as far as service worker support. I based this PR on your comment:
This is a first draft. I could use a bit more guidance, so I'll leave some notes across the changed files.