W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2011

[Bug 12340] New: It is not clear which worker to use when using nameless SharedWorker

From: <bugzilla@jessica.w3.org>
Date: Sat, 19 Mar 2011 14:10:02 +0000
To: public-webapps@w3.org
Message-ID: <bug-12340-2927@http.www.w3.org/Bugs/Public/>
http://www.w3.org/Bugs/Public/show_bug.cgi?id=12340

           Summary: It is not clear which worker to use when using
                    nameless SharedWorker
           Product: WebAppsWG
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Web Workers (editor: Ian Hickson)
        AssignedTo: ian@hixie.ch
        ReportedBy: Olli.Pettay@gmail.com
         QAContact: member-webapi-cvs@w3.org
                CC: mike@w3.org, public-webapps@w3.org


http://www.w3.org/TR/2011/WD-workers-20110310/#shared-workers-and-the-sharedworker-interface

Step 7.5 is
"If name is not the empty string and there exists a SharedWorkerGlobalScope
object whose closing flag is false, whose name attribute is exactly equal to
name, and whose location attribute represents an absolute URL with the same
origin as scriptURL, then let worker global scope be that
SharedWorkerGlobalScope object."

7.6. is 
"Otherwise, if name is the empty string and there exists a
SharedWorkerGlobalScope object whose closing flag is false, and whose location
attribute represents an absolute URL that is exactly equal to scriptURL, then
let worker global scope be that SharedWorkerGlobalScope object."

7.8 is
"Create a new SharedWorkerGlobalScope object. Let worker global scope be this
new object."


Example web page is
<script>
  var sw1 = new SharedWorker("worker.js", "1");
  sw1.port.onmessage = function(e) { alert("sw1: " + e.data); }
  var sw2 = new SharedWorker("worker.js", "2");
  sw2.port.onmessage = function(e) { alert("sw2: " + e.data); }
  var sw3 = new SharedWorker("worker.js");
  sw3.port.onmessage = function(e) { alert("sw3: " + e.data); }
</script>

and worker 
onconnect = function(e) {
  var port = e.ports[0];
  port.postMessage("worker name: " + name);
}

Since sw1 and sw2 have different names, they get separate workers per 7.5 and
7.8.

Because sw3 doesn't have name, 7.6 applies. Both sw1 and sw2 fulfill the
criteria of a worker
whose closing flag is false and location attribute is the same as sw3's
location, so sw3 is
connected randomly to either one of those workers.
That is very strange.


Opera seems to implement what the spec says, Chrome creates a new worker for
sw3.

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
Received on Saturday, 19 March 2011 14:10:04 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:43 GMT