Bug 1535175 - Throw error for empty string in readIdentifierName. r=Yoric
authorTooru Fujisawa <arai_a@mac.com>
Thu, 14 Mar 2019 06:48:43 +0000
changeset 524852 8014816b11ed14f3483b12c42e6785b02a414614
parent 524851 bf03fb29b472b6a1bbf7026877a6473f3502fea2
child 524853 da11c85f5bb2fe50c6a4e9a754e518f6d0ce46d4
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1535175
milestone67.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 1535175 - Throw error for empty string in readIdentifierName. r=Yoric Differential Revision: https://phabricator.services.mozilla.com/D23439
js/src/frontend/BinASTTokenReaderMultipart.cpp
js/src/jit-test/tests/binast/invalid/identifier-null.binjs
js/src/jit-test/tests/binast/invalid/identifier-null.dir
js/src/jsapi-tests/binast/invalid/lib/filter_utils.py
js/src/jsapi-tests/binast/invalid/tests/identifier-null.js
js/src/jsapi-tests/binast/invalid/tests/identifier-null.py
--- a/js/src/frontend/BinASTTokenReaderMultipart.cpp
+++ b/js/src/frontend/BinASTTokenReaderMultipart.cpp
@@ -288,17 +288,17 @@ JS::Result<JSAtom*> BinASTTokenReaderMul
     if (!IsIdentifier(result)) {
       return raiseError("Invalid identifier");
     }
   }
   return result;
 }
 
 JS::Result<JSAtom*> BinASTTokenReaderMultipart::readIdentifierName() {
-  BINJS_MOZ_TRY_DECL(result, readMaybeAtom());
+  BINJS_MOZ_TRY_DECL(result, readAtom());
   if (!IsIdentifier(result)) {
     return raiseError("Invalid identifier");
   }
   return result;
 }
 
 JS::Result<JSAtom*> BinASTTokenReaderMultipart::readMaybePropertyKey() {
   return readMaybeAtom();
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ebcaf42d7933b03db18cf58aa296b31ea08b248d
GIT binary patch
literal 210
zc$`I!PYZ%T5XF~8Lc)&`(lMf2mkdOV^swtqI&3=1fd3dLs4rh_cG!2D_kPTK=QO`)
zStcsVvPj*qhJle^$9J%g<{5~g))nEzNjKh2r>k*-txd2UdW*)-iNIdtaByZ}s0B`!
zR}BJ%j?!!xe$4KQ3}m|e(F0-Sh~QsW>O!S?qTM22dLL01Dvq5Ou7#CcNl*A<(dP68
DcJxS-
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/binast/invalid/identifier-null.dir
@@ -0,0 +1,1 @@
+// |jit-test| error: Empty string
\ No newline at end of file
--- a/js/src/jsapi-tests/binast/invalid/lib/filter_utils.py
+++ b/js/src/jsapi-tests/binast/invalid/lib/filter_utils.py
@@ -301,29 +301,40 @@ class wrap:
         if type_ != 'identifier name':
             raise Exception('expected a identifier name, got {}'.format(type_))
         return self
 
     def set_identifier_name(self, value):
         """
         Set identifier name value
 
-        :param value (int)
+        :param value (str)
                the value to set
         :return (wrap)
                 self
         :raises Exception
                 If value is not correct type
         """
         self.assert_identifier_name()
         if type(value) is not str and type(value) is not unicode:
             raise Exception('passed value is not string: {}'.format(value))
         self.obj['@VALUE'] = value
         return self
 
+    def set_null_identifier_name(self):
+        """
+        Set identifier name value to null
+
+        :return (wrap)
+                self
+        """
+        self.assert_identifier_name()
+        self.obj['@VALUE'] = None
+        return self
+
     # ==== unsigned long ====
 
     def assert_unsigned_long(self):
         """
         Assert that this object is a unsigned long
 
         :return (wrap)
                 self
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/identifier-null.js
@@ -0,0 +1,1 @@
+a = 10;
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/identifier-null.py
@@ -0,0 +1,17 @@
+def filter_ast(ast):
+    # AssignmentTargetIdentifier with null string.
+    import filter_utils as utils
+
+    utils.wrap(ast) \
+        .assert_interface('Script') \
+        .field('statements') \
+        .elem(0) \
+        .assert_interface('ExpressionStatement') \
+        .field('expression') \
+        .assert_interface('AssignmentExpression') \
+        .field('binding') \
+        .assert_interface('AssignmentTargetIdentifier') \
+        .field('name') \
+        .set_null_identifier_name()
+
+    return ast