这是indexloc提供的服务,不要输入任何密码
Skip to content

Define an active service worker for a srcdoc/blank iframe - take 2 #3725

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 1 commit into
base: main
Choose a base branch
from

Conversation

yoavweiss
Copy link
Contributor

@yoavweiss yoavweiss commented May 30, 2018

I'm switching to a new PR as GH doesn't enable me to change branches :/
This is a continuation of #3714 which closes w3c/ServiceWorker#765.

/cc @annevk @domenic @wanderview


💥 Error: Wattsi server error 💥

PR Preview failed to build. (Last tried on Jan 15, 2021, 7:58 AM UTC).

More

PR Preview relies on a number of web services to run. There seems to be an issue with the following one:

🚨 Wattsi Server - Wattsi Server is the web service used to build the WHATWG HTML spec.

🔗 Related URL

Command failed: /home/noderunner/wattsi/bin/wattsi /tmp/upload_d543357cc1f894b1ddc6806c90d42c6c (sha not provided) rlh4mjlmf99 default /tmp/upload_5bb277c0994b0c37cbf69ccfbb795be2

If you don't have enough information above to solve the error by yourself (or to understand to which web service the error is related to, if any), please file an issue.

@yoavweiss
Copy link
Contributor Author

Following @zetafunction's comments on #3714 (comment), it seems like there are multiple different cases here that need to be handled (assuming that active service worker and origin should always be in sync):

  • srcdoc iframe document's origin is always the same as the parent.
  • about:blank documents seems to vary based on whether they are "initial" vs. "non-initial". For "non-initial", it may differ if "script was involved". TBH, I'm not 100% sure what that means.
  • javascript: documents - I think it means that they inherit the origin from the about:blank document that they navigated, but would love confirmation that I'm reading it right.
  • data: URLs are always an opaque origin, so we should make sure that their subresources (if any) would not be intercepted. (That probably already happens, just need to avoid breaking it)

It was also pointed out by @kinu that we need to make sure we take the iframe's sandbox attribute into account.

@wanderview
Copy link
Member

@yoavweiss We probably need to try to write some test cases for each one so we can reason about them. I also am not sure all the cases for "non-initial about:blank".

Also, there are blob: URLs which inherit their origin from the window that called URL.createObjectURL(). There is an open spec issue about where the service worker should be inherited from, though. See w3c/ServiceWorker#1261.

There are some tests for initial about:blank and about:srcdoc here:

https://github.com/web-platform-tests/wpt/blob/master/service-workers/service-worker/about-blank-replacement.https.html

There are some tests with data and blob URLs in here:

https://github.com/web-platform-tests/wpt/blob/master/service-workers/service-worker/local-url-inherit-controller.https.html

Looks like we need to add non-initial about:blank and javascript: URL testing.

@wanderview
Copy link
Member

I asked around a bit regarding "non-initial about:blank". Some cases to consider:

  • iframe A triggers the navigation of iframe B using <a target="B" href="about:blank">. That should result in an iframe B with iframe A's origin.
  • iframe A can use parent[indexOfB].location = "about:blank". This should also result in an iframe B with iframe A's origin.
  • iframe B could set its own location to "about:blank". In this case it should preserve its own origin.

Does that sound right @annevk?

An open question is if we should always inherit the service worker controller from the parent or from the source of the origin inheritance. There is some discussion of this in w3c/ServiceWorker#1261.

@yoavweiss
Copy link
Contributor Author

Is there some way that we can sync the active service worker with the origin without handling all those cases one by one? I'm afraid that doing the latter might be error-prone and hard to maintain. We can do it if there's no alternative, but it might be worth while to try to come up with one

@wanderview
Copy link
Member

I think it would be wonderful to have a "inherit stuff" algorithm that brought forward origin, service worker controller, etc. Maybe it would include stuff like CSP as well, etc. Then specs could just be written to "inherit stuff" and it would get everything.

The question is, do we currently inherit everything consistently today? And if we don't, can we align them all to inherit consistently?

This definitely seems like a bigger set of refactoring to the spec, though.

@monica-ch
Copy link

@yoavweiss Are you working on this? If not, is that okay If i take over it to complete.

@yoavweiss
Copy link
Contributor Author

@yoavweiss Are you working on this? If not, is that okay If i take over it to complete.

I'm not actively working on this. Thanks for taking it on! :)

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

Successfully merging this pull request may close these issues.

serviceworker for iframes with srcdoc
3 participants