-
Notifications
You must be signed in to change notification settings - Fork 313
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
Sharing scope with manifests #137
Comments
In particular, if the scope is not going to be origin, we need some way of making sure all kinds of APIs know what the scope is for a given URL (and therefore what manifest, worker, etc. apply to it). |
here's an example manifest in a format I've made up: {
"name": "Acme Example",
"description": "...",
"developer": {
"name": "Acme Corp.",
"url": "http://acme.com/example"
}
"icons": { "128": "/example/assets/images/v1/icon_128.png", ... },
"launch_path": "http://acme.com/example",
"service_worker": {
"scope": "/example/*",
"url": "http://acme.com/example/controller.js"
},
"content_security_policy":
"default-src 'self'; sandbox; ...",
"requested_permissions": {
"alarms": "synchronize data in the background",
"push": "notify you of important product announcements",
"...", "..."
},
} The scope here mirrors what the app itself would register: // http://acme.com/example/app.manifest
navigator.registerServiceWorker("/example*", "/example/controller.js").then(..., ...); And here's a page that both registers an SW and includes a reference to the manifest: <!DOCTYPE html>
<html>
<head>
<meta http-equiv="manifest" content="/example/app.manifest">
<script>
navigator.registerServiceWorker("/example*", "/example/assets/v1/ctrl.js").then(...);
</script>
</head>
<body>...</body>
</html> Now, of course, these could have different registrations. The SW that the page registers could include an SW for a different scope, or it could point to a different URL. The question is what to do in the various scenarios.
What becomes really interesting here is the question of alternative browsing contexts. It's possible to imagine that UAs that do something with the manifest will launch content via them in a separate browsing content (separate storage partition, profile, etc.). In that case, identical registrations will cause separate installs -- however they wouldn't necessarily be visible to each other, reducing confusion. I think this is perhaps the best solution for UAs when "keeping" apps they discover to have manifests. Does that cover all the questions you had, @annevk & @marcoscaceres? |
Well, it's an idea. I'm not sure I like it though as it has race conditions and the potential for trivial errors. I would prefer something that was more centralized. |
Does it even make sense for manifests and ServiceWorkers to share the same scope? What if you want mutliple ServiceWorkers for one app, or even multiple apps (on the same origin) which share the same ServiceWorker? How would you define the scope of an app which has no ServiceWorkers? I can see it makes sense to enumerate ServiceWorkers in the manifest so that they can be registered when the app is bookmarked/installed, and the manifest scope could work in much the same way as ServiceWorker scope, but I'm not sure they can be the same thing? See also w3c/manifest#114 |
Fair point. I guess SW <> app is not necessarily 1:1. I was sort of expecting that to be the goal, but maybe we should not enforce that. |
If we have manifests, it would be great if they had the same scope as their app worker. How do we do that?
@marcoscaceres
The text was updated successfully, but these errors were encountered: