Bug 697279 - Properly disable some E4X opcodes in strict mode. r=brendan
authorTom Schuster <evilpies@gmail.com>
Mon, 14 Nov 2011 20:43:33 +0100
changeset 80236 6b839530a88aba110b69c8ead1df5d1d77ee63a7
parent 80235 920c5da54a5cf988c931791e76737b265b3259cc
child 80237 53ef2ac3a1fc037aebd120dd707b6446b3e6b053
push id323
push userrcampbell@mozilla.com
push dateTue, 15 Nov 2011 21:58:36 +0000
treeherderfx-team@3ea216303184 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbrendan
bugs697279
milestone11.0a1
Bug 697279 - Properly disable some E4X opcodes in strict mode. r=brendan
js/src/frontend/Parser.cpp
js/src/jit-test/tests/basic/xml-in-strict.js
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -6925,22 +6925,30 @@ Parser::primaryExpr(TokenKind tt, JSBool
         pn->setInParens(true);
         if (!genexp)
             MUST_MATCH_TOKEN(TOK_RP, JSMSG_PAREN_IN_PAREN);
         break;
       }
 
 #if JS_HAS_XML_SUPPORT
       case TOK_STAR:
+        if (tc->inStrictMode()) {
+            reportErrorNumber(NULL, JSREPORT_ERROR, JSMSG_SYNTAX_ERROR);
+            return NULL;
+        }
         pn = qualifiedIdentifier();
         if (!pn)
             return NULL;
         break;
 
       case TOK_AT:
+        if (tc->inStrictMode()) {
+            reportErrorNumber(NULL, JSREPORT_ERROR, JSMSG_SYNTAX_ERROR);
+            return NULL;
+        }      
         pn = attributeIdentifier();
         if (!pn)
             return NULL;
         break;
 
       case TOK_XMLSTAGO:
         pn = xmlElementOrListRoot(JS_TRUE);
         if (!pn)
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/xml-in-strict.js
@@ -0,0 +1,17 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+function checkSyntaxError(code) {
+    var error;
+    try {
+        eval(code);
+    } catch (e) {
+        error = e;
+    }
+    assertEq(error.name, 'SyntaxError');
+}
+
+checkSyntaxError('"use strict"; *');
+checkSyntaxError('"use strict"; @7');