Skip to content

Worker constructor specification doesn't match browser behaviour for cross-origin URLs #12046

@jdm

Description

@jdm

What is the issue with the HTML Standard?

Testcase, running from a local http server on port 8000:

<script>
const urls = [
  "http://localhost:8001/worker.js",
  "https://example.com/worker.js",
  "file:///tmp/worker.js",
  "chrome://worker.js",
];
for (const url of urls) {
  try {
    let w = new Worker(url);
    w.onerror = (e) => console.log(url + ": asynchronous exception", e);
  } catch(e) {
    console.log(url + ": synchronous exception", e);
  }
}
</script>

Firefox:

chrome://worker.js: synchronous exception
http://localhost:8001/worker.js: asynchronous exception
https://example.com/worker.js: asynchronous exception
file:///tmp/worker.js: asynchronous exception

Chrome & Safari:

http://localhost:8001/worker.js: synchronous exception
w.html:13 https://example.com/worker.js: synchronous exception
w.html:13 file:///tmp/worker.js: synchronous exception
w.html:13 chrome://worker.js: synchronous exception

Servo (per the specification):

chrome://worker.js: asynchronous exception
https://example.com/worker.js: asynchronous exception
file:///tmp/worker.js: asynchronous exception
http://localhost:8001/worker.js: asynchronous exception

This is supposedly tested by https://github.com/web-platform-tests/wpt/blob/a94b364692b80c5cc02634dcb7e4935c76d0ebd7/workers/constructors/Worker/same-origin.html, but I can't figure out why Chrome is reported as failing the tests while Safari apparently passes them. However, when I run the tests in Safari on wpt.live, the expected tests fail just like Chrome.

Firefox's behaviour was pointed out in #2289 (comment), but nobody investigated other browsers as far as I can tell.

This came up because I noticed that sfgate.com creates a worker with chrome://juggler/content (why? who can say?) and other browsers behaved differently than Servo handling that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions