Bug 871887 - Make sure |this|-binding is correct or marquee event listeners. r=bz

This commit is contained in:
Bobby Holley 2013-05-20 11:33:49 -06:00
parent d82b494a39
commit aef9decad9
2 changed files with 8 additions and 4 deletions

View File

@ -13,14 +13,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=871887
/** Test for Bug 871887 **/
SimpleTest.waitForExplicitFinish();
function checkpoint() {
// NB: onstart ends up getting invoked twice, for mysterious and potentially-
// IE6-related reasons.
function checkpoint(invocant) {
ok(true, "onstart called");
is(invocant, $('llama'), "this-binding is correct");
$('llama').loop = 1;
$('llama').scrollDelay = 1;
$('llama').scrollAmount = 500;
}
function done() {
function done(invocant) {
is(invocant, $('llama'), "this-binding is correct");
ok(true, "onfinish called");
SimpleTest.finish();
}
@ -31,7 +35,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=871887
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=871887">Mozilla Bug 871887</a>
<p id="display"></p>
<div id="content">
<marquee id="llama" onstart="checkpoint();" onfinish="done();">Watch the Llama</marquee>
<marquee id="llama" onstart="checkpoint(this);" onfinish="done(this);">Watch the Llama</marquee>
</div>
<pre id="test">
</pre>

View File

@ -265,7 +265,7 @@
// NB: Make sure to wrap the constructor in parentheses to
// deal with the weird precedence of |new| in JS.
var contentFn = new (XPCNativeWrapper.unwrap(window).Function)("event", aValue);
this["_on" + aName] = function(e) { return contentFn(e); };
this["_on" + aName] = function(e) { return contentFn.call(this, e); };
}
catch(e) {
return false;