This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 19491 - There doesn't appear to be a way to create a worker by name. SharedWorker constructor requires always providing a correct URL.
Summary: There doesn't appear to be a way to create a worker by name. SharedWorker con...
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-12 01:04 UTC by contributor
Modified: 2013-01-29 00:48 UTC (History)
9 users (show)

See Also:


Attachments

Description contributor 2012-10-12 01:04:27 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html
Multipage: http://www.whatwg.org/C#shared-workers
Complete: http://www.whatwg.org/c#shared-workers

Comment:
There doesn't appear to be a way to create a worker by name. SharedWorker
constructor requires always providing a correct URL.

Posted from: 17.245.107.141
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14
Comment 1 Alexey Proskuryakov 2012-10-12 01:05:31 UTC
There is non-normative text that implies that this should be possible: "Shared workers are identified in one of two ways: either by the URL of the script used to create it, or by explicit name. When created by name, the URL used by the first page to create the worker with that name is the URL of the script that will be used for that worker. This allows multiple applications on a domain to all use a single shared worker to provide a common service, without the applications having to keep track of a common URL for the script used to provide the service."
Comment 2 Ian 'Hixie' Hickson 2012-10-17 23:11:29 UTC
Well you have to provide a URL so that if the shared worker doesn't exist, it can be started, but as far as I can tell what is suggested above works fine. Can you elaborate on what you want to do but can't do?
Comment 3 Alexey Proskuryakov 2012-10-18 05:39:34 UTC
Well, it's just what is quoted from the spec in comment 2: "This allows multiple applications on a domain to all use a single shared worker to provide a common service, without the applications having to keep track of a common URL for the script used to provide the service"

This is not what name is for - AFAICT is sole purpose is to create multiple workers from the same source, not to use a single one without knowing its URL.
Comment 4 Ian 'Hixie' Hickson 2012-10-18 18:46:20 UTC
As far as I can tell, the purpose is to let multiple applications on the same origin share a common service, with each application having their own copy of the service's script so that you don't need to put the service in its own URL space and give that URL to everyone, instead each app can just launch it with their own copy of the service's script and whichever one is launched first is the one that is used in case multiple apps try to launch it in turn.
Comment 5 Alexey Proskuryakov 2012-10-18 20:03:04 UTC
Step 7.1 says: "If worker global scope's location attribute represents an absolute URL that is not exactly equal to scriptURL, then throw a URLMismatchError exception and abort all these steps."

So, we'll just get an exception in this scenario.
Comment 6 Ian 'Hixie' Hickson 2012-10-19 20:06:38 UTC
Ah, yes, missed that. You're saying you want that removed? So long as it's same-origin, it should work?

(That's actually the last mention of URLMismatchError, so if we remove that we can also drop that error code.)


Anyone else have an opinion? Should it be possible for two different attempts to start a shared worker to get the same worker even though they used different URLs?
Comment 7 Alexey Proskuryakov 2012-10-19 20:35:45 UTC
I don't care much. Slightly less work if this doesn't need to be supported.
Comment 8 Olli Pettay 2013-01-29 00:31:39 UTC
I think I'd prefer requiring the same URL.
That would lead less surprising results - the "service" ends up running 
the same script always.
Comment 9 contributor 2013-01-29 00:48:58 UTC
Checked in as WHATWG revision r7663.
Check-in comment: Make tutorial match actual requirements.
http://html5.org/tools/web-apps-tracker?from=7662&to=7663