Closed
Bug 585240
Opened 15 years ago
Closed 15 years ago
Can't add message handlers by setting the onmessage property
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
People
(Reporter: adob321, Assigned: smaug)
Details
(Keywords: testcase)
Attachments
(2 files)
118 bytes,
text/html
|
Details | |
5.13 KB,
patch
|
Waldo
:
review+
jst
:
approval2.0+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.458.1 Safari/534.3
Build Identifier: Mozilla/5.0 (X11; Linux i686; rv:2.0b4pre) Gecko/20100806 Minefield/4.0b4pre
The window.onmessage event handler does not fire when the postMessage function is called.
Reproducible: Always
Steps to Reproduce:
1. Open an html file containing the following:
<script>
window.onmessage = function(event) {
alert(event.data);
}
window.postMessage("hello", "*");
</script>
Actual Results:
Nothing happens.
Expected Results:
A message box containing the words "hello".
Works as expected in Chrome.
![]() |
Reporter | |
Comment 1•15 years ago
|
||
![]() |
Reporter | |
Updated•15 years ago
|
OS: Linux → All
Hardware: x86 → All
Comment 2•15 years ago
|
||
I can reproduce on Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.0b6pre) Gecko/20100904 Firefox/4.0b6pre, seems valid.
Status: UNCONFIRMED → NEW
Component: General → DOM
Ever confirmed: true
Keywords: testcase
Product: Firefox → Core
QA Contact: general → general
Summary: onmessage event handler does not fire → onmessage event handler does not fire when using window.postMessage to post a message to itself
Version: unspecified → Trunk
![]() |
||
Comment 3•15 years ago
|
||
This has nothing to do with posting a message to itself, and everything to do with "onmessage" not being a property of windows in Gecko. Using
addEventListener("message", function() { /* whatever */ }, false);
works fine.
Summary: onmessage event handler does not fire when using window.postMessage to post a message to itself → Can't add message handlers by setting the onmessage property
Comment 4•15 years ago
|
||
Oops! Thanks for correcting me, bz!
![]() |
||
Comment 5•15 years ago
|
||
Just adding to nsContentUtils::InitializeEventTable might be good enough to make this work....
Assignee | ||
Comment 6•15 years ago
|
||
Add onmessage to nsDOMClassInfo...
Assignee | ||
Updated•15 years ago
|
Assignee: nobody → Olli.Pettay
Assignee | ||
Comment 7•15 years ago
|
||
Attachment #472289 -
Flags: review?(jwalden+bmo)
Comment 8•15 years ago
|
||
Comment on attachment 472289 [details] [diff] [review]
patch
I don't know much about the on*-property code, but going from the diff it seems plausible. rs=me seems about the right level of confidence.
What I presume is a big filter to check a string against a gazillion on*-names looks like it wants some sort of gperf-hash-like thing; I'm vaguely curious if anyone's ever filed a bug on doing that.
It would be marginally better form, I think, to use location.href instead of "*" for the target origin.
Attachment #472289 -
Flags: review?(jwalden+bmo) → review+
Assignee | ||
Comment 9•15 years ago
|
||
We should just add onfoo properties to the interfaces, but that is larger change
than what I want to do in this bug.
Assignee | ||
Updated•15 years ago
|
Attachment #472289 -
Flags: approval2.0?
Updated•15 years ago
|
Attachment #472289 -
Flags: approval2.0? → approval2.0+
Assignee | ||
Comment 10•15 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/64d3f6db6544
http://hg.mozilla.org/mozilla-central/rev/f06a18912bb4
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•