Open Bug 1434966 Opened 6 years ago Updated 2 years ago

Need to report worker load failures usefully

Categories

(Core :: DOM: Workers, defect, P2)

defect

Tracking

()

People

(Reporter: bzbarsky, Unassigned)

Details

STEPS TO REPRODUCE:

1)  Open web console.
2)  Load https://bug1085060.bmoattachments.org/attachment.cgi?id=8507482
3)  Click "Test Worker Thread"

EXPECTED RESULTS: Error in console about cross-origin worker load.

ACTUAL RESULTS: Nothing happens; no worker running, no messages.

Chrome's console says:

Uncaught DOMException: Failed to construct 'Worker': Script at 'https://bug1085060.bugzilla.mozilla.org/attachment.cgi?id=8507477' cannot be accessed from origin 'https://bug1085060.bmoattachments.org'.
Firefox 40 gives a not very informative SecurityError in the console, but at least it gives _something_.
Priority: -- → P2
So we're landing in ReportCompileErrorRunnable::WorkerRun, which fires a simple event named "error" at the Worker, and then does nothing else.

Compare how WorkerErrorReport::ReportError works: it reports to console, etc.

Looking at the spec, https://html.spec.whatwg.org/multipage/workers.html#run-a-worker step 13 says:

  If the algorithm asynchronously completes with null, queue a task to fire an event
  named error at worker, and return.

Which is fine as far as it goes, but it still feels like we should report to console somehow...

I did check, and in Chrome if I preventDefault the "error" event here that does _not_ affect the console report.

I haven't tested what happens if there is an actual script error in the script; I would hope we do report that....
Ah, yes, we only use ReportCompileErrorRunnable if CompileScriptRunnable::WorkerRun has a failure that's not a JS exception.

This bit:

    if (rv.Failed() && !rv.IsJSException()) {
      ReportCompileErrorRunnable::CreateAndDispatch(aCx, aWorkerPrivate);
      rv.SuppressException();

in CompileScriptRunnable::WorkerRun doesn't send along any info from "rv" to the ReportCompileErrorRunnable.  Looking at rv at this point, it's a DOMException with the message:

  Failed to load worker script at "https://bug1085060.bmoattachments.org/attachment.cgi?id=8507477"

and 0x80530012 as the nsresult.  That's NS_ERROR_DOM_SECURITY_ERR.

So we have decent data here and we're just failing to ship it over to mainthread and report it.
Type: defect → task

Fwiw, bug 1602090 least restored the state described in comment 1, where we now report:

Security Error: Content at https://bug1085060.bmoattachments.org/attachment.cgi?id=8507482 may not load data from https://bug1085060.bugzilla.mozilla.org/attachment.cgi?id=8507477.

but that still doesn't say anything about workers.

And I disagree about this being a "task" instead of a "defect": it directly impacts web developers' ability to debug in Firefox!

Type: task → defect
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.