Closed Bug 473861 Opened 15 years ago Closed 15 years ago

Workers: Using functions (rather than attributes) for message/error handlers doesn't work

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.1

People

(Reporter: bent.mozilla, Assigned: bent.mozilla)

Details

(Keywords: fixed1.9.1)

Attachments

(1 file)

Attached patch Patch, v1Splinter Review
Workers currently must use this syntax for the message/error handlers:

  onmessage = function(event) { ... }

It would be cooler if they could also do this:

  function onmessage(event) { ... }

Patch attached that does this. And it has tests!
Attachment #357271 - Flags: superreview?(jst)
Attachment #357271 - Flags: review?(jst)
Attachment #357271 - Flags: approval1.9.1?
Attachment #357271 - Flags: approval1.9.1? → approval1.9.1+
Comment on attachment 357271 [details] [diff] [review]
Patch, v1

>diff --git a/dom/src/threads/nsDOMWorker.cpp b/dom/src/threads/nsDOMWorker.cpp
>+  JSObject* funObj;
>+  if (!(JSVAL_IS_STRING(aId) &&
>+        JSVAL_IS_OBJECT(*aVp) &&
>+        (funObj = JSVAL_TO_OBJECT(*aVp)) &&
>+        JS_ObjectIsFunction(aCx, funObj))) {

Nit: This line is under-indented by one space.

r+sr=mrbkap with that.
Attachment #357271 - Flags: superreview?(jst)
Attachment #357271 - Flags: superreview+
Attachment #357271 - Flags: review?(jst)
Attachment #357271 - Flags: review+
(In reply to comment #1)

It's correct :)
Pushed revision 3783169ac623 to mozilla-central.
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Pushed revision 0bd3d851a214 to mozilla-1.9.1.
Keywords: fixed1.9.1
Component: DOM: Mozilla Extensions → DOM
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: