Bug 27515 - Implement AbstractWorker::dispatchScriptErrorEvent by generating an ErrorEvent.
Summary: Implement AbstractWorker::dispatchScriptErrorEvent by generating an ErrorEvent.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Jian Li
URL:
Keywords:
Depends on:
Blocks: 27525
  Show dependency treegraph
 
Reported: 2009-07-21 13:49 PDT by Jian Li
Modified: 2009-07-21 20:22 PDT (History)
2 users (show)

See Also:


Attachments
Proposed Patch (1.63 KB, patch)
2009-07-21 14:00 PDT, Jian Li
levin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jian Li 2009-07-21 13:49:53 PDT
Implement AbstractWorker::dispatchScriptErrorEvent by generating an ErrorEvent.
Comment 1 Jian Li 2009-07-21 14:00:04 PDT
Created attachment 33211 [details]
Proposed Patch
Comment 2 Jian Li 2009-07-21 14:48:13 PDT
This is to adhere to the latest Web Worker spec (http://www.whatwg.org/specs/web-workers/current-work/#runtime-script-errors):

  When the user agent is to fire a worker error event at a Worker object, it must dispatch an event that uses the ErrorEvent interface, with the name error, that doesn't bubble and is cancelable, with its message, filename, and lineno attributes set appropriately.

I will have other patch that will fix the error handling flow in WorkerContext and Worker.
Comment 3 David Levin 2009-07-21 16:42:24 PDT
> I will have other patch that will fix the error handling flow in WorkerContext
and Worker.
Please file a bug for this.
Comment 4 David Levin 2009-07-21 17:25:04 PDT
Comment on attachment 33211 [details]
Proposed Patch

Please do a variable name change below before landing.


> +void AbstractWorker::dispatchScriptErrorEvent(const String& message, const String& sourceURL, int lineNumber)
>  {
> +    RefPtr<ErrorEvent> evt = ErrorEvent::create(message, sourceURL, static_cast<unsigned>(lineNumber));

Use full words, except in the rare case where an abbreviation would be more canonical and easier to understand.
s/evt/event/

> +    if (m_onErrorListener) {
> +        evt->setTarget(this);
> +        evt->setCurrentTarget(this);
> +        m_onErrorListener->handleEvent(evt.get(), true);
> +    }
> +
> +    ExceptionCode ec = 0;
> +    dispatchEvent(evt.release(), ec);
> +    ASSERT(!ec);
>  }
>  
>  } // namespace WebCore
Comment 5 Jian Li 2009-07-21 17:44:19 PDT
Committed as http://trac.webkit.org/changeset/46203
Comment 6 Sam Weinig 2009-07-21 18:59:18 PDT
This should really have a test case.  Is there a reason this cannot be tested?
Comment 7 Jian Li 2009-07-21 20:22:32 PDT
(In reply to comment #6)
> This should really have a test case.  Is there a reason this cannot be tested?

This is the first patch towards fixing error handling in workers. It can not be tested before completing the changes for 27525. I will add test cases in dealing with 27525.