Bug 1525855 - Add testcase with WTF-8 characters in several places. r=Yoric
authorTooru Fujisawa <arai_a@mac.com>
Tue, 26 Feb 2019 13:20:52 +0000
changeset 519036 29032f75438b955adc0849f7ac435fc1b44ff39f
parent 519035 7e5a341f5662da8ab99d7ab4ac8b895016ba71ed
child 519037 1d2a9559d6d6c38d2ae46d8f618cba55237e48c4
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1525855
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 1525855 - Add testcase with WTF-8 characters in several places. r=Yoric Differential Revision: https://phabricator.services.mozilla.com/D20993
js/src/jit-test/tests/binast/invalid/wtf-8-field-name.binjs
js/src/jit-test/tests/binast/invalid/wtf-8-interface-name.binjs
js/src/jit-test/tests/binast/invalid/wtf-8-interface-name.dir
js/src/jit-test/tests/binast/invalid/wtf-8-scope-name.binjs
js/src/jit-test/tests/binast/invalid/wtf-8-scope-name.dir
js/src/jit-test/tests/binast/invalid/wtf-8-variable-name.binjs
js/src/jit-test/tests/binast/invalid/wtf-8-variable-name.dir
js/src/jsapi-tests/binast/invalid/lib/filter_utils.py
js/src/jsapi-tests/binast/invalid/tests/wtf-8-field-name.js
js/src/jsapi-tests/binast/invalid/tests/wtf-8-field-name.py
js/src/jsapi-tests/binast/invalid/tests/wtf-8-interface-name.js
js/src/jsapi-tests/binast/invalid/tests/wtf-8-interface-name.py
js/src/jsapi-tests/binast/invalid/tests/wtf-8-scope-name.js
js/src/jsapi-tests/binast/invalid/tests/wtf-8-scope-name.py
js/src/jsapi-tests/binast/invalid/tests/wtf-8-variable-name.js
js/src/jsapi-tests/binast/invalid/tests/wtf-8-variable-name.py
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..46f28b933007d2f697f1fa862632d0c0b19204cd
GIT binary patch
literal 209
zc$`I!y$ZrW5QM`aK_rhM!BWJ|#t7j!F)8lS1&cG;goXUESwUZ3JY#Xw?aar{TvUEF
zqLezxvP9pphJlgar%!Z9<{5~gHWlH-vKt?^Gu1f3&L!9my+hO2MBuJ*IC`_N)B>yJ
zRf9mWrwm($AG5z91KBQr_CQ#9BKp^rrqC*v#xDwmuw|js)LZc;a1x<d1?ynZ_WT7M
C$Vc%2
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0a42bbe83fbcc1616e78c74537e7ca8a01e0edeb
GIT binary patch
literal 197
zc${<c^z#a4igpij^!0TNip@+(%`3?)skDB^W8_#|oLW?pni8B`lvz;Xo|B)Hm=m0w
zUy!N+l*vrb%LOWRttco;1@iLqOb~)0iACwDC7xiT(lS$v416+6Qi~FE{7Q3Ei!zfD
zdUzm4^SxcLFaGVexzWKPL7sl@!3bBdF)<}ZhXlF0B81d97=VC@i;0DSjR6ck*aHB%
C`$dre
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/binast/invalid/wtf-8-interface-name.dir
@@ -0,0 +1,1 @@
+// |jit-test| error:SyntaxError
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..141cce1ca9ca26983413081d98b729f44fb3c41a
GIT binary patch
literal 238
zc${61Jqp4=5QW1Mf=IBjw~!!~Vryf>5F(l)8*GBen2a*8`C+n(9!BsKmfpxaC=n6-
z%J+CbvmjhZk@%6jTDj4NGAuOd%cLthL$|JxHD+^66)<KY<T(C{GG(f?ugV=LnU)py
zXH;ZV9D=4|PspPsX=G60F-NA<J6DW#O=V$!!h<z1!A{|40QB2({<V@58An0r%ip=4
kWu1Tpbe^}z_IbZ1apZYFd)yMjFpW2&Z3x>GmeJr$Ul{CAF#rGn
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/binast/invalid/wtf-8-scope-name.dir
@@ -0,0 +1,1 @@
+// |jit-test| error:SyntaxError
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ba221702d16b1d0f2ae670fe4e55774f99d78068
GIT binary patch
literal 215
zc${<c^z#a4igpij^!0TNip@+(%`3?)skHvbW8_#|oLW?pni8B`lvz;Xo|B)Hm=m0w
zUy!N+l*vrb%LOWRttco;1@iLqOb~)0iACwDC7xiT(lS$v)DWtIOA<>`L23+qGD}j6
z5_9}Yb5n~llMyO-Al5|(hXi^0xd$U$B*et`cEP^*x7+4MhXlF0A|%wf7=VC@jfsVU
Jg8>Xw8~|LiOp*Wq
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/binast/invalid/wtf-8-variable-name.dir
@@ -0,0 +1,1 @@
+// |jit-test| error:SyntaxError
--- a/js/src/jsapi-tests/binast/invalid/lib/filter_utils.py
+++ b/js/src/jsapi-tests/binast/invalid/lib/filter_utils.py
@@ -76,16 +76,31 @@ def assert_interface(obj, expected_name)
            The name of the interface
     """
     assert_tagged_tuple(obj)
     actual_name = obj['@INTERFACE']
     if actual_name != expected_name:
         raise Exception('expected {}, got {}'.format(expected_name, actual_name))
 
 
+def set_interface_name(obj, name):
+    """
+    Set the tagged tuple's interface name
+
+    :param obj (dict)
+           The tagged tuple
+    :param name (string)
+           The name of the interface
+    """
+    assert_tagged_tuple(obj)
+    obj['@INTERFACE'] = name
+    if type(name) is not str and type(name) is not unicode:
+        raise Exception('passed value is not string: {}'.format(name))
+
+
 def get_field(obj, name):
     """
     Returns the field of the tagged tuple.
 
     :param obj (dict)
            The tagged tuple
     :param name (string)
            The name of the field to get
@@ -141,16 +156,39 @@ def remove_field(obj, name):
     for field in fields:
         if field['@FIELD_NAME'] == name:
             del fields[i]
             return
         i += 1
     raise Exception('No such field: {}'.format(name))
 
 
+def append_field(obj, name, value):
+    """
+    Append a field to the tagged tuple
+
+    :param obj (dict)
+           the tagged tuple
+    :param name (string)
+           the name of the field to add
+    :param value (dict)
+           the value of the field to add
+    """
+    assert_tagged_tuple(obj)
+    fields = obj['@FIELDS']
+    if type(name) is not str and type(name) is not unicode:
+        raise Exception('passed name is not string: {}'.format(name))
+    if type(value) is not dict:
+        raise Exception('passed value is not dict: {}'.format(value))
+    fields.append({
+        '@FIELD_NAME': name,
+        '@FIELD_VALUE': value,
+    })
+
+
 def get_element(obj, i):
     """
     Returns the element of the list.
 
     :param obj (dict)
            The list
     :param i (int)
            The indef of the element to get
@@ -251,26 +289,26 @@ def set_string(obj, value):
     Set string value
 
     :param obj (dict)
            the string object
     :param value (int)
            the value to set
     """
     assert_string(obj)
-    if type(value) is not str:
+    if type(value) is not str and type(value) is not unicode:
         raise Exception('passed value is not string: {}'.format(value))
     obj['@VALUE'] = value
 
 
 def set_identifier_name(obj, value):
     """
     Set identifier name value
 
     :param obj (dict)
            the identifier name object
     :param value (int)
            the value to set
     """
     assert_identifier_name(obj)
-    if type(value) is not str:
+    if type(value) is not str and type(value) is not unicode:
         raise Exception('passed value is not string: {}'.format(value))
     obj['@VALUE'] = value
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/wtf-8-field-name.js
@@ -0,0 +1,1 @@
+a = 10;
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/wtf-8-field-name.py
@@ -0,0 +1,18 @@
+def filter_ast(ast):
+    # Put WTF-8 string into field name.
+    # In multipart format, field name is not encoded into the file,
+    # so this has no effect.
+    import filter_utils as utils
+
+    utils.assert_interface(ast, 'Script')
+    global_stmts = utils.get_field(ast, 'statements')
+
+    expr_stmt = utils.get_element(global_stmts, 0)
+    utils.assert_interface(expr_stmt, 'ExpressionStatement')
+
+    field = utils.get_field(expr_stmt, 'expression')
+
+    utils.append_field(expr_stmt, u'\uD83E_\uDD9D', field)
+    utils.remove_field(expr_stmt, 'expression')
+
+    return ast
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/wtf-8-interface-name.js
@@ -0,0 +1,1 @@
+a = 1;
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/wtf-8-interface-name.py
@@ -0,0 +1,13 @@
+def filter_ast(ast):
+    # Put WTF-8 string into interface name.
+    import filter_utils as utils
+
+    utils.assert_interface(ast, 'Script')
+    global_stmts = utils.get_field(ast, 'statements')
+
+    expr_stmt = utils.get_element(global_stmts, 0)
+    utils.assert_interface(expr_stmt, 'ExpressionStatement')
+
+    utils.set_interface_name(expr_stmt, u'\uD83E_\uDD9D')
+
+    return ast
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/wtf-8-scope-name.js
@@ -0,0 +1,1 @@
+var a = 10;
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/wtf-8-scope-name.py
@@ -0,0 +1,18 @@
+def filter_ast(ast):
+    # Put WTF-8 string into scope name.
+    import filter_utils as utils
+
+    utils.assert_interface(ast, 'Script')
+
+    scope = utils.get_field(ast, 'scope')
+    utils.assert_interface(scope, 'AssertedScriptGlobalScope')
+
+    names = utils.get_field(scope, 'declaredNames')
+
+    decl_name = utils.get_element(names, 0)
+    utils.assert_interface(decl_name, 'AssertedDeclaredName')
+
+    name = utils.get_field(decl_name, 'name')
+    utils.set_identifier_name(name, u'\uD83E_\uDD9D')
+
+    return ast
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/wtf-8-variable-name.js
@@ -0,0 +1,1 @@
+a = 10;
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/wtf-8-variable-name.py
@@ -0,0 +1,20 @@
+def filter_ast(ast):
+    # Put WTF-8 string into identifier name.
+    import filter_utils as utils
+
+    utils.assert_interface(ast, 'Script')
+    global_stmts = utils.get_field(ast, 'statements')
+
+    expr_stmt = utils.get_element(global_stmts, 0)
+    utils.assert_interface(expr_stmt, 'ExpressionStatement')
+
+    assign_expr = utils.get_field(expr_stmt, 'expression')
+    utils.assert_interface(assign_expr, 'AssignmentExpression')
+
+    binding = utils.get_field(assign_expr, 'binding')
+    utils.assert_interface(binding, 'AssignmentTargetIdentifier')
+
+    name = utils.get_field(binding, 'name')
+    utils.set_identifier_name(name, u'\uD83E_\uDD9D')
+
+    return ast