Bug 871887 - Make sure |this|-binding is correct or marquee event listeners. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Mon, 20 May 2013 11:33:49 -0600
changeset 143926 41c950a2f7db29deb8c134623bd1f6632bdc8c5f
parent 143925 8bce57ee8b173e3aa7bfc2bcf53c8db416051776
child 143927 da52b9dee5038baf01fd82560e139c50d8b33ded
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs871887
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 871887 - Make sure |this|-binding is correct or marquee event listeners. r=bz
js/xpconnect/tests/mochitest/test_bug871887.html
layout/style/xbl-marquee/xbl-marquee.xml
--- a/js/xpconnect/tests/mochitest/test_bug871887.html
+++ b/js/xpconnect/tests/mochitest/test_bug871887.html
@@ -8,32 +8,36 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 871887</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript;version=1.7">
 
   /** 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();
   }
 
   </script>
 </head>
 <body>
 <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>
 </body>
 </html>
--- a/layout/style/xbl-marquee/xbl-marquee.xml
+++ b/layout/style/xbl-marquee/xbl-marquee.xml
@@ -260,17 +260,17 @@
               if (!aIgnoreNextCall) {
                 try {
                   // Work around bug 872772 by wrapping the cross-compartment-
                   // wrapped function in a function from this scope.
                   //
                   // 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;
                 }
                 this.addEventListener(aName, this["_on" + aName], false);
               }
               else {
                 this["_on" + aName] = aValue;