-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
Cannot intercept requests from dynamically-created frame , can anyone help ? #1006
Comments
The frame create like this
|
I think this issue relative to w3c/ServiceWorker#765 |
Hey, @hzzcc. What is your expected behavior? What request are we speaking about? Could you please provide more details? |
Here is the repo, run |
Hey, @hzzcc. Thank you for putting together a reproduction repository. Root causeThe issue itself is related to how sandboxed iframes inherit the service worker from the parental scope (see w3c/ServiceWorker#765 and w3c/ServiceWorker#1390). According to the W3C decision, such iframes must inherit the worker and be listed in its clients. That, however, doesn't happen. This inheritance is required in order for the worker to know that it should control the nested iframe. Without it, the worker doesn't know that the iframe emits any requests and, thus, cannot catch them. That's why you don't get the This may be related to the browser not implementing this inheritance, like this Chromium bug. SolutionThere's nothing we can do on the library's side to facilitate this. The service worker behavior implementation is the browser's responsibility. We operate on the higher level, on the already implemented worker spec. Unfortunately, using the iframe scenario like yours isn't possible at the moment due to how browsers implement worker inheritance for such iframes. You should be able to have request interception in iframes if you use the <iframe title="frame" src="./frame.html"></iframe> Requests from such nested iframe will be caught and mocked because the |
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: