Bug 1144802 part 4. Stop returning true from ByteCodeEmitter::needsImplicitThis based on the compileAndGo flag. r=luke
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 20 Mar 2015 00:34:08 -0400
changeset 263537 bb9ce50ad44257a38018f45494935d9dd78925ff
parent 263536 daa6b17cb3d455476b95bd2fd11ded2bbd1b9fa9
child 263538 12a39a29eb7bce8d2ba9356726b647e5c8bbe585
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1144802
milestone39.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 1144802 part 4. Stop returning true from ByteCodeEmitter::needsImplicitThis based on the compileAndGo flag. r=luke
dom/events/test/mochitest.ini
dom/events/test/test_eventhandler_scoping.html
js/src/frontend/BytecodeEmitter.cpp
js/src/vm/Xdr.h
--- a/dom/events/test/mochitest.ini
+++ b/dom/events/test/mochitest.ini
@@ -178,8 +178,9 @@ support-files =
 support-files =
   bug989198_embedded.html
   bug989198_helper.js
 skip-if = buildapp == 'b2g' || e10s
 [test_bug1096146.html]
 support-files =
   bug1096146_embedded.html
 [test_offsetxy.html]
+[test_eventhandler_scoping.html]
new file mode 100644
--- /dev/null
+++ b/dom/events/test/test_eventhandler_scoping.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Test for event handler scoping</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var queryResult;
+test(function() {
+  var d = document.createElement("div");
+  d.setAttribute("onclick", "queryResult = querySelector('span')");
+  var s = document.createElement("span");
+  d.appendChild(s);
+  d.dispatchEvent(new Event("click"));
+  assert_equals(queryResult, s, "Should have gotten the right object");
+}, "Test for bareword calls in an event handler using the element as 'this'");
+</script>
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -2153,19 +2153,16 @@ BytecodeEmitter::checkSingletonContext()
         return false;
     hasSingletons = true;
     return true;
 }
 
 bool
 BytecodeEmitter::needsImplicitThis()
 {
-    if (!script->compileAndGo())
-        return true;
-
     if (sc->isFunctionBox()) {
         if (sc->asFunctionBox()->inWith)
             return true;
     } else {
         JSObject *scope = sc->asGlobalSharedContext()->scopeChain();
         while (scope) {
             if (scope->is<DynamicWithObject>())
                 return true;
--- a/js/src/vm/Xdr.h
+++ b/js/src/vm/Xdr.h
@@ -24,17 +24,17 @@ namespace js {
  * versions.  If deserialization fails, the data should be invalidated if
  * possible.
  *
  * When you change this, run make_opcode_doc.py and copy the new output into
  * this wiki page:
  *
  *  https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode
  */
-static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 262;
+static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 263;
 static const uint32_t XDR_BYTECODE_VERSION =
     uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);
 
 static_assert(JSErr_Limit == 388,
               "GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or "
               "removed MSG_DEFs from js.msg, you should increment "
               "XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's "
               "expected JSErr_Limit value.");