New issue
Advanced search Search tips

Issue 640724 link

Starred by 6 users

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 1
Type: Bug



Sign in to add a comment

Error event inside a worker does not provide the actual exception value

Reported by bzbar...@mit.edu, Aug 24 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:51.0) Gecko/20100101 Firefox/51.0

Example URL:

Steps to reproduce the problem:
1. Load attached testcase.
2. Look at the developer console output.

What is the expected behavior?
The string that gets logged should be "Error".

What went wrong?
The string that gets logged is "null".

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? No Firefox.

Chrome version: 54.0.2837.0 (Official Build) dev (64-bit)  Channel: n/a
OS Version: OS X 10.10
Flash Version: 

WebKit nightly gets this right.

See https://html.spec.whatwg.org/multipage/workers.html#runtime-script-errors-2 which should go to https://html.spec.whatwg.org/multipage/webappapis.html#report-the-error which in step 12 should propagate through the exception value.

The Firefox issue is tracked in https://bugzilla.mozilla.org/show_bug.cgi?id=986459
 
/baz.html
313 bytes View Download
Components: -Blink Blink>Workers
Status: Untriaged (was: Unconfirmed)

Comment 2 by horo@chromium.org, Aug 29 2016

Owner: nhiroki@chromium.org
Status: Assigned (was: Untriaged)
nhiorki@
Can you handle this issue?

Comment 3 by falken@chromium.org, Oct 11 2016

Is this related to Issue 590219?

Comment 4 by bzbar...@mit.edu, Oct 11 2016

Doesn't seem likely: that issue is about the error event seen _outside_ the worker, while this one is for the error event _inside_ the worker.

Comment 5 by falken@chromium.org, Mar 30 2017

Cc: rbasuvula@chromium.org
Issue 706037 has been merged into this issue.

Comment 6 by falken@chromium.org, Mar 30 2017

Cc: jakearchibald@chromium.org
Components: Blink>ServiceWorker
Labels: WorkerPainPaint Hotlist-Google
This is biting people using service workers also.

I'd be interested in seeing if there are WPT tests for this.

Comment 7 by falken@chromium.org, Mar 30 2017

Labels: -WorkerPainPaint WorkerPainPoint
Labels: -Pri-2 -OS-Mac M-59 OS-All Pri-1
Mozilla added a WPT for this in the linked bug: 
https://cs.chromium.org/chromium/src/third_party/WebKit/LayoutTests/external/wpt/workers/Worker_ErrorEvent_error.htm

Considering Mozilla vetted the spec and added this test, looks like we just need to get this test passing.
Status: Started (was: Assigned)
I'm now investigating...
Cc: bashi@chromium.org
bashi@ helped me to investigate this (thank you!) and we found there're two issues here:

1) In WorkerOrWorkletScriptController.cpp, 'ErrorEvent' is created without 'error' attribute[1]. This results in 'e.error == null' in following code:

  // worker.js
  addEventListener("error", function(e) {
    // e.error == null here because the event is created w/o 'error' attribute.
  });
  throw "hello";

2) Currently, Blink's WorkerGlobalScope.idl does not support "OnErrorEventHandler" interface (see foolip@'s comment on [2]). This results in 'e.error == null' in following code:

  // worker.js
  onerror = function(message, location, line, col, error) {
    // error == null here because the idl does not support this callback signature.
  }
  throw "hello";

I think fixing only the case 1) would be enough for real applications, we need to fix the both cases to pass the web-platform-test (Worker_ErrorEvent_error.htm) though.

[1] https://chromium.googlesource.com/chromium/src/+/f98f8cb0517d4b28943102a007528063252e0ce0/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp#326
[2] https://chromium.googlesource.com/chromium/src/+/f98f8cb0517d4b28943102a007528063252e0ce0/third_party/WebKit/Source/core/workers/WorkerGlobalScope.idl#38
Agree that fixing 1) is a good first thing to do.
Cc: nhiroki@chromium.org
Owner: yiyix@chromium.org
yiyix@, do you think you could take a look at 1) on c#10? Probably, we could...

  1) add a new ctor which takes a ScriptValue and assigns it to |m_error|.
  2) pass |state.exception| to the ctor in [1].
  3) add a new layout test for this change (because the wpt test does not work yet at this point)
^^^ 1) add a new ctor *to ErrorEvent* which takes...
Filed a separate issue for 2) "OnErrorEventHandler" ( issue 708857 )
Project Member

Comment 15 by bugdroid1@chromium.org, Apr 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0662e1de8c6d9800c4baed479249c1fa5201c24c

commit 0662e1de8c6d9800c4baed479249c1fa5201c24c
Author: yiyix <yiyix@chromium.org>
Date: Thu Apr 06 14:16:37 2017

Update Error Event inside a worker to provide the exact exception value

In WorkerOrWorkletScriptController.cpp, 'ErrorEvent' used to be created
without exception value, so the exception, |m_error|, is always set to
null. A new constructor of ErrorEvent is added in this patch which
takes exception as input and set |m_error| to the exception value.

TEST=error-script.js and error-worker-script.js

BUG= 640724 

Review-Url: https://codereview.chromium.org/2804533002
Cr-Commit-Position: refs/heads/master@{#462458}

[add] https://crrev.com/0662e1de8c6d9800c4baed479249c1fa5201c24c/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/ServiceWorkerGlobalScope/resources/error-worker.js
[add] https://crrev.com/0662e1de8c6d9800c4baed479249c1fa5201c24c/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/ServiceWorkerGlobalScope/service-worker-error-event.https.html
[add] https://crrev.com/0662e1de8c6d9800c4baed479249c1fa5201c24c/third_party/WebKit/LayoutTests/fast/workers/dedicated-worker-error-event.html
[add] https://crrev.com/0662e1de8c6d9800c4baed479249c1fa5201c24c/third_party/WebKit/LayoutTests/fast/workers/resources/error-script.js
[modify] https://crrev.com/0662e1de8c6d9800c4baed479249c1fa5201c24c/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp
[modify] https://crrev.com/0662e1de8c6d9800c4baed479249c1fa5201c24c/third_party/WebKit/Source/core/events/ErrorEvent.cpp
[modify] https://crrev.com/0662e1de8c6d9800c4baed479249c1fa5201c24c/third_party/WebKit/Source/core/events/ErrorEvent.h

Status: Fixed (was: Started)
Thanks for the fix!

Sign in to add a comment