summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/for-await-of
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/language/statements/for-await-of')
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-from-sync-iterator-continuation-abrupt-completion-get-constructor.js55
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-assignment.js48
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-evaluation.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-arrow.js57
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-class.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-cover.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-fn.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-gen.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-in.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-order.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-simple-no-strict.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-yield-ident-invalid-strict.js36
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-yield-ident-valid.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-iter-nrml-close.js82
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-invalid.js35
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-null.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined-hole.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined-own.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-yield-ident-invalid-strict.js36
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-yield-ident-valid.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-invalid.js35
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-null.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined-hole.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined-own.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-yield-ident-invalid-strict.js36
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-yield-ident-valid.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-const.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref-no-get.js52
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref-user-err.js48
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-unresolvable-no-strict.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-unresolvable-strict-strict.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-identifier.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-simple-strict-strict.js36
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-yield-invalid-strict.js36
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-yield-valid.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-null.js85
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elision-val-array.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elision-val-string.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-empty-val-array.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-empty-val-string.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-after-element.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-after-elision.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-elision.js48
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-iteration.js53
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-null.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined-hole.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined-own.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-yield-ident-valid.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-null.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined-hole.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined-own.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-yield-ident-valid.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-put-prop-ref-no-get.js53
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-put-prop-ref.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-put-unresolvable-no-strict.js41
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-yield-ident-valid.js48
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-bool.js41
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-num.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-obj.js41
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-string.js41
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-symbol.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-first.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-last.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-lone.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-middle.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-trlng.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-missing.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-null.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-truthy.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-undef.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-evaluation.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-arrow.js58
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-class.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-cover.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-fn.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-gen.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-in.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-order.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-simple-no-strict.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-yield-ident-valid.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-put-unresolvable-no-strict.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-simple-no-strict.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-missing.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-null.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-truthy.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-undef.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-evaluation.js48
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-arrow.js56
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-class.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-cover.js58
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-fn.js58
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-gen.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-in.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-yield-ident-valid.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-target-yield-ident-valid.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-first.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-last.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-lone.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-middle.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-trlng.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-name-evaluation.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-array-yield-ident-valid.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-array.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-obj-yield-ident-valid.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-obj.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-order.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-prop-ref-no-get.js50
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-prop-ref.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-unresolvable-no-strict.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-descriptors.js58
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-empty-obj.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-getter.js52
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-number.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-same-name.js57
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-skip-non-enumerable.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-str-val.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-symbol-val.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-to-property-with-setter.js55
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-to-property.js51
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-valid-object.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-close.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-get-err.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-no-close.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-name-iter-val.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elem-init.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elem-iter.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elision-init.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elision-iter.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-empty-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-empty-iter.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-rest-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-rest-iter.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-val-null.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-exhausted.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-class.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-hole.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-skipped.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-throws.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-undef.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-unresolvable.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-complete.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-done.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-step-err.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val-err.js84
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-id-init.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-id.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-prop-id-init.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-prop-id.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-null.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-undef.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-exhausted.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-iter-close.js56
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-step-err.js77
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision.js80
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-empty.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-elem.js86
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-elision.js93
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-empty.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-rest.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision-next-err.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-exhausted.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-close.js56
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-step-err.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-val-err.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-init-ary.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-init-id.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-init-obj.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-not-final-ary.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-not-final-id.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-not-final-obj.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-obj-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-obj-prop-id.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-close.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-no-close.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-name-iter-val.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-init.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-init.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-init.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-hole.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-skipped.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-undef.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-complete.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-done.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-val.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision-exhausted.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision.js83
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-empty.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elem.js89
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elision.js96
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-empty.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-rest.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-elision.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-exhausted.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-ary.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-ary.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-id.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-prop-id.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-empty.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-class.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-skipped.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-trailing-comma.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init-skipped.js84
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-getter.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-val-obj.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-init-null.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-init-undefined.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-empty.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-get-value-err.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-arrow.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-class.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-cover.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-fn.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-gen.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-skipped.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-throws.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-unresolvable.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-trailing-comma.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-list-err.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-init.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-trailing-comma.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-value-null.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-eval-err.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-get-value-err.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-skipped.js81
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-throws.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-unresolvable.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-trailing-comma.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-init.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-null.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-undef.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-getter.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-skip-non-enumerable.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-val-obj.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-close.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-get-err.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-no-close.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-name-iter-val.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elem-init.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elem-iter.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elision-init.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elision-iter.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-empty-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-empty-iter.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-rest-init.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-rest-iter.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-val-null.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-exhausted.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-class.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-hole.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-skipped.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-throws.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-undef.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-unresolvable.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-complete.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-done.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-step-err.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val-err.js84
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-id-init.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-id.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-prop-id-init.js77
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-prop-id.js77
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-null.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-undef.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-exhausted.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-iter-close.js56
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-step-err.js77
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision.js81
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-empty.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-elem.js87
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-elision.js94
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-empty.js77
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-rest.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision-next-err.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-exhausted.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-close.js56
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-step-err.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-val-err.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-init-ary.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-init-id.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-init-obj.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-not-final-ary.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-not-final-id.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-not-final-obj.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-obj-id.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-obj-prop-id.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-close.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-no-close.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-name-iter-val.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-init.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-init.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-init.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-hole.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-skipped.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-undef.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-complete.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-done.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-val.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision-exhausted.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision.js83
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-empty.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elem.js89
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elision.js96
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-empty.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-rest.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-elision.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-exhausted.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-ary.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-ary.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-id.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-prop-id.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-empty.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-class.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-skipped.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-trailing-comma.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init-skipped.js84
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-getter.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-val-obj.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-init-null.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-init-undefined.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-empty.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-get-value-err.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-arrow.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-class.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-cover.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-fn.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-gen.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-skipped.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-throws.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-unresolvable.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-trailing-comma.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-list-err.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-init.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-trailing-comma.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-value-null.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-eval-err.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-get-value-err.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-skipped.js82
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-throws.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-unresolvable.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-trailing-comma.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-init.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-null.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-undef.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-getter.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-skip-non-enumerable.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-val-obj.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-close.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-get-err.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-no-close.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-name-iter-val.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elem-init.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elem-iter.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elision-init.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elision-iter.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-empty-init.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-empty-iter.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-rest-init.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-rest-iter.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-val-null.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-exhausted.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-class.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-hole.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-skipped.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-throws.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-undef.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-unresolvable.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-complete.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-done.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-step-err.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val-err.js83
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-id-init.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-id.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-prop-id-init.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-prop-id.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-null.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-undef.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-exhausted.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-iter-close.js52
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-step-err.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-empty.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-elem.js84
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-elision.js91
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-empty.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-rest.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision-next-err.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-exhausted.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-close.js52
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-step-err.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-val-err.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-init-ary.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-init-id.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-init-obj.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-not-final-ary.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-not-final-id.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-not-final-obj.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-obj-id.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-obj-prop-id.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-close.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-no-close.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-name-iter-val.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-init.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-init.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-init.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-hole.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-skipped.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-undef.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-complete.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-done.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-val.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision-exhausted.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision.js83
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-empty.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elem.js89
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elision.js96
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-empty.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-rest.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-elision.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-exhausted.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-ary.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-ary.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-id.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-prop-id.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-empty.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-class.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-skipped.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-trailing-comma.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init-skipped.js84
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-getter.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-val-obj.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-init-null.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-init-undefined.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-empty.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-get-value-err.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-arrow.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-class.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-cover.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-fn.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-gen.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-skipped.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-throws.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-unresolvable.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-trailing-comma.js57
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-list-err.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-trailing-comma.js57
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-value-null.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-eval-err.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-get-value-err.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-skipped.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-throws.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-unresolvable.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-trailing-comma.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-null.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-undef.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-getter.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-skip-non-enumerable.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-val-obj.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-assignment.js48
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-evaluation.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-arrow.js57
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-class.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-cover.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-fn.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-gen.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-in.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-order.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-simple-no-strict.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-yield-expr.js51
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-get-err.js54
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-err.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-null.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-skip.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close.js82
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-rtrn-close-null.js84
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-thrw-close-skip.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-null.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined-hole.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined-own.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-yield-expr.js52
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-null.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined-hole.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined-own.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-yield-expr.js52
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-const.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref-no-get.js52
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref-user-err.js48
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-unresolvable-no-strict.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-unresolvable-strict-strict.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-simple-no-strict.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-yield-expr.js55
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-err.js83
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-null.js85
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-skip.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close.js94
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close-err.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close-skip.js77
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close.js90
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-thrw-close-skip.js77
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-rest-nrml-close-skip.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-iter-nrml-close-skip.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-iter-nrml-close.js87
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-val-array.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-val-string.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-empty-iter-close.js81
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-empty-val-array.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-empty-val-string.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-after-element.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-after-elision.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-elision.js48
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-iter-nrml-close-skip.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-iteration.js53
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-lref.js81
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-null.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined-hole.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined-own.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-yield-expr.js51
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-null.js44
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined-hole.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined-own.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-yield-expr.js52
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-prop-ref-no-get.js53
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-prop-ref.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-unresolvable-no-strict.js41
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-yield-expr.js56
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-bool.js41
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-num.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-obj.js41
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-string.js41
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-symbol.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-first.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-last.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-lone.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-middle.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-trlng.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-missing.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-null.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-truthy.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-undef.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-evaluation.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-arrow.js58
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-class.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-cover.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-fn.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-gen.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-in.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-order.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-simple-no-strict.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-yield-expr.js51
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-put-unresolvable-no-strict.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-simple-no-strict.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-missing.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-null.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-truthy.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-undef.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-evaluation.js48
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-arrow.js56
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-class.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-cover.js58
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-fn.js58
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-gen.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-in.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-yield-expr.js50
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-target-yield-expr.js50
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-first.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-last.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-lone.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-middle.js43
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-trlng.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-name-evaluation.js45
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-array-yield-expr.js51
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-array.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-obj-yield-expr.js51
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-obj.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-order.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-prop-ref-no-get.js50
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-prop-ref.js42
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-unresolvable-no-strict.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-descriptors.js58
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-empty-obj.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-getter.js52
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-number.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-same-name.js57
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-skip-non-enumerable.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-str-val.js47
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-symbol-val.js46
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-to-property-with-setter.js55
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-to-property.js51
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-valid-object.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-close.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-get-err.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-no-close.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-name-iter-val.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elem-init.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elem-iter.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elision-init.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elision-iter.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-empty-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-empty-iter.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-rest-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-rest-iter.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-val-null.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-exhausted.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-class.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-hole.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-skipped.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-throws.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-undef.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-unresolvable.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-complete.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-done.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-step-err.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val-err.js83
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-id-init.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-id.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-prop-id-init.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-prop-id.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-null.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-undef.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-exhausted.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-iter-close.js56
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-step-err.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision.js80
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-empty.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-init-err.js21
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-elem.js86
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-elision.js93
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-empty.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-rest.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision-next-err.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-exhausted.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-close.js56
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-step-err.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-val-err.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-init-ary.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-init-id.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-init-obj.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-not-final-ary.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-not-final-id.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-not-final-obj.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-obj-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-obj-prop-id.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-close.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-no-close.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-name-iter-val.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-init.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-init.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-init.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-hole.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-skipped.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-undef.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-complete.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-done.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-val.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision-exhausted.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision.js83
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-empty.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elem.js89
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elision.js96
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-empty.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-rest.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-elision.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-exhausted.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-ary.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-ary.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-id.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-prop-id.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-empty.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-class.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-skipped.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-trailing-comma.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init-skipped.js84
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-getter.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-val-obj.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-init-null.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-init-undefined.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-empty.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-get-value-err.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-arrow.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-class.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-cover.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-fn.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-gen.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-skipped.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-throws.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-unresolvable.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-trailing-comma.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-init-err.js21
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-list-err.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-init.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-trailing-comma.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-value-null.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-eval-err.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-get-value-err.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-skipped.js81
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-throws.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-unresolvable.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-trailing-comma.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-init.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-null.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-undef.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-getter.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-skip-non-enumerable.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-val-obj.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-close.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-get-err.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-no-close.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-name-iter-val.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elem-init.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elem-iter.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elision-init.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elision-iter.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-empty-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-empty-iter.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-rest-init.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-rest-iter.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-val-null.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-exhausted.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-class.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-hole.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-skipped.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-throws.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-undef.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-unresolvable.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-complete.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-done.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-step-err.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val-err.js83
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-id-init.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-id.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-prop-id-init.js77
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-prop-id.js77
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-null.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-undef.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-exhausted.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-iter-close.js56
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-step-err.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision.js81
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-empty.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-init-err.js21
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-elem.js87
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-elision.js94
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-empty.js77
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-rest.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision-next-err.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-exhausted.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-close.js56
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-step-err.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-val-err.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-init-ary.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-init-id.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-init-obj.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-not-final-ary.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-not-final-id.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-not-final-obj.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-obj-id.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-obj-prop-id.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-close.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-no-close.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-name-iter-val.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-init.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-init.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-init.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-hole.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-skipped.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-undef.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-complete.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-done.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-val.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision-exhausted.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision.js83
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-empty.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elem.js89
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elision.js96
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-empty.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-rest.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-elision.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-exhausted.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-ary.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-ary.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-id.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-prop-id.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-empty.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-class.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-skipped.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-trailing-comma.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init-skipped.js84
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-getter.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-val-obj.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-init-null.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-init-undefined.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-empty.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-get-value-err.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-arrow.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-class.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-cover.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-fn.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-gen.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-skipped.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-throws.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-unresolvable.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-trailing-comma.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-init-err.js21
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-list-err.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-init.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-trailing-comma.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-value-null.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-eval-err.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-get-value-err.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-skipped.js82
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-throws.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-unresolvable.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-trailing-comma.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-init.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-null.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-undef.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-getter.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-skip-non-enumerable.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-val-obj.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-close.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-get-err.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-no-close.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-name-iter-val.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elem-init.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elem-iter.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elision-init.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elision-iter.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-empty-init.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-empty-iter.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-rest-init.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-rest-iter.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-val-null.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-exhausted.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-class.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-hole.js59
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-skipped.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-throws.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-undef.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-unresolvable.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-complete.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-done.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-step-err.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val-err.js84
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-id-init.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-id.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-prop-id-init.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-prop-id.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-null.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-undef.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-exhausted.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-iter-close.js53
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-step-err.js77
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-empty.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-init-err.js21
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-elem.js84
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-elision.js91
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-empty.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-rest.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision-next-err.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-exhausted.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-close.js53
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-step-err.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-val-err.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-init-ary.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-init-id.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-init-obj.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-not-final-ary.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-not-final-id.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-not-final-obj.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-obj-id.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-obj-prop-id.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-close.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-no-close.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-name-iter-val.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-init.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-init.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-init.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-hole.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-skipped.js73
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-undef.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-complete.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-done.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-val.js76
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id-init.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision-exhausted.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision.js83
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-empty.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elem.js89
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elision.js96
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-empty.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-rest.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-elision.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-exhausted.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-ary.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-ary.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-obj.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-id.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-prop-id.js75
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-empty.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js68
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-class.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-skipped.js72
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-trailing-comma.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init-skipped.js84
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj-init.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-getter.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js74
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-val-obj.js71
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-init-null.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-init-undefined.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-empty.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-get-value-err.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-arrow.js63
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-class.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-cover.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-fn.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-gen.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-skipped.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-throws.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-unresolvable.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-trailing-comma.js57
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-init-err.js21
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-list-err.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-trailing-comma.js57
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-value-null.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-eval-err.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-get-value-err.js67
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-skipped.js79
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js70
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-trailing-comma.js61
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-init.js65
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-null.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-undef.js62
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj.js64
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-getter.js60
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-skip-non-enumerable.js69
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-val-obj.js66
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/browser.js0
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/escaped-of.js27
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/head-const-init.js21
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/head-let-init.js21
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/head-lhs-async.js24
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/head-var-init.js21
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/iterator-close-non-throw-get-method-abrupt.js54
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/iterator-close-non-throw-get-method-is-null.js52
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/iterator-close-non-throw-get-method-non-callable.js53
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/iterator-close-throw-get-method-abrupt.js52
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/iterator-close-throw-get-method-non-callable.js52
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/let-array-with-newline.js25
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/let-block-with-newline.js21
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/let-identifier-with-newline.js21
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/shell.js113
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/ticks-with-async-iter-resolved-promise-and-constructor-lookup-two.js92
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/ticks-with-async-iter-resolved-promise-and-constructor-lookup.js78
-rw-r--r--js/src/tests/test262/language/statements/for-await-of/ticks-with-sync-iter-resolved-promise-and-constructor-lookup.js93
1234 files changed, 79174 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-from-sync-iterator-continuation-abrupt-completion-get-constructor.js b/js/src/tests/test262/language/statements/for-await-of/async-from-sync-iterator-continuation-abrupt-completion-get-constructor.js
new file mode 100644
index 0000000000..132f8e80f7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-from-sync-iterator-continuation-abrupt-completion-get-constructor.js
@@ -0,0 +1,55 @@
+// |reftest| async
+// Copyright (C) 2019 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-asyncfromsynciteratorcontinuation
+description: >
+ Reject promise when PromiseResolve in AsyncFromSyncIteratorContinuation throws.
+info: |
+ 25.1.4.4 AsyncFromSyncIteratorContinuation ( result, promiseCapability )
+ ...
+ 5. Let valueWrapper be PromiseResolve(%Promise%, « value »).
+ 6. IfAbruptRejectPromise(valueWrapper, promiseCapability).
+ ...
+
+includes: [compareArray.js]
+flags: [async]
+features: [async-iteration]
+---*/
+
+var expected = [
+ "start",
+
+ // `valueWrapper` promise rejected.
+ "tick 1",
+
+ // `Await(nextResult)` in 13.7.5.13 done.
+ "tick 2",
+
+ // catch handler executed.
+ "catch",
+];
+
+var actual = [];
+
+async function f() {
+ var p = Promise.resolve(0);
+ Object.defineProperty(p, "constructor", {
+ get() {
+ throw new Error();
+ }
+ });
+ actual.push("start");
+ for await (var x of [p]);
+ actual.push("never reached");
+}
+
+Promise.resolve(0)
+ .then(() => actual.push("tick 1"))
+ .then(() => actual.push("tick 2"))
+ .then(() => {
+ assert.compareArray(actual, expected);
+}).then($DONE, $DONE);
+
+f().catch(() => actual.push("catch"));
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-assignment.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-assignment.js
new file mode 100644
index 0000000000..d9f6199e3f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-assignment.js
@@ -0,0 +1,48 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-assignment.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let v2, vNull, vHole, vUndefined, vOob;
+
+let iterCount = 0;
+async function fn() {
+ for await ([v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14] of [[2, null, , undefined]]) {
+ assert.sameValue(v2, 2);
+ assert.sameValue(vNull, null);
+ assert.sameValue(vHole, 12);
+ assert.sameValue(vUndefined, 13);
+ assert.sameValue(vOob, 14);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-evaluation.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-evaluation.js
new file mode 100644
index 0000000000..10584a9fd7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-evaluation.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-evaluation.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: The Initializer should only be evaluated if v is undefined. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let flag1 = false, flag2 = false;
+let _;
+
+let iterCount = 0;
+async function fn() {
+ for await ([ _ = flag1 = true, _ = flag2 = true ] of [[14]]) {
+ assert.sameValue(flag1, false);
+ assert.sameValue(flag2, true);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-arrow.js
new file mode 100644
index 0000000000..47b71f01a5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-arrow.js
@@ -0,0 +1,57 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-fn-name-arrow.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (ArrowFunction) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 7. If Initializer is present and value is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(v, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
+
+---*/
+let arrow;
+
+let iterCount = 0;
+async function fn() {
+ for await ([ arrow = () => {} ] of [[]]) {
+ verifyProperty(arrow, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'arrow'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-class.js
new file mode 100644
index 0000000000..b448a69d86
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-class.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-fn-name-class.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (ClassExpression) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [class, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 7. If Initializer is present and value is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(v, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
+
+---*/
+let xCls, cls, xCls2;
+
+let iterCount = 0;
+async function fn() {
+ for await ([ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } ] of [[]]) {
+ assert(xCls.name !== 'xCls');
+ assert(xCls2.name !== 'xCls2');
+
+ verifyProperty(cls, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'cls'
+ });
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-cover.js
new file mode 100644
index 0000000000..4a83164729
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-cover.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-fn-name-cover.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (CoverParenthesizedExpression) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 7. If Initializer is present and value is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(v, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
+
+---*/
+let xCover, cover;
+
+let iterCount = 0;
+async function fn() {
+ for await ([ xCover = (0, function() {}), cover = (function() {}) ] of [[]]) {
+ assert(xCover.name !== 'xCover');
+
+ verifyProperty(cover, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'cover'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-fn.js
new file mode 100644
index 0000000000..62dc6819e9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-fn.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-fn-name-fn.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (FunctionExpression) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [class, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 7. If Initializer is present and value is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(v, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
+
+---*/
+let xFnexp, fnexp;
+
+let iterCount = 0;
+async function fn() {
+ for await ([ xFnexp = function x() {}, fnexp = function() {} ] of [[]]) {
+ assert(xFnexp.name !== 'xFnexp');
+
+ verifyProperty(fnexp, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'fnexp'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-gen.js
new file mode 100644
index 0000000000..be35a917b1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-fn-name-gen.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-fn-name-gen.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (GeneratorExpression) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 7. If Initializer is present and value is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(v, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
+
+---*/
+let xGen, gen;
+
+let iterCount = 0;
+async function fn() {
+ for await ([ xGen = function* x() {}, gen = function*() {} ] of [[]]) {
+ assert.notSameValue(xGen.name, 'xGen');
+
+ verifyProperty(gen, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'gen'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-in.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-in.js
new file mode 100644
index 0000000000..15a9714702
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-in.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-in.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: The Initializer in an AssignmentElement may be an `in` expression. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ([ x = 'x' in {} ] of [[]]) {
+ assert.sameValue(x, false);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-order.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-order.js
new file mode 100644
index 0000000000..5676cf70e2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-order.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-order.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Initializer values should be assigned in left-to-right order. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = 0;
+let a, b;
+
+let iterCount = 0;
+async function fn() {
+ for await ([ a = x += 1, b = x *= 2 ] of [[]]) {
+ assert.sameValue(a, 1);
+ assert.sameValue(b, 2);
+ assert.sameValue(x, 2);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-simple-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-simple-no-strict.js
new file mode 100644
index 0000000000..b8da6c954f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-simple-no-strict.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-simple-no-strict.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Identifiers that appear as the DestructuringAssignmentTarget in an AssignmentElement should take on the iterated value corresponding to their position in the ArrayAssignmentPattern. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let argument, eval;
+
+let iterCount = 0;
+async function fn() {
+ for await ([arguments = 4, eval = 5] of [[]]) {
+ assert.sameValue(arguments, 4);
+ assert.sameValue(eval, 5);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-yield-ident-invalid-strict.js
new file mode 100644
index 0000000000..370cf97c5f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-yield-ident-invalid-strict.js
@@ -0,0 +1,36 @@
+// |reftest| error:SyntaxError
+'use strict';
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-yield-ident-invalid.case
+// - src/dstr-assignment-for-await/error-async-function-syntax/async-func-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of an AssignmentElement outside of a generator function body, it behaves as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, onlyStrict]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+$DONOTEVALUATE();
+
+async function fn() {
+ for await ([ x = yield ] of [[]]) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-yield-ident-valid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-yield-ident-valid.js
new file mode 100644
index 0000000000..47d5619581
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-init-yield-ident-valid.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-yield-ident-valid.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of an AssignmentElement outside of a generator function body, it behaves as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let yield = 4;
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ([ x = yield ] of [[]]) {
+ assert.sameValue(x, 4);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-iter-nrml-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-iter-nrml-close.js
new file mode 100644
index 0000000000..238119431d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-iter-nrml-close.js
@@ -0,0 +1,82 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-iter-nrml-close.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: IteratorClose is called when assignment evaluation has not exhausted the iterator (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ AssignmentElementList ]
+
+ [...]
+ 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
+ 5. Return result.
+
+ 7.4.6 IteratorClose ( iterator, completion )
+
+ [...]
+ 5. Let innerResult be Call(return, iterator, « »).
+ [...]
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let thisValue = null;
+let args = null;
+let _;
+let iterable = {};
+let iterator = {
+ next() {
+ nextCount += 1;
+ // Set an upper-bound to limit unnecessary iteration in non-conformant
+ // implementations
+ return { done: nextCount > 10 };
+ },
+ return() {
+ returnCount += 1;
+ thisValue = this;
+ args = arguments;
+ return {};
+ }
+};
+iterable[Symbol.iterator] = function() {
+ return iterator;
+};
+
+let iterCount = 0;
+async function fn() {
+ for await ([ _ ] of [iterable]) {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 1);
+ assert.sameValue(thisValue, iterator, 'correct `this` value');
+ assert(!!args, 'arguments object provided');
+ assert.sameValue(args.length, 0, 'zero arguments specified');
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-invalid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-invalid.js
new file mode 100644
index 0000000000..bbbd8f0805
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-invalid.js
@@ -0,0 +1,35 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array-invalid.case
+// - src/dstr-assignment-for-await/error-async-function-syntax/async-func-decl.template
+/*---
+description: It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral or an ArrayLiteral and if the lexical token sequence matched by LeftHandSideExpression cannot be parsed with no tokens left over using AssignmentPattern as the goal symbol. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+$DONOTEVALUATE();
+
+async function fn() {
+ for await ([[(x, y)]] of [[[]]]) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-null.js
new file mode 100644
index 0000000000..eb8b410368
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-null.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array-null.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the value is `null`, a TypeError should be thrown. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let _;
+
+
+let iterCount = 0;
+async function fn() {
+ for await ([[ _ ]] of [[null]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined-hole.js
new file mode 100644
index 0000000000..913138eb2a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined-hole.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array-undefined-hole.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the value is a "hole", a TypeError should be thrown. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let _;
+
+
+let iterCount = 0;
+async function fn() {
+ for await ([[ _ ]] of [[ , ]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined-own.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined-own.js
new file mode 100644
index 0000000000..6bada38c5c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined-own.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array-undefined-own.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the value is `undefined`, a TypeError should be thrown. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let _;
+
+
+let iterCount = 0;
+async function fn() {
+ for await ([[ x ]] of [[undefined]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined.js
new file mode 100644
index 0000000000..d688ad3a4b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-undefined.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array-undefined.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and no value is defined, a TypeError should be thrown. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let _;
+
+let iterCount = 0;
+async function fn() {
+ for await ([[ x ]] of [[]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-yield-ident-invalid-strict.js
new file mode 100644
index 0000000000..c733558621
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-yield-ident-invalid-strict.js
@@ -0,0 +1,36 @@
+// |reftest| error:SyntaxError
+'use strict';
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array-yield-ident-invalid.case
+// - src/dstr-assignment-for-await/error-async-function-syntax/async-func-decl.template
+/*---
+description: When a `yield` token appears within the DestructuringAssignmentTarget of a nested destructuring assignment outside of strict mode, it behaves as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, onlyStrict]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+$DONOTEVALUATE();
+
+async function fn() {
+ for await ([[x[yield]]] of [[[]]]) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-yield-ident-valid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-yield-ident-valid.js
new file mode 100644
index 0000000000..e17d7978db
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array-yield-ident-valid.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array-yield-ident-valid.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When a `yield` token appears within the DestructuringAssignmentTarget of a nested destructuring assignment outside of strict mode, it behaves as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let yield = 'prop';
+let x = {};
+
+let iterCount = 0;
+async function fn() {
+ for await ([[x[yield]]] of [[[22]]]) {
+ assert.sameValue(x.prop, 22);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array.js
new file mode 100644
index 0000000000..5ceb6c4785
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-array.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ([[x]] of [[[1]]]) {
+ assert.sameValue(x, 1);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-invalid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-invalid.js
new file mode 100644
index 0000000000..199ea6ddc1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-invalid.js
@@ -0,0 +1,35 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj-invalid.case
+// - src/dstr-assignment-for-await/error-async-function-syntax/async-func-decl.template
+/*---
+description: It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral or an ArrayLiteral and if the lexical token sequence matched by LeftHandSideExpression cannot be parsed with no tokens left over using AssignmentPattern as the goal symbol. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+$DONOTEVALUATE();
+
+async function fn() {
+ for await ([{ get x() {} }] of [[{}]]) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-null.js
new file mode 100644
index 0000000000..6986b9d0bf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-null.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj-null.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal and the value is `null`, a TypeError should be thrown. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ([{ x }] of [[null]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined-hole.js
new file mode 100644
index 0000000000..5cca476000
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined-hole.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj-undefined-hole.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal and the value is a "hole", a TypeError should be thrown. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+
+let iterCount = 0;
+async function fn() {
+ for await ([{ x }] of [[ , ]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined-own.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined-own.js
new file mode 100644
index 0000000000..e2c68273a1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined-own.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj-undefined-own.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal and the value is `undefined`, a TypeError should be thrown. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+
+let iterCount = 0;
+async function fn() {
+ for await ([{ x }] of [[undefined]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined.js
new file mode 100644
index 0000000000..7592b67c7c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-undefined.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj-undefined.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal and no value is defined, a TypeError should be thrown. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+
+let iterCount = 0;
+async function fn() {
+ for await ([{ x }] of [[]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-yield-ident-invalid-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-yield-ident-invalid-strict.js
new file mode 100644
index 0000000000..5f4b574b53
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-yield-ident-invalid-strict.js
@@ -0,0 +1,36 @@
+// |reftest| error:SyntaxError
+'use strict';
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj-yield-ident-invalid.case
+// - src/dstr-assignment-for-await/error-async-function-syntax/async-func-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of a nested destructuring assignment outside of a generator function body, it behaves as a IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, onlyStrict]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+$DONOTEVALUATE();
+
+async function fn() {
+ for await ([{ x = yield }] of [[{}]]) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-yield-ident-valid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-yield-ident-valid.js
new file mode 100644
index 0000000000..2d4d252280
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj-yield-ident-valid.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj-yield-ident-valid.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of a nested destructuring assignment outside of a generator function body, it behaves as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let yield = 2;
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ([{ x = yield }] of [[{}]]) {
+ assert.sameValue(x, 2);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj.js
new file mode 100644
index 0000000000..78b632797f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-nested-obj.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal, it should be parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ([{ x }] of [[{ x: 2 }]]) {
+ assert.sameValue(x, 2);
+
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-const.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-const.js
new file mode 100644
index 0000000000..6aa0f9f4dd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-const.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-put-const.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: The assignment target should obey `const` semantics. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [const, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+const c = null;
+
+let iterCount = 0;
+async function fn() {
+ for await ([ c ] of [[1]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref-no-get.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref-no-get.js
new file mode 100644
index 0000000000..5f167e380c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref-no-get.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-put-prop-ref-no-get.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: If the DestructuringAssignmentTarget of an AssignmentElement is a PropertyReference, it should not be evaluated. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, setValue;
+x = {
+ get y() {
+ throw new Test262Error('The property should not be accessed.');
+ },
+ set y(val) {
+ setValue = val;
+ }
+};
+
+let iterCount = 0;
+async function fn() {
+ for await ([x.y] of [[23]]) {
+ assert.sameValue(setValue, 23);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref-user-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref-user-err.js
new file mode 100644
index 0000000000..5fd9a391ab
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref-user-err.js
@@ -0,0 +1,48 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-put-prop-ref-user-err.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Any error raised as a result of setting the value should be forwarded to the runtime. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = {
+ set y(val) {
+ throw new Test262Error();
+ }
+};
+
+let iterCount = 0;
+async function fn() {
+ for await ([x.y] of [[23]
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, Test262Error);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref.js
new file mode 100644
index 0000000000..8820acde6c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-prop-ref.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-put-prop-ref.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: The DestructuringAssignmentTarget of an AssignmentElement may be a PropertyReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = {};
+
+let iterCount = 0;
+async function fn() {
+ for await ([x.y] of [[4]]) {
+ assert.sameValue(x.y, 4);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-unresolvable-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-unresolvable-no-strict.js
new file mode 100644
index 0000000000..a0adcc8f9b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-unresolvable-no-strict.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-put-unresolvable-no-strict.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Outside of strict mode, if the the assignment target is an unresolvable reference, a new `var` binding should be created in the environment record. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function fn() {
+ for await ([ unresolvable ] of [[]]) {
+ assert.sameValue(unresolvable, undefined);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-unresolvable-strict-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-unresolvable-strict-strict.js
new file mode 100644
index 0000000000..06f7890500
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-put-unresolvable-strict-strict.js
@@ -0,0 +1,44 @@
+// |reftest| async
+'use strict';
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-put-unresolvable-strict.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: In strict mode, if the the assignment target is an unresolvable reference, a ReferenceError should be thrown. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, onlyStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function fn() {
+ for await ([ unresolvable ] of [[]
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, ReferenceError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-identifier.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-identifier.js
new file mode 100644
index 0000000000..f666630b8f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-identifier.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-target-identifier.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: Identifiers that appear as the DestructuringAssignmentTarget in an AssignmentElement should take on the iterated value corresponding to their position in the ArrayAssignmentPattern. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, y, z;
+
+let iterCount = 0;
+async function fn() {
+ for await ([x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-simple-strict-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-simple-strict-strict.js
new file mode 100644
index 0000000000..aafbf570a1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-simple-strict-strict.js
@@ -0,0 +1,36 @@
+// |reftest| error:SyntaxError
+'use strict';
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-target-simple-strict.case
+// - src/dstr-assignment-for-await/error-async-function-syntax/async-func-decl.template
+/*---
+description: It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral and IsValidSimpleAssignmentTarget(LeftHandSideExpression) is false. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, onlyStrict]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+$DONOTEVALUATE();
+
+async function fn() {
+ for await ([arguments] of [[]]) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-yield-invalid-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-yield-invalid-strict.js
new file mode 100644
index 0000000000..4f444fcbd2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-yield-invalid-strict.js
@@ -0,0 +1,36 @@
+// |reftest| error:SyntaxError
+'use strict';
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-target-yield-invalid.case
+// - src/dstr-assignment-for-await/error-async-function-syntax/async-func-decl.template
+/*---
+description: When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentElement and outside of a generator function body, it behaves as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, onlyStrict]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+$DONOTEVALUATE();
+
+async function fn() {
+ for await ([ x[yield] ] of [[]]) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-yield-valid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-yield-valid.js
new file mode 100644
index 0000000000..b47dfa58f6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-target-yield-valid.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-target-yield-valid.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentElement outside of a generator function body, it behaves as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let yield = 'prop';
+let x = {};
+
+let iterCount = 0;
+async function fn() {
+ for await ([ x[yield] ] of [[33]]) {
+ assert.sameValue(x.prop, 33);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-null.js
new file mode 100644
index 0000000000..4ef1ff107c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-null.js
@@ -0,0 +1,85 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-trlg-iter-elision-iter-nrml-close-null.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: IteratorClose throws a TypeError when `return` returns a non-Object value (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern :
+ [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
+
+ [...]
+ 6. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. If status is an abrupt completion, then
+ [...]
+ 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
+ status).
+
+ 7.4.6 IteratorClose( iterator, completion )
+
+ [...]
+ 6. Let innerResult be Call(return, iterator, « »).
+ 7. If completion.[[type]] is throw, return Completion(completion).
+ 8. If innerResult.[[type]] is throw, return Completion(innerResult).
+ 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
+ exception.
+
+---*/
+let x;
+let nextCount = 0;
+let iterator = {
+ next() {
+ nextCount += 1;
+ // Set an upper-bound to limit unnecessary iteration in non-conformant
+ // implementations
+ return { done: nextCount > 10 };
+ },
+ return() {
+ return null;
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+
+let iterCount = 0;
+async function fn() {
+ for await ([ x , , ] of [iterable]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(nextCount, 2);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elision-val-array.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elision-val-array.js
new file mode 100644
index 0000000000..8a1e62fdc3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elision-val-array.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elision-val-array.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: An ArrayAssignmentPattern containing only Elisions requires iterable values (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function fn() {
+ for await ([,] of [[]
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elision-val-string.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elision-val-string.js
new file mode 100644
index 0000000000..f56014a5b1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-elision-val-string.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elision-val-string.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: An ArrayAssignmentPattern containing only Elisions requires iterable values (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function fn() {
+ for await ([,] of ['string literal'
+
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-empty-val-array.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-empty-val-array.js
new file mode 100644
index 0000000000..3bae15002d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-empty-val-array.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-empty-val-array.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: An ArrayAssignmentPattern without an AssignmentElementList requires iterable values. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function fn() {
+ for await ([] of [[]
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-empty-val-string.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-empty-val-string.js
new file mode 100644
index 0000000000..da8449375d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-empty-val-string.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-empty-val-string.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: An ArrayAssignmentPattern without an AssignmentElementList requires iterable values. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function fn() {
+ for await ([] of ['string literal'
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-after-element.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-after-element.js
new file mode 100644
index 0000000000..e6443e2206
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-after-element.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-after-element.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: An AssignmentRestElement following an AssignmentElement consumes all remaining iterable values. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, y;
+
+let iterCount = 0;
+async function fn() {
+ for await ([x, ...y] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y.length, 2);
+ assert.sameValue(y[0], 2);
+ assert.sameValue(y[1], 3);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-after-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-after-elision.js
new file mode 100644
index 0000000000..2804426bba
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-after-elision.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-after-elision.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: An AssignmentRestElement following an elision consumes all remaining iterable values. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ([, ...x] of [[1, 2, 3]]) {
+ assert.sameValue(x.length, 2);
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 3);
+
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-elision.js
new file mode 100644
index 0000000000..f4e946849d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-elision.js
@@ -0,0 +1,48 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-elision.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: ArrayAssignmentPattern may include elisions at any position preceding a AssignmentRestElement in a AssignmentElementList. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, y;
+
+let iterCount = 0;
+async function fn() {
+ for await ([, , x, , ...y] of [[1, 2, 3, 4, 5, 6]]) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y.length, 2);
+ assert.sameValue(y[0], 5);
+ assert.sameValue(y[1], 6);
+
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-iteration.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-iteration.js
new file mode 100644
index 0000000000..48802ac3f3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-iteration.js
@@ -0,0 +1,53 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-iteration.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: In the presense of an AssignmentRestElement, value iteration exhausts the iterable value; (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let count = 0;
+let g = function*() {
+ count += 1;
+ yield;
+ count += 1;
+ yield;
+ count += 1;
+}
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ([...x] of [g()]) {
+ assert.sameValue(count, 3);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-null.js
new file mode 100644
index 0000000000..08606b68d1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-null.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-array-null.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the iterable emits `null` as the only value, an array with a single `null` element should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, y;
+
+let iterCount = 0;
+async function fn() {
+ for await ([...[x, y]] of [[null]]) {
+ assert.sameValue(x, null);
+ assert.sameValue(y, undefined);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined-hole.js
new file mode 100644
index 0000000000..342c884fb1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined-hole.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-array-undefined-hole.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the iterable is an array with a "hole", an array with a single `undefined` element should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function fn() {
+ for await ([...[x]] of [[ , ]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined-own.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined-own.js
new file mode 100644
index 0000000000..dbd04e18ca
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined-own.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-array-undefined-own.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the iterable emits `undefined` as the only value, an array with a single `undefined` element should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function fn() {
+ for await ([...[x]] of [[undefined]]) {
+ assert.sameValue(x, undefined);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined.js
new file mode 100644
index 0000000000..8c98ddc93f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-undefined.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-array-undefined.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the iterable is emits no values, an empty array should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function fn() {
+ for await ([...[x]] of [[]]) {
+ assert.sameValue(x, undefined);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-yield-ident-valid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-yield-ident-valid.js
new file mode 100644
index 0000000000..d9372d0a72
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array-yield-ident-valid.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-array-yield-ident-valid.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When a `yield` token appears within the DestructuringAssignmentTarget of a nested destructuring assignment and outside of a generator function body, it should behave as an IdentifierExpression. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let yield = 'prop';
+let x = {};
+
+let iterCount = 0;
+async function fn() {
+ for await ([...[x[yield]]] of [[86]]) {
+ assert.sameValue(x.prop, 86);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array.js
new file mode 100644
index 0000000000..56fc56585f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-array.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-array.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ([...[x]] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-null.js
new file mode 100644
index 0000000000..02a920044f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-null.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-obj-null.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal and the iterable emits `null` as the only value, an array with a single `null` element should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, length;
+
+let iterCount = 0;
+async function fn() {
+ for await ([...{ 0: x, length }] of [[null]]) {
+ assert.sameValue(x, null);
+ assert.sameValue(length, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined-hole.js
new file mode 100644
index 0000000000..0879e1803b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined-hole.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-obj-undefined-hole.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the iterable is an array with a "hole", an array with a single `undefined` element should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+// Use the the top-level lexical scope for 'length' to provide compatibility with browsers
+// where length and name are properties of WindowProxy
+let length;
+
+let iterCount = 0;
+async function fn() {
+ for await ([...{ 0: x, length }] of [[ , ]]) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(length, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined-own.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined-own.js
new file mode 100644
index 0000000000..64ef636388
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined-own.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-obj-undefined-own.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the iterable emits `undefined` as the only value, an array with a single `undefined` element should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+// Use the the top-level lexical scope for 'length' to provide compatibility with browsers
+// where length and name are properties of WindowProxy
+let length;
+
+let iterCount = 0;
+async function fn() {
+ for await ([...{ 0: x, length }] of [[undefined]]) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(length, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined.js
new file mode 100644
index 0000000000..cf07d69030
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-undefined.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-obj-undefined.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an obect literal and the iterable is emits no values, an empty array should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+// Use the the top-level lexical scope for 'length' to provide compatibility with browsers
+// where length and name are properties of WindowProxy
+let length;
+
+let iterCount = 0;
+async function fn() {
+ for await ([...{ 0: x, length }] of [[]]) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(length, 0);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-yield-ident-valid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-yield-ident-valid.js
new file mode 100644
index 0000000000..8e32afb31e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj-yield-ident-valid.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-obj-yield-ident-valid.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of a nested destructuring assignment and outside of a generator function body, it should behave as an IdentifierExpression. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let yield = 2;
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ([...{ x = yield }] of [[{}]]) {
+ assert.sameValue(x, 2);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj.js
new file mode 100644
index 0000000000..02dac3a16f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-nested-obj.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-obj.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal, it should be parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ([...{ 1: x }] of [[1, 2, 3]]) {
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-put-prop-ref-no-get.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-put-prop-ref-no-get.js
new file mode 100644
index 0000000000..20fd6eb688
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-put-prop-ref-no-get.js
@@ -0,0 +1,53 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-put-prop-ref-no-get.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: If the DestructuringAssignmentTarget of an AssignmentElement is a PropertyReference, it should not be evaluated. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let setValue;
+let x = {
+ get y() {
+ throw new Test262Error('The property should not be accessed.');
+ },
+ set y(val) {
+ setValue = val;
+ }
+};
+
+let iterCount = 0;
+async function fn() {
+ for await ([...x.y] of [[23, 45, 99]]) {
+ assert.sameValue(setValue.length, 3);
+ assert.sameValue(setValue[0], 23);
+ assert.sameValue(setValue[1], 45);
+ assert.sameValue(setValue[2], 99);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-put-prop-ref.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-put-prop-ref.js
new file mode 100644
index 0000000000..1b85b75ce0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-put-prop-ref.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-put-prop-ref.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: The DestructuringAssignmentTarget of an AssignmentElement may be a PropertyReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = {};
+
+let iterCount = 0;
+async function fn() {
+ for await ([...x.y] of [[4, 3, 2]]) {
+ assert.sameValue(x.y.length, 3);
+ assert.sameValue(x.y[0], 4);
+ assert.sameValue(x.y[1], 3);
+ assert.sameValue(x.y[2], 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-put-unresolvable-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-put-unresolvable-no-strict.js
new file mode 100644
index 0000000000..d3537fc3f0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-put-unresolvable-no-strict.js
@@ -0,0 +1,41 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-put-unresolvable-no-strict.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Outside of strict mode, if the the assignment target is an unresolvable reference, a new `var` binding should be created in the environment record. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function fn() {
+ for await ([ ...unresolvable ] of [[]]) {
+ assert.sameValue(unresolvable.length, 0);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-yield-ident-valid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-yield-ident-valid.js
new file mode 100644
index 0000000000..6774bfd24c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-array-rest-yield-ident-valid.js
@@ -0,0 +1,48 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-yield-ident-valid.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentRestElement and outside of a generator function body, it should behave as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let yield = 'prop';
+let x = {};
+
+let iterCount = 0;
+async function fn() {
+ for await ([...x[yield]] of [[33, 44, 55]]) {
+ assert.sameValue(x.prop.length, 3);
+ assert.sameValue(x.prop[0], 33);
+ assert.sameValue(x.prop[1], 44);
+ assert.sameValue(x.prop[2], 55);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-bool.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-bool.js
new file mode 100644
index 0000000000..11559a1ad8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-bool.js
@@ -0,0 +1,41 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-empty-bool.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: An ObjectAssignmentPattern without an AssignmentPropertyList requires an object-coercible value (boolean value) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function fn() {
+ for await ({} of [false]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-num.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-num.js
new file mode 100644
index 0000000000..545d619e56
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-num.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-empty-num.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: An ObjectAssignmentPattern without an AssignmentPropertyList requires an object-coercible value (number value) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function fn() {
+ for await ({} of [0
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-obj.js
new file mode 100644
index 0000000000..bf0a73d59b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-obj.js
@@ -0,0 +1,41 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-empty-obj.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: An ObjectAssignmentPattern without an AssignmentPropertyList requires an object-coercible value (object value) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function fn() {
+ for await ({} of [{}]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-string.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-string.js
new file mode 100644
index 0000000000..bae132d096
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-string.js
@@ -0,0 +1,41 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-empty-string.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: An ObjectAssignmentPattern without an AssignmentPropertyList requires an object-coercible value (string value) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function fn() {
+ for await ({} of ['']) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-symbol.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-symbol.js
new file mode 100644
index 0000000000..cc882e7bff
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-empty-symbol.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-empty-symbol.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: An ObjectAssignmentPattern without an AssignmentPropertyList requires an object-coercible value (symbol value) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let s = Symbol();
+
+let iterCount = 0;
+async function fn() {
+ for await ({} of [s]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-first.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-first.js
new file mode 100644
index 0000000000..1984d5d48e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-first.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-identifier-resolution-first.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (first of many) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+let y;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x, y } of [{ x: 3 }]) {
+ assert.sameValue(x, 3);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-last.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-last.js
new file mode 100644
index 0000000000..2462d21723
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-last.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-identifier-resolution-last.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (last of many) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+let w;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ w, x } of [{ x: 4 }]) {
+ assert.sameValue(x, 4);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-lone.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-lone.js
new file mode 100644
index 0000000000..0f3e520df7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-lone.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-identifier-resolution-lone.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (lone identifier) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x, } of [{ x: 2 }]) {
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-middle.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-middle.js
new file mode 100644
index 0000000000..138a134e48
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-middle.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-identifier-resolution-middle.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (within many) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+let w, y;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ w, x, y } of [{ x: 5 }]) {
+ assert.sameValue(x, 5);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-trlng.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-trlng.js
new file mode 100644
index 0000000000..20036be82b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-identifier-resolution-trlng.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-identifier-resolution-trlng.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (lone identifier with trailing comma) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x } of [{ x: 1 }]) {
+ assert.sameValue(x, 1);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-missing.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-missing.js
new file mode 100644
index 0000000000..cf28c8fb0d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-missing.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-assignment-missing.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference (no corresponding property defined). (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x = 1 } of [{}]) {
+ assert.sameValue(x, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-null.js
new file mode 100644
index 0000000000..f1dde95c25
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-null.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-assignment-null.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference (null property value defined). (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x = 1 } of [{ x: null }]) {
+ assert.sameValue(x, null);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-truthy.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-truthy.js
new file mode 100644
index 0000000000..4418fcbc33
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-truthy.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-assignment-truthy.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference (truthy property value defined). (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x = 1 } of [{ x: 2 }]) {
+ assert.sameValue(x, 2);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-undef.js
new file mode 100644
index 0000000000..df2ba6cb76
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-assignment-undef.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-assignment-undef.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference ("undefined" property value defined). (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x = 1 } of [{ x: undefined }]) {
+ assert.sameValue(x, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-evaluation.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-evaluation.js
new file mode 100644
index 0000000000..aabc0a8742
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-evaluation.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-evaluation.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: The Initializer should only be evaluated if v is undefined. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let flag1 = false;
+let flag2 = false;
+let x, y;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x = flag1 = true, y = flag2 = true } of [{ y: 1 }]) {
+ assert.sameValue(flag1, true);
+ assert.sameValue(flag2, false);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..b9ba69c7e9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-arrow.js
@@ -0,0 +1,58 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-fn-name-arrow.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (ArrowFunction) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentProperty : IdentifierReference Initializeropt
+ [...] 6. If Initializeropt is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v, P).
+
+---*/
+let arrow;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ arrow = () => {} } of [{}]) {
+ verifyProperty(arrow, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'arrow'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-class.js
new file mode 100644
index 0000000000..00d16aa4ab
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-class.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-fn-name-class.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (ClassExpression) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [class, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentProperty : IdentifierReference Initializeropt
+ [...] 6. If Initializeropt is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v, P).
+
+---*/
+let xCls, cls, xCls2;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } } of [{}]) {
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ verifyProperty(cls, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'cls'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..2e6d0dad01
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-cover.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-fn-name-cover.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (CoverParenthesizedExpression) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentProperty : IdentifierReference Initializeropt
+ [...] 6. If Initializeropt is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v, P).
+
+---*/
+let xCover, cover;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ xCover = (0, function() {}), cover = (function() {}) } of [{}]) {
+ assert.notSameValue(xCover.name, 'xCover');
+
+ verifyProperty(cover, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'cover'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..cec9dec8fa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-fn.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-fn-name-fn.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (FunctionExpression) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentProperty : IdentifierReference Initializeropt
+ [...] 6. If Initializeropt is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v, P).
+
+---*/
+let xFnexp, fnexp;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ xFnexp = function x() {}, fnexp = function() {} } of [{}]) {
+ assert.notSameValue(xFnexp.name, 'xFnexp');
+
+ verifyProperty(fnexp, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'fnexp'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..5abb352ff1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-gen.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-fn-name-gen.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (GeneratorExpression) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentProperty : IdentifierReference Initializeropt
+ [...] 6. If Initializeropt is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v, P).
+
+---*/
+let xGen, gen;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ xGen = function* x() {}, gen = function*() {} } of [{}]) {
+ assert.notSameValue(xGen.name, 'xGen');
+
+ verifyProperty(gen, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'gen'
+ });
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-in.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-in.js
new file mode 100644
index 0000000000..4c83f67d5a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-in.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-in.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: The Initializer in an AssignmentProperty may be an `in` expression. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let prop;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ prop = 'x' in {} } of [{}]) {
+ assert.sameValue(prop, false);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-order.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-order.js
new file mode 100644
index 0000000000..dc4f34f859
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-order.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-order.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Initializer values should be assigned in left-to-right order. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = 0;
+let a, b;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ a = x += 1, b = x *= 2 } of [{}]) {
+ assert.sameValue(a, 1);
+ assert.sameValue(b, 2);
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-simple-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-simple-no-strict.js
new file mode 100644
index 0000000000..fa798ee61e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-simple-no-strict.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-simple-no-strict.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let eval, arguments;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ eval = 3, arguments = 4 } of [{}]) {
+ assert.sameValue(eval, 3);
+ assert.sameValue(arguments, 4);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-yield-ident-valid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-yield-ident-valid.js
new file mode 100644
index 0000000000..69b6631586
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-yield-ident-valid.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-yield-ident-valid.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of an AssignmentProperty and outside of a generator function body, it should behave as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let yield = 3;
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x = yield } of [{}]) {
+ assert.sameValue(x, 3);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-put-unresolvable-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-put-unresolvable-no-strict.js
new file mode 100644
index 0000000000..e98e99ea9e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-put-unresolvable-no-strict.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-put-unresolvable-no-strict.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Outside of strict mode, if the the assignment target is an unresolvable reference, a new `var` binding should be created in the environment record. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+{
+
+let iterCount = 0;
+async function fn() {
+ for await ({ unresolvable } of [{}]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => {
+ assert.sameValue(unresolvable, undefined);
+ assert.sameValue(iterCount, 1, 'iteration occurred as expected');
+ }, $DONE)
+ .then($DONE, $DONE);
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-simple-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-simple-no-strict.js
new file mode 100644
index 0000000000..0ca0171f9b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-simple-no-strict.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-simple-no-strict.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let eval;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ eval } of [{ eval: 1 }]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => {
+ assert.sameValue(eval, 1);
+ assert.sameValue(iterCount, 1, 'iteration occurred as expected');
+ }, $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-missing.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-missing.js
new file mode 100644
index 0000000000..81ee5d33e0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-missing.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-assignment-missing.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference (non-existent property) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ y: x = 1 } of [{}]) {
+ assert.sameValue(x, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-null.js
new file mode 100644
index 0000000000..34c9d3923f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-null.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-assignment-null.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: If the Initializer is present and v is not undefined, the Initializer should be evaluated and the result assigned to the target reference (null value) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ y: x = 1 } of [{ y: null }]) {
+ assert.sameValue(x, null);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-truthy.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-truthy.js
new file mode 100644
index 0000000000..9f509fca1e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-truthy.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-assignment-truthy.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: If the Initializer is present and v is not undefined, the Initializer should be evaluated and the result assigned to the target reference (truthy value) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ y: x = 1 } of [{ y: 2 }]) {
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-undef.js
new file mode 100644
index 0000000000..62bca21f4f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-assignment-undef.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-assignment-undef.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference (undefined value) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ y: x = 1 } of [{ y: undefined }]) {
+ assert.sameValue(x, 1);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-evaluation.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-evaluation.js
new file mode 100644
index 0000000000..71e8d2c189
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-evaluation.js
@@ -0,0 +1,48 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-evaluation.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: The Initializer should only be evaluated if v is undefined. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let flag1 = false;
+let flag2 = false;
+let x, y;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: x = flag1 = true, y: y = flag2 = true } of [{ y: 1 }]) {
+ assert.sameValue(x, true, 'value of `x`');
+ assert.sameValue(flag1, true, 'value of `flag1`');
+ assert.sameValue(y, 1, 'value of `y`');
+ assert.sameValue(flag2, false, 'value of `flag2`');
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-arrow.js
new file mode 100644
index 0000000000..b64e025e55
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-arrow.js
@@ -0,0 +1,56 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-arrow.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (ArrowFunction) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 6. If Initializer is present and v is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)).
+
+---*/
+let arrow;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: arrow = () => {} } of [{}]) {
+ verifyProperty(arrow, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'arrow'
+ });
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-class.js
new file mode 100644
index 0000000000..e18bfb47f6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-class.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-class.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (ClassExpression) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [class, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 6. If Initializer is present and v is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)).
+
+---*/
+let xCls, cls, xCls2;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: xCls = class x {}, x: cls = class {}, x: xCls2 = class { static name() {} } } of [{}]) {
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ verifyProperty(cls, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'cls'
+ });
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-cover.js
new file mode 100644
index 0000000000..fec8257e89
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-cover.js
@@ -0,0 +1,58 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-cover.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (CoverParenthesizedExpression) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 6. If Initializer is present and v is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)).
+
+---*/
+let xCover, cover;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: xCover = (0, function() {}), x: cover = (function() {}) } of [{}]) {
+ assert.notSameValue(xCover.name, 'xCover');
+
+ verifyProperty(cover, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'cover'
+ });
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-fn.js
new file mode 100644
index 0000000000..db0ef4055f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-fn.js
@@ -0,0 +1,58 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-fn.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (FunctionExpression) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 6. If Initializer is present and v is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)).
+
+---*/
+let xFnexp, fnexp;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: xFnexp = function x() {}, x: fnexp = function() {} } of [{}]) {
+ assert.notSameValue(xFnexp.name, 'xFnexp');
+
+ verifyProperty(fnexp, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'fnexp'
+ });
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-gen.js
new file mode 100644
index 0000000000..720fa3e05f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-fn-name-gen.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-gen.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Assignment of function `name` attribute (GeneratorExpression) (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 6. If Initializer is present and v is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)).
+
+---*/
+let xGen, gen;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: xGen = function* x() {}, x: gen = function*() {} } of [{}]) {
+ assert.notSameValue(xGen.name, 'xGen');
+
+ verifyProperty(gen, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'gen'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-in.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-in.js
new file mode 100644
index 0000000000..6185a66bd2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-in.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-in.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: The Initializer in an AssignmentElement may be an `in` expression. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let prop;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: prop = 'x' in {} } of [{}]) {
+ assert.sameValue(prop, false);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-yield-ident-valid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-yield-ident-valid.js
new file mode 100644
index 0000000000..4685795345
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-init-yield-ident-valid.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-yield-ident-valid.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of an AssignmentElement and outside of a generator function body, it should behave as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let yield = 4;
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: x = yield } of [{}]) {
+ assert.sameValue(x, 4);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-target-yield-ident-valid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-target-yield-ident-valid.js
new file mode 100644
index 0000000000..a22c6ec7e9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-elem-target-yield-ident-valid.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-target-yield-ident-valid.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentElement and outside of a generator function body, it should behave as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let yield = 'prop';
+let x = {};
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: x[yield] } of [{ x: 23 }]) {
+ assert.sameValue(x.prop, 23);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-first.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-first.js
new file mode 100644
index 0000000000..8c29dcea97
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-first.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-identifier-resolution-first.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (first of many). (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+let y;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ a: x, y } of [{ a: 3 }]) {
+ assert.sameValue(x, 3);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-last.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-last.js
new file mode 100644
index 0000000000..70d4939c28
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-last.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-identifier-resolution-last.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (last of many). (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+let w;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ w, a: x } of [{ a: 4 }]) {
+ assert.sameValue(x, 4);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-lone.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-lone.js
new file mode 100644
index 0000000000..3d5ab19eb6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-lone.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-identifier-resolution-lone.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (lone element). (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ a: x } of [{ a: 1 }]) {
+ assert.sameValue(x, 1);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-middle.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-middle.js
new file mode 100644
index 0000000000..a04952f5ed
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-middle.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-identifier-resolution-middle.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (within many). (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+let w, y;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ w, a: x, y } of [{ a: 5 }]) {
+ assert.sameValue(x, 5);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-trlng.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-trlng.js
new file mode 100644
index 0000000000..5a63f61ac1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-identifier-resolution-trlng.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-identifier-resolution-trlng.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (lone element with trailing comma). (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ a: x, } of [{ a: 2 }]) {
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-name-evaluation.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-name-evaluation.js
new file mode 100644
index 0000000000..5265532217
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-name-evaluation.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-name-evaluation.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: PropertyName of an AssignmentProperty may be a ComputedPropertyName. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, y, xy;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ ['x' + 'y']: x } of [{ x: 1, xy: 23, y: 2 }]) {
+ assert.sameValue(x, 23);
+ assert.sameValue(y, undefined);
+ assert.sameValue(xy, undefined);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-array-yield-ident-valid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-array-yield-ident-valid.js
new file mode 100644
index 0000000000..80b839a402
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-array-yield-ident-valid.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-nested-array-yield-ident-valid.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of a nested destructuring assignment and outside of a generator function body, it should behave as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let yield = 22;
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: [x = yield] } of [{ x: [] }]) {
+ assert.sameValue(x, 22);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-array.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-array.js
new file mode 100644
index 0000000000..a7c8de9f17
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-array.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-nested-array.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let y;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: [y] } of [{ x: [321] }]) {
+ assert.sameValue(y, 321);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-obj-yield-ident-valid.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-obj-yield-ident-valid.js
new file mode 100644
index 0000000000..3b91a8fe9f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-obj-yield-ident-valid.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-nested-obj-yield-ident-valid.case
+// - src/dstr-assignment-for-await/async-function/async-func-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of a nested destructuring assignment and outside of a generator function body, it should behave as an IdentifierReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let yield = 2;
+let result, x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: { x = yield } } of [{ x: {} }]) {
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-obj.js
new file mode 100644
index 0000000000..1255b403cc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-nested-obj.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-nested-obj.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal, it should be parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let result, y;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: { y } } of [{ x: { y: 2 } }]) {
+ assert.sameValue(y, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-order.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-order.js
new file mode 100644
index 0000000000..0930026efa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-order.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-put-order.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: The AssignmentElements in an AssignmentElementList are evaluated in left- to-right order. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ z: x, a: x } of [{ a: 2, z: 1 }]) {
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-prop-ref-no-get.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-prop-ref-no-get.js
new file mode 100644
index 0000000000..521720a5de
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-prop-ref-no-get.js
@@ -0,0 +1,50 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-put-prop-ref-no-get.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: If the DestructuringAssignmentTarget of an AssignmentElement is a PropertyReference, it should not be evaluated. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let setValue;
+let x = {
+ get y() {
+ throw new Test262Error('The property should not be accessed.');
+ },
+ set y(val) {
+ setValue = val;
+ }
+};
+
+let iterCount = 0;
+async function fn() {
+ for await ({ a: x.y } of [{ a: 23 }]) {
+ assert.sameValue(setValue, 23);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-prop-ref.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-prop-ref.js
new file mode 100644
index 0000000000..a53b50335f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-prop-ref.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-put-prop-ref.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: The DestructuringAssignmentTarget of an AssignmentElement may be a PropertyReference. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = {};
+
+let iterCount = 0;
+async function fn() {
+ for await ({ xy: x.y } of [{ xy: 4 }]) {
+ assert.sameValue(x.y, 4);
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-unresolvable-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-unresolvable-no-strict.js
new file mode 100644
index 0000000000..9a520c00d4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-prop-put-unresolvable-no-strict.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-put-unresolvable-no-strict.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Outside of strict mode, if the the assignment target is an unresolvable reference, a new `var` binding should be created in the environment record. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+{
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x: unresolvable } of [{}]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => {
+ assert.sameValue(unresolvable, undefined);
+ assert.sameValue(iterCount, 1, 'iteration occurred as expected');
+ }, $DONE)
+ .then($DONE, $DONE);
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-descriptors.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-descriptors.js
new file mode 100644
index 0000000000..9d1f5ae8c7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-descriptors.js
@@ -0,0 +1,58 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-descriptors.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Object created from rest deconstruction doesn't copy source object property descriptors. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest;
+let obj = {};
+Object.defineProperty(obj, "a", { value: 3, configurable: false, enumerable: true });
+Object.defineProperty(obj, "b", { value: 4, writable: false, enumerable: true });
+
+let iterCount = 0;
+async function fn() {
+ for await ({...rest} of [obj]) {
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-empty-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-empty-obj.js
new file mode 100644
index 0000000000..10170c8afc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-empty-obj.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-empty-obj.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: RestBindingInitialization creates a new object even if lhs is an empty object (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest;
+
+
+let iterCount = 0;
+async function fn() {
+ for await ({...rest} of [{}]) {
+ assert.notSameValue(rest, undefined);
+ assert.notSameValue(rest, null);
+ assert.sameValue(typeof rest, "object");
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-getter.js
new file mode 100644
index 0000000000..9e068fccce
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-getter.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-getter.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+let count = 0;
+
+let iterCount = 0;
+async function fn() {
+ for await ({...x} of [{ get v() { count++; return 2; } }]) {
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-number.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-number.js
new file mode 100644
index 0000000000..4b60a029a0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-number.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-number.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: RestBindingInitialization creates a new object even if lhs is a Number (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest;
+
+
+let iterCount = 0;
+async function fn() {
+ for await ({...rest} of [51]) {
+ assert.notSameValue(rest, undefined);
+ assert.notSameValue(rest, null);
+ assert(rest instanceof Object);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-same-name.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-same-name.js
new file mode 100644
index 0000000000..9c1d664feb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-same-name.js
@@ -0,0 +1,57 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-same-name.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Proper setting in the values for rest name equal to a property name. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let o = {
+ x: 42,
+ y: 39,
+ z: 'cheeseburger'
+};
+
+let x, y, z;
+
+let iterCount = 0;
+async function fn() {
+ for await ({ x, ...z } of [o]) {
+ assert.sameValue(x, 42);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z.y, 39);
+ assert.sameValue(z.z, 'cheeseburger');
+
+ let keys = Object.getOwnPropertyNames(z);
+ assert.sameValue(keys.length, 2);
+ assert.sameValue(keys[0], 'y');
+ assert.sameValue(keys[1], 'z');
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..f219395561
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-skip-non-enumerable.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-skip-non-enumerable.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest;
+let obj = {a: 3, b: 4};
+Object.defineProperty(obj, "x", { value: 4, enumerable: false });
+
+let iterCount = 0;
+async function fn() {
+ for await ({...rest} of [obj]) {
+ assert.sameValue(Object.getOwnPropertyDescriptor(rest, "x"), undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-str-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-str-val.js
new file mode 100644
index 0000000000..2f74cf157c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-str-val.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-str-val.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: RestBindingInitialization creats an object with indexes as property name (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest;
+
+
+let iterCount = 0;
+async function fn() {
+ for await ({...rest} of ["foo"]) {
+ assert.sameValue(rest["0"], "f");
+ assert.sameValue(rest["1"], "o");
+ assert.sameValue(rest["2"], "o");
+ assert(rest instanceof Object);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-symbol-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-symbol-val.js
new file mode 100644
index 0000000000..89e4f89d0f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-symbol-val.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-symbol-val.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: RestBindingInitialization creates a new object if lhs is a Symbol (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, Symbol, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest;
+
+
+let iterCount = 0;
+async function fn() {
+ for await ({...rest} of [Symbol("foo")]) {
+ assert.notSameValue(rest, undefined);
+ assert.notSameValue(rest, null);
+ assert(rest instanceof Object);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-to-property-with-setter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-to-property-with-setter.js
new file mode 100644
index 0000000000..3570cf1d11
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-to-property-with-setter.js
@@ -0,0 +1,55 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-to-property-with-setter.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object property setter, its value should be binded as rest object. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let settedValue;
+let executedGetter = false;
+let src = {
+ get y() {
+ executedGetter = true;
+ },
+ set y(v) {
+ settedValue = v;
+ },
+};
+src.y = undefined;
+
+let iterCount = 0;
+async function fn() {
+ for await ({...src.y} of [{ x: 1, y: 2}]) {
+ assert.sameValue(settedValue.x, 1);
+ assert.sameValue(settedValue.y, 2);
+ assert(!executedGetter, "The property should not be accessed");
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-to-property.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-to-property.js
new file mode 100644
index 0000000000..434595ea24
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-to-property.js
@@ -0,0 +1,51 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-to-property.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object property, its value should be binded as rest object. (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let src = {};
+
+let iterCount = 0;
+async function fn() {
+ for await ({...src.y} of [{ x: 1, y: 2}]) {
+ assert.sameValue(src.y.x, 1);
+ assert.sameValue(src.y.y, 2);
+
+ verifyProperty(src, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-valid-object.js b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-valid-object.js
new file mode 100644
index 0000000000..33a7219ba2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-rest-valid-object.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-valid-object.case
+// - src/dstr-assignment-for-await/default/async-func-decl.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement in an async function declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest, a, b;
+
+
+let iterCount = 0;
+async function fn() {
+ for await ({a, b, ...rest} of [{x: 1, y: 2, a: 5, b: 3}]) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-close.js
new file mode 100644
index 0000000000..8f22becec0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-close.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: false };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [x] of [iter]) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-get-err.js
new file mode 100644
index 0000000000..81e54394c3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-get-err.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-get-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Abrupt completion returned by GetIterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ 1. Let iterator be ? GetIterator(value).
+
+---*/
+var iter = {};
+iter[Symbol.iterator] = function() {
+ throw new Test262Error();
+};
+
+async function fn() {
+ for await (const [x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..b19e968f92
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-init-iter-no-close.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-no-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: true };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [x] of [iter]) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-name-iter-val.js
new file mode 100644
index 0000000000..9c8617e260
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-name-iter-val.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-name-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding with normal value iteration (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..9e43c81257
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [[x, y, z] = [4, 5, 6]] of [[]]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..e1aaca9de4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [[x, y, z] = [4, 5, 6]] of [[[7, 8, 9]]]) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..0b9e2fef5e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [[,] = g()] of [[]]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..71de673889
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var callCount = 0;
+function* g() {
+ callCount += 1;
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [[,] = g()] of [[[]]]) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..94de9fc3d7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var initCount = 0;
+var iterCount = 0;
+var iter = function*() { iterCount += 1; }();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [[] = function() { initCount += 1; return iter; }()] of [[]]) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..4b2944747d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var initCount = 0;
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [[] = function() { initCount += 1; }()] of [[[23]]]) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..1c7235ff89
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [[...x] = values] of [[]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..c5feb0f1d2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+var initCount = 0;
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [[...x] = function() { initCount += 1; }()] of [[values]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-val-null.js
new file mode 100644
index 0000000000..27cb241101
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-ary-val-null.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-val-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Nested array destructuring with a null value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ 1. Let iterator be ? GetIterator(value).
+---*/
+
+async function fn() {
+ for await (const [[x]] of [[null]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..35e3f1bc7f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [x = 23] of [[]]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..9e00d52430
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [arrow = () => {}] of [[]]) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..34fd8d304e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of [[]]) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..32208d9420
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [cover = (function () {}), xCover = (0, function() {})] of [[]]) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..76b0b46ac0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [fn = function () {}, xFn = function x() {}] of [[]]) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..be5f635c89
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [gen = function* () {}, xGen = function* x() {}] of [[]]) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..b43f7aac81
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Destructuring initializer with a "hole" (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ SingleNameBinding : BindingIdentifier Initializer_opt
+ [...] 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v). 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [x = 23] of [[,]]) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..6124458ee4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ 7. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [w = counter(), x = counter(), y = counter(), z = counter()] of [[null, 0, false, '']]) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-throws.js
new file mode 100644
index 0000000000..910554aa72
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-throws.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Destructuring initializer returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+---*/
+
+async function fn() {
+ for await (const [x = (function() { throw new Test262Error(); })()] of [[undefined]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..63c376a0ef
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Destructuring initializer with an undefined value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [x = 23] of [[undefined]]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-unresolvable.js
new file mode 100644
index 0000000000..26ff5de4ea
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-init-unresolvable.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function fn() {
+ for await (const [ x = unresolvableReference ] of [[]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..39afc5d8df
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding when value iteration completes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [x] of [[]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..60df0e48da
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [_, x] of [[]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-step-err.js
new file mode 100644
index 0000000000..226d1296ef
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-step-err.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+
+---*/
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next() {
+ throw new Test262Error();
+ }
+ };
+};
+
+async function fn() {
+ for await (const [x] of [g]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val-err.js
new file mode 100644
index 0000000000..c8aaa6d454
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val-err.js
@@ -0,0 +1,84 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ iii. ReturnIfAbrupt(v).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedValue;
+ }
+ };
+};
+
+async function fn() {
+ for await (const [x] of [g]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..25bb07a3cb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..c0fd2aeb40
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[]]) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..9a9e131114
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[{ x: 11, y: 22, z: 33 }]]) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..4ff8652aa3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[]]) {
+ assert.sameValue(v, 444);
+ assert.sameValue(x, 555);
+ assert.sameValue(z, 666);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..de52ec1bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[{ u: 777, w: 888, y: 999 }]]) {
+ assert.sameValue(v, 777);
+ assert.sameValue(x, 888);
+ assert.sameValue(z, 999);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-null.js
new file mode 100644
index 0000000000..33dfeab157
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-null.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-val-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Nested object destructuring with a null value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ObjectBindingPattern
+
+ 1. Let valid be RequireObjectCoercible(value).
+ 2. ReturnIfAbrupt(valid).
+---*/
+
+async function fn() {
+ for await (const [{ x }] of [[null]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-undef.js
new file mode 100644
index 0000000000..efd18dce88
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elem-obj-val-undef.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-val-undef.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Nested object destructuring with a value of `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ObjectBindingPattern
+
+ 1. Let valid be RequireObjectCoercible(value).
+ 2. ReturnIfAbrupt(valid).
+---*/
+
+async function fn() {
+ for await (const [{ x }] of [[]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..d1ed8ad5dd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Elision accepts exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [,] of [iter]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-iter-close.js
new file mode 100644
index 0000000000..6ccb652379
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-iter-close.js
@@ -0,0 +1,56 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-iter-close.case
+// - src/dstr-binding-for-await/iter-close/for-await-of-async-func-const.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for-await-of statement in an async function)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+
+async function fn() {
+ for await (const [,] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(() => {
+ assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-step-err.js
new file mode 100644
index 0000000000..25ec629ac5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision-step-err.js
@@ -0,0 +1,77 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Elision advances iterator and forwards abrupt completions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+
+---*/
+var following = 0;
+var iter = function* () {
+ throw new Test262Error();
+ following += 1;
+}();
+
+async function fn() {
+ for await (const [,] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+ assert.sameValue(following, 0, "iterator is properly closed");
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision.js
new file mode 100644
index 0000000000..9732ae1da4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-elision.js
@@ -0,0 +1,80 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Elision advances iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [,] of [g()]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-empty.js
new file mode 100644
index 0000000000..28c763af98
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-empty.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [] of [iter]) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..b630a40eec
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,86 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...[x, y, z]] of [[3, 4, 5]]) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..44cf0a06b7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,93 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element containing an elision (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...[,]] of [g()]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..f2821c7e45
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element containing an "empty" array pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...[]] of [iter]) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..fc58ef8457
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element containing a rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...[...x]] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision-next-err.js
new file mode 100644
index 0000000000..05fedaa896
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision-next-err.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision-next-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+
+---*/
+var iter = (function*() { throw new Test262Error(); })();
+
+async function fn() {
+ for await (const [, ...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..bbb79b8f0a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+---*/
+var values = [1, 2, 3, 4, 5];
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [ , , ...x] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 3);
+ assert.sameValue(x[1], 4);
+ assert.sameValue(x[2], 5);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..b0ddb463ba
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: RestElement applied to an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. If environment is undefined, return PutValue(lhs, A).
+ ii. Return InitializeReferencedBinding(lhs, A).
+
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [, , ...x] of [[1, 2]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-close.js
new file mode 100644
index 0000000000..8fe38d2d61
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-close.js
@@ -0,0 +1,56 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-close.case
+// - src/dstr-binding-for-await/iter-close/for-await-of-async-func-const.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for-await-of statement in an async function)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+
+async function fn() {
+ for await (const [...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(() => {
+ assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-step-err.js
new file mode 100644
index 0000000000..af1d3314fe
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-step-err.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ a. If iteratorRecord.[[done]] is false,
+ i. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ ii. If next is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ iii. ReturnIfAbrupt(next).
+
+---*/
+var first = 0;
+var second = 0;
+var iter = function*() {
+ first += 1;
+ throw new Test262Error();
+ second += 1;
+}();
+
+async function fn() {
+ for await (const [...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-val-err.js
new file mode 100644
index 0000000000..81311aaf7a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id-iter-val-err.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-val-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ c. Let nextValue be IteratorValue(next).
+ d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ e. ReturnIfAbrupt(nextValue).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedValue;
+ }
+ };
+};
+
+async function fn() {
+ for await (const [...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..d30020f5e2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-id.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Lone rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat
+ [...]
+ f. Let status be CreateDataProperty(A, ToString (n), nextValue).
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...x] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..90091aa851
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,62 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...[ x ] = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..666b9983a2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-init-id.js
@@ -0,0 +1,62 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element (identifier) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...x = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..693a803d1f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,62 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...{ x } = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..5ababb2ab4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,62 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...[x], y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..ab883d5173
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,62 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...x, y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..0e4f9725d5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,62 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...{ x }, y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..c4398e4e43
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...{ length }] of [[1, 2, 3]]) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..0faf104cd0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+let length = "outer";
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of [[7, 8, 9]]) {
+ assert.sameValue(v, 7);
+ assert.sameValue(w, 8);
+ assert.sameValue(x, 9);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 3);
+
+ assert.sameValue(length, "outer", "the length prop is not set as a binding name");
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-close.js
new file mode 100644
index 0000000000..725060354b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-close.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: false };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (const [x] of asyncIter) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..f306dd5842
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-init-iter-no-close.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-no-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: true };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (const [x] of asyncIter) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-name-iter-val.js
new file mode 100644
index 0000000000..474fe89735
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-name-iter-val.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-name-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding with normal value iteration (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (const [x, y, z] of asyncIter) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..dda0b9a98f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [[x, y, z] = [4, 5, 6]] of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..00e169b5e9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[7, 8, 9]]];
+})();
+
+async function fn() {
+ for await (const [[x, y, z] = [4, 5, 6]] of asyncIter) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..85843facba
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [[,] = g()] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..c6cd48b91c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var callCount = 0;
+function* g() {
+ callCount += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[]]];
+})();
+
+async function fn() {
+ for await (const [[,] = g()] of asyncIter) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..dce673ae02
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var initCount = 0;
+var iterCount = 0;
+var iter = function*() { iterCount += 1; }();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [[] = function() { initCount += 1; return iter; }()] of asyncIter) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..24e10a7c86
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var initCount = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[23]]];
+})();
+
+async function fn() {
+ for await (const [[] = function() { initCount += 1; }()] of asyncIter) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..1226460b51
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [[...x] = values] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..03c61ae850
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+var initCount = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[values]];
+})();
+
+async function fn() {
+ for await (const [[...x] = function() { initCount += 1; }()] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..3729fd8d1a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..91733877f9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [arrow = () => {}] of asyncIter) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..22eaf10400
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of asyncIter) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..d539676a97
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [cover = (function () {}), xCover = (0, function() {})] of asyncIter) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..800d69b794
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [fn = function () {}, xFn = function x() {}] of asyncIter) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..d35b728b07
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [gen = function* () {}, xGen = function* x() {}] of asyncIter) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..a45009a602
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Destructuring initializer with a "hole" (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ SingleNameBinding : BindingIdentifier Initializer_opt
+ [...] 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v). 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[,]];
+})();
+
+async function fn() {
+ for await (const [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..208c7da6a8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ 7. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[null, 0, false, '']];
+})();
+
+async function fn() {
+ for await (const [w = counter(), x = counter(), y = counter(), z = counter()] of asyncIter) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..09a499e6f4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Destructuring initializer with an undefined value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[undefined]];
+})();
+
+async function fn() {
+ for await (const [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..432ab192ed
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding when value iteration completes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [x] of asyncIter) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..c8c635724d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [_, x] of asyncIter) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..8983a1ba7d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (const [x, y, z] of asyncIter) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..b3003dc0b3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..3e32b0dcf2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[{ x: 11, y: 22, z: 33 }]];
+})();
+
+async function fn() {
+ for await (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..1689bf2401
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) {
+ assert.sameValue(v, 444);
+ assert.sameValue(x, 555);
+ assert.sameValue(z, 666);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..c78a9a8aab
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[{ u: 777, w: 888, y: 999 }]];
+})();
+
+async function fn() {
+ for await (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) {
+ assert.sameValue(v, 777);
+ assert.sameValue(x, 888);
+ assert.sameValue(z, 999);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..b74ae085a1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Elision accepts exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (const [,] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision.js
new file mode 100644
index 0000000000..088c3f1ba3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-elision.js
@@ -0,0 +1,83 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Elision advances iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [g()];
+})();
+
+async function fn() {
+ for await (const [,] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-empty.js
new file mode 100644
index 0000000000..a932db724a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-empty.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (const [] of asyncIter) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..4e0c8465ea
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,89 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[3, 4, 5]];
+})();
+
+async function fn() {
+ for await (const [...[x, y, z]] of asyncIter) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..26f73986fa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,96 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element containing an elision (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [g()];
+})();
+
+async function fn() {
+ for await (const [...[,]] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..957663382b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element containing an "empty" array pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (const [...[]] of asyncIter) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..8750641d06
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element containing a rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function fn() {
+ for await (const [...[...x]] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..2e393b4fea
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+---*/
+var values = [1, 2, 3, 4, 5];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function fn() {
+ for await (const [ , , ...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 3);
+ assert.sameValue(x[1], 4);
+ assert.sameValue(x[2], 5);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..6adc39564a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: RestElement applied to an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. If environment is undefined, return PutValue(lhs, A).
+ ii. Return InitializeReferencedBinding(lhs, A).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2]];
+})();
+
+async function fn() {
+ for await (const [, , ...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..a8066035df
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-id.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Lone rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat
+ [...]
+ f. Let status be CreateDataProperty(A, ToString (n), nextValue).
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function fn() {
+ for await (const [...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..75e0b26ee8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [...[ x ] = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..821aabe6db
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-id.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element (identifier) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [...x = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..12a71dfba3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (const [...{ x } = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..4b4ef09d43
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (const [...[x], y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..bb57e4b17e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (const [...x, y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..5b011925bc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (const [...{ x }, y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..238d59a412
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (const [...{ length }] of asyncIter) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..e8eb69cd7c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+let length = "outer";
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[7, 8, 9]];
+})();
+
+async function fn() {
+ for await (const [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of asyncIter) {
+ assert.sameValue(v, 7);
+ assert.sameValue(w, 8);
+ assert.sameValue(x, 9);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 3);
+
+ assert.sameValue(length, "outer", "the length prop is not set as a binding name");
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-empty.js
new file mode 100644
index 0000000000..7ad1910a90
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-empty.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [obj];
+})();
+
+async function fn() {
+ for await (const {} of asyncIter) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..9530628be4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (const { arrow = () => {} } of asyncIter) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..385663466d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (const { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of asyncIter) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..27ecfa9b21
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (const { cover = (function () {}), xCover = (0, function() {}) } of asyncIter) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..0fc48366a7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (const { fn = function () {}, xFn = function x() {} } of asyncIter) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..18396a9319
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (const { gen = function* () {}, xGen = function* x() {} } of asyncIter) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..052d82dc83
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: null, x: 0, y: false, z: '' }];
+})();
+
+async function fn() {
+ for await (const { w = counter(), x = counter(), y = counter(), z = counter() } of asyncIter) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..3cf0d734f8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function fn() {
+ for await (const { x, } of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..cd707f0b14
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (const { w: [x, y, z] = [4, 5, 6] } of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..ade4b90c6f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: [45] }];
+})();
+
+async function fn() {
+ for await (const { x: [y], } of asyncIter) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..4d39972bb3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-ary.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: [7, undefined, ] }];
+})();
+
+async function fn() {
+ for await (const { w: [x, y, z] = [4, 5, 6] } of asyncIter) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..913df967bc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,84 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ s: null, u: 0, w: false, y: '' }];
+})();
+
+async function fn() {
+ for await (const { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of asyncIter) {
+ assert.sameValue(t, null);
+ assert.sameValue(v, 0);
+ assert.sameValue(x, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ assert.throws(ReferenceError, function() {
+ s;
+ });
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..16ea4aa191
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-init.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ }];
+})();
+
+async function fn() {
+ for await (const { x: y = 33 } of asyncIter) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..af124bc277
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function fn() {
+ for await (const { x: y, } of asyncIter) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..d4b900ed8b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-id.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Binding as specified via property name and identifier (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function fn() {
+ for await (const { x: y } of asyncIter) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..e7cf8e94a0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: undefined }];
+})();
+
+async function fn() {
+ for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..2b05dc444f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-prop-obj.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: { x: undefined, z: 7 } }];
+})();
+
+async function fn() {
+ for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..bc970bc1c3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-getter.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-getter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var count = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ get v() { count++; return 2; } }];
+})();
+
+async function fn() {
+ for await (const {...x} of asyncIter) {
+ assert.sameValue(x.v, 2);
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..e4a3df8f4e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [o];
+})();
+
+async function fn() {
+ for await (const {...rest} of asyncIter) {
+ assert.sameValue(rest.a, 3);
+ assert.sameValue(rest.b, 4);
+ assert.sameValue(rest.x, undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..d2682a3fe0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-async-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{x: 1, y: 2, a: 5, b: 3}];
+})();
+
+async function fn() {
+ for await (const {a, b, ...rest} of asyncIter) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-init-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-init-null.js
new file mode 100644
index 0000000000..8c4a83c068
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-init-null.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-init-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+async function fn() {
+ for await (const {} of [null]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-init-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-init-undefined.js
new file mode 100644
index 0000000000..d661c1e474
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-init-undefined.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-init-undefined.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (undefined) (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+async function fn() {
+ for await (const {} of [undefined]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-empty.js
new file mode 100644
index 0000000000..58b9ea53f8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-empty.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const {} of [obj]) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-get-value-err.js
new file mode 100644
index 0000000000..8bd3ee5381
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-get-value-err.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-get-value-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. Let v be GetV(value, propertyName).
+ 5. ReturnIfAbrupt(v).
+---*/
+var poisonedProperty = Object.defineProperty({}, 'poisoned', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+async function fn() {
+ for await (const { poisoned } of [poisonedProperty]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..930aa3bd16
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { arrow = () => {} } of [{}]) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..c1729d6aba
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of [{}]) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..c81bf7b908
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { cover = (function () {}), xCover = (0, function() {}) } of [{}]) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..cbd7dfee3b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { fn = function () {}, xFn = function x() {} } of [{}]) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..ea8932f178
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { gen = function* () {}, xGen = function* x() {} } of [{}]) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..beaaa664d1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { w = counter(), x = counter(), y = counter(), z = counter() } of [{ w: null, x: 0, y: false, z: '' }]) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-throws.js
new file mode 100644
index 0000000000..5b7192dd2d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-throws.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Error thrown when evaluating the initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ c. ReturnIfAbrupt(v).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function fn() {
+ for await (const { x = thrower() } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-unresolvable.js
new file mode 100644
index 0000000000..4293aefe73
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-init-unresolvable.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function fn() {
+ for await (const { x = unresolvableReference } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..8bd239b3fc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { x, } of [{ x: 23 }]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-list-err.js
new file mode 100644
index 0000000000..a8b7a73b3c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-list-err.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-list-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPropertyList : BindingPropertyList , BindingProperty
+
+ 1. Let status be the result of performing BindingInitialization for
+ BindingPropertyList using value and environment as arguments.
+ 2. ReturnIfAbrupt(status).
+---*/
+var initCount = 0;
+function thrower() {
+ throw new Test262Error();
+}
+
+async function fn() {
+ for await (const { a, b = thrower(), c = ++initCount } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..55eca251f6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { w: [x, y, z] = [4, 5, 6] } of [{}]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..ae961f46d0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { x: [y], } of [{ x: [45] }]) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-value-null.js
new file mode 100644
index 0000000000..b5fac1fbfe
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary-value-null.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-value-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Object binding pattern with "nested" array binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function fn() {
+ for await (const { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..fc8736f248
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-ary.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { w: [x, y, z] = [4, 5, 6] } of [{ w: [7, undefined, ] }]) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-eval-err.js
new file mode 100644
index 0000000000..1f22426a69
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-eval-err.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-eval-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Evaluation of property name returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingProperty : PropertyName : BindingElement
+
+ 1. Let P be the result of evaluating PropertyName
+ 2. ReturnIfAbrupt(P).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function fn() {
+ for await (const { [thrower()]: x } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-get-value-err.js
new file mode 100644
index 0000000000..fc4f176f48
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-get-value-err.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-get-value-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. Let v be GetV(value, propertyName).
+ 2. ReturnIfAbrupt(v).
+---*/
+var initEvalCount = 0;
+var poisonedProperty = Object.defineProperty({}, 'poisoned', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+async function fn() {
+ for await (const { poisoned: x = ++initEvalCount } of [poisonedProperty]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..3d2f8baba1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,81 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of [{ s: null, u: 0, w: false, y: '' }]) {
+ assert.sameValue(t, null);
+ assert.sameValue(v, 0);
+ assert.sameValue(x, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ assert.throws(ReferenceError, function() {
+ s;
+ });
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-throws.js
new file mode 100644
index 0000000000..13b3b11890
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-throws.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Error thrown when evaluating the initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function fn() {
+ for await (const { x: y = thrower() } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-unresolvable.js
new file mode 100644
index 0000000000..d963af6e1f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init-unresolvable.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function fn() {
+ for await (const { x: y = unresolvableReference } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..4eba86c84d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-init.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { x: y = 33 } of [{ }]) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..55557a596a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { x: y, } of [{ x: 23 }]) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..0435cd3e64
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-id.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Binding as specified via property name and identifier (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { x: y } of [{ x: 23 }]) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..821c8b71b3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: undefined }]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-null.js
new file mode 100644
index 0000000000..4d5fe76888
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-null.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-value-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function fn() {
+ for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-undef.js
new file mode 100644
index 0000000000..79ee455724
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj-value-undef.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-value-undef.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-const.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function fn() {
+ for await (const { w: { x, y, z } = undefined } of [{ }]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..621b5ffac3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-prop-obj.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: { x: undefined, z: 7 } }]) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..33c2dbcc73
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-getter.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-getter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var count = 0;
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const {...x} of [{ get v() { count++; return 2; } }]) {
+ assert.sameValue(x.v, 2);
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..7b7ff100dc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const {...rest} of [o]) {
+ assert.sameValue(rest.a, 3);
+ assert.sameValue(rest.b, 4);
+ assert.sameValue(rest.x, undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..91ebd839a6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-const-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-const.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (const {a, b, ...rest} of [{x: 1, y: 2, a: 5, b: 3}]) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-close.js
new file mode 100644
index 0000000000..6b06e8c0a8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-close.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: false };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [x] of [iter]) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-get-err.js
new file mode 100644
index 0000000000..f74d9531da
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-get-err.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-get-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Abrupt completion returned by GetIterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ 1. Let iterator be ? GetIterator(value).
+
+---*/
+var iter = {};
+iter[Symbol.iterator] = function() {
+ throw new Test262Error();
+};
+
+async function fn() {
+ for await (let [x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..ae5a4e0bed
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-init-iter-no-close.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-no-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: true };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [x] of [iter]) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-name-iter-val.js
new file mode 100644
index 0000000000..17b2fea0bf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-name-iter-val.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-name-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding with normal value iteration (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..1bca9befba
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [[x, y, z] = [4, 5, 6]] of [[]]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..ea43552f92
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [[x, y, z] = [4, 5, 6]] of [[[7, 8, 9]]]) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..4ae2828174
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [[,] = g()] of [[]]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..f32b0acfcd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var callCount = 0;
+function* g() {
+ callCount += 1;
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [[,] = g()] of [[[]]]) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..c3b49708f9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var initCount = 0;
+var iterCount = 0;
+var iter = function*() { iterCount += 1; }();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [[] = function() { initCount += 1; return iter; }()] of [[]]) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..e261bb9858
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var initCount = 0;
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [[] = function() { initCount += 1; }()] of [[[23]]]) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..d35bcecbe1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [[...x] = values] of [[]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..e8f117980b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+var initCount = 0;
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [[...x] = function() { initCount += 1; }()] of [[values]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-val-null.js
new file mode 100644
index 0000000000..80dd73dc97
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-ary-val-null.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-val-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Nested array destructuring with a null value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ 1. Let iterator be ? GetIterator(value).
+---*/
+
+async function fn() {
+ for await (let [[x]] of [[null]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..bd05e11478
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [x = 23] of [[]]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..4091d0ade6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [arrow = () => {}] of [[]]) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..b7e9803f27
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of [[]]) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..4207d078ee
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [cover = (function () {}), xCover = (0, function() {})] of [[]]) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..7adb183626
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [fn = function () {}, xFn = function x() {}] of [[]]) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..25f5498e43
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [gen = function* () {}, xGen = function* x() {}] of [[]]) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..8de9a8a8b9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Destructuring initializer with a "hole" (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ SingleNameBinding : BindingIdentifier Initializer_opt
+ [...] 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v). 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [x = 23] of [[,]]) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..3a4a94df71
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ 7. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [w = counter(), x = counter(), y = counter(), z = counter()] of [[null, 0, false, '']]) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-throws.js
new file mode 100644
index 0000000000..ae41a49441
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-throws.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Destructuring initializer returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+---*/
+
+async function fn() {
+ for await (let [x = (function() { throw new Test262Error(); })()] of [[undefined]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..e7ec30c4aa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Destructuring initializer with an undefined value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [x = 23] of [[undefined]]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-unresolvable.js
new file mode 100644
index 0000000000..6d14254f67
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-init-unresolvable.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function fn() {
+ for await (let [ x = unresolvableReference ] of [[]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..4c929da0f2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding when value iteration completes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [x] of [[]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..5a7bf170a7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [_, x] of [[]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-step-err.js
new file mode 100644
index 0000000000..b8ce4e2b0d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-step-err.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+
+---*/
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next() {
+ throw new Test262Error();
+ }
+ };
+};
+
+async function fn() {
+ for await (let [x] of [g]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val-err.js
new file mode 100644
index 0000000000..fb683d05cb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val-err.js
@@ -0,0 +1,84 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ iii. ReturnIfAbrupt(v).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedValue;
+ }
+ };
+};
+
+async function fn() {
+ for await (let [x] of [g]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..db942d0fea
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..adc6f46d6f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[]]) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..fe0cd57fb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[{ x: 11, y: 22, z: 33 }]]) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..02ec6caed3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,77 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[]]) {
+ assert.sameValue(v, 444);
+ assert.sameValue(x, 555);
+ assert.sameValue(z, 666);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..05f2e157d1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,77 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[{ u: 777, w: 888, y: 999 }]]) {
+ assert.sameValue(v, 777);
+ assert.sameValue(x, 888);
+ assert.sameValue(z, 999);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-null.js
new file mode 100644
index 0000000000..87a8f06fcd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-null.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-val-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Nested object destructuring with a null value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ObjectBindingPattern
+
+ 1. Let valid be RequireObjectCoercible(value).
+ 2. ReturnIfAbrupt(valid).
+---*/
+
+async function fn() {
+ for await (let [{ x }] of [[null]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-undef.js
new file mode 100644
index 0000000000..846967279f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elem-obj-val-undef.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-val-undef.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Nested object destructuring with a value of `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ObjectBindingPattern
+
+ 1. Let valid be RequireObjectCoercible(value).
+ 2. ReturnIfAbrupt(valid).
+---*/
+
+async function fn() {
+ for await (let [{ x }] of [[]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..ad682d1160
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Elision accepts exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [,] of [iter]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-iter-close.js
new file mode 100644
index 0000000000..cde9f9bfb1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-iter-close.js
@@ -0,0 +1,56 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-iter-close.case
+// - src/dstr-binding-for-await/iter-close/for-await-of-async-func-let.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+async function fn() {
+ for await (let [,] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(() => {
+ assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-step-err.js
new file mode 100644
index 0000000000..4d250f00ce
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision-step-err.js
@@ -0,0 +1,77 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Elision advances iterator and forwards abrupt completions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+
+---*/
+var following = 0;
+var iter = function* () {
+ throw new Test262Error();
+ following += 1;
+}();
+
+async function fn() {
+ for await (let [,] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+ assert.sameValue(following, 0, "iterator is properly closed");
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision.js
new file mode 100644
index 0000000000..d10d5ce7b8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-elision.js
@@ -0,0 +1,81 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Elision advances iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [,] of [g()]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-empty.js
new file mode 100644
index 0000000000..f435cb9903
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-empty.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [] of [iter]) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..3223cdbe0c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,87 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...[x, y, z]] of [[3, 4, 5]]) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..7c53baa06a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,94 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element containing an elision (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...[,]] of [g()]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..41e5ffa77b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,77 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element containing an "empty" array pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...[]] of [iter]) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..84ace75a77
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element containing a rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...[...x]] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision-next-err.js
new file mode 100644
index 0000000000..d066552a3e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision-next-err.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision-next-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+
+---*/
+var iter = (function*() { throw new Test262Error(); })();
+
+async function fn() {
+ for await (let [, ...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..8c8d639556
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+---*/
+var values = [1, 2, 3, 4, 5];
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [ , , ...x] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 3);
+ assert.sameValue(x[1], 4);
+ assert.sameValue(x[2], 5);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..6ab10508b8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: RestElement applied to an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. If environment is undefined, return PutValue(lhs, A).
+ ii. Return InitializeReferencedBinding(lhs, A).
+
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [, , ...x] of [[1, 2]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-close.js
new file mode 100644
index 0000000000..2e1cbd6d7d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-close.js
@@ -0,0 +1,56 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-close.case
+// - src/dstr-binding-for-await/iter-close/for-await-of-async-func-let.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+async function fn() {
+ for await (let [...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(() => {
+ assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-step-err.js
new file mode 100644
index 0000000000..d4239d145c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-step-err.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ a. If iteratorRecord.[[done]] is false,
+ i. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ ii. If next is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ iii. ReturnIfAbrupt(next).
+
+---*/
+var first = 0;
+var second = 0;
+var iter = function*() {
+ first += 1;
+ throw new Test262Error();
+ second += 1;
+}();
+
+async function fn() {
+ for await (let [...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-val-err.js
new file mode 100644
index 0000000000..ca3566bb33
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id-iter-val-err.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-val-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ c. Let nextValue be IteratorValue(next).
+ d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ e. ReturnIfAbrupt(nextValue).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedValue;
+ }
+ };
+};
+
+async function fn() {
+ for await (let [...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..e78d345248
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-id.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Lone rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat
+ [...]
+ f. Let status be CreateDataProperty(A, ToString (n), nextValue).
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...x] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..3fb7d69957
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,63 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...[ x ] = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..1b6c269247
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-init-id.js
@@ -0,0 +1,63 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element (identifier) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...x = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..5fca922302
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,63 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...{ x } = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..e3b8ce461a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,63 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...[x], y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..527bfb7769
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,63 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...x, y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..cce68de75e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,63 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...{ x }, y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..dea34094e2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...{ length }] of [[1, 2, 3]]) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..87e31b2f24
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+let length = "outer";
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of [[7, 8, 9]]) {
+ assert.sameValue(v, 7);
+ assert.sameValue(w, 8);
+ assert.sameValue(x, 9);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 3);
+
+ assert.sameValue(length, "outer", "the length prop is not set as a binding name");
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-close.js
new file mode 100644
index 0000000000..2c12803cf7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-close.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: false };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (let [x] of asyncIter) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..2184bcda14
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-init-iter-no-close.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-no-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: true };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (let [x] of asyncIter) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-name-iter-val.js
new file mode 100644
index 0000000000..bfd65c558f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-name-iter-val.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-name-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding with normal value iteration (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (let [x, y, z] of asyncIter) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..2766da1d4a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [[x, y, z] = [4, 5, 6]] of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..34c058130d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[7, 8, 9]]];
+})();
+
+async function fn() {
+ for await (let [[x, y, z] = [4, 5, 6]] of asyncIter) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..1d104ca257
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [[,] = g()] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..b1f8ad96b2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var callCount = 0;
+function* g() {
+ callCount += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[]]];
+})();
+
+async function fn() {
+ for await (let [[,] = g()] of asyncIter) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..586d125470
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var initCount = 0;
+var iterCount = 0;
+var iter = function*() { iterCount += 1; }();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [[] = function() { initCount += 1; return iter; }()] of asyncIter) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..7382b80419
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var initCount = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[23]]];
+})();
+
+async function fn() {
+ for await (let [[] = function() { initCount += 1; }()] of asyncIter) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..5c61b8dd7b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [[...x] = values] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..2dad1b779e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+var initCount = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[values]];
+})();
+
+async function fn() {
+ for await (let [[...x] = function() { initCount += 1; }()] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..30f620de44
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..9a16fb16f2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [arrow = () => {}] of asyncIter) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..46d3a44ef5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of asyncIter) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..2f9f5e907f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [cover = (function () {}), xCover = (0, function() {})] of asyncIter) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..2a0df7eb4d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [fn = function () {}, xFn = function x() {}] of asyncIter) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..6dfa8cc773
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [gen = function* () {}, xGen = function* x() {}] of asyncIter) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..4dd91bd901
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Destructuring initializer with a "hole" (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ SingleNameBinding : BindingIdentifier Initializer_opt
+ [...] 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v). 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[,]];
+})();
+
+async function fn() {
+ for await (let [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..d1ffd57f8a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ 7. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[null, 0, false, '']];
+})();
+
+async function fn() {
+ for await (let [w = counter(), x = counter(), y = counter(), z = counter()] of asyncIter) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..1bf414da2d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Destructuring initializer with an undefined value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[undefined]];
+})();
+
+async function fn() {
+ for await (let [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..355fde2704
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding when value iteration completes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [x] of asyncIter) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..098c6a56bc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [_, x] of asyncIter) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..b8910d2ff7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (let [x, y, z] of asyncIter) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..5ad039e006
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..73bc1eb8c0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[{ x: 11, y: 22, z: 33 }]];
+})();
+
+async function fn() {
+ for await (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..5294a30bec
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) {
+ assert.sameValue(v, 444);
+ assert.sameValue(x, 555);
+ assert.sameValue(z, 666);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..91489c0466
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[{ u: 777, w: 888, y: 999 }]];
+})();
+
+async function fn() {
+ for await (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) {
+ assert.sameValue(v, 777);
+ assert.sameValue(x, 888);
+ assert.sameValue(z, 999);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..d50ff7feeb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Elision accepts exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (let [,] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision.js
new file mode 100644
index 0000000000..54e9aa732d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-elision.js
@@ -0,0 +1,83 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Elision advances iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [g()];
+})();
+
+async function fn() {
+ for await (let [,] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-empty.js
new file mode 100644
index 0000000000..1412548d25
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-empty.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (let [] of asyncIter) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..80b839b34f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,89 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[3, 4, 5]];
+})();
+
+async function fn() {
+ for await (let [...[x, y, z]] of asyncIter) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..98cc27fa93
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,96 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element containing an elision (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [g()];
+})();
+
+async function fn() {
+ for await (let [...[,]] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..df7cda990a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element containing an "empty" array pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (let [...[]] of asyncIter) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..c02d9edb22
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element containing a rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function fn() {
+ for await (let [...[...x]] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..2d0f072732
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+---*/
+var values = [1, 2, 3, 4, 5];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function fn() {
+ for await (let [ , , ...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 3);
+ assert.sameValue(x[1], 4);
+ assert.sameValue(x[2], 5);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..eb3b77a5d7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: RestElement applied to an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. If environment is undefined, return PutValue(lhs, A).
+ ii. Return InitializeReferencedBinding(lhs, A).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2]];
+})();
+
+async function fn() {
+ for await (let [, , ...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..a0e3d197ce
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-id.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Lone rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat
+ [...]
+ f. Let status be CreateDataProperty(A, ToString (n), nextValue).
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function fn() {
+ for await (let [...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..70196a5c7f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [...[ x ] = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..e92b94f566
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-id.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element (identifier) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [...x = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..11783bfbe5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (let [...{ x } = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..b9ac9ec762
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (let [...[x], y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..6c88048761
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (let [...x, y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..a44f20aa89
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (let [...{ x }, y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..1c3d70aa6b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (let [...{ length }] of asyncIter) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..9bd5d8e561
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+let length = "outer";
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[7, 8, 9]];
+})();
+
+async function fn() {
+ for await (let [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of asyncIter) {
+ assert.sameValue(v, 7);
+ assert.sameValue(w, 8);
+ assert.sameValue(x, 9);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 3);
+
+ assert.sameValue(length, "outer", "the length prop is not set as a binding name");
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-empty.js
new file mode 100644
index 0000000000..2f800465d2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-empty.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [obj];
+})();
+
+async function fn() {
+ for await (let {} of asyncIter) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..978ff88e80
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (let { arrow = () => {} } of asyncIter) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..ea7a8e93b9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (let { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of asyncIter) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..8d809eba94
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (let { cover = (function () {}), xCover = (0, function() {}) } of asyncIter) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..58af128faa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (let { fn = function () {}, xFn = function x() {} } of asyncIter) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..3dab3ca931
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (let { gen = function* () {}, xGen = function* x() {} } of asyncIter) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..76164457df
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: null, x: 0, y: false, z: '' }];
+})();
+
+async function fn() {
+ for await (let { w = counter(), x = counter(), y = counter(), z = counter() } of asyncIter) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..1bb45428a4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function fn() {
+ for await (let { x, } of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..723b10f800
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (let { w: [x, y, z] = [4, 5, 6] } of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..7bfcefb058
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: [45] }];
+})();
+
+async function fn() {
+ for await (let { x: [y], } of asyncIter) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..f5419463c5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-ary.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: [7, undefined, ] }];
+})();
+
+async function fn() {
+ for await (let { w: [x, y, z] = [4, 5, 6] } of asyncIter) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..ea3a1ff91e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,84 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ s: null, u: 0, w: false, y: '' }];
+})();
+
+async function fn() {
+ for await (let { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of asyncIter) {
+ assert.sameValue(t, null);
+ assert.sameValue(v, 0);
+ assert.sameValue(x, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ assert.throws(ReferenceError, function() {
+ s;
+ });
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..941aef4d56
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-init.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ }];
+})();
+
+async function fn() {
+ for await (let { x: y = 33 } of asyncIter) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..c0e670d6b8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function fn() {
+ for await (let { x: y, } of asyncIter) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..312666e1fb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-id.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Binding as specified via property name and identifier (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function fn() {
+ for await (let { x: y } of asyncIter) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..9ef3856ecf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: undefined }];
+})();
+
+async function fn() {
+ for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..846ee5bbcd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-prop-obj.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: { x: undefined, z: 7 } }];
+})();
+
+async function fn() {
+ for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..e0e7b90086
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-getter.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-getter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var count = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ get v() { count++; return 2; } }];
+})();
+
+async function fn() {
+ for await (let {...x} of asyncIter) {
+ assert.sameValue(x.v, 2);
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..3d0cceb4c6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [o];
+})();
+
+async function fn() {
+ for await (let {...rest} of asyncIter) {
+ assert.sameValue(rest.a, 3);
+ assert.sameValue(rest.b, 4);
+ assert.sameValue(rest.x, undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..c4439f08a6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-async-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{x: 1, y: 2, a: 5, b: 3}];
+})();
+
+async function fn() {
+ for await (let {a, b, ...rest} of asyncIter) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-init-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-init-null.js
new file mode 100644
index 0000000000..3fb5bcb541
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-init-null.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-init-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+async function fn() {
+ for await (let {} of [null]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-init-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-init-undefined.js
new file mode 100644
index 0000000000..49bab4b83d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-init-undefined.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-init-undefined.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (undefined) (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+async function fn() {
+ for await (let {} of [undefined]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-empty.js
new file mode 100644
index 0000000000..ad61c089e6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-empty.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let {} of [obj]) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-get-value-err.js
new file mode 100644
index 0000000000..94ca615a63
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-get-value-err.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-get-value-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. Let v be GetV(value, propertyName).
+ 5. ReturnIfAbrupt(v).
+---*/
+var poisonedProperty = Object.defineProperty({}, 'poisoned', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+async function fn() {
+ for await (let { poisoned } of [poisonedProperty]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..e8ad4d887b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { arrow = () => {} } of [{}]) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..cc8eee4ee4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of [{}]) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..29508617bc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { cover = (function () {}), xCover = (0, function() {}) } of [{}]) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..e200a2ee9b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { fn = function () {}, xFn = function x() {} } of [{}]) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..1f8a286b74
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { gen = function* () {}, xGen = function* x() {} } of [{}]) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..e987b36a07
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { w = counter(), x = counter(), y = counter(), z = counter() } of [{ w: null, x: 0, y: false, z: '' }]) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-throws.js
new file mode 100644
index 0000000000..f52c10fb02
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-throws.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Error thrown when evaluating the initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ c. ReturnIfAbrupt(v).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function fn() {
+ for await (let { x = thrower() } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-unresolvable.js
new file mode 100644
index 0000000000..5e491f763d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-init-unresolvable.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function fn() {
+ for await (let { x = unresolvableReference } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..1dc4057c6a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { x, } of [{ x: 23 }]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-list-err.js
new file mode 100644
index 0000000000..629ef0ea8f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-list-err.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-list-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPropertyList : BindingPropertyList , BindingProperty
+
+ 1. Let status be the result of performing BindingInitialization for
+ BindingPropertyList using value and environment as arguments.
+ 2. ReturnIfAbrupt(status).
+---*/
+var initCount = 0;
+function thrower() {
+ throw new Test262Error();
+}
+
+async function fn() {
+ for await (let { a, b = thrower(), c = ++initCount } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..49b32ed8dc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { w: [x, y, z] = [4, 5, 6] } of [{}]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..d6031925a9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { x: [y], } of [{ x: [45] }]) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-value-null.js
new file mode 100644
index 0000000000..e26dc3722c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary-value-null.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-value-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Object binding pattern with "nested" array binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function fn() {
+ for await (let { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..80d9fc026a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-ary.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { w: [x, y, z] = [4, 5, 6] } of [{ w: [7, undefined, ] }]) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-eval-err.js
new file mode 100644
index 0000000000..947d617028
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-eval-err.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-eval-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Evaluation of property name returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingProperty : PropertyName : BindingElement
+
+ 1. Let P be the result of evaluating PropertyName
+ 2. ReturnIfAbrupt(P).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function fn() {
+ for await (let { [thrower()]: x } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-get-value-err.js
new file mode 100644
index 0000000000..2e8977b2f2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-get-value-err.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-get-value-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. Let v be GetV(value, propertyName).
+ 2. ReturnIfAbrupt(v).
+---*/
+var initEvalCount = 0;
+var poisonedProperty = Object.defineProperty({}, 'poisoned', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+async function fn() {
+ for await (let { poisoned: x = ++initEvalCount } of [poisonedProperty]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..46c30af3ec
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,82 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of [{ s: null, u: 0, w: false, y: '' }]) {
+ assert.sameValue(t, null);
+ assert.sameValue(v, 0);
+ assert.sameValue(x, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ assert.throws(ReferenceError, function() {
+ s;
+ });
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-throws.js
new file mode 100644
index 0000000000..cdbab8e6d5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-throws.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Error thrown when evaluating the initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function fn() {
+ for await (let { x: y = thrower() } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-unresolvable.js
new file mode 100644
index 0000000000..f46d6d5abe
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init-unresolvable.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function fn() {
+ for await (let { x: y = unresolvableReference } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..0716115e94
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-init.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { x: y = 33 } of [{ }]) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..1652da3f6e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { x: y, } of [{ x: 23 }]) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..bc8953ff47
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-id.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Binding as specified via property name and identifier (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { x: y } of [{ x: 23 }]) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..727e856636
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: undefined }]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-null.js
new file mode 100644
index 0000000000..80ee10948e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-null.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-value-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function fn() {
+ for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-undef.js
new file mode 100644
index 0000000000..f6ce1ad197
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj-value-undef.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-value-undef.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-let.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function fn() {
+ for await (let { w: { x, y, z } = undefined } of [{ }]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..12472646ab
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-prop-obj.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: { x: undefined, z: 7 } }]) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..91fb8b1065
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-getter.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-getter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var count = 0;
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let {...x} of [{ get v() { count++; return 2; } }]) {
+ assert.sameValue(x.v, 2);
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..ce8dff6cbf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let {...rest} of [o]) {
+ assert.sameValue(rest.a, 3);
+ assert.sameValue(rest.b, 4);
+ assert.sameValue(rest.x, undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..8e6054101e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-let-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (let {a, b, ...rest} of [{x: 1, y: 2, a: 5, b: 3}]) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-close.js
new file mode 100644
index 0000000000..26b5bcf376
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-close.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: false };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [x] of [iter]) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-get-err.js
new file mode 100644
index 0000000000..81e058dcd4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-get-err.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-get-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Abrupt completion returned by GetIterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ 1. Let iterator be ? GetIterator(value).
+
+---*/
+var iter = {};
+iter[Symbol.iterator] = function() {
+ throw new Test262Error();
+};
+
+async function fn() {
+ for await (var [x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..5072dc9c53
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-init-iter-no-close.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-no-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: true };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [x] of [iter]) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-name-iter-val.js
new file mode 100644
index 0000000000..066fd1e445
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-name-iter-val.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-name-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding with normal value iteration (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..ffad66eea0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [[x, y, z] = [4, 5, 6]] of [[]]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..8bf634f7bc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [[x, y, z] = [4, 5, 6]] of [[[7, 8, 9]]]) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..b8634948d4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [[,] = g()] of [[]]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..ab16b2e1d1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var callCount = 0;
+function* g() {
+ callCount += 1;
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [[,] = g()] of [[[]]]) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..7f944b95a3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var initCount = 0;
+var iterCount = 0;
+var iter = function*() { iterCount += 1; }();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [[] = function() { initCount += 1; return iter; }()] of [[]]) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..b7b169f347
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var initCount = 0;
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [[] = function() { initCount += 1; }()] of [[[23]]]) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..088ad41542
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [[...x] = values] of [[]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..8af8a1979a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+var initCount = 0;
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [[...x] = function() { initCount += 1; }()] of [[values]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-val-null.js
new file mode 100644
index 0000000000..c557e9d433
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-ary-val-null.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-val-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Nested array destructuring with a null value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ 1. Let iterator be ? GetIterator(value).
+---*/
+
+async function fn() {
+ for await (var [[x]] of [[null]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..8105d0ce19
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [x = 23] of [[]]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..c38a52f8ce
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [arrow = () => {}] of [[]]) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..abdadc9f49
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of [[]]) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..1a6d611578
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [cover = (function () {}), xCover = (0, function() {})] of [[]]) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..5846b64e36
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [fn = function () {}, xFn = function x() {}] of [[]]) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..891530e078
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [gen = function* () {}, xGen = function* x() {}] of [[]]) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..cad6486c31
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Destructuring initializer with a "hole" (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ SingleNameBinding : BindingIdentifier Initializer_opt
+ [...] 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v). 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [x = 23] of [[,]]) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..e28047e1a1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ 7. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [w = counter(), x = counter(), y = counter(), z = counter()] of [[null, 0, false, '']]) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-throws.js
new file mode 100644
index 0000000000..c49994d415
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-throws.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Destructuring initializer returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+---*/
+
+async function fn() {
+ for await (var [x = (function() { throw new Test262Error(); })()] of [[undefined]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..b264770d37
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Destructuring initializer with an undefined value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [x = 23] of [[undefined]]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-unresolvable.js
new file mode 100644
index 0000000000..cf636d7a2e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-init-unresolvable.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function fn() {
+ for await (var [ x = unresolvableReference ] of [[]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..e64d354e95
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding when value iteration completes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [x] of [[]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..739bb48158
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [_, x] of [[]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-step-err.js
new file mode 100644
index 0000000000..7d57f363a2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-step-err.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+
+---*/
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next() {
+ throw new Test262Error();
+ }
+ };
+};
+
+async function fn() {
+ for await (var [x] of [g]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val-err.js
new file mode 100644
index 0000000000..d91b0135a6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val-err.js
@@ -0,0 +1,83 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ iii. ReturnIfAbrupt(v).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedValue;
+ }
+ };
+};
+
+async function fn() {
+ for await (var [x] of [g]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..e74fb6774c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..1b8cfb331b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[]]) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..7fafa23296
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[{ x: 11, y: 22, z: 33 }]]) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..575118b691
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[]]) {
+ assert.sameValue(v, 444);
+ assert.sameValue(x, 555);
+ assert.sameValue(z, 666);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..cbfd541c03
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[{ u: 777, w: 888, y: 999 }]]) {
+ assert.sameValue(v, 777);
+ assert.sameValue(x, 888);
+ assert.sameValue(z, 999);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-null.js
new file mode 100644
index 0000000000..b021321fdb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-null.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-val-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Nested object destructuring with a null value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ObjectBindingPattern
+
+ 1. Let valid be RequireObjectCoercible(value).
+ 2. ReturnIfAbrupt(valid).
+---*/
+
+async function fn() {
+ for await (var [{ x }] of [[null]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-undef.js
new file mode 100644
index 0000000000..d3ac9206d6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elem-obj-val-undef.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-val-undef.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Nested object destructuring with a value of `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ObjectBindingPattern
+
+ 1. Let valid be RequireObjectCoercible(value).
+ 2. ReturnIfAbrupt(valid).
+---*/
+
+async function fn() {
+ for await (var [{ x }] of [[]]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..0c79532e9f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Elision accepts exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [,] of [iter]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-iter-close.js
new file mode 100644
index 0000000000..decc9af81c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-iter-close.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-iter-close.case
+// - src/dstr-binding-for-await/iter-close/for-await-of-async-func-var.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+async function fn() {
+ for await (var [,] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(() => {
+ assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-step-err.js
new file mode 100644
index 0000000000..9cd0b776e3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision-step-err.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Elision advances iterator and forwards abrupt completions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+
+---*/
+var following = 0;
+var iter = function* () {
+ throw new Test262Error();
+ following += 1;
+}();
+
+async function fn() {
+ for await (var [,] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+ assert.sameValue(following, 0, "iterator is properly closed");
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision.js
new file mode 100644
index 0000000000..8df07cdec2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-elision.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Elision advances iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [,] of [g()]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-empty.js
new file mode 100644
index 0000000000..d650f9b862
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-empty.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [] of [iter]) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..6805be6f11
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,84 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...[x, y, z]] of [[3, 4, 5]]) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..3738643618
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,91 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element containing an elision (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...[,]] of [g()]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..6a99e37fe8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element containing an "empty" array pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...[]] of [iter]) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..59869b0c60
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element containing a rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...[...x]] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision-next-err.js
new file mode 100644
index 0000000000..8b8aaf4af6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision-next-err.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision-next-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+
+---*/
+var iter = (function*() { throw new Test262Error(); })();
+
+async function fn() {
+ for await (var [, ...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..b30aa70e2f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+---*/
+var values = [1, 2, 3, 4, 5];
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [ , , ...x] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 3);
+ assert.sameValue(x[1], 4);
+ assert.sameValue(x[2], 5);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..3434568917
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: RestElement applied to an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. If environment is undefined, return PutValue(lhs, A).
+ ii. Return InitializeReferencedBinding(lhs, A).
+
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [, , ...x] of [[1, 2]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-close.js
new file mode 100644
index 0000000000..fbb941c0e6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-close.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-close.case
+// - src/dstr-binding-for-await/iter-close/for-await-of-async-func-var.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+async function fn() {
+ for await (var [...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(() => {
+ assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-step-err.js
new file mode 100644
index 0000000000..5420a02533
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-step-err.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ a. If iteratorRecord.[[done]] is false,
+ i. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ ii. If next is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ iii. ReturnIfAbrupt(next).
+
+---*/
+var first = 0;
+var second = 0;
+var iter = function*() {
+ first += 1;
+ throw new Test262Error();
+ second += 1;
+}();
+
+async function fn() {
+ for await (var [...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-val-err.js
new file mode 100644
index 0000000000..19c5cffbcf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id-iter-val-err.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-val-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ c. Let nextValue be IteratorValue(next).
+ d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ e. ReturnIfAbrupt(nextValue).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedValue;
+ }
+ };
+};
+
+async function fn() {
+ for await (var [...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..dac2d39a7c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-id.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Lone rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat
+ [...]
+ f. Let status be CreateDataProperty(A, ToString (n), nextValue).
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...x] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..0f9cab368a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,60 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...[ x ] = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..d1c6118774
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-init-id.js
@@ -0,0 +1,60 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element (identifier) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...x = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..59b0bec6a3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,60 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...{ x } = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..cbcef9096a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,60 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...[x], y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..4c442a32ce
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,60 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...x, y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..c11cd1e2b5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,60 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...{ x }, y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..36155c51b2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...{ length }] of [[1, 2, 3]]) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..7a0ec789c5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+let length = "outer";
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of [[7, 8, 9]]) {
+ assert.sameValue(v, 7);
+ assert.sameValue(w, 8);
+ assert.sameValue(x, 9);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 3);
+
+ assert.sameValue(length, "outer", "the length prop is not set as a binding name");
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-close.js
new file mode 100644
index 0000000000..0f3b483569
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-close.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: false };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (var [x] of asyncIter) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..b3efd2ace2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-init-iter-no-close.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-no-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: true };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (var [x] of asyncIter) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-name-iter-val.js
new file mode 100644
index 0000000000..c07b541a84
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-name-iter-val.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-name-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding with normal value iteration (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (var [x, y, z] of asyncIter) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..d28f01aff2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [[x, y, z] = [4, 5, 6]] of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..92e97133c5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[7, 8, 9]]];
+})();
+
+async function fn() {
+ for await (var [[x, y, z] = [4, 5, 6]] of asyncIter) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..23e85da9f3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [[,] = g()] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..e86c02a621
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var callCount = 0;
+function* g() {
+ callCount += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[]]];
+})();
+
+async function fn() {
+ for await (var [[,] = g()] of asyncIter) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..c040c9e34b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var initCount = 0;
+var iterCount = 0;
+var iter = function*() { iterCount += 1; }();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [[] = function() { initCount += 1; return iter; }()] of asyncIter) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..4e62a83478
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var initCount = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[23]]];
+})();
+
+async function fn() {
+ for await (var [[] = function() { initCount += 1; }()] of asyncIter) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..c4569ed3f2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [[...x] = values] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..a6fe729989
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+var initCount = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[values]];
+})();
+
+async function fn() {
+ for await (var [[...x] = function() { initCount += 1; }()] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..c11407299b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..065bcf0066
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [arrow = () => {}] of asyncIter) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..ab076ab31f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of asyncIter) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..b167a39ee2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [cover = (function () {}), xCover = (0, function() {})] of asyncIter) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..3ea0e025eb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [fn = function () {}, xFn = function x() {}] of asyncIter) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..54f22820f6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [gen = function* () {}, xGen = function* x() {}] of asyncIter) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..5276dcf6ee
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Destructuring initializer with a "hole" (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ SingleNameBinding : BindingIdentifier Initializer_opt
+ [...] 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v). 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[,]];
+})();
+
+async function fn() {
+ for await (var [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..6fe00cd9e4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ 7. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[null, 0, false, '']];
+})();
+
+async function fn() {
+ for await (var [w = counter(), x = counter(), y = counter(), z = counter()] of asyncIter) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..16a6aa2a75
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Destructuring initializer with an undefined value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[undefined]];
+})();
+
+async function fn() {
+ for await (var [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..08bffc62bb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding when value iteration completes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [x] of asyncIter) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..4589986582
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [_, x] of asyncIter) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..1fe2e32cf2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (var [x, y, z] of asyncIter) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..52a1935e46
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..7d08ae79c1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[{ x: 11, y: 22, z: 33 }]];
+})();
+
+async function fn() {
+ for await (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..4566b35187
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) {
+ assert.sameValue(v, 444);
+ assert.sameValue(x, 555);
+ assert.sameValue(z, 666);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..ef5ae3fda6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[{ u: 777, w: 888, y: 999 }]];
+})();
+
+async function fn() {
+ for await (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) {
+ assert.sameValue(v, 777);
+ assert.sameValue(x, 888);
+ assert.sameValue(z, 999);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..bebe950c0d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Elision accepts exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (var [,] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision.js
new file mode 100644
index 0000000000..ecd0b28c80
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-elision.js
@@ -0,0 +1,83 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Elision advances iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [g()];
+})();
+
+async function fn() {
+ for await (var [,] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-empty.js
new file mode 100644
index 0000000000..ef42e42961
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-empty.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (var [] of asyncIter) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..e1aca14e3b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,89 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[3, 4, 5]];
+})();
+
+async function fn() {
+ for await (var [...[x, y, z]] of asyncIter) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..f5ecdeb98e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,96 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element containing an elision (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [g()];
+})();
+
+async function fn() {
+ for await (var [...[,]] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..9498b9025b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element containing an "empty" array pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function fn() {
+ for await (var [...[]] of asyncIter) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..bc3dcafc1c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element containing a rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function fn() {
+ for await (var [...[...x]] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..c678f2fea5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+---*/
+var values = [1, 2, 3, 4, 5];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function fn() {
+ for await (var [ , , ...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 3);
+ assert.sameValue(x[1], 4);
+ assert.sameValue(x[2], 5);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..526b778b9b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: RestElement applied to an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. If environment is undefined, return PutValue(lhs, A).
+ ii. Return InitializeReferencedBinding(lhs, A).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2]];
+})();
+
+async function fn() {
+ for await (var [, , ...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..694de9c966
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-id.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Lone rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat
+ [...]
+ f. Let status be CreateDataProperty(A, ToString (n), nextValue).
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function fn() {
+ for await (var [...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..8d6ea4b7c3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [...[ x ] = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..aba8fc38d0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-id.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element (identifier) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [...x = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..21d02c1534
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function fn() {
+ for await (var [...{ x } = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..9fd265fb5a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (var [...[x], y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..44f77eebe8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (var [...x, y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..1147b4ac6c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (var [...{ x }, y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..9b9295f030
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function fn() {
+ for await (var [...{ length }] of asyncIter) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..d28f85bb82
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+let length = "outer";
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[7, 8, 9]];
+})();
+
+async function fn() {
+ for await (var [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of asyncIter) {
+ assert.sameValue(v, 7);
+ assert.sameValue(w, 8);
+ assert.sameValue(x, 9);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 3);
+
+ assert.sameValue(length, "outer", "the length prop is not set as a binding name");
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-empty.js
new file mode 100644
index 0000000000..dcb75fb088
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-empty.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [obj];
+})();
+
+async function fn() {
+ for await (var {} of asyncIter) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..a799e6c3e3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (var { arrow = () => {} } of asyncIter) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..be1f66f282
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (var { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of asyncIter) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..67122fcca1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (var { cover = (function () {}), xCover = (0, function() {}) } of asyncIter) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..fe4d937394
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (var { fn = function () {}, xFn = function x() {} } of asyncIter) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..29cb95d428
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (var { gen = function* () {}, xGen = function* x() {} } of asyncIter) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..ed8a23a970
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: null, x: 0, y: false, z: '' }];
+})();
+
+async function fn() {
+ for await (var { w = counter(), x = counter(), y = counter(), z = counter() } of asyncIter) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..9d5b467d66
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function fn() {
+ for await (var { x, } of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..7576067d19
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function fn() {
+ for await (var { w: [x, y, z] = [4, 5, 6] } of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..e82be30f10
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: [45] }];
+})();
+
+async function fn() {
+ for await (var { x: [y], } of asyncIter) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..cd233bba5b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-ary.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: [7, undefined, ] }];
+})();
+
+async function fn() {
+ for await (var { w: [x, y, z] = [4, 5, 6] } of asyncIter) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..f0fa636031
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,84 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ s: null, u: 0, w: false, y: '' }];
+})();
+
+async function fn() {
+ for await (var { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of asyncIter) {
+ assert.sameValue(t, null);
+ assert.sameValue(v, 0);
+ assert.sameValue(x, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ assert.throws(ReferenceError, function() {
+ s;
+ });
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..408cd38e19
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-init.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ }];
+})();
+
+async function fn() {
+ for await (var { x: y = 33 } of asyncIter) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..0ee2bb4680
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function fn() {
+ for await (var { x: y, } of asyncIter) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..77129a4e9b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-id.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Binding as specified via property name and identifier (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function fn() {
+ for await (var { x: y } of asyncIter) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..de7aee268f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: undefined }];
+})();
+
+async function fn() {
+ for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..e6197ffd3f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-prop-obj.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: { x: undefined, z: 7 } }];
+})();
+
+async function fn() {
+ for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..028b098e1a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-getter.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-getter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var count = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ get v() { count++; return 2; } }];
+})();
+
+async function fn() {
+ for await (var {...x} of asyncIter) {
+ assert.sameValue(x.v, 2);
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..b296c76684
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [o];
+})();
+
+async function fn() {
+ for await (var {...rest} of asyncIter) {
+ assert.sameValue(rest.a, 3);
+ assert.sameValue(rest.b, 4);
+ assert.sameValue(rest.x, undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..260669b53f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-async-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{x: 1, y: 2, a: 5, b: 3}];
+})();
+
+async function fn() {
+ for await (var {a, b, ...rest} of asyncIter) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-init-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-init-null.js
new file mode 100644
index 0000000000..d0c035361d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-init-null.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-init-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+async function fn() {
+ for await (var {} of [null]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-init-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-init-undefined.js
new file mode 100644
index 0000000000..292c3dc196
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-init-undefined.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-init-undefined.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (undefined) (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+async function fn() {
+ for await (var {} of [undefined]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-empty.js
new file mode 100644
index 0000000000..da7d82f965
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-empty.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var {} of [obj]) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-get-value-err.js
new file mode 100644
index 0000000000..4c43fda5c7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-get-value-err.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-get-value-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. Let v be GetV(value, propertyName).
+ 5. ReturnIfAbrupt(v).
+---*/
+var poisonedProperty = Object.defineProperty({}, 'poisoned', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+async function fn() {
+ for await (var { poisoned } of [poisonedProperty]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..cdd5bad606
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { arrow = () => {} } of [{}]) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..180deff0f6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of [{}]) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..03cc5c9b2d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { cover = (function () {}), xCover = (0, function() {}) } of [{}]) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..7e4a863d69
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { fn = function () {}, xFn = function x() {} } of [{}]) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..6aeae53c91
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { gen = function* () {}, xGen = function* x() {} } of [{}]) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..cb71ca490c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { w = counter(), x = counter(), y = counter(), z = counter() } of [{ w: null, x: 0, y: false, z: '' }]) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-throws.js
new file mode 100644
index 0000000000..6f6f8df34f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-throws.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Error thrown when evaluating the initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ c. ReturnIfAbrupt(v).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function fn() {
+ for await (var { x = thrower() } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-unresolvable.js
new file mode 100644
index 0000000000..69ef5f75ca
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-init-unresolvable.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function fn() {
+ for await (var { x = unresolvableReference } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..78bea5ca5a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,57 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { x, } of [{ x: 23 }]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-list-err.js
new file mode 100644
index 0000000000..5bcbd0d6a1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-list-err.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-list-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPropertyList : BindingPropertyList , BindingProperty
+
+ 1. Let status be the result of performing BindingInitialization for
+ BindingPropertyList using value and environment as arguments.
+ 2. ReturnIfAbrupt(status).
+---*/
+var initCount = 0;
+function thrower() {
+ throw new Test262Error();
+}
+
+async function fn() {
+ for await (var { a, b = thrower(), c = ++initCount } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..6b3df9dbb9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { w: [x, y, z] = [4, 5, 6] } of [{}]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..a12cc2cd05
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,57 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { x: [y], } of [{ x: [45] }]) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-value-null.js
new file mode 100644
index 0000000000..827a8a9a93
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary-value-null.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-value-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Object binding pattern with "nested" array binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function fn() {
+ for await (var { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..93ac81ff5e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-ary.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { w: [x, y, z] = [4, 5, 6] } of [{ w: [7, undefined, ] }]) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-eval-err.js
new file mode 100644
index 0000000000..3693581ae5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-eval-err.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-eval-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Evaluation of property name returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingProperty : PropertyName : BindingElement
+
+ 1. Let P be the result of evaluating PropertyName
+ 2. ReturnIfAbrupt(P).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function fn() {
+ for await (var { [thrower()]: x } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-get-value-err.js
new file mode 100644
index 0000000000..5edac98684
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-get-value-err.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-get-value-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. Let v be GetV(value, propertyName).
+ 2. ReturnIfAbrupt(v).
+---*/
+var initEvalCount = 0;
+var poisonedProperty = Object.defineProperty({}, 'poisoned', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+async function fn() {
+ for await (var { poisoned: x = ++initEvalCount } of [poisonedProperty]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..620981233a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of [{ s: null, u: 0, w: false, y: '' }]) {
+ assert.sameValue(t, null);
+ assert.sameValue(v, 0);
+ assert.sameValue(x, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ assert.throws(ReferenceError, function() {
+ s;
+ });
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-throws.js
new file mode 100644
index 0000000000..3497bcc6d5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-throws.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Error thrown when evaluating the initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function fn() {
+ for await (var { x: y = thrower() } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-unresolvable.js
new file mode 100644
index 0000000000..a9bfe10c6c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init-unresolvable.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function fn() {
+ for await (var { x: y = unresolvableReference } of [{}]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..75bd40967a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-init.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { x: y = 33 } of [{ }]) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..8a48ffe8a0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { x: y, } of [{ x: 23 }]) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..3012b769ae
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-id.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Binding as specified via property name and identifier (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { x: y } of [{ x: 23 }]) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..e188ec0aec
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: undefined }]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-null.js
new file mode 100644
index 0000000000..f3a234a025
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-null.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-value-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function fn() {
+ for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-undef.js
new file mode 100644
index 0000000000..09f903fcd8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj-value-undef.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-value-undef.case
+// - src/dstr-binding-for-await/error/for-await-of-async-func-var.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function fn() {
+ for await (var { w: { x, y, z } = undefined } of [{ }]) {
+ return;
+ }
+}
+
+fn()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..d317904880
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-prop-obj.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: { x: undefined, z: 7 } }]) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..bb588ec81a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-getter.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-getter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+---*/
+var count = 0;
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var {...x} of [{ get v() { count++; return 2; } }]) {
+ assert.sameValue(x.v, 2);
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..843a85325d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var {...rest} of [o]) {
+ assert.sameValue(rest.a, 3);
+ assert.sameValue(rest.b, 4);
+ assert.sameValue(rest.x, undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..8d0cdb775e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-func-dstr-var-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-func-var.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+
+async function fn() {
+ for await (var {a, b, ...rest} of [{x: 1, y: 2, a: 5, b: 3}]) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-assignment.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-assignment.js
new file mode 100644
index 0000000000..a62872d7d9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-assignment.js
@@ -0,0 +1,48 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-assignment.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let v2, vNull, vHole, vUndefined, vOob;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([v2 = 10, vNull = 11, vHole = 12, vUndefined = 13, vOob = 14] of [[2, null, , undefined]]) {
+ assert.sameValue(v2, 2);
+ assert.sameValue(vNull, null);
+ assert.sameValue(vHole, 12);
+ assert.sameValue(vUndefined, 13);
+ assert.sameValue(vOob, 14);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-evaluation.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-evaluation.js
new file mode 100644
index 0000000000..96b72fb272
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-evaluation.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-evaluation.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: The Initializer should only be evaluated if v is undefined. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let flag1 = false, flag2 = false;
+let _;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ _ = flag1 = true, _ = flag2 = true ] of [[14]]) {
+ assert.sameValue(flag1, false);
+ assert.sameValue(flag2, true);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-arrow.js
new file mode 100644
index 0000000000..bc074cd5c2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-arrow.js
@@ -0,0 +1,57 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-fn-name-arrow.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (ArrowFunction) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 7. If Initializer is present and value is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(v, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
+
+---*/
+let arrow;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ arrow = () => {} ] of [[]]) {
+ verifyProperty(arrow, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'arrow'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-class.js
new file mode 100644
index 0000000000..f2c70ad77b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-class.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-fn-name-class.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (ClassExpression) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [class, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 7. If Initializer is present and value is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(v, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
+
+---*/
+let xCls, cls, xCls2;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } ] of [[]]) {
+ assert(xCls.name !== 'xCls');
+ assert(xCls2.name !== 'xCls2');
+
+ verifyProperty(cls, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'cls'
+ });
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-cover.js
new file mode 100644
index 0000000000..5eb7b7618e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-cover.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-fn-name-cover.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (CoverParenthesizedExpression) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 7. If Initializer is present and value is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(v, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
+
+---*/
+let xCover, cover;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ xCover = (0, function() {}), cover = (function() {}) ] of [[]]) {
+ assert(xCover.name !== 'xCover');
+
+ verifyProperty(cover, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'cover'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-fn.js
new file mode 100644
index 0000000000..af0d772a74
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-fn.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-fn-name-fn.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (FunctionExpression) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [class, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 7. If Initializer is present and value is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(v, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
+
+---*/
+let xFnexp, fnexp;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ xFnexp = function x() {}, fnexp = function() {} ] of [[]]) {
+ assert(xFnexp.name !== 'xFnexp');
+
+ verifyProperty(fnexp, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'fnexp'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-gen.js
new file mode 100644
index 0000000000..0efad4abd6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-fn-name-gen.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-fn-name-gen.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (GeneratorExpression) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 7. If Initializer is present and value is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(v, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
+
+---*/
+let xGen, gen;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ xGen = function* x() {}, gen = function*() {} ] of [[]]) {
+ assert.notSameValue(xGen.name, 'xGen');
+
+ verifyProperty(gen, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'gen'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-in.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-in.js
new file mode 100644
index 0000000000..93cc08e217
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-in.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-in.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: The Initializer in an AssignmentElement may be an `in` expression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x = 'x' in {} ] of [[]]) {
+ assert.sameValue(x, false);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-order.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-order.js
new file mode 100644
index 0000000000..691c66fbf1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-order.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-order.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Initializer values should be assigned in left-to-right order. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = 0;
+let a, b;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ a = x += 1, b = x *= 2 ] of [[]]) {
+ assert.sameValue(a, 1);
+ assert.sameValue(b, 2);
+ assert.sameValue(x, 2);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-simple-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-simple-no-strict.js
new file mode 100644
index 0000000000..b8298c1963
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-simple-no-strict.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-simple-no-strict.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Identifiers that appear as the DestructuringAssignmentTarget in an AssignmentElement should take on the iterated value corresponding to their position in the ArrayAssignmentPattern. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let argument, eval;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([arguments = 4, eval = 5] of [[]]) {
+ assert.sameValue(arguments, 4);
+ assert.sameValue(eval, 5);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-yield-expr.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-yield-expr.js
new file mode 100644
index 0000000000..4ef1de9687
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-init-yield-expr.js
@@ -0,0 +1,51 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-init-yield-expr.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of an AssignmentElement within a generator function body, it behaves as a YieldExpression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let value = [];
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x = yield ] of [[]]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, false);
+ assert.sameValue(x, undefined);
+
+ iter.next(4).then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, true);
+ assert.sameValue(x, 4);
+ }).then($DONE, $DONE);
+}, $DONE).catch($DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-get-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-get-err.js
new file mode 100644
index 0000000000..ef6a190929
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-get-err.js
@@ -0,0 +1,54 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-iter-get-err.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: Abrupt completion returned from GetIterator (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ AssignmentElementList ]
+
+ 1. Let iterator be ? GetIterator(value).
+
+---*/
+let iterable = {
+ [Symbol.iterator]() {
+ throw new Test262Error();
+ }
+};
+let _;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ _ ] of [iterable]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+}).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-err.js
new file mode 100644
index 0000000000..1046dac206
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-err.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-iter-nrml-close-err.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: Abrupt completion returned from IteratorClose (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ AssignmentElementList ]
+
+ [...]
+ 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let _;
+let iterator = {
+ next() {
+ nextCount += 1;
+ // Set an upper-bound to limit unnecessary iteration in non-conformant
+ // implementations
+ return { done: nextCount > 10 };
+ },
+ return() {
+ returnCount += 1;
+ throw new Test262Error();
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ _ ] of [iterable]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 1);
+ assert.sameValue(constructor, Test262Error);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-null.js
new file mode 100644
index 0000000000..72040af2d8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-null.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-iter-nrml-close-null.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose throws a TypeError when `return` returns a non-Object value (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ AssignmentElementList ]
+
+ [...]
+ 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
+ 5. Return result.
+
+ 7.4.6 IteratorClose( iterator, completion )
+
+ [...]
+ 5. Let innerResult be Call(return, iterator, « »).
+ 6. If completion.[[Type]] is throw, return Completion(completion).
+ 7. If innerResult.[[Type]] is throw, return Completion(innerResult).
+ 8. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
+
+---*/
+let _;
+let nextCount = 0;
+let iterator = {
+ next() {
+ nextCount += 1;
+ // Set an upper-bound to limit unnecessary iteration in non-conformant
+ // implementations
+ return { done: nextCount > 10 };
+ },
+ return() {
+ return null;
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ _ ] of [iterable]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-skip.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-skip.js
new file mode 100644
index 0000000000..037f78f5d5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close-skip.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-iter-nrml-close-skip.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose is not called when assignment evaluation has exhausted the iterator (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ AssignmentElementList ]
+
+ [...]
+ 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
+ 5. Return result.
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let _;
+let iterator = {
+ next() {
+ nextCount += 1;
+ return { done: true };
+ },
+ return() {
+ returnCount += 1;
+ return {};
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ _ ] of [iterable]) {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(() => {
+ assert.sameValue(iterCount, 1);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close.js
new file mode 100644
index 0000000000..ae28397bbc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-nrml-close.js
@@ -0,0 +1,82 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-iter-nrml-close.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: IteratorClose is called when assignment evaluation has not exhausted the iterator (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ AssignmentElementList ]
+
+ [...]
+ 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
+ 5. Return result.
+
+ 7.4.6 IteratorClose ( iterator, completion )
+
+ [...]
+ 5. Let innerResult be Call(return, iterator, « »).
+ [...]
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let thisValue = null;
+let args = null;
+let _;
+let iterable = {};
+let iterator = {
+ next() {
+ nextCount += 1;
+ // Set an upper-bound to limit unnecessary iteration in non-conformant
+ // implementations
+ return { done: nextCount > 10 };
+ },
+ return() {
+ returnCount += 1;
+ thisValue = this;
+ args = arguments;
+ return {};
+ }
+};
+iterable[Symbol.iterator] = function() {
+ return iterator;
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ _ ] of [iterable]) {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 1);
+ assert.sameValue(thisValue, iterator, 'correct `this` value');
+ assert(!!args, 'arguments object provided');
+ assert.sameValue(args.length, 0, 'zero arguments specified');
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-rtrn-close-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-rtrn-close-null.js
new file mode 100644
index 0000000000..84616ef77d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-rtrn-close-null.js
@@ -0,0 +1,84 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-iter-rtrn-close-null.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose throws a TypeError when `return` returns a non-Object value (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ AssignmentElementList ]
+
+ [...]
+ 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
+ 5. Return result.
+
+ 7.4.6 IteratorClose( iterator, completion )
+
+ [...]
+ 5. Let innerResult be Call(return, iterator, « »).
+ 6. If completion.[[Type]] is throw, return Completion(completion).
+ 7. If innerResult.[[Type]] is throw, return Completion(innerResult).
+ 8. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
+
+---*/
+let unreachable = 0;
+let nextCount = 0;
+let returnCount = 0;
+let iterator = {
+ next() {
+ nextCount += 1;
+ return {done: false, value: undefined};
+ },
+ return() {
+ returnCount += 1;
+ return null;
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ {} = yield ] of [iterable]) {
+ unreachable += 1;
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(result => {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 0);
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, false);
+
+ iter.return().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 1);
+ assert.sameValue(unreachable, 0);
+ assert.sameValue(constructor, TypeError);
+ }).then($DONE, $DONE);
+}, $DONE).catch($DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-thrw-close-skip.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-thrw-close-skip.js
new file mode 100644
index 0000000000..cf1f8a4307
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-iter-thrw-close-skip.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-iter-thrw-close-skip.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose is not called when iteration produces an abrupt completion (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ AssignmentElementList ]
+
+ [...]
+ 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
+ 5. Return result.
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let iterator = {
+ next() {
+ nextCount += 1;
+ throw new Test262Error();
+ },
+ return() {
+ returnCount += 1;
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+let _;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x ] of [iterable]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 0);
+}).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-null.js
new file mode 100644
index 0000000000..7afe07801c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-null.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array-null.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the value is `null`, a TypeError should be thrown. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let _;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([[ _ ]] of [[null]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined-hole.js
new file mode 100644
index 0000000000..b244c1e20a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined-hole.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array-undefined-hole.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the value is a "hole", a TypeError should be thrown. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let _;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([[ _ ]] of [[ , ]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined-own.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined-own.js
new file mode 100644
index 0000000000..6256d66ec4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined-own.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array-undefined-own.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the value is `undefined`, a TypeError should be thrown. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let _;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([[ x ]] of [[undefined]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined.js
new file mode 100644
index 0000000000..ac8c22c22d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-undefined.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array-undefined.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and no value is defined, a TypeError should be thrown. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let _;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([[ x ]] of [[]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-yield-expr.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-yield-expr.js
new file mode 100644
index 0000000000..f31bda2f65
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-array-yield-expr.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-array-yield-expr.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: When a `yield` token appears within the DestructuringAssignmentTarget of a nested destructuring assignment and within a generator function body, it behaves as a YieldExpression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let value = [[22]];
+let x = {};
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([[x[yield]]] of [value]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, false);
+ assert.sameValue(x.prop, undefined);
+
+ iter.next('prop').then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, true);
+ assert.sameValue(x.prop, 22);
+ }).then($DONE, $DONE);
+}, $DONE).catch($DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-null.js
new file mode 100644
index 0000000000..a70c3dc021
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-null.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj-null.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal and the value is `null`, a TypeError should be thrown. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([{ x }] of [[null]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined-hole.js
new file mode 100644
index 0000000000..0de7721145
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined-hole.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj-undefined-hole.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal and the value is a "hole", a TypeError should be thrown. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([{ x }] of [[ , ]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined-own.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined-own.js
new file mode 100644
index 0000000000..996b41e5b0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined-own.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj-undefined-own.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal and the value is `undefined`, a TypeError should be thrown. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([{ x }] of [[undefined]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined.js
new file mode 100644
index 0000000000..d768f7cb5c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-undefined.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj-undefined.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal and no value is defined, a TypeError should be thrown. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([{ x }] of [[]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-yield-expr.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-yield-expr.js
new file mode 100644
index 0000000000..53610bed18
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj-yield-expr.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj-yield-expr.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of a nested destructuring assignment and within a generator function body, it behaves as a YieldExpression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([{ x = yield }] of [[{}]]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, false);
+ assert.sameValue(x, undefined);
+
+ iter.next(4).then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, true);
+ assert.sameValue(x, 4);
+ }).then($DONE, $DONE);
+}, $DONE).catch($DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj.js
new file mode 100644
index 0000000000..0fe44214d9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-nested-obj.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-nested-obj.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal, it should be parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([{ x }] of [[{ x: 2 }]]) {
+ assert.sameValue(x, 2);
+
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-const.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-const.js
new file mode 100644
index 0000000000..f98c976527
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-const.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-put-const.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: The assignment target should obey `const` semantics. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [const, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+const c = null;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ c ] of [[1]]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref-no-get.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref-no-get.js
new file mode 100644
index 0000000000..699fa733ca
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref-no-get.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-put-prop-ref-no-get.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: If the DestructuringAssignmentTarget of an AssignmentElement is a PropertyReference, it should not be evaluated. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, setValue;
+x = {
+ get y() {
+ throw new Test262Error('The property should not be accessed.');
+ },
+ set y(val) {
+ setValue = val;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([x.y] of [[23]]) {
+ assert.sameValue(setValue, 23);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref-user-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref-user-err.js
new file mode 100644
index 0000000000..3880421c06
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref-user-err.js
@@ -0,0 +1,48 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-put-prop-ref-user-err.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Any error raised as a result of setting the value should be forwarded to the runtime. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = {
+ set y(val) {
+ throw new Test262Error();
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([x.y] of [[23]
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, Test262Error);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref.js
new file mode 100644
index 0000000000..8fa0bdd32d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-prop-ref.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-put-prop-ref.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: The DestructuringAssignmentTarget of an AssignmentElement may be a PropertyReference. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = {};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([x.y] of [[4]]) {
+ assert.sameValue(x.y, 4);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-unresolvable-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-unresolvable-no-strict.js
new file mode 100644
index 0000000000..d9484d887e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-unresolvable-no-strict.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-put-unresolvable-no-strict.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Outside of strict mode, if the the assignment target is an unresolvable reference, a new `var` binding should be created in the environment record. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ unresolvable ] of [[]]) {
+ assert.sameValue(unresolvable, undefined);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-unresolvable-strict-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-unresolvable-strict-strict.js
new file mode 100644
index 0000000000..f6df9eafce
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-put-unresolvable-strict-strict.js
@@ -0,0 +1,44 @@
+// |reftest| async
+'use strict';
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-put-unresolvable-strict.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: In strict mode, if the the assignment target is an unresolvable reference, a ReferenceError should be thrown. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, onlyStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ unresolvable ] of [[]
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, ReferenceError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-simple-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-simple-no-strict.js
new file mode 100644
index 0000000000..3276ff23f1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-simple-no-strict.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-target-simple-no-strict.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: Identifiers that appear as the DestructuringAssignmentTarget in an AssignmentElement should take on the iterated value corresponding to their position in the ArrayAssignmentPattern. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let argument, eval;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([arguments, eval] of [[2, 3]]) {
+ assert.sameValue(arguments, 2);
+ assert.sameValue(eval, 3);
+
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-yield-expr.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-yield-expr.js
new file mode 100644
index 0000000000..26a22ec1f3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-target-yield-expr.js
@@ -0,0 +1,55 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-target-yield-expr.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentElement within a generator function body, it behaves as a YieldExpression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let value = [33];
+let x = {};
+let iterationResult;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x[yield] ] of [[33]
+
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(iterationResult => {
+ assert.sameValue(iterationResult.value, undefined);
+ assert.sameValue(iterationResult.done, false);
+ assert.sameValue(x.prop, undefined);
+
+ iter.next('prop').then(iterationResult => {
+ assert.sameValue(iterationResult.value, undefined);
+ assert.sameValue(iterationResult.done, true);
+ assert.sameValue(x.prop, 33);
+ }).then($DONE, $DONE);
+});
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-err.js
new file mode 100644
index 0000000000..e39b6702a0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-err.js
@@ -0,0 +1,83 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-trlg-iter-elision-iter-nrml-close-err.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: Abrupt completion returned from IteratorClose (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern :
+ [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
+
+ [...]
+ 6. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. If status is an abrupt completion, then
+ [...]
+ 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
+ status).
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let x;
+let iterator = {
+ next() {
+ nextCount += 1;
+
+ // Set an upper-bound to limit unnecessary iteration in non-conformant
+ // implementations
+ return { done: nextCount > 10 };
+ },
+ return() {
+ returnCount += 1;
+ throw new Test262Error();
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x , , ] of [iterable]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(nextCount, 2);
+ assert.sameValue(returnCount, 1);
+ assert.sameValue(constructor, Test262Error);
+}).then($DONE, $DONE);
+
+
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-null.js
new file mode 100644
index 0000000000..49ab96979c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-null.js
@@ -0,0 +1,85 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-trlg-iter-elision-iter-nrml-close-null.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: IteratorClose throws a TypeError when `return` returns a non-Object value (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern :
+ [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
+
+ [...]
+ 6. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. If status is an abrupt completion, then
+ [...]
+ 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
+ status).
+
+ 7.4.6 IteratorClose( iterator, completion )
+
+ [...]
+ 6. Let innerResult be Call(return, iterator, « »).
+ 7. If completion.[[type]] is throw, return Completion(completion).
+ 8. If innerResult.[[type]] is throw, return Completion(innerResult).
+ 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
+ exception.
+
+---*/
+let x;
+let nextCount = 0;
+let iterator = {
+ next() {
+ nextCount += 1;
+ // Set an upper-bound to limit unnecessary iteration in non-conformant
+ // implementations
+ return { done: nextCount > 10 };
+ },
+ return() {
+ return null;
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x , , ] of [iterable]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise.then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(nextCount, 2);
+ assert.sameValue(constructor, TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-skip.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-skip.js
new file mode 100644
index 0000000000..53f159aae9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close-skip.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-trlg-iter-elision-iter-nrml-close-skip.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose not invoked when elision exhausts the iterator (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern :
+ [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
+
+ [...]
+ 5. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. If status is an abrupt completion, then
+
+ [...]
+
+ 7. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
+ status).
+ 9. Return Completion(status).
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let x;
+let iterator = {
+ next() {
+ nextCount += 1;
+
+ return { done: nextCount > 1 };
+ },
+ return() {
+ returnCount += 1;
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x , , ] of [iterable]) {
+ assert.sameValue(nextCount, 2);
+ assert.sameValue(returnCount, 0);
+
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close.js
new file mode 100644
index 0000000000..b2990c00dc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-elision-iter-nrml-close.js
@@ -0,0 +1,94 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-trlg-iter-elision-iter-nrml-close.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose invoked when elision does not exhaust the iterator (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern :
+ [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
+
+ [...]
+ 5. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. If status is an abrupt completion, then
+
+ [...]
+
+ 7. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
+ status).
+
+ 7.4.6 IteratorClose ( iterator, completion )
+
+ [...]
+ 5. Let innerResult be Call(return, iterator, « »).
+ [...]
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let thisValue = null;
+let args = null;
+let x;
+let iterator = {
+ next() {
+ nextCount += 1;
+
+ // Set an upper-bound to limit unnecessary iteration in non-conformant
+ // implementations
+ return { done: nextCount > 10 };
+ },
+ return() {
+ returnCount += 1;
+ thisValue = this;
+ args = arguments;
+ return {};
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x , , ] of [iterable]) {
+ assert.sameValue(nextCount, 2);
+ assert.sameValue(returnCount, 1);
+ assert.sameValue(thisValue, iterator, 'correct `this` value');
+ assert(!!args, 'arguments object provided');
+ assert.sameValue(args.length, 0, 'zero arguments specified');
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close-err.js
new file mode 100644
index 0000000000..23238efa46
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close-err.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-trlg-iter-list-nrml-close-err.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: Abrupt completion returned from IteratorClose (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern :
+ [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
+
+ [...]
+ 2. Let iteratorRecord be Record {[[Iterator]]: iterator, [[Done]]: false}.
+ 3. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
+ iteratorRecord as the argument.
+ 4. If status is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status).
+ b. Return Completion(status).
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let thrower = function() {
+ throw new Test262Error();
+};
+let x;
+let iterator = {
+ next() {
+ nextCount += 1;
+ return { done: nextCount > 10 };
+ },
+ return() {
+ returnCount += 1;
+ throw new Test262Error();
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x , ] of [iterable]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 1);
+ assert.sameValue(constructor, Test262Error);
+}).then($DONE, $DONE);
+
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close-skip.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close-skip.js
new file mode 100644
index 0000000000..9ab6342057
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close-skip.js
@@ -0,0 +1,77 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-trlg-iter-list-nrml-close-skip.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose is not invoked when evaluation of AssignmentElementList exhausts the iterator (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern :
+ [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
+
+ [...]
+ 2. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}.
+ 3. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
+ iteratorRecord as the argument.
+ 4. If status is an abrupt completion, then
+ a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
+ status).
+ b. Return Completion(status).
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let thrower = function() {
+ throw new Test262Error();
+};
+let x;
+let iterator = {
+ next() {
+ nextCount += 1;
+ return { done: true };
+ },
+ return() {
+ returnCount += 1;
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x , ] of [iterable]) {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close.js
new file mode 100644
index 0000000000..22d6c2c046
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-nrml-close.js
@@ -0,0 +1,90 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-trlg-iter-list-nrml-close.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose is invoked when evaluation of AssignmentElementList completes without exhausting the iterator (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern :
+ [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
+
+ [...]
+ 2. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}.
+ 3. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
+ iteratorRecord as the argument.
+ 4. If status is an abrupt completion, then
+ a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
+ status).
+ b. Return Completion(status).
+
+ 7.4.6 IteratorClose ( iterator, completion )
+
+ [...]
+ 5. Let innerResult be Call(return, iterator, « »).
+ [...]
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let thisValue = null;
+let args = null;
+let x;
+let iterator = {
+ next() {
+ nextCount += 1;
+ // Set an upper-bound to limit unnecessary iteration in non-conformant
+ // implementations
+ return { done: nextCount > 10 };
+ },
+ return() {
+ returnCount += 1;
+ thisValue = this;
+ args = arguments;
+ return {};
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x , ] of [iterable]) {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 1);
+ assert.sameValue(thisValue, iterator, 'correct `this` value');
+ assert(!!args, 'arguments object provided');
+ assert.sameValue(args.length, 0, 'zero arguments specified');
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-thrw-close-skip.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-thrw-close-skip.js
new file mode 100644
index 0000000000..cac04d3d82
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-list-thrw-close-skip.js
@@ -0,0 +1,77 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-trlg-iter-list-thrw-close-skip.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose is not invoked when evaluation of AssignmentElementList returns an abrupt completion and the iterator has been marked as "done" (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern :
+ [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
+
+ [...]
+ 3. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}.
+ 4. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of AssignmentElementList using
+ iteratorRecord as the argument.
+ 5. If status is an abrupt completion, then
+ a. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
+ status).
+ b. Return Completion(status).
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let iterable = {};
+let thrower = function() {
+ throw new Test262Error();
+};
+let iterator = {
+ next() {
+ nextCount += 1;
+ throw new Test262Error();
+ },
+ return() {
+ returnCount += 1;
+ }
+};
+iterable[Symbol.iterator] = function() {
+ return iterator;
+};
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x , ] of [iterable]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(() => $DONE('Promise incorrectly fulfilled.'), ({ constructor }) => {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 0);
+ assert.sameValue(iterCount, 0);
+ assert.sameValue(constructor, Test262Error);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-rest-nrml-close-skip.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-rest-nrml-close-skip.js
new file mode 100644
index 0000000000..3e8ec83f3b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elem-trlg-iter-rest-nrml-close-skip.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elem-trlg-iter-rest-nrml-close-skip.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose is not called when rest element evaluation has exhausted the iterator (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern :
+ [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
+
+ [...]
+ 6. If AssignmentRestElement is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of AssignmentRestElement
+ with iteratorRecord as the argument.
+ 7. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, status).
+ 8. Return Completion(status).
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let x, y;
+let iterator = {
+ next() {
+ nextCount += 1;
+ return { value: nextCount, done: nextCount > 1 };
+ },
+ return() {
+ returnCount += 1;
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ x , ...y ] of [iterable]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(() => {
+ iter.return().then(() => {
+ assert.sameValue(nextCount, 2, 'nextCount');
+ assert.sameValue(returnCount, 0, 'returnCount');
+ assert.sameValue(x, 1, 'x');
+ assert.sameValue(y.length, 0, 'y.length');
+ }).then($DONE, $DONE);
+}, $DONE).catch($DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-iter-nrml-close-skip.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-iter-nrml-close-skip.js
new file mode 100644
index 0000000000..2435e768d9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-iter-nrml-close-skip.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elision-iter-nrml-close-skip.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose is not called when iteration has exhausted the iterator (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ Elision ]
+
+ 1. Let iterator be ? GetIterator(value).
+
+ [...]
+
+ 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result)..
+ [...]
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let iterator = {
+ next() {
+ nextCount += 1;
+ return { done: true };
+ },
+ return() {
+ returnCount += 1;
+ return {};
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ , ] of [iterable]) {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-iter-nrml-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-iter-nrml-close.js
new file mode 100644
index 0000000000..a4f8ac92cb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-iter-nrml-close.js
@@ -0,0 +1,87 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elision-iter-nrml-close.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose is called when assignment evaluation has not exhausted the iterator (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ Elision ]
+
+ 1. Let iterator be ? GetIterator(value).
+
+ [...]
+
+ 4. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result)..
+ [...]
+
+ 7.4.6 IteratorClose ( iterator, completion )
+
+ [...]
+ 5. Let innerResult be Call(return, iterator, « »).
+ [...]
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let thisValue = null;
+let args = null;
+let iterator = {
+ next() {
+ nextCount += 1;
+ // Set an upper-bound to limit unnecessary iteration in non-conformant
+ // implementations
+ return { done: nextCount > 10 };
+ },
+ return() {
+ returnCount += 1;
+ thisValue = this;
+ args = arguments;
+ return {};
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ , ] of [iterable]) {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 1);
+ assert.sameValue(thisValue, iterator, 'correct `this` value');
+ assert(!!args, 'arguments object provided');
+ assert.sameValue(args.length, 0, 'zero arguments specified');
+
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-val-array.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-val-array.js
new file mode 100644
index 0000000000..ce8c2e2299
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-val-array.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elision-val-array.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: An ArrayAssignmentPattern containing only Elisions requires iterable values (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function * fn() {
+ for await ([,] of [[]
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-val-string.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-val-string.js
new file mode 100644
index 0000000000..e6beb05b35
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-elision-val-string.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-elision-val-string.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: An ArrayAssignmentPattern containing only Elisions requires iterable values (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function * fn() {
+ for await ([,] of ['string literal'
+
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-empty-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-empty-iter-close.js
new file mode 100644
index 0000000000..4afab5f0d4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-empty-iter-close.js
@@ -0,0 +1,81 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-empty-iter-close.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: Iterator is closed without iterating (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ ]
+
+ 1. Let iterator be GetIterator(value).
+ 2. ReturnIfAbrupt(iterator).
+ 3. Return IteratorClose(iterator, NormalCompletion(empty)).
+
+ 7.4.6 IteratorClose ( iterator, completion )
+
+ [...]
+ 5. Let innerResult be Call(return, iterator, « »).
+ [...]
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let thisValue = null;
+let args = null;
+let iterator = {
+ next() {
+ nextCount += 1;
+ return { done: true };
+ },
+ return() {
+ returnCount += 1;
+ thisValue = this;
+ args = arguments;
+ return {};
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([] of [iterable]) {
+ assert.sameValue(nextCount, 0);
+ assert.sameValue(returnCount, 1);
+ assert.sameValue(thisValue, iterator, 'correct `this` value');
+ assert(!!args, 'arguments object provided');
+ assert.sameValue(args.length, 0, 'zero arguments specified');
+
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-empty-val-array.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-empty-val-array.js
new file mode 100644
index 0000000000..3b0d2c6f35
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-empty-val-array.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-empty-val-array.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: An ArrayAssignmentPattern without an AssignmentElementList requires iterable values. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function * fn() {
+ for await ([] of [[]
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-empty-val-string.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-empty-val-string.js
new file mode 100644
index 0000000000..2c5cdd4ef1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-empty-val-string.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-empty-val-string.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: An ArrayAssignmentPattern without an AssignmentElementList requires iterable values. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function * fn() {
+ for await ([] of ['string literal'
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-after-element.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-after-element.js
new file mode 100644
index 0000000000..15850f5d71
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-after-element.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-after-element.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: An AssignmentRestElement following an AssignmentElement consumes all remaining iterable values. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, y;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([x, ...y] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y.length, 2);
+ assert.sameValue(y[0], 2);
+ assert.sameValue(y[1], 3);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-after-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-after-elision.js
new file mode 100644
index 0000000000..d39640d596
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-after-elision.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-after-elision.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: An AssignmentRestElement following an elision consumes all remaining iterable values. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([, ...x] of [[1, 2, 3]]) {
+ assert.sameValue(x.length, 2);
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 3);
+
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-elision.js
new file mode 100644
index 0000000000..77db3d5337
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-elision.js
@@ -0,0 +1,48 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-elision.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: ArrayAssignmentPattern may include elisions at any position preceding a AssignmentRestElement in a AssignmentElementList. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, y;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([, , x, , ...y] of [[1, 2, 3, 4, 5, 6]]) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y.length, 2);
+ assert.sameValue(y[0], 5);
+ assert.sameValue(y[1], 6);
+
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-iter-nrml-close-skip.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-iter-nrml-close-skip.js
new file mode 100644
index 0000000000..f794208314
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-iter-nrml-close-skip.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-iter-nrml-close-skip.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: IteratorClose is not called when assignment evaluation has exhausted the iterator (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
+
+ [...]
+ 4. Let result be the result of performing
+ IteratorDestructuringAssignmentEvaluation of AssignmentRestElement
+ with iteratorRecord as the argument.
+ 5. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
+ 6. Return result.
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let x;
+let iterator = {
+ next() {
+ nextCount += 1;
+ return { done: true };
+ },
+ return() {
+ returnCount += 1;
+ }
+};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ ...x ] of [iterable]) {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-iteration.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-iteration.js
new file mode 100644
index 0000000000..cc4a95b005
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-iteration.js
@@ -0,0 +1,53 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-iteration.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: In the presense of an AssignmentRestElement, value iteration exhausts the iterable value; (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let count = 0;
+let g = function*() {
+ count += 1;
+ yield;
+ count += 1;
+ yield;
+ count += 1;
+}
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...x] of [g()]) {
+ assert.sameValue(count, 3);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-lref.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-lref.js
new file mode 100644
index 0000000000..1f7b06d136
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-lref.js
@@ -0,0 +1,81 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-lref.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: Reference is evaluated during assignment (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
+
+ [...]
+ 4. Let result be the result of performing
+ IteratorDestructuringAssignmentEvaluation of AssignmentRestElement
+ with iteratorRecord as the argument.
+ 5. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iterator, result).
+
+
+ AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget
+
+ 1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an
+ ArrayLiteral, then
+ a. Let lref be the result of evaluating DestructuringAssignmentTarget.
+ b. ReturnIfAbrupt(lref).
+ [...]
+
+---*/
+let nextCount = 0;
+let returnCount = 0;
+let iterator = {
+ next() {
+ nextCount += 1;
+ return { done: true };
+ },
+ return() {
+ returnCount += 1;
+ }
+};
+let obj = {};
+let iterable = {
+ [Symbol.iterator]() {
+ return iterator;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...obj['a' + 'b']] of [iterable]) {
+ assert.sameValue(nextCount, 1);
+ assert.sameValue(returnCount, 0);
+ assert(!!obj.ab);
+ assert.sameValue(obj.ab.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-null.js
new file mode 100644
index 0000000000..1ed8a5853e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-null.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-array-null.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the iterable emits `null` as the only value, an array with a single `null` element should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, y;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...[x, y]] of [[null]]) {
+ assert.sameValue(x, null);
+ assert.sameValue(y, undefined);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined-hole.js
new file mode 100644
index 0000000000..3628b3ed78
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined-hole.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-array-undefined-hole.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the iterable is an array with a "hole", an array with a single `undefined` element should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...[x]] of [[ , ]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined-own.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined-own.js
new file mode 100644
index 0000000000..a0f699d0df
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined-own.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-array-undefined-own.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the iterable emits `undefined` as the only value, an array with a single `undefined` element should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...[x]] of [[undefined]]) {
+ assert.sameValue(x, undefined);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined.js
new file mode 100644
index 0000000000..f57a9b3d91
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-undefined.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-array-undefined.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the iterable is emits no values, an empty array should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...[x]] of [[]]) {
+ assert.sameValue(x, undefined);
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-yield-expr.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-yield-expr.js
new file mode 100644
index 0000000000..f3749215b0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array-yield-expr.js
@@ -0,0 +1,51 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-array-yield-expr.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: When a `yield` token appears within the DestructuringAssignmentTarget of a nested destructuring assignment and within a generator function body, it should behave as a YieldExpression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = {};
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...[x[yield]]] of [[86]]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(iterationResult => {
+ assert.sameValue(iterationResult.value, undefined);
+ assert.sameValue(iterationResult.done, false);
+ assert.sameValue(x.prop, undefined);
+
+ iter.next('prop').then(iterationResult => {
+ assert.sameValue(iterationResult.value, undefined);
+ assert.sameValue(iterationResult.done, true);
+ assert.sameValue(x.prop, 86);
+ }).then($DONE, $DONE);
+});
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array.js
new file mode 100644
index 0000000000..f927230cdf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-array.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-array.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...[x]] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-null.js
new file mode 100644
index 0000000000..f4fdebbec7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-null.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-obj-null.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal and the iterable emits `null` as the only value, an array with a single `null` element should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, length;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...{ 0: x, length }] of [[null]]) {
+ assert.sameValue(x, null);
+ assert.sameValue(length, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined-hole.js
new file mode 100644
index 0000000000..930cd51a7f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined-hole.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-obj-undefined-hole.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the iterable is an array with a "hole", an array with a single `undefined` element should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+// Use the the top-level lexical scope for 'length' to provide compatibility with browsers
+// where length and name are properties of WindowProxy
+let length;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...{ 0: x, length }] of [[ , ]]) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(length, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined-own.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined-own.js
new file mode 100644
index 0000000000..9afe34ec1e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined-own.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-obj-undefined-own.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal and the iterable emits `undefined` as the only value, an array with a single `undefined` element should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+// Use the the top-level lexical scope for 'length' to provide compatibility with browsers
+// where length and name are properties of WindowProxy
+let length;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...{ 0: x, length }] of [[undefined]]) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(length, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined.js
new file mode 100644
index 0000000000..4834ca72f5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-undefined.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-obj-undefined.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an obect literal and the iterable is emits no values, an empty array should be used as the value of the nested DestructuringAssignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+// Use the the top-level lexical scope for 'length' to provide compatibility with browsers
+// where length and name are properties of WindowProxy
+let length;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...{ 0: x, length }] of [[]]) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(length, 0);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-yield-expr.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-yield-expr.js
new file mode 100644
index 0000000000..a4c9290b7b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj-yield-expr.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-obj-yield-expr.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of a nested destructuring assignment and within a generator function body, it should behave as a YieldExpression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...{ x = yield }] of [[{}]]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(iterationResult => {
+ assert.sameValue(iterationResult.value, undefined);
+ assert.sameValue(iterationResult.done, false);
+ assert.sameValue(x, undefined);
+
+ iter.next(4).then(iterationResult => {
+ assert.sameValue(iterationResult.value, undefined);
+ assert.sameValue(iterationResult.done, true);
+ assert.sameValue(x, 4);
+ }).then($DONE, $DONE);
+});
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj.js
new file mode 100644
index 0000000000..26940a44d8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-nested-obj.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-nested-obj.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal, it should be parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...{ 1: x }] of [[1, 2, 3]]) {
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-prop-ref-no-get.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-prop-ref-no-get.js
new file mode 100644
index 0000000000..ae2a380d03
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-prop-ref-no-get.js
@@ -0,0 +1,53 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-put-prop-ref-no-get.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: If the DestructuringAssignmentTarget of an AssignmentElement is a PropertyReference, it should not be evaluated. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let setValue;
+let x = {
+ get y() {
+ throw new Test262Error('The property should not be accessed.');
+ },
+ set y(val) {
+ setValue = val;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...x.y] of [[23, 45, 99]]) {
+ assert.sameValue(setValue.length, 3);
+ assert.sameValue(setValue[0], 23);
+ assert.sameValue(setValue[1], 45);
+ assert.sameValue(setValue[2], 99);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-prop-ref.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-prop-ref.js
new file mode 100644
index 0000000000..bd4cc03b94
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-prop-ref.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-put-prop-ref.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: The DestructuringAssignmentTarget of an AssignmentElement may be a PropertyReference. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = {};
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...x.y] of [[4, 3, 2]]) {
+ assert.sameValue(x.y.length, 3);
+ assert.sameValue(x.y[0], 4);
+ assert.sameValue(x.y[1], 3);
+ assert.sameValue(x.y[2], 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-unresolvable-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-unresolvable-no-strict.js
new file mode 100644
index 0000000000..d1cee94575
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-put-unresolvable-no-strict.js
@@ -0,0 +1,41 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-put-unresolvable-no-strict.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Outside of strict mode, if the the assignment target is an unresolvable reference, a new `var` binding should be created in the environment record. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function * fn() {
+ for await ([ ...unresolvable ] of [[]]) {
+ assert.sameValue(unresolvable.length, 0);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-yield-expr.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-yield-expr.js
new file mode 100644
index 0000000000..411a465739
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-array-rest-yield-expr.js
@@ -0,0 +1,56 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/array-rest-yield-expr.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentRestElement and within the body of a generator function, it should behave as a YieldExpression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = {};
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ([...x[yield]] of [[33, 44, 55]]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(iterationResult => {
+ assert.sameValue(iterationResult.value, undefined);
+ assert.sameValue(iterationResult.done, false);
+ assert.sameValue(x.prop, undefined);
+
+ iter.next('prop').then(iterationResult => {
+ assert.sameValue(iterationResult.value, undefined);
+ assert.sameValue(iterationResult.done, true);
+ assert.sameValue(x.prop.length, 3);
+ assert.sameValue(x.prop[0], 33);
+ assert.sameValue(x.prop[1], 44);
+ assert.sameValue(x.prop[2], 55);
+ assert.sameValue(iterCount, 1);
+ }).then($DONE, $DONE);
+});
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-bool.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-bool.js
new file mode 100644
index 0000000000..f7691736b4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-bool.js
@@ -0,0 +1,41 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-empty-bool.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: An ObjectAssignmentPattern without an AssignmentPropertyList requires an object-coercible value (boolean value) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function * fn() {
+ for await ({} of [false]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-num.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-num.js
new file mode 100644
index 0000000000..8b75c2640e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-num.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-empty-num.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: An ObjectAssignmentPattern without an AssignmentPropertyList requires an object-coercible value (number value) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function * fn() {
+ for await ({} of [0
+]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-obj.js
new file mode 100644
index 0000000000..0d75b22d6b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-obj.js
@@ -0,0 +1,41 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-empty-obj.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: An ObjectAssignmentPattern without an AssignmentPropertyList requires an object-coercible value (object value) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function * fn() {
+ for await ({} of [{}]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-string.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-string.js
new file mode 100644
index 0000000000..6bd00b4d73
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-string.js
@@ -0,0 +1,41 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-empty-string.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: An ObjectAssignmentPattern without an AssignmentPropertyList requires an object-coercible value (string value) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+
+let iterCount = 0;
+async function * fn() {
+ for await ({} of ['']) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-symbol.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-symbol.js
new file mode 100644
index 0000000000..99a940350a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-empty-symbol.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-empty-symbol.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: An ObjectAssignmentPattern without an AssignmentPropertyList requires an object-coercible value (symbol value) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let s = Symbol();
+
+let iterCount = 0;
+async function * fn() {
+ for await ({} of [s]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-first.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-first.js
new file mode 100644
index 0000000000..a095a55f7b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-first.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-identifier-resolution-first.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (first of many) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+let y;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x, y } of [{ x: 3 }]) {
+ assert.sameValue(x, 3);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-last.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-last.js
new file mode 100644
index 0000000000..af16fd7b3f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-last.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-identifier-resolution-last.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (last of many) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+let w;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ w, x } of [{ x: 4 }]) {
+ assert.sameValue(x, 4);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-lone.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-lone.js
new file mode 100644
index 0000000000..40c3ed7028
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-lone.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-identifier-resolution-lone.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (lone identifier) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x, } of [{ x: 2 }]) {
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-middle.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-middle.js
new file mode 100644
index 0000000000..9e8bdaf3f4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-middle.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-identifier-resolution-middle.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (within many) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+let w, y;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ w, x, y } of [{ x: 5 }]) {
+ assert.sameValue(x, 5);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-trlng.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-trlng.js
new file mode 100644
index 0000000000..aaf3ccd209
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-identifier-resolution-trlng.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-identifier-resolution-trlng.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (lone identifier with trailing comma) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x } of [{ x: 1 }]) {
+ assert.sameValue(x, 1);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-missing.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-missing.js
new file mode 100644
index 0000000000..d42b41ead6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-missing.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-assignment-missing.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference (no corresponding property defined). (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x = 1 } of [{}]) {
+ assert.sameValue(x, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-null.js
new file mode 100644
index 0000000000..2a1a082f52
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-null.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-assignment-null.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference (null property value defined). (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x = 1 } of [{ x: null }]) {
+ assert.sameValue(x, null);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-truthy.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-truthy.js
new file mode 100644
index 0000000000..f864840f10
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-truthy.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-assignment-truthy.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference (truthy property value defined). (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x = 1 } of [{ x: 2 }]) {
+ assert.sameValue(x, 2);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-undef.js
new file mode 100644
index 0000000000..62d7dc4c89
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-assignment-undef.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-assignment-undef.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference ("undefined" property value defined). (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x = 1 } of [{ x: undefined }]) {
+ assert.sameValue(x, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-evaluation.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-evaluation.js
new file mode 100644
index 0000000000..fd45946338
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-evaluation.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-evaluation.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: The Initializer should only be evaluated if v is undefined. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let flag1 = false;
+let flag2 = false;
+let x, y;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x = flag1 = true, y = flag2 = true } of [{ y: 1 }]) {
+ assert.sameValue(flag1, true);
+ assert.sameValue(flag2, false);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..2a37d1d9a3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-arrow.js
@@ -0,0 +1,58 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-fn-name-arrow.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (ArrowFunction) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentProperty : IdentifierReference Initializeropt
+ [...] 6. If Initializeropt is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v, P).
+
+---*/
+let arrow;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ arrow = () => {} } of [{}]) {
+ verifyProperty(arrow, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'arrow'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-class.js
new file mode 100644
index 0000000000..ee88417a4e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-class.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-fn-name-class.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (ClassExpression) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [class, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentProperty : IdentifierReference Initializeropt
+ [...] 6. If Initializeropt is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v, P).
+
+---*/
+let xCls, cls, xCls2;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } } of [{}]) {
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ verifyProperty(cls, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'cls'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..bb33fc5e1c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-cover.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-fn-name-cover.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (CoverParenthesizedExpression) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentProperty : IdentifierReference Initializeropt
+ [...] 6. If Initializeropt is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v, P).
+
+---*/
+let xCover, cover;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ xCover = (0, function() {}), cover = (function() {}) } of [{}]) {
+ assert.notSameValue(xCover.name, 'xCover');
+
+ verifyProperty(cover, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'cover'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..cbb5298b54
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-fn.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-fn-name-fn.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (FunctionExpression) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentProperty : IdentifierReference Initializeropt
+ [...] 6. If Initializeropt is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v, P).
+
+---*/
+let xFnexp, fnexp;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ xFnexp = function x() {}, fnexp = function() {} } of [{}]) {
+ assert.notSameValue(xFnexp.name, 'xFnexp');
+
+ verifyProperty(fnexp, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'fnexp'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..a79e9447bd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-fn-name-gen.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-fn-name-gen.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (GeneratorExpression) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentProperty : IdentifierReference Initializeropt
+ [...] 6. If Initializeropt is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v, P).
+
+---*/
+let xGen, gen;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ xGen = function* x() {}, gen = function*() {} } of [{}]) {
+ assert.notSameValue(xGen.name, 'xGen');
+
+ verifyProperty(gen, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'gen'
+ });
+
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-in.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-in.js
new file mode 100644
index 0000000000..07b837f0eb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-in.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-in.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: The Initializer in an AssignmentProperty may be an `in` expression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let prop;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ prop = 'x' in {} } of [{}]) {
+ assert.sameValue(prop, false);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-order.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-order.js
new file mode 100644
index 0000000000..d26397f6e2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-order.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-order.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Initializer values should be assigned in left-to-right order. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = 0;
+let a, b;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ a = x += 1, b = x *= 2 } of [{}]) {
+ assert.sameValue(a, 1);
+ assert.sameValue(b, 2);
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-simple-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-simple-no-strict.js
new file mode 100644
index 0000000000..d9e2dbf228
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-simple-no-strict.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-simple-no-strict.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let eval, arguments;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ eval = 3, arguments = 4 } of [{}]) {
+ assert.sameValue(eval, 3);
+ assert.sameValue(arguments, 4);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-yield-expr.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-yield-expr.js
new file mode 100644
index 0000000000..f831a39cb7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-init-yield-expr.js
@@ -0,0 +1,51 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-init-yield-expr.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of an AssignmentProperty and within a generator function body, it should behave as a YieldExpression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x = yield } of [{}]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, false);
+ assert.sameValue(x, undefined);
+
+ iter.next(3).then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, true);
+ assert.sameValue(x, 3);
+ }).then($DONE, $DONE);
+});
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-put-unresolvable-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-put-unresolvable-no-strict.js
new file mode 100644
index 0000000000..2812364b98
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-put-unresolvable-no-strict.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-put-unresolvable-no-strict.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Outside of strict mode, if the the assignment target is an unresolvable reference, a new `var` binding should be created in the environment record. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+{
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ unresolvable } of [{}]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => {
+ assert.sameValue(unresolvable, undefined);
+ assert.sameValue(iterCount, 1, 'iteration occurred as expected');
+ }, $DONE)
+ .then($DONE, $DONE);
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-simple-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-simple-no-strict.js
new file mode 100644
index 0000000000..8cb069a2ff
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-id-simple-no-strict.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-id-simple-no-strict.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let eval;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ eval } of [{ eval: 1 }]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => {
+ assert.sameValue(eval, 1);
+ assert.sameValue(iterCount, 1, 'iteration occurred as expected');
+ }, $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-missing.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-missing.js
new file mode 100644
index 0000000000..180b928f28
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-missing.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-assignment-missing.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference (non-existent property) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ y: x = 1 } of [{}]) {
+ assert.sameValue(x, 1);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-null.js
new file mode 100644
index 0000000000..16e6c2ac95
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-null.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-assignment-null.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: If the Initializer is present and v is not undefined, the Initializer should be evaluated and the result assigned to the target reference (null value) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ y: x = 1 } of [{ y: null }]) {
+ assert.sameValue(x, null);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-truthy.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-truthy.js
new file mode 100644
index 0000000000..205a23a245
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-truthy.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-assignment-truthy.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: If the Initializer is present and v is not undefined, the Initializer should be evaluated and the result assigned to the target reference (truthy value) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ y: x = 1 } of [{ y: 2 }]) {
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-undef.js
new file mode 100644
index 0000000000..10121c5ffb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-assignment-undef.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-assignment-undef.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: If the Initializer is present and v is undefined, the Initializer should be evaluated and the result assigned to the target reference (undefined value) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ y: x = 1 } of [{ y: undefined }]) {
+ assert.sameValue(x, 1);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-evaluation.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-evaluation.js
new file mode 100644
index 0000000000..9d3d1ae8bf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-evaluation.js
@@ -0,0 +1,48 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-evaluation.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: The Initializer should only be evaluated if v is undefined. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let flag1 = false;
+let flag2 = false;
+let x, y;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: x = flag1 = true, y: y = flag2 = true } of [{ y: 1 }]) {
+ assert.sameValue(x, true, 'value of `x`');
+ assert.sameValue(flag1, true, 'value of `flag1`');
+ assert.sameValue(y, 1, 'value of `y`');
+ assert.sameValue(flag2, false, 'value of `flag2`');
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-arrow.js
new file mode 100644
index 0000000000..e57bf67dbf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-arrow.js
@@ -0,0 +1,56 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-arrow.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (ArrowFunction) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 6. If Initializer is present and v is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)).
+
+---*/
+let arrow;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: arrow = () => {} } of [{}]) {
+ verifyProperty(arrow, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'arrow'
+ });
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-class.js
new file mode 100644
index 0000000000..4f0fad13a4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-class.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-class.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (ClassExpression) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [class, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 6. If Initializer is present and v is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)).
+
+---*/
+let xCls, cls, xCls2;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: xCls = class x {}, x: cls = class {}, x: xCls2 = class { static name() {} } } of [{}]) {
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ verifyProperty(cls, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'cls'
+ });
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-cover.js
new file mode 100644
index 0000000000..5964705d0c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-cover.js
@@ -0,0 +1,58 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-cover.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (CoverParenthesizedExpression) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 6. If Initializer is present and v is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)).
+
+---*/
+let xCover, cover;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: xCover = (0, function() {}), x: cover = (function() {}) } of [{}]) {
+ assert.notSameValue(xCover.name, 'xCover');
+
+ verifyProperty(cover, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'cover'
+ });
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-fn.js
new file mode 100644
index 0000000000..be988c8b65
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-fn.js
@@ -0,0 +1,58 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-fn.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (FunctionExpression) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 6. If Initializer is present and v is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)).
+
+---*/
+let xFnexp, fnexp;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: xFnexp = function x() {}, x: fnexp = function() {} } of [{}]) {
+ assert.notSameValue(xFnexp.name, 'xFnexp');
+
+ verifyProperty(fnexp, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'fnexp'
+ });
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-gen.js
new file mode 100644
index 0000000000..caeca6b7b9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-fn-name-gen.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-fn-name-gen.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Assignment of function `name` attribute (GeneratorExpression) (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+
+ AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
+ [...] 6. If Initializer is present and v is undefined and
+ IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
+ DestructuringAssignmentTarget are both true, then
+ a. Let hasNameProperty be ? HasOwnProperty(rhsValue, "name").
+ b. If hasNameProperty is false, perform SetFunctionName(rhsValue, GetReferencedName(lref)).
+
+---*/
+let xGen, gen;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: xGen = function* x() {}, x: gen = function*() {} } of [{}]) {
+ assert.notSameValue(xGen.name, 'xGen');
+
+ verifyProperty(gen, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true,
+ value: 'gen'
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-in.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-in.js
new file mode 100644
index 0000000000..3caee8d3c0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-in.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-in.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: The Initializer in an AssignmentElement may be an `in` expression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let prop;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: prop = 'x' in {} } of [{}]) {
+ assert.sameValue(prop, false);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-yield-expr.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-yield-expr.js
new file mode 100644
index 0000000000..b043ccd363
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-init-yield-expr.js
@@ -0,0 +1,50 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-init-yield-expr.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of an AssignmentElement and within a generator function body, it should behave as a YieldExpression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: x = yield } of [{}]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, false);
+ assert.sameValue(x, undefined);
+
+ iter.next(86).then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, true);
+ assert.sameValue(x, 86);
+ }).then($DONE, $DONE);
+});
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-target-yield-expr.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-target-yield-expr.js
new file mode 100644
index 0000000000..93443810fd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-elem-target-yield-expr.js
@@ -0,0 +1,50 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-elem-target-yield-expr.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: When a `yield` token appears within the DestructuringAssignmentTarget of an AssignmentElement and within a generator function body, it should behave as a YieldExpression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = {};
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: x[yield] } of [{ x: 23 }]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, false);
+ assert.sameValue(x.prop, undefined);
+
+ iter.next('prop').then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, true);
+ assert.sameValue(x.prop, 23);
+ }).then($DONE, $DONE);
+});
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-first.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-first.js
new file mode 100644
index 0000000000..2fa0ea057f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-first.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-identifier-resolution-first.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (first of many). (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+let y;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ a: x, y } of [{ a: 3 }]) {
+ assert.sameValue(x, 3);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-last.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-last.js
new file mode 100644
index 0000000000..166fbd9e28
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-last.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-identifier-resolution-last.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (last of many). (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+let w;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ w, a: x } of [{ a: 4 }]) {
+ assert.sameValue(x, 4);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-lone.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-lone.js
new file mode 100644
index 0000000000..802e6d5e04
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-lone.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-identifier-resolution-lone.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (lone element). (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ a: x } of [{ a: 1 }]) {
+ assert.sameValue(x, 1);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-middle.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-middle.js
new file mode 100644
index 0000000000..bfa2d3e605
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-middle.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-identifier-resolution-middle.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (within many). (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+let w, y;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ w, a: x, y } of [{ a: 5 }]) {
+ assert.sameValue(x, 5);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-trlng.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-trlng.js
new file mode 100644
index 0000000000..f1ee18019a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-identifier-resolution-trlng.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-identifier-resolution-trlng.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Evaluation of DestructuringAssignmentTarget (lone element with trailing comma). (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = null;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ a: x, } of [{ a: 2 }]) {
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-name-evaluation.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-name-evaluation.js
new file mode 100644
index 0000000000..c68005f71e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-name-evaluation.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-name-evaluation.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: PropertyName of an AssignmentProperty may be a ComputedPropertyName. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x, y, xy;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ ['x' + 'y']: x } of [{ x: 1, xy: 23, y: 2 }]) {
+ assert.sameValue(x, 23);
+ assert.sameValue(y, undefined);
+ assert.sameValue(xy, undefined);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-array-yield-expr.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-array-yield-expr.js
new file mode 100644
index 0000000000..cbdc78fa7c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-array-yield-expr.js
@@ -0,0 +1,51 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-nested-array-yield-expr.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of a nested destructuring assignment and within a generator function body, it should behave as a YieldExpression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: [x = yield] } of [{ x: [] }]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, false);
+ assert.sameValue(x, undefined);
+
+ iter.next(24601).then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, true);
+ assert.sameValue(x, 24601);
+ }).then($DONE, $DONE);
+});
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-array.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-array.js
new file mode 100644
index 0000000000..d9618345b9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-array.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-nested-array.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an array literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let y;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: [y] } of [{ x: [321] }]) {
+ assert.sameValue(y, 321);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-obj-yield-expr.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-obj-yield-expr.js
new file mode 100644
index 0000000000..f61ef9e60a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-obj-yield-expr.js
@@ -0,0 +1,51 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-nested-obj-yield-expr.case
+// - src/dstr-assignment-for-await/async-generator/async-gen-decl.template
+/*---
+description: When a `yield` token appears within the Initializer of a nested destructuring assignment and within a generator function body, it should behave as a YieldExpression. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = undefined;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: { x = yield } } of [{ x: {} }]) {
+
+ iterCount += 1;
+ }
+}
+
+let iter = fn();
+
+iter.next().then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, false);
+ assert.sameValue(x, undefined);
+
+ iter.next(4).then(result => {
+ assert.sameValue(result.value, undefined);
+ assert.sameValue(result.done, true);
+ assert.sameValue(x, 4);
+ }).then($DONE, $DONE);
+});
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-obj.js
new file mode 100644
index 0000000000..3fd9d13f01
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-nested-obj.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-nested-obj.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object literal, it should be parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let result, y;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: { y } } of [{ x: { y: 2 } }]) {
+ assert.sameValue(y, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-order.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-order.js
new file mode 100644
index 0000000000..5dfc8b3b9d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-order.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-put-order.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: The AssignmentElements in an AssignmentElementList are evaluated in left- to-right order. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ z: x, a: x } of [{ a: 2, z: 1 }]) {
+ assert.sameValue(x, 2);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-prop-ref-no-get.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-prop-ref-no-get.js
new file mode 100644
index 0000000000..a308ca07ab
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-prop-ref-no-get.js
@@ -0,0 +1,50 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-put-prop-ref-no-get.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: If the DestructuringAssignmentTarget of an AssignmentElement is a PropertyReference, it should not be evaluated. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let setValue;
+let x = {
+ get y() {
+ throw new Test262Error('The property should not be accessed.');
+ },
+ set y(val) {
+ setValue = val;
+ }
+};
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ a: x.y } of [{ a: 23 }]) {
+ assert.sameValue(setValue, 23);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-prop-ref.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-prop-ref.js
new file mode 100644
index 0000000000..2692d2127a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-prop-ref.js
@@ -0,0 +1,42 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-put-prop-ref.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: The DestructuringAssignmentTarget of an AssignmentElement may be a PropertyReference. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x = {};
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ xy: x.y } of [{ xy: 4 }]) {
+ assert.sameValue(x.y, 4);
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-unresolvable-no-strict.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-unresolvable-no-strict.js
new file mode 100644
index 0000000000..01e67f9471
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-prop-put-unresolvable-no-strict.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-prop-put-unresolvable-no-strict.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Outside of strict mode, if the the assignment target is an unresolvable reference, a new `var` binding should be created in the environment record. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, noStrict, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+{
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x: unresolvable } of [{}]) {
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => {
+ assert.sameValue(unresolvable, undefined);
+ assert.sameValue(iterCount, 1, 'iteration occurred as expected');
+ }, $DONE)
+ .then($DONE, $DONE);
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-descriptors.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-descriptors.js
new file mode 100644
index 0000000000..f3a9e8abe8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-descriptors.js
@@ -0,0 +1,58 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-descriptors.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Object created from rest deconstruction doesn't copy source object property descriptors. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest;
+let obj = {};
+Object.defineProperty(obj, "a", { value: 3, configurable: false, enumerable: true });
+Object.defineProperty(obj, "b", { value: 4, writable: false, enumerable: true });
+
+let iterCount = 0;
+async function * fn() {
+ for await ({...rest} of [obj]) {
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-empty-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-empty-obj.js
new file mode 100644
index 0000000000..af7cfaad45
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-empty-obj.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-empty-obj.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: RestBindingInitialization creates a new object even if lhs is an empty object (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ({...rest} of [{}]) {
+ assert.notSameValue(rest, undefined);
+ assert.notSameValue(rest, null);
+ assert.sameValue(typeof rest, "object");
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-getter.js
new file mode 100644
index 0000000000..c54b5ba60b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-getter.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-getter.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let x;
+let count = 0;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({...x} of [{ get v() { count++; return 2; } }]) {
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-number.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-number.js
new file mode 100644
index 0000000000..6f6f837b71
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-number.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-number.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: RestBindingInitialization creates a new object even if lhs is a Number (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ({...rest} of [51]) {
+ assert.notSameValue(rest, undefined);
+ assert.notSameValue(rest, null);
+ assert(rest instanceof Object);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-same-name.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-same-name.js
new file mode 100644
index 0000000000..fde8c78a3b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-same-name.js
@@ -0,0 +1,57 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-same-name.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Proper setting in the values for rest name equal to a property name. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let o = {
+ x: 42,
+ y: 39,
+ z: 'cheeseburger'
+};
+
+let x, y, z;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({ x, ...z } of [o]) {
+ assert.sameValue(x, 42);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z.y, 39);
+ assert.sameValue(z.z, 'cheeseburger');
+
+ let keys = Object.getOwnPropertyNames(z);
+ assert.sameValue(keys.length, 2);
+ assert.sameValue(keys[0], 'y');
+ assert.sameValue(keys[1], 'z');
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..f564d3ada6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-skip-non-enumerable.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-skip-non-enumerable.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest;
+let obj = {a: 3, b: 4};
+Object.defineProperty(obj, "x", { value: 4, enumerable: false });
+
+let iterCount = 0;
+async function * fn() {
+ for await ({...rest} of [obj]) {
+ assert.sameValue(Object.getOwnPropertyDescriptor(rest, "x"), undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-str-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-str-val.js
new file mode 100644
index 0000000000..ccb96eb575
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-str-val.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-str-val.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: RestBindingInitialization creats an object with indexes as property name (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ({...rest} of ["foo"]) {
+ assert.sameValue(rest["0"], "f");
+ assert.sameValue(rest["1"], "o");
+ assert.sameValue(rest["2"], "o");
+ assert(rest instanceof Object);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-symbol-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-symbol-val.js
new file mode 100644
index 0000000000..bfb3c7c4b0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-symbol-val.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-symbol-val.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: RestBindingInitialization creates a new object if lhs is a Symbol (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, Symbol, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ({...rest} of [Symbol("foo")]) {
+ assert.notSameValue(rest, undefined);
+ assert.notSameValue(rest, null);
+ assert(rest instanceof Object);
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-to-property-with-setter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-to-property-with-setter.js
new file mode 100644
index 0000000000..e924f39069
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-to-property-with-setter.js
@@ -0,0 +1,55 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-to-property-with-setter.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object property setter, its value should be binded as rest object. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let settedValue;
+let executedGetter = false;
+let src = {
+ get y() {
+ executedGetter = true;
+ },
+ set y(v) {
+ settedValue = v;
+ },
+};
+src.y = undefined;
+
+let iterCount = 0;
+async function * fn() {
+ for await ({...src.y} of [{ x: 1, y: 2}]) {
+ assert.sameValue(settedValue.x, 1);
+ assert.sameValue(settedValue.y, 2);
+ assert(!executedGetter, "The property should not be accessed");
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-to-property.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-to-property.js
new file mode 100644
index 0000000000..a66ec73fcc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-to-property.js
@@ -0,0 +1,51 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-to-property.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: When DestructuringAssignmentTarget is an object property, its value should be binded as rest object. (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let src = {};
+
+let iterCount = 0;
+async function * fn() {
+ for await ({...src.y} of [{ x: 1, y: 2}]) {
+ assert.sameValue(src.y.x, 1);
+ assert.sameValue(src.y.y, 2);
+
+ verifyProperty(src, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-valid-object.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-valid-object.js
new file mode 100644
index 0000000000..32b3902752
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-decl-dstr-obj-rest-valid-object.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-assignment-for-await/obj-rest-valid-object.case
+// - src/dstr-assignment-for-await/default/async-gen-decl.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement in an async generator declaration)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( LeftHandSideExpression of AssignmentExpression ) Statement
+
+ 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
+ AssignmentExpression, iterate).
+ 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
+ keyResult, assignment, labelSet).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 5. If destructuring is true and if lhsKind is assignment, then
+ a. Assert: lhs is a LeftHandSideExpression.
+ b. Let assignmentPattern be the parse of the source text corresponding to
+ lhs using AssignmentPattern as the goal symbol.
+ [...]
+---*/
+let rest, a, b;
+
+
+let iterCount = 0;
+async function * fn() {
+ for await ({a, b, ...rest} of [{x: 1, y: 2, a: 5, b: 3}]) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+let promise = fn().next();
+
+promise
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-close.js
new file mode 100644
index 0000000000..6cec2e7ee6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-close.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: false };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [x] of [iter]) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-get-err.js
new file mode 100644
index 0000000000..59c2465c32
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-get-err.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-get-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Abrupt completion returned by GetIterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ 1. Let iterator be ? GetIterator(value).
+
+---*/
+var iter = {};
+iter[Symbol.iterator] = function() {
+ throw new Test262Error();
+};
+
+async function * gen() {
+ for await (const [x] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..d354bb2487
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-init-iter-no-close.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-no-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: true };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [x] of [iter]) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-name-iter-val.js
new file mode 100644
index 0000000000..eefdd83b2e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-name-iter-val.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-name-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding with normal value iteration (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..9007021f74
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [[x, y, z] = [4, 5, 6]] of [[]]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..0e2842263a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [[x, y, z] = [4, 5, 6]] of [[[7, 8, 9]]]) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..8ba1b1cb60
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [[,] = g()] of [[]]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..a6798fce97
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var callCount = 0;
+function* g() {
+ callCount += 1;
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [[,] = g()] of [[[]]]) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..91ac0cad9f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var initCount = 0;
+var iterCount = 0;
+var iter = function*() { iterCount += 1; }();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [[] = function() { initCount += 1; return iter; }()] of [[]]) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..fe2298da22
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var initCount = 0;
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [[] = function() { initCount += 1; }()] of [[[23]]]) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..5d25409871
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [[...x] = values] of [[]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..37b3be9e1e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+var initCount = 0;
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [[...x] = function() { initCount += 1; }()] of [[values]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-val-null.js
new file mode 100644
index 0000000000..cd54a65f13
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-ary-val-null.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-val-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Nested array destructuring with a null value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ 1. Let iterator be ? GetIterator(value).
+---*/
+
+async function * gen() {
+ for await (const [[x]] of [[null]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..5f4be10de2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [x = 23] of [[]]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..ee72fb458c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [arrow = () => {}] of [[]]) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..609ce3b405
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of [[]]) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..a0c0939c46
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [cover = (function () {}), xCover = (0, function() {})] of [[]]) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..5d035888b4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [fn = function () {}, xFn = function x() {}] of [[]]) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..74e82cef42
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [gen = function* () {}, xGen = function* x() {}] of [[]]) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..af03294d93
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Destructuring initializer with a "hole" (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ SingleNameBinding : BindingIdentifier Initializer_opt
+ [...] 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v). 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [x = 23] of [[,]]) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..8cd70af980
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ 7. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [w = counter(), x = counter(), y = counter(), z = counter()] of [[null, 0, false, '']]) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-throws.js
new file mode 100644
index 0000000000..5bef09fda3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-throws.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Destructuring initializer returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+---*/
+
+async function * gen() {
+ for await (const [x = (function() { throw new Test262Error(); })()] of [[undefined]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..2c86b964d6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Destructuring initializer with an undefined value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [x = 23] of [[undefined]]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-unresolvable.js
new file mode 100644
index 0000000000..9e8489bff9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-init-unresolvable.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function * gen() {
+ for await (const [ x = unresolvableReference ] of [[]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..e0f8fa2db5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding when value iteration completes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [x] of [[]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..c91491cf8e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [_, x] of [[]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-step-err.js
new file mode 100644
index 0000000000..a2c148c7fc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-step-err.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+
+---*/
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next() {
+ throw new Test262Error();
+ }
+ };
+};
+
+async function * gen() {
+ for await (const [x] of [g]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val-err.js
new file mode 100644
index 0000000000..4875ad9171
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val-err.js
@@ -0,0 +1,83 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ iii. ReturnIfAbrupt(v).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedValue;
+ }
+ };
+};
+
+async function * gen() {
+ for await (const [x] of [g]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..70287a039a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..ae049288f4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[]]) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..c7c6d3117e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[{ x: 11, y: 22, z: 33 }]]) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..2b2f5bc987
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[]]) {
+ assert.sameValue(v, 444);
+ assert.sameValue(x, 555);
+ assert.sameValue(z, 666);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..499084ad63
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[{ u: 777, w: 888, y: 999 }]]) {
+ assert.sameValue(v, 777);
+ assert.sameValue(x, 888);
+ assert.sameValue(z, 999);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-null.js
new file mode 100644
index 0000000000..8b0de4325c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-null.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-val-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Nested object destructuring with a null value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ObjectBindingPattern
+
+ 1. Let valid be RequireObjectCoercible(value).
+ 2. ReturnIfAbrupt(valid).
+---*/
+
+async function * gen() {
+ for await (const [{ x }] of [[null]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-undef.js
new file mode 100644
index 0000000000..17f4bc966a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elem-obj-val-undef.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-val-undef.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Nested object destructuring with a value of `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ObjectBindingPattern
+
+ 1. Let valid be RequireObjectCoercible(value).
+ 2. ReturnIfAbrupt(valid).
+---*/
+
+async function * gen() {
+ for await (const [{ x }] of [[]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..a509176939
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Elision accepts exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [,] of [iter]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-iter-close.js
new file mode 100644
index 0000000000..cd306e16fb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-iter-close.js
@@ -0,0 +1,56 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-iter-close.case
+// - src/dstr-binding-for-await/iter-close/for-await-of-async-gen-const.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+async function* fn() {
+ for await (const [,] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .next()
+ .then(() => {
+ assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-step-err.js
new file mode 100644
index 0000000000..f1ded0cf52
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision-step-err.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Elision advances iterator and forwards abrupt completions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+
+---*/
+var following = 0;
+var iter = function* () {
+ throw new Test262Error();
+ following += 1;
+}();
+
+async function * gen() {
+ for await (const [,] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+ assert.sameValue(following, 0, "iterator is properly closed");
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision.js
new file mode 100644
index 0000000000..c273e78fa6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-elision.js
@@ -0,0 +1,80 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Elision advances iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [,] of [g()]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-empty.js
new file mode 100644
index 0000000000..6aa317d85f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-empty.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [] of [iter]) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-init-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-init-err.js
new file mode 100644
index 0000000000..4182780a63
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-init-err.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-iteration-statements
+description: >
+ Initializer is not allowed in head's ForDeclaration position.
+info: |
+ IterationStatement:
+ for await (ForDeclaration of AssignmentExpression) Statement
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+async function fn() {
+ for await (const [x] = 1 of []) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..c6efbb70d1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,86 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...[x, y, z]] of [[3, 4, 5]]) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..1df0095a47
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,93 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element containing an elision (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...[,]] of [g()]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..a1080bd08b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element containing an "empty" array pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...[]] of [iter]) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..5ecb46a0c0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element containing a rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...[...x]] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision-next-err.js
new file mode 100644
index 0000000000..51ac654414
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision-next-err.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision-next-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+
+---*/
+var iter = (function*() { throw new Test262Error(); })();
+
+async function * gen() {
+ for await (const [, ...x] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..dc0087c5fb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+---*/
+var values = [1, 2, 3, 4, 5];
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [ , , ...x] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 3);
+ assert.sameValue(x[1], 4);
+ assert.sameValue(x[2], 5);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..2e50476322
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: RestElement applied to an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. If environment is undefined, return PutValue(lhs, A).
+ ii. Return InitializeReferencedBinding(lhs, A).
+
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [, , ...x] of [[1, 2]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-close.js
new file mode 100644
index 0000000000..1bec78e7d0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-close.js
@@ -0,0 +1,56 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-close.case
+// - src/dstr-binding-for-await/iter-close/for-await-of-async-gen-const.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+async function* fn() {
+ for await (const [...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .next()
+ .then(() => {
+ assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-step-err.js
new file mode 100644
index 0000000000..aac96520f4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-step-err.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ a. If iteratorRecord.[[done]] is false,
+ i. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ ii. If next is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ iii. ReturnIfAbrupt(next).
+
+---*/
+var first = 0;
+var second = 0;
+var iter = function*() {
+ first += 1;
+ throw new Test262Error();
+ second += 1;
+}();
+
+async function * gen() {
+ for await (const [...x] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-val-err.js
new file mode 100644
index 0000000000..e220ff4cf8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id-iter-val-err.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-val-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ c. Let nextValue be IteratorValue(next).
+ d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ e. ReturnIfAbrupt(nextValue).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedValue;
+ }
+ };
+};
+
+async function * gen() {
+ for await (const [...x] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..ff94d6b7d6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-id.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Lone rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat
+ [...]
+ f. Let status be CreateDataProperty(A, ToString (n), nextValue).
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...x] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..e49292c53c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,62 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...[ x ] = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..553e9d8fea
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-init-id.js
@@ -0,0 +1,62 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element (identifier) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...x = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..9666c674e3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,62 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...{ x } = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..0f3f29caae
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,62 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...[x], y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..9271ea8bf6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,62 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...x, y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..ff9bc7efc5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,62 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...{ x }, y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..755a742c23
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...{ length }] of [[1, 2, 3]]) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..f20a857172
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+let length = "outer";
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of [[7, 8, 9]]) {
+ assert.sameValue(v, 7);
+ assert.sameValue(w, 8);
+ assert.sameValue(x, 9);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 3);
+
+ assert.sameValue(length, "outer", "the length prop is not set as a binding name");
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-close.js
new file mode 100644
index 0000000000..9ac5efed97
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-close.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: false };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (const [x] of asyncIter) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..7cd58a3df9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-init-iter-no-close.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-no-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: true };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (const [x] of asyncIter) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-name-iter-val.js
new file mode 100644
index 0000000000..84a99a08a1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-name-iter-val.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-name-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding with normal value iteration (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (const [x, y, z] of asyncIter) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..3b3b201523
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [[x, y, z] = [4, 5, 6]] of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..cbc2d85d21
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[7, 8, 9]]];
+})();
+
+async function *fn() {
+ for await (const [[x, y, z] = [4, 5, 6]] of asyncIter) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..989ebda481
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [[,] = g()] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..5148322b14
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var callCount = 0;
+function* g() {
+ callCount += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[]]];
+})();
+
+async function *fn() {
+ for await (const [[,] = g()] of asyncIter) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..f0c5a8d09e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var initCount = 0;
+var iterCount = 0;
+var iter = function*() { iterCount += 1; }();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [[] = function() { initCount += 1; return iter; }()] of asyncIter) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..b52b44a78c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var initCount = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[23]]];
+})();
+
+async function *fn() {
+ for await (const [[] = function() { initCount += 1; }()] of asyncIter) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..980b98d5b1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [[...x] = values] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..d91e2c27ea
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+var initCount = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[values]];
+})();
+
+async function *fn() {
+ for await (const [[...x] = function() { initCount += 1; }()] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..59ee1da1f0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..cd556fc650
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [arrow = () => {}] of asyncIter) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..532ccbf1eb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of asyncIter) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..3613fc45c4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [cover = (function () {}), xCover = (0, function() {})] of asyncIter) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..73ceca7210
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [fn = function () {}, xFn = function x() {}] of asyncIter) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..fd39deaf50
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [gen = function* () {}, xGen = function* x() {}] of asyncIter) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..c263ff68ec
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Destructuring initializer with a "hole" (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ SingleNameBinding : BindingIdentifier Initializer_opt
+ [...] 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v). 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[,]];
+})();
+
+async function *fn() {
+ for await (const [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..f8492e5dfa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ 7. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[null, 0, false, '']];
+})();
+
+async function *fn() {
+ for await (const [w = counter(), x = counter(), y = counter(), z = counter()] of asyncIter) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..9c232e121b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Destructuring initializer with an undefined value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[undefined]];
+})();
+
+async function *fn() {
+ for await (const [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..52e0933021
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding when value iteration completes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [x] of asyncIter) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..158a11f5ab
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [_, x] of asyncIter) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..f5ea9d3f8e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (const [x, y, z] of asyncIter) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..81acc40f05
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..a5bc92f1bf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[{ x: 11, y: 22, z: 33 }]];
+})();
+
+async function *fn() {
+ for await (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..58e42372b8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) {
+ assert.sameValue(v, 444);
+ assert.sameValue(x, 555);
+ assert.sameValue(z, 666);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..354846a40f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[{ u: 777, w: 888, y: 999 }]];
+})();
+
+async function *fn() {
+ for await (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) {
+ assert.sameValue(v, 777);
+ assert.sameValue(x, 888);
+ assert.sameValue(z, 999);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..3a74a065ad
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Elision accepts exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (const [,] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision.js
new file mode 100644
index 0000000000..b7ebceb517
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-elision.js
@@ -0,0 +1,83 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Elision advances iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [g()];
+})();
+
+async function *fn() {
+ for await (const [,] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-empty.js
new file mode 100644
index 0000000000..13287f15bd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-empty.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (const [] of asyncIter) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..3d012227c5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,89 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[3, 4, 5]];
+})();
+
+async function *fn() {
+ for await (const [...[x, y, z]] of asyncIter) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..b5f9743481
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,96 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element containing an elision (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [g()];
+})();
+
+async function *fn() {
+ for await (const [...[,]] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..6a8594233f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element containing an "empty" array pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (const [...[]] of asyncIter) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..44f0fcf3ca
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element containing a rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function *fn() {
+ for await (const [...[...x]] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..ae0e190382
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+---*/
+var values = [1, 2, 3, 4, 5];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function *fn() {
+ for await (const [ , , ...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 3);
+ assert.sameValue(x[1], 4);
+ assert.sameValue(x[2], 5);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..96c8375d65
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: RestElement applied to an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. If environment is undefined, return PutValue(lhs, A).
+ ii. Return InitializeReferencedBinding(lhs, A).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2]];
+})();
+
+async function *fn() {
+ for await (const [, , ...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..898546f63e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-id.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Lone rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat
+ [...]
+ f. Let status be CreateDataProperty(A, ToString (n), nextValue).
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function *fn() {
+ for await (const [...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..f4420e2b22
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [...[ x ] = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..efc9fb724f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-id.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element (identifier) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [...x = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..e995cfa3d8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (const [...{ x } = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..cf1c1fcc0a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (const [...[x], y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..339a57a067
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (const [...x, y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..1a21c4035a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (const [...{ x }, y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..aa8a03da44
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (const [...{ length }] of asyncIter) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..3c4c6b960b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+let length = "outer";
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[7, 8, 9]];
+})();
+
+async function *fn() {
+ for await (const [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of asyncIter) {
+ assert.sameValue(v, 7);
+ assert.sameValue(w, 8);
+ assert.sameValue(x, 9);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 3);
+
+ assert.sameValue(length, "outer", "the length prop is not set as a binding name");
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-empty.js
new file mode 100644
index 0000000000..bb9ff7d45b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-empty.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [obj];
+})();
+
+async function *fn() {
+ for await (const {} of asyncIter) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..6807d9aac5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (const { arrow = () => {} } of asyncIter) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..8c4a64ef60
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (const { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of asyncIter) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..c40dd1bb73
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (const { cover = (function () {}), xCover = (0, function() {}) } of asyncIter) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..f5f91cfbc9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (const { fn = function () {}, xFn = function x() {} } of asyncIter) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..34382e743d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (const { gen = function* () {}, xGen = function* x() {} } of asyncIter) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..13dfaed511
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: null, x: 0, y: false, z: '' }];
+})();
+
+async function *fn() {
+ for await (const { w = counter(), x = counter(), y = counter(), z = counter() } of asyncIter) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..074cb709f8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function *fn() {
+ for await (const { x, } of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..d4977ab61d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (const { w: [x, y, z] = [4, 5, 6] } of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..ce42f37ae2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: [45] }];
+})();
+
+async function *fn() {
+ for await (const { x: [y], } of asyncIter) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..dd4b499fe4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-ary.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: [7, undefined, ] }];
+})();
+
+async function *fn() {
+ for await (const { w: [x, y, z] = [4, 5, 6] } of asyncIter) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..c9774412ff
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,84 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ s: null, u: 0, w: false, y: '' }];
+})();
+
+async function *fn() {
+ for await (const { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of asyncIter) {
+ assert.sameValue(t, null);
+ assert.sameValue(v, 0);
+ assert.sameValue(x, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ assert.throws(ReferenceError, function() {
+ s;
+ });
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..d228fb884e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-init.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ }];
+})();
+
+async function *fn() {
+ for await (const { x: y = 33 } of asyncIter) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..cb4e9545a0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function *fn() {
+ for await (const { x: y, } of asyncIter) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..0fe010e188
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-id.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Binding as specified via property name and identifier (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function *fn() {
+ for await (const { x: y } of asyncIter) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..1dca393613
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: undefined }];
+})();
+
+async function *fn() {
+ for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..2c23caa068
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-prop-obj.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: { x: undefined, z: 7 } }];
+})();
+
+async function *fn() {
+ for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..26e0b9447f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-getter.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-getter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var count = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ get v() { count++; return 2; } }];
+})();
+
+async function *fn() {
+ for await (const {...x} of asyncIter) {
+ assert.sameValue(x.v, 2);
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..a4a9143c6c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [o];
+})();
+
+async function *fn() {
+ for await (const {...rest} of asyncIter) {
+ assert.sameValue(rest.a, 3);
+ assert.sameValue(rest.b, 4);
+ assert.sameValue(rest.x, undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..d76c8c96e6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-async-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{x: 1, y: 2, a: 5, b: 3}];
+})();
+
+async function *fn() {
+ for await (const {a, b, ...rest} of asyncIter) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-init-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-init-null.js
new file mode 100644
index 0000000000..fdf23348d2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-init-null.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-init-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+async function * gen() {
+ for await (const {} of [null]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-init-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-init-undefined.js
new file mode 100644
index 0000000000..2cc73ea41a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-init-undefined.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-init-undefined.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (undefined) (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+async function * gen() {
+ for await (const {} of [undefined]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-empty.js
new file mode 100644
index 0000000000..63fd4dc67b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-empty.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const {} of [obj]) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-get-value-err.js
new file mode 100644
index 0000000000..58936dcc28
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-get-value-err.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-get-value-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. Let v be GetV(value, propertyName).
+ 5. ReturnIfAbrupt(v).
+---*/
+var poisonedProperty = Object.defineProperty({}, 'poisoned', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+async function * gen() {
+ for await (const { poisoned } of [poisonedProperty]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..c79cc06842
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { arrow = () => {} } of [{}]) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..791585672c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of [{}]) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..2b2049f5be
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { cover = (function () {}), xCover = (0, function() {}) } of [{}]) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..99be94f242
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { fn = function () {}, xFn = function x() {} } of [{}]) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..c74cf15f45
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { gen = function* () {}, xGen = function* x() {} } of [{}]) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..58755a3fe6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { w = counter(), x = counter(), y = counter(), z = counter() } of [{ w: null, x: 0, y: false, z: '' }]) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-throws.js
new file mode 100644
index 0000000000..47408bd506
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-throws.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Error thrown when evaluating the initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ c. ReturnIfAbrupt(v).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function * gen() {
+ for await (const { x = thrower() } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-unresolvable.js
new file mode 100644
index 0000000000..0b28b3a76d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-init-unresolvable.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function * gen() {
+ for await (const { x = unresolvableReference } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..e5a90e7c49
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { x, } of [{ x: 23 }]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-init-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-init-err.js
new file mode 100644
index 0000000000..8f00dc220c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-init-err.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-iteration-statements
+description: >
+ Initializer is not allowed in head's ForDeclaration position.
+info: |
+ IterationStatement:
+ for await (ForDeclaration of AssignmentExpression) Statement
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+async function fn() {
+ for await (const {x} = 1 of []) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-list-err.js
new file mode 100644
index 0000000000..62841bc8cb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-list-err.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-list-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPropertyList : BindingPropertyList , BindingProperty
+
+ 1. Let status be the result of performing BindingInitialization for
+ BindingPropertyList using value and environment as arguments.
+ 2. ReturnIfAbrupt(status).
+---*/
+var initCount = 0;
+function thrower() {
+ throw new Test262Error();
+}
+
+async function * gen() {
+ for await (const { a, b = thrower(), c = ++initCount } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..d5646be7cd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { w: [x, y, z] = [4, 5, 6] } of [{}]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..003954fa85
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { x: [y], } of [{ x: [45] }]) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-value-null.js
new file mode 100644
index 0000000000..269a7b68ba
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary-value-null.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-value-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Object binding pattern with "nested" array binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function * gen() {
+ for await (const { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..04e81f7c3e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-ary.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { w: [x, y, z] = [4, 5, 6] } of [{ w: [7, undefined, ] }]) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-eval-err.js
new file mode 100644
index 0000000000..99fc040723
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-eval-err.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-eval-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Evaluation of property name returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingProperty : PropertyName : BindingElement
+
+ 1. Let P be the result of evaluating PropertyName
+ 2. ReturnIfAbrupt(P).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function * gen() {
+ for await (const { [thrower()]: x } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-get-value-err.js
new file mode 100644
index 0000000000..5d391e6f89
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-get-value-err.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-get-value-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. Let v be GetV(value, propertyName).
+ 2. ReturnIfAbrupt(v).
+---*/
+var initEvalCount = 0;
+var poisonedProperty = Object.defineProperty({}, 'poisoned', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+async function * gen() {
+ for await (const { poisoned: x = ++initEvalCount } of [poisonedProperty]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..943291982f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,81 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of [{ s: null, u: 0, w: false, y: '' }]) {
+ assert.sameValue(t, null);
+ assert.sameValue(v, 0);
+ assert.sameValue(x, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ assert.throws(ReferenceError, function() {
+ s;
+ });
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-throws.js
new file mode 100644
index 0000000000..0996544422
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-throws.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Error thrown when evaluating the initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function * gen() {
+ for await (const { x: y = thrower() } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-unresolvable.js
new file mode 100644
index 0000000000..17070d5ff1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init-unresolvable.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function * gen() {
+ for await (const { x: y = unresolvableReference } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..ce9d312ff4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-init.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { x: y = 33 } of [{ }]) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..02414c3296
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { x: y, } of [{ x: 23 }]) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..9196b1886f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-id.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Binding as specified via property name and identifier (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { x: y } of [{ x: 23 }]) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..cecfce5d95
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: undefined }]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-null.js
new file mode 100644
index 0000000000..8e000e6b76
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-null.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-value-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function * gen() {
+ for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-undef.js
new file mode 100644
index 0000000000..949612ff5c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj-value-undef.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-value-undef.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-const.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function * gen() {
+ for await (const { w: { x, y, z } = undefined } of [{ }]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..1f4985d42d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-prop-obj.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: { x: undefined, z: 7 } }]) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..a44b56862b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-getter.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-getter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var count = 0;
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const {...x} of [{ get v() { count++; return 2; } }]) {
+ assert.sameValue(x.v, 2);
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..b6b53eccef
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const {...rest} of [o]) {
+ assert.sameValue(rest.a, 3);
+ assert.sameValue(rest.b, 4);
+ assert.sameValue(rest.x, undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..f386ce9717
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-const-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-const.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (const {a, b, ...rest} of [{x: 1, y: 2, a: 5, b: 3}]) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-close.js
new file mode 100644
index 0000000000..9431b89ad5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-close.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: false };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [x] of [iter]) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-get-err.js
new file mode 100644
index 0000000000..a743d37c65
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-get-err.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-get-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Abrupt completion returned by GetIterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ 1. Let iterator be ? GetIterator(value).
+
+---*/
+var iter = {};
+iter[Symbol.iterator] = function() {
+ throw new Test262Error();
+};
+
+async function * gen() {
+ for await (let [x] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..310419d2c7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-init-iter-no-close.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-no-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: true };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [x] of [iter]) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-name-iter-val.js
new file mode 100644
index 0000000000..a4212b9a32
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-name-iter-val.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-name-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding with normal value iteration (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..72d4ace1fc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [[x, y, z] = [4, 5, 6]] of [[]]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..2f0844275a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [[x, y, z] = [4, 5, 6]] of [[[7, 8, 9]]]) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..a7283e83b3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [[,] = g()] of [[]]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..9ec86f9450
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var callCount = 0;
+function* g() {
+ callCount += 1;
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [[,] = g()] of [[[]]]) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..a9cea6cb75
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var initCount = 0;
+var iterCount = 0;
+var iter = function*() { iterCount += 1; }();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [[] = function() { initCount += 1; return iter; }()] of [[]]) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..c90c36f069
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var initCount = 0;
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [[] = function() { initCount += 1; }()] of [[[23]]]) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..825f913245
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [[...x] = values] of [[]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..8e365473f1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+var initCount = 0;
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [[...x] = function() { initCount += 1; }()] of [[values]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-val-null.js
new file mode 100644
index 0000000000..95aba046a3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-ary-val-null.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-val-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Nested array destructuring with a null value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ 1. Let iterator be ? GetIterator(value).
+---*/
+
+async function * gen() {
+ for await (let [[x]] of [[null]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..9f3ebf7a1d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [x = 23] of [[]]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..7aa0c1163b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [arrow = () => {}] of [[]]) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..29dd699226
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of [[]]) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..8e051acb55
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [cover = (function () {}), xCover = (0, function() {})] of [[]]) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..051310d8f6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [fn = function () {}, xFn = function x() {}] of [[]]) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..fa4c9b27d2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [gen = function* () {}, xGen = function* x() {}] of [[]]) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..996b9b3e7e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Destructuring initializer with a "hole" (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ SingleNameBinding : BindingIdentifier Initializer_opt
+ [...] 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v). 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [x = 23] of [[,]]) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..ae434d7332
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ 7. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [w = counter(), x = counter(), y = counter(), z = counter()] of [[null, 0, false, '']]) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-throws.js
new file mode 100644
index 0000000000..567232a951
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-throws.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Destructuring initializer returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+---*/
+
+async function * gen() {
+ for await (let [x = (function() { throw new Test262Error(); })()] of [[undefined]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..db6fb62cdf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Destructuring initializer with an undefined value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [x = 23] of [[undefined]]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-unresolvable.js
new file mode 100644
index 0000000000..ab20b24fcd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-init-unresolvable.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function * gen() {
+ for await (let [ x = unresolvableReference ] of [[]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..f1b7a619f7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding when value iteration completes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [x] of [[]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..98cb7b775d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [_, x] of [[]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-step-err.js
new file mode 100644
index 0000000000..704a12c64e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-step-err.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+
+---*/
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next() {
+ throw new Test262Error();
+ }
+ };
+};
+
+async function * gen() {
+ for await (let [x] of [g]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val-err.js
new file mode 100644
index 0000000000..8b75b269ba
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val-err.js
@@ -0,0 +1,83 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ iii. ReturnIfAbrupt(v).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedValue;
+ }
+ };
+};
+
+async function * gen() {
+ for await (let [x] of [g]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..c8d9fddc12
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..1c61b5302a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[]]) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..0ea9b718de
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[{ x: 11, y: 22, z: 33 }]]) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..1e5e8efc7a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,77 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[]]) {
+ assert.sameValue(v, 444);
+ assert.sameValue(x, 555);
+ assert.sameValue(z, 666);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..5d3492cadf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,77 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[{ u: 777, w: 888, y: 999 }]]) {
+ assert.sameValue(v, 777);
+ assert.sameValue(x, 888);
+ assert.sameValue(z, 999);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-null.js
new file mode 100644
index 0000000000..96b54e5426
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-null.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-val-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Nested object destructuring with a null value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ObjectBindingPattern
+
+ 1. Let valid be RequireObjectCoercible(value).
+ 2. ReturnIfAbrupt(valid).
+---*/
+
+async function * gen() {
+ for await (let [{ x }] of [[null]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-undef.js
new file mode 100644
index 0000000000..985868ed1c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elem-obj-val-undef.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-val-undef.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Nested object destructuring with a value of `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ObjectBindingPattern
+
+ 1. Let valid be RequireObjectCoercible(value).
+ 2. ReturnIfAbrupt(valid).
+---*/
+
+async function * gen() {
+ for await (let [{ x }] of [[]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..aa264362a9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Elision accepts exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [,] of [iter]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-iter-close.js
new file mode 100644
index 0000000000..6e46db606a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-iter-close.js
@@ -0,0 +1,56 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-iter-close.case
+// - src/dstr-binding-for-await/iter-close/for-await-of-async-gen-let.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+async function* fn() {
+ for await (let [,] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .next()
+ .then(() => {
+ assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-step-err.js
new file mode 100644
index 0000000000..5baa34e19c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision-step-err.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Elision advances iterator and forwards abrupt completions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+
+---*/
+var following = 0;
+var iter = function* () {
+ throw new Test262Error();
+ following += 1;
+}();
+
+async function * gen() {
+ for await (let [,] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+ assert.sameValue(following, 0, "iterator is properly closed");
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision.js
new file mode 100644
index 0000000000..cfef54e6c6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-elision.js
@@ -0,0 +1,81 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Elision advances iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [,] of [g()]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-empty.js
new file mode 100644
index 0000000000..b30b893eae
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-empty.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [] of [iter]) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-init-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-init-err.js
new file mode 100644
index 0000000000..6289bd9ae2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-init-err.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-iteration-statements
+description: >
+ Initializer is not allowed in head's ForDeclaration position.
+info: |
+ IterationStatement:
+ for await (ForDeclaration of AssignmentExpression) Statement
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+async function fn() {
+ for await (let [x] = 1 of []) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..e4a88ef409
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,87 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...[x, y, z]] of [[3, 4, 5]]) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..54be808440
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,94 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element containing an elision (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...[,]] of [g()]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..2b9ac630de
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,77 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element containing an "empty" array pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...[]] of [iter]) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..7b116a5a66
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element containing a rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...[...x]] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision-next-err.js
new file mode 100644
index 0000000000..968021ce1c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision-next-err.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision-next-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+
+---*/
+var iter = (function*() { throw new Test262Error(); })();
+
+async function * gen() {
+ for await (let [, ...x] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..a881416a91
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+---*/
+var values = [1, 2, 3, 4, 5];
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [ , , ...x] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 3);
+ assert.sameValue(x[1], 4);
+ assert.sameValue(x[2], 5);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..011e5bd44d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: RestElement applied to an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. If environment is undefined, return PutValue(lhs, A).
+ ii. Return InitializeReferencedBinding(lhs, A).
+
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [, , ...x] of [[1, 2]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-close.js
new file mode 100644
index 0000000000..f56ba47dde
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-close.js
@@ -0,0 +1,56 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-close.case
+// - src/dstr-binding-for-await/iter-close/for-await-of-async-gen-let.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+async function* fn() {
+ for await (let [...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .next()
+ .then(() => {
+ assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-step-err.js
new file mode 100644
index 0000000000..a8680d02cd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-step-err.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ a. If iteratorRecord.[[done]] is false,
+ i. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ ii. If next is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ iii. ReturnIfAbrupt(next).
+
+---*/
+var first = 0;
+var second = 0;
+var iter = function*() {
+ first += 1;
+ throw new Test262Error();
+ second += 1;
+}();
+
+async function * gen() {
+ for await (let [...x] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-val-err.js
new file mode 100644
index 0000000000..bb4036263e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id-iter-val-err.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-val-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ c. Let nextValue be IteratorValue(next).
+ d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ e. ReturnIfAbrupt(nextValue).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedValue;
+ }
+ };
+};
+
+async function * gen() {
+ for await (let [...x] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..40b3825117
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-id.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Lone rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat
+ [...]
+ f. Let status be CreateDataProperty(A, ToString (n), nextValue).
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...x] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..d131ef31ca
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,63 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...[ x ] = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..21fc460ded
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-init-id.js
@@ -0,0 +1,63 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element (identifier) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...x = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..fb6ba2bfe9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,63 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...{ x } = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..f30bf1b66c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,63 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...[x], y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..0d1284830c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,63 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...x, y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..5777f1df92
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,63 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...{ x }, y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..e1edc14dcc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...{ length }] of [[1, 2, 3]]) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..867ead687f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+let length = "outer";
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of [[7, 8, 9]]) {
+ assert.sameValue(v, 7);
+ assert.sameValue(w, 8);
+ assert.sameValue(x, 9);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 3);
+
+ assert.sameValue(length, "outer", "the length prop is not set as a binding name");
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-close.js
new file mode 100644
index 0000000000..40c431bed5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-close.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: false };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (let [x] of asyncIter) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..cbd77fc4ff
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-init-iter-no-close.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-no-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: true };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (let [x] of asyncIter) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-name-iter-val.js
new file mode 100644
index 0000000000..07a9402024
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-name-iter-val.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-name-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding with normal value iteration (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (let [x, y, z] of asyncIter) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..ffdd08fe42
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [[x, y, z] = [4, 5, 6]] of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..af3ce60a2c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[7, 8, 9]]];
+})();
+
+async function *fn() {
+ for await (let [[x, y, z] = [4, 5, 6]] of asyncIter) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..81544aa47f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [[,] = g()] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..2d403f9e96
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var callCount = 0;
+function* g() {
+ callCount += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[]]];
+})();
+
+async function *fn() {
+ for await (let [[,] = g()] of asyncIter) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..4effbe25e4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var initCount = 0;
+var iterCount = 0;
+var iter = function*() { iterCount += 1; }();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [[] = function() { initCount += 1; return iter; }()] of asyncIter) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..4735dd78e4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var initCount = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[23]]];
+})();
+
+async function *fn() {
+ for await (let [[] = function() { initCount += 1; }()] of asyncIter) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..3992f62a3e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [[...x] = values] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..43c2dcee13
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+var initCount = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[values]];
+})();
+
+async function *fn() {
+ for await (let [[...x] = function() { initCount += 1; }()] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..097e7c834c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..74e2cbe287
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [arrow = () => {}] of asyncIter) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..ab65f44ca8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of asyncIter) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..ad923a8ba1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [cover = (function () {}), xCover = (0, function() {})] of asyncIter) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..968fcc269f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [fn = function () {}, xFn = function x() {}] of asyncIter) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..83c39b0a31
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [gen = function* () {}, xGen = function* x() {}] of asyncIter) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..f8e83f7aff
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Destructuring initializer with a "hole" (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ SingleNameBinding : BindingIdentifier Initializer_opt
+ [...] 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v). 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[,]];
+})();
+
+async function *fn() {
+ for await (let [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..b2097cfb15
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ 7. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[null, 0, false, '']];
+})();
+
+async function *fn() {
+ for await (let [w = counter(), x = counter(), y = counter(), z = counter()] of asyncIter) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..c6d7e2d841
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Destructuring initializer with an undefined value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[undefined]];
+})();
+
+async function *fn() {
+ for await (let [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..b81d106f21
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding when value iteration completes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [x] of asyncIter) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..dcd15846be
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [_, x] of asyncIter) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..ccf2a2ad95
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (let [x, y, z] of asyncIter) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..24cb0fc5ba
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..683745c5ff
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[{ x: 11, y: 22, z: 33 }]];
+})();
+
+async function *fn() {
+ for await (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..6026b06ce0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) {
+ assert.sameValue(v, 444);
+ assert.sameValue(x, 555);
+ assert.sameValue(z, 666);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..274290a1a2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[{ u: 777, w: 888, y: 999 }]];
+})();
+
+async function *fn() {
+ for await (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) {
+ assert.sameValue(v, 777);
+ assert.sameValue(x, 888);
+ assert.sameValue(z, 999);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..a6ab7f035a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Elision accepts exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (let [,] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision.js
new file mode 100644
index 0000000000..bb5b7490f9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-elision.js
@@ -0,0 +1,83 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Elision advances iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [g()];
+})();
+
+async function *fn() {
+ for await (let [,] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-empty.js
new file mode 100644
index 0000000000..9cfb506be7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-empty.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (let [] of asyncIter) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..164ffeab45
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,89 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[3, 4, 5]];
+})();
+
+async function *fn() {
+ for await (let [...[x, y, z]] of asyncIter) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..654516bbfa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,96 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element containing an elision (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [g()];
+})();
+
+async function *fn() {
+ for await (let [...[,]] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..67858f6b6f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element containing an "empty" array pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (let [...[]] of asyncIter) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..ab804e307e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element containing a rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function *fn() {
+ for await (let [...[...x]] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..19ec3755cd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+---*/
+var values = [1, 2, 3, 4, 5];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function *fn() {
+ for await (let [ , , ...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 3);
+ assert.sameValue(x[1], 4);
+ assert.sameValue(x[2], 5);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..f3228bd356
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: RestElement applied to an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. If environment is undefined, return PutValue(lhs, A).
+ ii. Return InitializeReferencedBinding(lhs, A).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2]];
+})();
+
+async function *fn() {
+ for await (let [, , ...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..b2807f2633
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-id.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Lone rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat
+ [...]
+ f. Let status be CreateDataProperty(A, ToString (n), nextValue).
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function *fn() {
+ for await (let [...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..9a24fad064
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [...[ x ] = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..756e186dd5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-id.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element (identifier) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [...x = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..a8c158410b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (let [...{ x } = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..f5a11b540e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (let [...[x], y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..f0a26042e6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (let [...x, y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..2159b1b101
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (let [...{ x }, y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..68e0645c1c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (let [...{ length }] of asyncIter) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..a6ce28973a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+let length = "outer";
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[7, 8, 9]];
+})();
+
+async function *fn() {
+ for await (let [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of asyncIter) {
+ assert.sameValue(v, 7);
+ assert.sameValue(w, 8);
+ assert.sameValue(x, 9);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 3);
+
+ assert.sameValue(length, "outer", "the length prop is not set as a binding name");
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-empty.js
new file mode 100644
index 0000000000..7dd445d9fe
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-empty.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [obj];
+})();
+
+async function *fn() {
+ for await (let {} of asyncIter) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..8f1fc70be9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (let { arrow = () => {} } of asyncIter) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..9a07f69c52
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (let { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of asyncIter) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..6115182d0e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (let { cover = (function () {}), xCover = (0, function() {}) } of asyncIter) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..9b7690f29d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (let { fn = function () {}, xFn = function x() {} } of asyncIter) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..40fdd82710
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (let { gen = function* () {}, xGen = function* x() {} } of asyncIter) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..e54d934dfa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: null, x: 0, y: false, z: '' }];
+})();
+
+async function *fn() {
+ for await (let { w = counter(), x = counter(), y = counter(), z = counter() } of asyncIter) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..b0b8d6e2b6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function *fn() {
+ for await (let { x, } of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..3a1edde3b5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (let { w: [x, y, z] = [4, 5, 6] } of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..2996d54738
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: [45] }];
+})();
+
+async function *fn() {
+ for await (let { x: [y], } of asyncIter) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..74b96223d6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-ary.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: [7, undefined, ] }];
+})();
+
+async function *fn() {
+ for await (let { w: [x, y, z] = [4, 5, 6] } of asyncIter) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..371a9e50ea
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,84 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ s: null, u: 0, w: false, y: '' }];
+})();
+
+async function *fn() {
+ for await (let { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of asyncIter) {
+ assert.sameValue(t, null);
+ assert.sameValue(v, 0);
+ assert.sameValue(x, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ assert.throws(ReferenceError, function() {
+ s;
+ });
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..d514a2ab4c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-init.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ }];
+})();
+
+async function *fn() {
+ for await (let { x: y = 33 } of asyncIter) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..4a52fd72c3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function *fn() {
+ for await (let { x: y, } of asyncIter) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..266dd4212d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-id.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Binding as specified via property name and identifier (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function *fn() {
+ for await (let { x: y } of asyncIter) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..8d63ad2835
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: undefined }];
+})();
+
+async function *fn() {
+ for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..a6e0bd73a0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-prop-obj.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: { x: undefined, z: 7 } }];
+})();
+
+async function *fn() {
+ for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..3fd2a3b5a8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-getter.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-getter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var count = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ get v() { count++; return 2; } }];
+})();
+
+async function *fn() {
+ for await (let {...x} of asyncIter) {
+ assert.sameValue(x.v, 2);
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..c57bfa6c4d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [o];
+})();
+
+async function *fn() {
+ for await (let {...rest} of asyncIter) {
+ assert.sameValue(rest.a, 3);
+ assert.sameValue(rest.b, 4);
+ assert.sameValue(rest.x, undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..ec814c481c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-async-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{x: 1, y: 2, a: 5, b: 3}];
+})();
+
+async function *fn() {
+ for await (let {a, b, ...rest} of asyncIter) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-init-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-init-null.js
new file mode 100644
index 0000000000..bf89725c40
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-init-null.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-init-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+async function * gen() {
+ for await (let {} of [null]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-init-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-init-undefined.js
new file mode 100644
index 0000000000..d57ee9345d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-init-undefined.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-init-undefined.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (undefined) (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+async function * gen() {
+ for await (let {} of [undefined]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-empty.js
new file mode 100644
index 0000000000..c66b4c0d21
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-empty.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let {} of [obj]) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-get-value-err.js
new file mode 100644
index 0000000000..d6efb7b093
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-get-value-err.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-get-value-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. Let v be GetV(value, propertyName).
+ 5. ReturnIfAbrupt(v).
+---*/
+var poisonedProperty = Object.defineProperty({}, 'poisoned', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+async function * gen() {
+ for await (let { poisoned } of [poisonedProperty]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..8a7c7e3525
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { arrow = () => {} } of [{}]) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..f36c14e64f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of [{}]) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..6a206b2e27
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { cover = (function () {}), xCover = (0, function() {}) } of [{}]) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..f904656d68
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { fn = function () {}, xFn = function x() {} } of [{}]) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..19408526c1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { gen = function* () {}, xGen = function* x() {} } of [{}]) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..0e913735c5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { w = counter(), x = counter(), y = counter(), z = counter() } of [{ w: null, x: 0, y: false, z: '' }]) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-throws.js
new file mode 100644
index 0000000000..f00aaa2c10
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-throws.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Error thrown when evaluating the initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ c. ReturnIfAbrupt(v).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function * gen() {
+ for await (let { x = thrower() } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-unresolvable.js
new file mode 100644
index 0000000000..f1c8e0a1a6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-init-unresolvable.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function * gen() {
+ for await (let { x = unresolvableReference } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..6c571ea79b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { x, } of [{ x: 23 }]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-init-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-init-err.js
new file mode 100644
index 0000000000..db0f426782
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-init-err.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-iteration-statements
+description: >
+ Initializer is not allowed in head's ForDeclaration position.
+info: |
+ IterationStatement:
+ for await (ForDeclaration of AssignmentExpression) Statement
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+async function fn() {
+ for await (let {x} = 1 of []) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-list-err.js
new file mode 100644
index 0000000000..0d9eb0ff16
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-list-err.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-list-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPropertyList : BindingPropertyList , BindingProperty
+
+ 1. Let status be the result of performing BindingInitialization for
+ BindingPropertyList using value and environment as arguments.
+ 2. ReturnIfAbrupt(status).
+---*/
+var initCount = 0;
+function thrower() {
+ throw new Test262Error();
+}
+
+async function * gen() {
+ for await (let { a, b = thrower(), c = ++initCount } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..c0506ebea9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { w: [x, y, z] = [4, 5, 6] } of [{}]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..68ce508b20
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { x: [y], } of [{ x: [45] }]) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-value-null.js
new file mode 100644
index 0000000000..50a021e464
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary-value-null.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-value-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Object binding pattern with "nested" array binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function * gen() {
+ for await (let { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..aed49d07fb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-ary.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { w: [x, y, z] = [4, 5, 6] } of [{ w: [7, undefined, ] }]) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-eval-err.js
new file mode 100644
index 0000000000..eb185a7241
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-eval-err.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-eval-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Evaluation of property name returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingProperty : PropertyName : BindingElement
+
+ 1. Let P be the result of evaluating PropertyName
+ 2. ReturnIfAbrupt(P).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function * gen() {
+ for await (let { [thrower()]: x } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-get-value-err.js
new file mode 100644
index 0000000000..43161a472c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-get-value-err.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-get-value-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. Let v be GetV(value, propertyName).
+ 2. ReturnIfAbrupt(v).
+---*/
+var initEvalCount = 0;
+var poisonedProperty = Object.defineProperty({}, 'poisoned', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+async function * gen() {
+ for await (let { poisoned: x = ++initEvalCount } of [poisonedProperty]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..f15f3c3510
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,82 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of [{ s: null, u: 0, w: false, y: '' }]) {
+ assert.sameValue(t, null);
+ assert.sameValue(v, 0);
+ assert.sameValue(x, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ assert.throws(ReferenceError, function() {
+ s;
+ });
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-throws.js
new file mode 100644
index 0000000000..705323261a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-throws.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Error thrown when evaluating the initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function * gen() {
+ for await (let { x: y = thrower() } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-unresolvable.js
new file mode 100644
index 0000000000..5c6989ec82
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init-unresolvable.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function * gen() {
+ for await (let { x: y = unresolvableReference } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..57695d3052
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-init.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { x: y = 33 } of [{ }]) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..7d4688eb21
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { x: y, } of [{ x: 23 }]) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..1aa4fcdc77
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-id.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Binding as specified via property name and identifier (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { x: y } of [{ x: 23 }]) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..0e968128be
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: undefined }]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-null.js
new file mode 100644
index 0000000000..3d2795ba15
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-null.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-value-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function * gen() {
+ for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-undef.js
new file mode 100644
index 0000000000..d006ea858e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj-value-undef.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-value-undef.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-let.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function * gen() {
+ for await (let { w: { x, y, z } = undefined } of [{ }]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..5f436b8c24
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-prop-obj.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: { x: undefined, z: 7 } }]) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..c990a01d69
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-getter.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-getter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var count = 0;
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let {...x} of [{ get v() { count++; return 2; } }]) {
+ assert.sameValue(x.v, 2);
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..1986b476c0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let {...rest} of [o]) {
+ assert.sameValue(rest.a, 3);
+ assert.sameValue(rest.b, 4);
+ assert.sameValue(rest.x, undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..47ba396f9e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-let-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-let.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (let {a, b, ...rest} of [{x: 1, y: 2, a: 5, b: 3}]) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-close.js
new file mode 100644
index 0000000000..06c3532b41
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-close.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: false };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [x] of [iter]) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-get-err.js
new file mode 100644
index 0000000000..93f17f88b8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-get-err.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-get-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Abrupt completion returned by GetIterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ 1. Let iterator be ? GetIterator(value).
+
+---*/
+var iter = {};
+iter[Symbol.iterator] = function() {
+ throw new Test262Error();
+};
+
+async function * gen() {
+ for await (var [x] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..8bbaefdde7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-init-iter-no-close.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-no-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: true };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [x] of [iter]) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-name-iter-val.js
new file mode 100644
index 0000000000..7f8e0087ab
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-name-iter-val.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-name-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding with normal value iteration (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..9a21708318
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [[x, y, z] = [4, 5, 6]] of [[]]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..4845d03226
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [[x, y, z] = [4, 5, 6]] of [[[7, 8, 9]]]) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..bdd8ce328e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [[,] = g()] of [[]]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..2c7a1455eb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var callCount = 0;
+function* g() {
+ callCount += 1;
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [[,] = g()] of [[[]]]) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..eae57654d4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var initCount = 0;
+var iterCount = 0;
+var iter = function*() { iterCount += 1; }();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [[] = function() { initCount += 1; return iter; }()] of [[]]) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..d8ca51ebf4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var initCount = 0;
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [[] = function() { initCount += 1; }()] of [[[23]]]) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..904bfb0d34
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [[...x] = values] of [[]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..be404a464c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+var initCount = 0;
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [[...x] = function() { initCount += 1; }()] of [[values]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-val-null.js
new file mode 100644
index 0000000000..2fb7b2850a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-ary-val-null.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-val-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Nested array destructuring with a null value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ 1. Let iterator be ? GetIterator(value).
+---*/
+
+async function * gen() {
+ for await (var [[x]] of [[null]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..0c141203b1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [x = 23] of [[]]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..cd850f865c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [arrow = () => {}] of [[]]) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..a65e87e048
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of [[]]) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..12e7209d72
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [cover = (function () {}), xCover = (0, function() {})] of [[]]) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..c8e782236c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [fn = function () {}, xFn = function x() {}] of [[]]) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..0e6e351e0b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [gen = function* () {}, xGen = function* x() {}] of [[]]) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..563985e649
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,59 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Destructuring initializer with a "hole" (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ SingleNameBinding : BindingIdentifier Initializer_opt
+ [...] 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v). 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [x = 23] of [[,]]) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..1a8cf680e6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ 7. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [w = counter(), x = counter(), y = counter(), z = counter()] of [[null, 0, false, '']]) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-throws.js
new file mode 100644
index 0000000000..5a43d294ae
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-throws.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Destructuring initializer returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+---*/
+
+async function * gen() {
+ for await (var [x = (function() { throw new Test262Error(); })()] of [[undefined]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..f3573de61f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Destructuring initializer with an undefined value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [x = 23] of [[undefined]]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-unresolvable.js
new file mode 100644
index 0000000000..b4974f5abb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-init-unresolvable.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function * gen() {
+ for await (var [ x = unresolvableReference ] of [[]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..3aebef3461
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding when value iteration completes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [x] of [[]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..99d4c32e42
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [_, x] of [[]]) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-step-err.js
new file mode 100644
index 0000000000..dfba3418ce
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-step-err.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+
+---*/
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next() {
+ throw new Test262Error();
+ }
+ };
+};
+
+async function * gen() {
+ for await (var [x] of [g]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val-err.js
new file mode 100644
index 0000000000..06ab471db7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val-err.js
@@ -0,0 +1,84 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ iii. ReturnIfAbrupt(v).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var g = {};
+g[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedValue;
+ }
+ };
+};
+
+async function * gen() {
+ for await (var [x] of [g]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..a8dd7c2f4d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [x, y, z] of [[1, 2, 3]]) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..26ed3ea914
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[]]) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..69ebbfec9e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[{ x: 11, y: 22, z: 33 }]]) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..03880ca375
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[]]) {
+ assert.sameValue(v, 444);
+ assert.sameValue(x, 555);
+ assert.sameValue(z, 666);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..94ecdbe81d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[{ u: 777, w: 888, y: 999 }]]) {
+ assert.sameValue(v, 777);
+ assert.sameValue(x, 888);
+ assert.sameValue(z, 999);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-null.js
new file mode 100644
index 0000000000..5e33bfa862
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-null.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-val-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Nested object destructuring with a null value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ObjectBindingPattern
+
+ 1. Let valid be RequireObjectCoercible(value).
+ 2. ReturnIfAbrupt(valid).
+---*/
+
+async function * gen() {
+ for await (var [{ x }] of [[null]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-undef.js
new file mode 100644
index 0000000000..133a9e5c95
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elem-obj-val-undef.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-val-undef.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Nested object destructuring with a value of `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ e. Else
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ObjectBindingPattern
+
+ 1. Let valid be RequireObjectCoercible(value).
+ 2. ReturnIfAbrupt(valid).
+---*/
+
+async function * gen() {
+ for await (var [{ x }] of [[]]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..a2debd56b6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Elision accepts exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [,] of [iter]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-iter-close.js
new file mode 100644
index 0000000000..915bbd108a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-iter-close.js
@@ -0,0 +1,53 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-iter-close.case
+// - src/dstr-binding-for-await/iter-close/for-await-of-async-gen-var.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+async function* fn() {
+ for await (var [,] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .next()
+ .then(() => {
+ assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-step-err.js
new file mode 100644
index 0000000000..0a4b238c4c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision-step-err.js
@@ -0,0 +1,77 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Elision advances iterator and forwards abrupt completions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+
+---*/
+var following = 0;
+var iter = function* () {
+ throw new Test262Error();
+ following += 1;
+}();
+
+async function * gen() {
+ for await (var [,] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+ assert.sameValue(following, 0, "iterator is properly closed");
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision.js
new file mode 100644
index 0000000000..93163065e2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-elision.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Elision advances iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [,] of [g()]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-empty.js
new file mode 100644
index 0000000000..07c307b1f9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-empty.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [] of [iter]) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-init-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-init-err.js
new file mode 100644
index 0000000000..c05d1c938d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-init-err.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-iteration-statements
+description: >
+ Initializer is not allowed in head's ForBinding position.
+info: |
+ IterationStatement:
+ for await (var ForBinding of AssignmentExpression) Statement
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+async function fn() {
+ for await (var [x] = 1 of []) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..5ac284fc8e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,84 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...[x, y, z]] of [[3, 4, 5]]) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..d5cd4c2b1d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,91 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element containing an elision (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...[,]] of [g()]) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..cedc01d6b8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element containing an "empty" array pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...[]] of [iter]) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..da569d8c16
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element containing a rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...[...x]] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision-next-err.js
new file mode 100644
index 0000000000..14f64e6c7d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision-next-err.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision-next-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+
+---*/
+var iter = (function*() { throw new Test262Error(); })();
+
+async function * gen() {
+ for await (var [, ...x] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..8ea6603624
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+---*/
+var values = [1, 2, 3, 4, 5];
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [ , , ...x] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 3);
+ assert.sameValue(x[1], 4);
+ assert.sameValue(x[2], 5);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..033f084b0d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: RestElement applied to an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. If environment is undefined, return PutValue(lhs, A).
+ ii. Return InitializeReferencedBinding(lhs, A).
+
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [, , ...x] of [[1, 2]]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-close.js
new file mode 100644
index 0000000000..9e1ee6f3e3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-close.js
@@ -0,0 +1,53 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-close.case
+// - src/dstr-binding-for-await/iter-close/for-await-of-async-gen-var.template
+/*---
+description: The iterator is properly consumed by the destructuring pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+---*/
+const iter = (function* () {
+ yield;
+ yield;
+})();
+
+
+async function* fn() {
+ for await (var [...x] of [iter]) {
+ return;
+ }
+}
+
+fn()
+ .next()
+ .then(() => {
+ assert.sameValue(iter.next().done, true, 'iteration occurred as expected');
+ })
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-step-err.js
new file mode 100644
index 0000000000..597381b309
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-step-err.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-step-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Error forwarding when IteratorStep returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ a. If iteratorRecord.[[done]] is false,
+ i. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ ii. If next is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ iii. ReturnIfAbrupt(next).
+
+---*/
+var first = 0;
+var second = 0;
+var iter = function*() {
+ first += 1;
+ throw new Test262Error();
+ second += 1;
+}();
+
+async function * gen() {
+ for await (var [...x] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-val-err.js
new file mode 100644
index 0000000000..6de121083f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id-iter-val-err.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-iter-val-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Error forwarding when IteratorValue returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ c. Let nextValue be IteratorValue(next).
+ d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to
+ true.
+ e. ReturnIfAbrupt(nextValue).
+
+---*/
+var poisonedValue = Object.defineProperty({}, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedValue;
+ }
+ };
+};
+
+async function * gen() {
+ for await (var [...x] of [iter]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..3f51ee7622
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-id.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Lone rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat
+ [...]
+ f. Let status be CreateDataProperty(A, ToString (n), nextValue).
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...x] of [values]) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..4789837e96
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,60 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...[ x ] = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..c1af67caec
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-init-id.js
@@ -0,0 +1,60 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element (identifier) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...x = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..ab1af8ae7e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,60 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...{ x } = []] of [[]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..0e93f066bf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,60 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...[x], y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..688ef10014
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,60 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...x, y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..3f108409ab
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,60 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...{ x }, y] of [[1, 2, 3]]) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..18de0f60e4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...{ length }] of [[1, 2, 3]]) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..c83b9f89af
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+let length = "outer";
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of [[7, 8, 9]]) {
+ assert.sameValue(v, 7);
+ assert.sameValue(w, 8);
+ assert.sameValue(x, 9);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 3);
+
+ assert.sameValue(length, "outer", "the length prop is not set as a binding name");
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-close.js
new file mode 100644
index 0000000000..593ba9e8e6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-close.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Iterator is closed when not exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: false };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (var [x] of asyncIter) {
+ assert.sameValue(doneCallCount, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-no-close.js
new file mode 100644
index 0000000000..e9c114c8d2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-init-iter-no-close.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-init-iter-no-close.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Iterator is not closed when exhausted by pattern evaluation (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPattern : ArrayBindingPattern
+
+ [...]
+ 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
+ result).
+ [...]
+
+---*/
+var doneCallCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return { value: null, done: true };
+ },
+ return() {
+ doneCallCount += 1;
+ return {};
+ }
+ };
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (var [x] of asyncIter) {
+ assert.sameValue(doneCallCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-name-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-name-iter-val.js
new file mode 100644
index 0000000000..c385c04073
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-name-iter-val.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-name-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding with normal value iteration (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (var [x, y, z] of asyncIter) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-init.js
new file mode 100644
index 0000000000..199d470bd8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [[x, y, z] = [4, 5, 6]] of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js
new file mode 100644
index 0000000000..019a7ecc51
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elem-iter.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[7, 8, 9]]];
+})();
+
+async function *fn() {
+ for await (var [[x, y, z] = [4, 5, 6]] of asyncIter) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, 8);
+ assert.sameValue(z, 9);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-init.js
new file mode 100644
index 0000000000..e643276a3a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-init.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [[,] = g()] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js
new file mode 100644
index 0000000000..c667ad806d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-elision-iter.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var callCount = 0;
+function* g() {
+ callCount += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[]]];
+})();
+
+async function *fn() {
+ for await (var [[,] = g()] of asyncIter) {
+ assert.sameValue(callCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-init.js
new file mode 100644
index 0000000000..ed8cb5aabc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-init.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+
+---*/
+var initCount = 0;
+var iterCount = 0;
+var iter = function*() { iterCount += 1; }();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [[] = function() { initCount += 1; return iter; }()] of asyncIter) {
+ assert.sameValue(initCount, 1);
+ assert.sameValue(iterCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js
new file mode 100644
index 0000000000..2c42fc2a0e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-empty-iter.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var initCount = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[[23]]];
+})();
+
+async function *fn() {
+ for await (var [[] = function() { initCount += 1; }()] of asyncIter) {
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-init.js
new file mode 100644
index 0000000000..5b9990aa33
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-init.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [[...x] = values] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js
new file mode 100644
index 0000000000..0d7f844260
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-ary-rest-iter.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: BindingElement with array binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ [...]
+ e. Else,
+ i. Let v be IteratorValue(next).
+ [...]
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+var values = [2, 1, 3];
+var initCount = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[values]];
+})();
+
+async function *fn() {
+ for await (var [[...x] = function() { initCount += 1; }()] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x[0], 2);
+ assert.sameValue(x[1], 1);
+ assert.sameValue(x[2], 3);
+ assert.sameValue(x.length, 3);
+ assert.notSameValue(x, values);
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js
new file mode 100644
index 0000000000..612648de18
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-exhausted.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Destructuring initializer with an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..7c6399885d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-arrow.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding does assign name to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [arrow = () => {}] of asyncIter) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js
new file mode 100644
index 0000000000..750ae97d6f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-class.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] of asyncIter) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..e09641bb05
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-cover.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [cover = (function () {}), xCover = (0, function() {})] of asyncIter) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..6777428490
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-fn.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [fn = function () {}, xFn = function x() {}] of asyncIter) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..745aca99a6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-fn-name-gen.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ c. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [gen = function* () {}, xGen = function* x() {}] of asyncIter) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-hole.js
new file mode 100644
index 0000000000..4e6027a0ce
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-hole.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Destructuring initializer with a "hole" (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ SingleNameBinding : BindingIdentifier Initializer_opt
+ [...] 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v). 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[,]];
+})();
+
+async function *fn() {
+ for await (var [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+ // another statement
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-skipped.js
new file mode 100644
index 0000000000..4ecc890784
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-skipped.js
@@ -0,0 +1,73 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ 7. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[null, 0, false, '']];
+})();
+
+async function *fn() {
+ for await (var [w = counter(), x = counter(), y = counter(), z = counter()] of asyncIter) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-undef.js
new file mode 100644
index 0000000000..1e91b59e9f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-init-undef.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Destructuring initializer with an undefined value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ [...]
+ 6. If environment is undefined, return PutValue(lhs, v).
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[undefined]];
+})();
+
+async function *fn() {
+ for await (var [x = 23] of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-complete.js
new file mode 100644
index 0000000000..91eb43130e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-complete.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding when value iteration completes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [x] of asyncIter) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-done.js
new file mode 100644
index 0000000000..c47e0395f9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-done.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ [...]
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [_, x] of asyncIter) {
+ assert.sameValue(x, undefined);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-val.js
new file mode 100644
index 0000000000..2c6d54e7e0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-id-iter-val.js
@@ -0,0 +1,76 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding when value iteration was completed previously (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (var [x, y, z] of asyncIter) {
+ assert.sameValue(x, 1);
+ assert.sameValue(y, 2);
+ assert.sameValue(z, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id-init.js
new file mode 100644
index 0000000000..e90c0f216e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id-init.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) {
+ assert.sameValue(x, 44);
+ assert.sameValue(y, 55);
+ assert.sameValue(z, 66);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id.js
new file mode 100644
index 0000000000..61fbc3df89
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-id.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[{ x: 11, y: 22, z: 33 }]];
+})();
+
+async function *fn() {
+ for await (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of asyncIter) {
+ assert.sameValue(x, 11);
+ assert.sameValue(y, 22);
+ assert.sameValue(z, 33);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js
new file mode 100644
index 0000000000..4ee40856c4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id-init.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) {
+ assert.sameValue(v, 444);
+ assert.sameValue(x, 555);
+ assert.sameValue(z, 666);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id.js
new file mode 100644
index 0000000000..0cf7c88109
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elem-obj-prop-id.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: BindingElement with object binding pattern and initializer is not used (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 2. If iteratorRecord.[[done]] is true, let v be undefined.
+ 3. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization of BindingPattern
+ with v and environment as the arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[{ u: 777, w: 888, y: 999 }]];
+})();
+
+async function *fn() {
+ for await (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of asyncIter) {
+ assert.sameValue(v, 777);
+ assert.sameValue(x, 888);
+ assert.sameValue(z, 999);
+
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision-exhausted.js
new file mode 100644
index 0000000000..ad505aacd3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision-exhausted.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Elision accepts exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ [...]
+ 2. Return NormalCompletion(empty).
+
+---*/
+var iter = function*() {}();
+iter.next();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (var [,] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision.js
new file mode 100644
index 0000000000..9af91b9d1f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-elision.js
@@ -0,0 +1,83 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Elision advances iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [g()];
+})();
+
+async function *fn() {
+ for await (var [,] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-empty.js
new file mode 100644
index 0000000000..415452a01f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-empty.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: No iteration occurs for an "empty" array binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (var [] of asyncIter) {
+ assert.sameValue(iterations, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elem.js
new file mode 100644
index 0000000000..af3f2f7b2d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elem.js
@@ -0,0 +1,89 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element containing an array BindingElementList pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 3. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ e. Else,
+ i. Let v be IteratorValue(next).
+ ii. If v is an abrupt completion, set
+ iteratorRecord.[[done]] to true.
+ iii. ReturnIfAbrupt(v).
+ 4. If iteratorRecord.[[done]] is true, let v be undefined.
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[3, 4, 5]];
+})();
+
+async function *fn() {
+ for await (var [...[x, y, z]] of asyncIter) {
+ assert.sameValue(x, 3);
+ assert.sameValue(y, 4);
+ assert.sameValue(z, 5);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elision.js
new file mode 100644
index 0000000000..19af300b5f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-elision.js
@@ -0,0 +1,96 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element containing an elision (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ Elision ]
+
+ 1. Return the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
+ as the argument.
+
+ 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
+
+ Elision : ,
+
+ 1. If iteratorRecord.[[done]] is false, then
+ a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+ d. If next is false, set iteratorRecord.[[done]] to true.
+ 2. Return NormalCompletion(empty).
+
+---*/
+var first = 0;
+var second = 0;
+function* g() {
+ first += 1;
+ yield;
+ second += 1;
+};
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [g()];
+})();
+
+async function *fn() {
+ for await (var [...[,]] of asyncIter) {
+ assert.sameValue(first, 1);
+ assert.sameValue(second, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-empty.js
new file mode 100644
index 0000000000..94eca8a5df
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-empty.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element containing an "empty" array pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ ArrayBindingPattern : [ ]
+
+ 1. Return NormalCompletion(empty).
+
+---*/
+var iterations = 0;
+var iter = function*() {
+ iterations += 1;
+}();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [iter];
+})();
+
+async function *fn() {
+ for await (var [...[]] of asyncIter) {
+ assert.sameValue(iterations, 1);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-rest.js
new file mode 100644
index 0000000000..5b04fab44d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-ary-rest.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element containing a rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function *fn() {
+ for await (var [...[...x]] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-elision.js
new file mode 100644
index 0000000000..0db74c51f6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-elision.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element following elision elements (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ ArrayBindingPattern : [ Elisionopt BindingRestElement ]
+ 1. If Elision is present, then
+ a. Let status be the result of performing
+ IteratorDestructuringAssignmentEvaluation of Elision with
+ iteratorRecord as the argument.
+ b. ReturnIfAbrupt(status).
+ 2. Return the result of performing IteratorBindingInitialization for
+ BindingRestElement with iteratorRecord and environment as arguments.
+---*/
+var values = [1, 2, 3, 4, 5];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function *fn() {
+ for await (var [ , , ...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 3);
+ assert.sameValue(x[1], 4);
+ assert.sameValue(x[2], 5);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-exhausted.js
new file mode 100644
index 0000000000..2751ead172
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id-exhausted.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: RestElement applied to an exhausted iterator (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [Symbol.iterator, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier,
+ environment).
+ 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat,
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. If environment is undefined, return PutValue(lhs, A).
+ ii. Return InitializeReferencedBinding(lhs, A).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2]];
+})();
+
+async function *fn() {
+ for await (var [, , ...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id.js
new file mode 100644
index 0000000000..578944fd8c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-id.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Lone rest element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+ BindingRestElement : ... BindingIdentifier
+ [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat
+ [...]
+ f. Let status be CreateDataProperty(A, ToString (n), nextValue).
+ [...]
+---*/
+var values = [1, 2, 3];
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [values];
+})();
+
+async function *fn() {
+ for await (var [...x] of asyncIter) {
+ assert(Array.isArray(x));
+ assert.sameValue(x.length, 3);
+ assert.sameValue(x[0], 1);
+ assert.sameValue(x[1], 2);
+ assert.sameValue(x[2], 3);
+ assert.notSameValue(x, values);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-ary.js
new file mode 100644
index 0000000000..5d05692fdd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-ary.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element (nested array pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [...[ x ] = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-id.js
new file mode 100644
index 0000000000..8effa424c8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-id.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element (identifier) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [...x = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-obj.js
new file mode 100644
index 0000000000..6849b9f651
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-init-obj.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element (nested object pattern) does not support initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[]];
+})();
+
+async function *fn() {
+ for await (var [...{ x } = []] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-ary.js
new file mode 100644
index 0000000000..ca8490907c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-ary.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element (array binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (var [...[x], y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-id.js
new file mode 100644
index 0000000000..9300892b93
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-id.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element (identifier) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (var [...x, y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-obj.js
new file mode 100644
index 0000000000..9773859053
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-not-final-obj.js
@@ -0,0 +1,65 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element (object binding pattern) may not be followed by any element (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+ ArrayBindingPattern[Yield] :
+ [ Elisionopt BindingRestElement[?Yield]opt ]
+ [ BindingElementList[?Yield] ]
+ [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ]
+---*/
+$DONOTEVALUATE();
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (var [...{ x }, y] of asyncIter) {
+
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-id.js
new file mode 100644
index 0000000000..1e1eb99e47
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-id.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[1, 2, 3]];
+})();
+
+async function *fn() {
+ for await (var [...{ length }] of asyncIter) {
+ assert.sameValue(length, 3);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-prop-id.js
new file mode 100644
index 0000000000..ee1ff5a2d6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-ary-ptrn-rest-obj-prop-id.js
@@ -0,0 +1,75 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest element containing an object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
+
+ BindingRestElement : ... BindingPattern
+
+ 1. Let A be ArrayCreate(0).
+ [...]
+ 3. Repeat
+ [...]
+ b. If iteratorRecord.[[done]] is true, then
+ i. Return the result of performing BindingInitialization of
+ BindingPattern with A and environment as the arguments.
+ [...]
+---*/
+let length = "outer";
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [[7, 8, 9]];
+})();
+
+async function *fn() {
+ for await (var [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of asyncIter) {
+ assert.sameValue(v, 7);
+ assert.sameValue(w, 8);
+ assert.sameValue(x, 9);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 3);
+
+ assert.sameValue(length, "outer", "the length prop is not set as a binding name");
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-empty.js
new file mode 100644
index 0000000000..baa8264124
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-empty.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [obj];
+})();
+
+async function *fn() {
+ for await (var {} of asyncIter) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..9f2dff73bb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,68 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (var { arrow = () => {} } of asyncIter) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..6c434009b7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (var { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of asyncIter) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..2bdf983c2c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (var { cover = (function () {}), xCover = (0, function() {}) } of asyncIter) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..f91252434f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (var { fn = function () {}, xFn = function x() {} } of asyncIter) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..5d7db6321b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (var { gen = function* () {}, xGen = function* x() {} } of asyncIter) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..1e38fdfe0b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,72 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: null, x: 0, y: false, z: '' }];
+})();
+
+async function *fn() {
+ for await (var { w = counter(), x = counter(), y = counter(), z = counter() } of asyncIter) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..9af1da68ac
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function *fn() {
+ for await (var { x, } of asyncIter) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..746eedea1a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{}];
+})();
+
+async function *fn() {
+ for await (var { w: [x, y, z] = [4, 5, 6] } of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..c4c5d538d0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: [45] }];
+})();
+
+async function *fn() {
+ for await (var { x: [y], } of asyncIter) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..6960af5ea7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-ary.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: [7, undefined, ] }];
+})();
+
+async function *fn() {
+ for await (var { w: [x, y, z] = [4, 5, 6] } of asyncIter) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..c8aa483eaa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,84 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ s: null, u: 0, w: false, y: '' }];
+})();
+
+async function *fn() {
+ for await (var { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of asyncIter) {
+ assert.sameValue(t, null);
+ assert.sameValue(v, 0);
+ assert.sameValue(x, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ assert.throws(ReferenceError, function() {
+ s;
+ });
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..38ed0c9a56
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-init.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ }];
+})();
+
+async function *fn() {
+ for await (var { x: y = 33 } of asyncIter) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..5f07f5d7dd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function *fn() {
+ for await (var { x: y, } of asyncIter) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..c3c7ae74b9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-id.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Binding as specified via property name and identifier (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ x: 23 }];
+})();
+
+async function *fn() {
+ for await (var { x: y } of asyncIter) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..adec783f36
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: undefined }];
+})();
+
+async function *fn() {
+ for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..5af2fbc062
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-prop-obj.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ w: { x: undefined, z: 7 } }];
+})();
+
+async function *fn() {
+ for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of asyncIter) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..0cfd28d583
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-getter.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-getter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var count = 0;
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{ get v() { count++; return 2; } }];
+})();
+
+async function *fn() {
+ for await (var {...x} of asyncIter) {
+ assert.sameValue(x.v, 2);
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..a90614e494
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [o];
+})();
+
+async function *fn() {
+ for await (var {...rest} of asyncIter) {
+ assert.sameValue(rest.a, 3);
+ assert.sameValue(rest.b, 4);
+ assert.sameValue(rest.x, undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..8a5edce9ae
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-async-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,71 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+var asyncIter = (async function*() {
+ yield* [{x: 1, y: 2, a: 5, b: 3}];
+})();
+
+async function *fn() {
+ for await (var {a, b, ...rest} of asyncIter) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-init-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-init-null.js
new file mode 100644
index 0000000000..d0dc989602
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-init-null.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-init-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (null) (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+async function * gen() {
+ for await (var {} of [null]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-init-undefined.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-init-undefined.js
new file mode 100644
index 0000000000..980ca381a2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-init-undefined.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-init-undefined.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Value specifed for object binding pattern must be object coercible (undefined) (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+async function * gen() {
+ for await (var {} of [undefined]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-empty.js
new file mode 100644
index 0000000000..e1fc02a521
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-empty.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-empty.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: No property access occurs for an "empty" object binding pattern (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ Runtime Semantics: BindingInitialization
+
+ ObjectBindingPattern : { }
+
+ 1. Return NormalCompletion(empty).
+---*/
+var accessCount = 0;
+var obj = Object.defineProperty({}, 'attr', {
+ get: function() {
+ accessCount += 1;
+ }
+});
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var {} of [obj]) {
+ assert.sameValue(accessCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-get-value-err.js
new file mode 100644
index 0000000000..a5b650821b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-get-value-err.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-get-value-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 4. Let v be GetV(value, propertyName).
+ 5. ReturnIfAbrupt(v).
+---*/
+var poisonedProperty = Object.defineProperty({}, 'poisoned', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+async function * gen() {
+ for await (var { poisoned } of [poisonedProperty]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-arrow.js
new file mode 100644
index 0000000000..5d9037cc61
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-arrow.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding assigns `name` to arrow functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { arrow = () => {} } of [{}]) {
+ assert.sameValue(arrow.name, 'arrow');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-class.js
new file mode 100644
index 0000000000..8c28f06c3b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-class.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" classes (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } of [{}]) {
+ assert.sameValue(cls.name, 'cls');
+ assert.notSameValue(xCls.name, 'xCls');
+ assert.notSameValue(xCls2.name, 'xCls2');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-cover.js
new file mode 100644
index 0000000000..1a6b75dbcb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-cover.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { cover = (function () {}), xCover = (0, function() {}) } of [{}]) {
+ assert.sameValue(cover.name, 'cover');
+ assert.notSameValue(xCover.name, 'xCover');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-fn.js
new file mode 100644
index 0000000000..49af584517
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-fn.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { fn = function () {}, xFn = function x() {} } of [{}]) {
+ assert.sameValue(fn.name, 'fn');
+ assert.notSameValue(xFn.name, 'xFn');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-gen.js
new file mode 100644
index 0000000000..28a31a695a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-fn-name-gen.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: SingleNameBinding assigns name to "anonymous" generator functions (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [generators, destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ d. If IsAnonymousFunctionDefinition(Initializer) is true, then
+ i. Let hasNameProperty be HasOwnProperty(v, "name").
+ ii. ReturnIfAbrupt(hasNameProperty).
+ iii. If hasNameProperty is false, perform SetFunctionName(v,
+ bindingId).
+
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { gen = function* () {}, xGen = function* x() {} } of [{}]) {
+ assert.sameValue(gen.name, 'gen');
+ assert.notSameValue(xGen.name, 'xGen');
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-skipped.js
new file mode 100644
index 0000000000..ae509d0916
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-skipped.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ [...]
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { w = counter(), x = counter(), y = counter(), z = counter() } of [{ w: null, x: 0, y: false, z: '' }]) {
+ assert.sameValue(w, null);
+ assert.sameValue(x, 0);
+ assert.sameValue(y, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-throws.js
new file mode 100644
index 0000000000..dc6e773486
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-throws.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Error thrown when evaluating the initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 6. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Let v be GetValue(defaultValue).
+ c. ReturnIfAbrupt(v).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function * gen() {
+ for await (var { x = thrower() } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-unresolvable.js
new file mode 100644
index 0000000000..4b0ad5d1d9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-init-unresolvable.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 5. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function * gen() {
+ for await (var { x = unresolvableReference } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-trailing-comma.js
new file mode 100644
index 0000000000..ea8c090508
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-id-trailing-comma.js
@@ -0,0 +1,57 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { x, } of [{ x: 23 }]) {
+ assert.sameValue(x, 23);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-init-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-init-err.js
new file mode 100644
index 0000000000..c319f9d21c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-init-err.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-iteration-statements
+description: >
+ Initializer is not allowed in head's ForBinding position.
+info: |
+ IterationStatement:
+ for await (var ForBinding of AssignmentExpression) Statement
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+async function fn() {
+ for await (var {x} = 1 of []) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-list-err.js
new file mode 100644
index 0000000000..ee67b85fd8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-list-err.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-list-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Binding property list evaluation is interrupted by an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingPropertyList : BindingPropertyList , BindingProperty
+
+ 1. Let status be the result of performing BindingInitialization for
+ BindingPropertyList using value and environment as arguments.
+ 2. ReturnIfAbrupt(status).
+---*/
+var initCount = 0;
+function thrower() {
+ throw new Test262Error();
+}
+
+async function * gen() {
+ for await (var { a, b = thrower(), c = ++initCount } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-init.js
new file mode 100644
index 0000000000..099b2458e5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-init.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Object binding pattern with "nested" array binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { w: [x, y, z] = [4, 5, 6] } of [{}]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-trailing-comma.js
new file mode 100644
index 0000000000..a224492c68
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-trailing-comma.js
@@ -0,0 +1,57 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { x: [y], } of [{ x: [45] }]) {
+ assert.sameValue(y,45);
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-value-null.js
new file mode 100644
index 0000000000..38d07d382b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary-value-null.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary-value-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Object binding pattern with "nested" array binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function * gen() {
+ for await (var { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary.js
new file mode 100644
index 0000000000..ca0fbb0d30
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-ary.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-ary.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Object binding pattern with "nested" array binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { w: [x, y, z] = [4, 5, 6] } of [{ w: [7, undefined, ] }]) {
+ assert.sameValue(x, 7);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, undefined);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-eval-err.js
new file mode 100644
index 0000000000..4cef150936
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-eval-err.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-eval-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Evaluation of property name returns an abrupt completion (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.5 Runtime Semantics: BindingInitialization
+
+ BindingProperty : PropertyName : BindingElement
+
+ 1. Let P be the result of evaluating PropertyName
+ 2. ReturnIfAbrupt(P).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function * gen() {
+ for await (var { [thrower()]: x } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-get-value-err.js
new file mode 100644
index 0000000000..9448e3bbb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-get-value-err.js
@@ -0,0 +1,67 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-get-value-err.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Error thrown when accessing the corresponding property of the value object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ 1. Let v be GetV(value, propertyName).
+ 2. ReturnIfAbrupt(v).
+---*/
+var initEvalCount = 0;
+var poisonedProperty = Object.defineProperty({}, 'poisoned', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+async function * gen() {
+ for await (var { poisoned: x = ++initEvalCount } of [poisonedProperty]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-skipped.js
new file mode 100644
index 0000000000..7e981a066d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-skipped.js
@@ -0,0 +1,79 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Destructuring initializer is not evaluated when value is not `undefined` (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+---*/
+var initCount = 0;
+function counter() {
+ initCount += 1;
+}
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of [{ s: null, u: 0, w: false, y: '' }]) {
+ assert.sameValue(t, null);
+ assert.sameValue(v, 0);
+ assert.sameValue(x, false);
+ assert.sameValue(z, '');
+ assert.sameValue(initCount, 0);
+
+ assert.throws(ReferenceError, function() {
+ s;
+ });
+ assert.throws(ReferenceError, function() {
+ u;
+ });
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+ assert.throws(ReferenceError, function() {
+ y;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js
new file mode 100644
index 0000000000..9e01a110bc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-throws.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-throws.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Error thrown when evaluating the initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+---*/
+function thrower() {
+ throw new Test262Error();
+}
+
+async function * gen() {
+ for await (var { x: y = thrower() } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, Test262Error);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js
new file mode 100644
index 0000000000..d1ab3fb0bb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init-unresolvable.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init-unresolvable.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Destructuring initializer is an unresolvable reference (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ BindingElement : BindingPattern Initializer_opt
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+
+ 6.2.4.1 GetValue ( V )
+
+ 1. ReturnIfAbrupt(V).
+ 2. If Type(V) is not Reference, return V.
+ 3. Let base be GetBase(V).
+ 4. If IsUnresolvableReference(V), throw a ReferenceError exception.
+---*/
+
+async function * gen() {
+ for await (var { x: y = unresolvableReference } of [{}]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, ReferenceError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init.js
new file mode 100644
index 0000000000..8edf8158f4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-init.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Binding as specified via property name, identifier, and initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { x: y = 33 } of [{ }]) {
+ assert.sameValue(y, 33);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-trailing-comma.js
new file mode 100644
index 0000000000..50b4b7258b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id-trailing-comma.js
@@ -0,0 +1,61 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Trailing comma is allowed following BindingPropertyList (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ ObjectBindingPattern[Yield] :
+ { }
+ { BindingPropertyList[?Yield] }
+ { BindingPropertyList[?Yield] , }
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { x: y, } of [{ x: 23 }]) {
+ assert.sameValue(y, 23);
+
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id.js
new file mode 100644
index 0000000000..c49254fef7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-id.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-id.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Binding as specified via property name and identifier (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ SingleNameBinding : BindingIdentifier Initializer_opt
+
+ [...]
+ 7. Return InitializeReferencedBinding(lhs, v).
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { x: y } of [{ x: 23 }]) {
+ assert.sameValue(y, 23);
+ assert.throws(ReferenceError, function() {
+ x;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-init.js
new file mode 100644
index 0000000000..ef52c2b307
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-init.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Object binding pattern with "nested" object binding pattern using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 4. If Initializer is present and v is undefined, then
+ a. Let defaultValue be the result of evaluating Initializer.
+ b. Set v to ? GetValue(defaultValue).
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: undefined }]) {
+ assert.sameValue(x, 4);
+ assert.sameValue(y, 5);
+ assert.sameValue(z, 6);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-null.js
new file mode 100644
index 0000000000..c76d8fc7e8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-null.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-value-null.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function * gen() {
+ for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-undef.js
new file mode 100644
index 0000000000..143d3d0df2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj-value-undef.js
@@ -0,0 +1,62 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj-value-undef.case
+// - src/dstr-binding-for-await/error/for-await-of-async-gen-var.template
+/*---
+description: Object binding pattern with "nested" object binding pattern taking the `null` value (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( ForDeclaration of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
+ lexicalBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ [...]
+ iii. Else,
+ 1. Assert: lhsKind is lexicalBinding.
+ 2. Assert: lhs is a ForDeclaration.
+ 3. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and iterationEnv as arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+async function * gen() {
+ for await (var { w: { x, y, z } = undefined } of [{ }]) {
+ return;
+ }
+}
+
+gen().next()
+ .then(_ => {
+ throw new Test262Error("Expected async function to reject, but resolved.");
+ }, ({ constructor }) => {
+ assert.sameValue(constructor, TypeError);
+
+ })
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj.js
new file mode 100644
index 0000000000..2c2e25a71d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-prop-obj.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-prop-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Object binding pattern with "nested" object binding pattern not using initializer (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [destructuring-binding, async-iteration]
+flags: [generated, async]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+
+ 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
+
+ [...]
+ 3. If Initializer is present and v is undefined, then
+ [...]
+ 4. Return the result of performing BindingInitialization for BindingPattern
+ passing v and environment as arguments.
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: { x: undefined, z: 7 } }]) {
+ assert.sameValue(x, undefined);
+ assert.sameValue(y, undefined);
+ assert.sameValue(z, 7);
+
+ assert.throws(ReferenceError, function() {
+ w;
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-getter.js
new file mode 100644
index 0000000000..b92cba280e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-getter.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-getter.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Getter is called when obj is being deconstructed to a rest Object (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+---*/
+var count = 0;
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var {...x} of [{ get v() { count++; return 2; } }]) {
+ assert.sameValue(x.v, 2);
+ assert.sameValue(count, 1);
+
+ verifyProperty(x, "v", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-skip-non-enumerable.js
new file mode 100644
index 0000000000..77e9242263
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-skip-non-enumerable.js
@@ -0,0 +1,69 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+---*/
+var o = {a: 3, b: 4};
+Object.defineProperty(o, "x", { value: 4, enumerable: false });
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var {...rest} of [o]) {
+ assert.sameValue(rest.a, 3);
+ assert.sameValue(rest.b, 4);
+ assert.sameValue(rest.x, undefined);
+
+ verifyProperty(rest, "a", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 3
+ });
+
+ verifyProperty(rest, "b", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 4
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-val-obj.js
new file mode 100644
index 0000000000..cc29ee053e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/async-gen-dstr-var-obj-ptrn-rest-val-obj.js
@@ -0,0 +1,66 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case
+// - src/dstr-binding-for-await/default/for-await-of-async-gen-var.template
+/*---
+description: Rest object contains just unextracted data (for-await-of statement)
+esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
+features: [object-rest, destructuring-binding, async-iteration]
+flags: [generated, async]
+includes: [propertyHelper.js]
+info: |
+ IterationStatement :
+ for await ( var ForBinding of AssignmentExpression ) Statement
+
+ [...]
+ 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
+ varBinding, labelSet, async).
+
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
+
+ [...]
+ 4. Let destructuring be IsDestructuring of lhs.
+ [...]
+ 6. Repeat
+ [...]
+ j. If destructuring is false, then
+ [...]
+ k. Else
+ i. If lhsKind is assignment, then
+ [...]
+ ii. Else if lhsKind is varBinding, then
+ 1. Assert: lhs is a ForBinding.
+ 2. Let status be the result of performing BindingInitialization
+ for lhs passing nextValue and undefined as the arguments.
+ [...]
+---*/
+
+var iterCount = 0;
+
+async function *fn() {
+ for await (var {a, b, ...rest} of [{x: 1, y: 2, a: 5, b: 3}]) {
+ assert.sameValue(rest.a, undefined);
+ assert.sameValue(rest.b, undefined);
+
+ verifyProperty(rest, "x", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 1
+ });
+
+ verifyProperty(rest, "y", {
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ value: 2
+ });
+
+ iterCount += 1;
+ }
+}
+
+fn().next()
+ .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
+ .then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/for-await-of/browser.js b/js/src/tests/test262/language/statements/for-await-of/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/browser.js
diff --git a/js/src/tests/test262/language/statements/for-await-of/escaped-of.js b/js/src/tests/test262/language/statements/for-await-of/escaped-of.js
new file mode 100644
index 0000000000..1903527feb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/escaped-of.js
@@ -0,0 +1,27 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-grammar-notation
+description: >
+ The `of` contextual keyword must not contain Unicode escape sequences.
+info: |
+ Terminal symbols are shown
+ in fixed width font, both in the productions of the grammars and throughout this
+ specification whenever the text directly refers to such a terminal symbol. These
+ are to appear in a script exactly as written. All terminal symbol code points
+ specified in this way are to be understood as the appropriate Unicode code points
+ from the Basic Latin range, as opposed to any similar-looking code points from
+ other Unicode ranges.
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+async function* f() {
+ for await (var x o\u0066 []) ;
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/head-const-init.js b/js/src/tests/test262/language/statements/for-await-of/head-const-init.js
new file mode 100644
index 0000000000..f83c77f54e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/head-const-init.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-iteration-statements
+description: >
+ Initializer is not allowed in head's ForDeclaration position.
+info: |
+ IterationStatement:
+ for await (ForDeclaration of AssignmentExpression) Statement
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+async function fn() {
+ for await (const x = 1 of []) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/head-let-init.js b/js/src/tests/test262/language/statements/for-await-of/head-let-init.js
new file mode 100644
index 0000000000..2112195d7f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/head-let-init.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-iteration-statements
+description: >
+ Initializer is not allowed in head's ForDeclaration position.
+info: |
+ IterationStatement:
+ for await (ForDeclaration of AssignmentExpression) Statement
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+async function fn() {
+ for await (let x = 1 of []) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/head-lhs-async.js b/js/src/tests/test262/language/statements/for-await-of/head-lhs-async.js
new file mode 100644
index 0000000000..141d07de0e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/head-lhs-async.js
@@ -0,0 +1,24 @@
+// |reftest| async
+// Copyright (C) 2021 Stuart Cook. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-for-in-and-for-of-statements
+description: >
+ The left-hand-side of a for-await-of loop may be the identifier `async`.
+info: |
+ ForInOfStatement[Yield, Await, Return]:
+ [+Await] for await ( [lookahead ≠ let] LeftHandSideExpression[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
+features: [async-iteration]
+flags: [async]
+---*/
+
+let async;
+
+async function fn() {
+ for await (async of [7]);
+}
+
+fn()
+ .then(() => assert.sameValue(async, 7), $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/head-var-init.js b/js/src/tests/test262/language/statements/for-await-of/head-var-init.js
new file mode 100644
index 0000000000..bad95b1dc5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/head-var-init.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-iteration-statements
+description: >
+ Initializer is not allowed in head's ForBinding position.
+info: |
+ IterationStatement:
+ for await (var ForBinding of AssignmentExpression) Statement
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+async function fn() {
+ for await (var x = 1 of []) {}
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/iterator-close-non-throw-get-method-abrupt.js b/js/src/tests/test262/language/statements/for-await-of/iterator-close-non-throw-get-method-abrupt.js
new file mode 100644
index 0000000000..781dc58b86
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/iterator-close-non-throw-get-method-abrupt.js
@@ -0,0 +1,54 @@
+// |reftest| async
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-asynciteratorclose
+description: >
+ If retrieving an iterator's `return` method generates an error while
+ closing the iterator with non-throw completion, the error should be
+ forwarded to the runtime.
+info: |
+ AsyncIteratorClose ( iteratorRecord, completion )
+
+ [...]
+ 4. Let innerResult be GetMethod(iterator, "return").
+ 5. If innerResult.[[Type]] is normal,
+ [...]
+ 6. If completion.[[Type]] is throw, return Completion(completion).
+ 7. If innerResult.[[Type]] is throw, return Completion(innerResult).
+
+ GetMethod ( V, P )
+
+ [...]
+ 2. Let func be ? GetV(V, P).
+features: [async-iteration]
+flags: [async]
+---*/
+
+const innerError = { name: "inner error" };
+const asyncIterable = {};
+asyncIterable[Symbol.asyncIterator] = function() {
+ return {
+ next: function() {
+ return { done: false, value: null };
+ },
+ get return() {
+ throw innerError;
+ },
+ };
+};
+
+let iterationCount = 0;
+const promise = (async function() {
+ for await (const x of asyncIterable) {
+ iterationCount += 1;
+ break;
+ }
+})();
+
+promise.then(function(value) {
+ throw new Test262Error("Promise should be rejected, got: " + value);
+}, function(error) {
+ assert.sameValue(error, innerError);
+ assert.sameValue(iterationCount, 1, "The loop body is evaluated");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/iterator-close-non-throw-get-method-is-null.js b/js/src/tests/test262/language/statements/for-await-of/iterator-close-non-throw-get-method-is-null.js
new file mode 100644
index 0000000000..61a35bacfc
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/iterator-close-non-throw-get-method-is-null.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-asynciteratorclose
+description: >
+ If iterator's "return" method is `null`,
+ received non-throw completion is forwarded to the runtime.
+info: |
+ AsyncIteratorClose ( iteratorRecord, completion )
+
+ [...]
+ 4. Let innerResult be GetMethod(iterator, "return").
+ 5. If innerResult.[[Type]] is normal,
+ a. Let return be innerResult.[[Value]].
+ b. If return is undefined, return Completion(completion).
+
+ GetMethod ( V, P )
+
+ [...]
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+features: [Symbol.asyncIterator, async-iteration]
+flags: [async]
+includes: [asyncHelpers.js]
+---*/
+
+var iterationCount = 0;
+var returnGets = 0;
+
+var iterable = {};
+iterable[Symbol.asyncIterator] = function() {
+ return {
+ next: function() {
+ return {value: 1, done: false};
+ },
+ get return() {
+ returnGets += 1;
+ return null;
+ },
+ };
+};
+
+asyncTest(async function() {
+ for await (var _ of iterable) {
+ iterationCount += 1;
+ break;
+ }
+
+ assert.sameValue(iterationCount, 1);
+ assert.sameValue(returnGets, 1);
+});
diff --git a/js/src/tests/test262/language/statements/for-await-of/iterator-close-non-throw-get-method-non-callable.js b/js/src/tests/test262/language/statements/for-await-of/iterator-close-non-throw-get-method-non-callable.js
new file mode 100644
index 0000000000..e06341f845
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/iterator-close-non-throw-get-method-non-callable.js
@@ -0,0 +1,53 @@
+// |reftest| async
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-asynciteratorclose
+description: >
+ If retrieving an iterator's `return` method generates an error while
+ closing the iterator with non-throw completion, the error should be
+ forwarded to the runtime.
+info: |
+ AsyncIteratorClose ( iteratorRecord, completion )
+
+ [...]
+ 4. Let innerResult be GetMethod(iterator, "return").
+ 5. If innerResult.[[Type]] is normal,
+ [...]
+ 6. If completion.[[Type]] is throw, return Completion(completion).
+ 7. If innerResult.[[Type]] is throw, return Completion(innerResult).
+
+ GetMethod ( V, P )
+
+ [...]
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+features: [async-iteration]
+flags: [async]
+---*/
+
+const asyncIterable = {};
+asyncIterable[Symbol.asyncIterator] = function() {
+ return {
+ next: function() {
+ return { done: false, value: null };
+ },
+ return: Symbol(),
+ };
+};
+
+let iterationCount = 0;
+const promise = (async function() {
+ for await (const x of asyncIterable) {
+ iterationCount += 1;
+ break;
+ }
+})();
+
+promise.then(function(value) {
+ throw new Test262Error("Promise should be rejected, got: " + value);
+}, function(error) {
+ assert.sameValue(error.constructor, TypeError);
+ assert.sameValue(iterationCount, 1, "The loop body is evaluated");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/iterator-close-throw-get-method-abrupt.js b/js/src/tests/test262/language/statements/for-await-of/iterator-close-throw-get-method-abrupt.js
new file mode 100644
index 0000000000..0f72094cc5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/iterator-close-throw-get-method-abrupt.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-asynciteratorclose
+description: >
+ If retrieving an iterator's `return` method generates an error while
+ closing the iterator with throw completion, this error should be suppressed.
+info: |
+ AsyncIteratorClose ( iteratorRecord, completion )
+
+ [...]
+ 4. Let innerResult be GetMethod(iterator, "return").
+ 5. If innerResult.[[Type]] is normal,
+ [...]
+ 6. If completion.[[Type]] is throw, return Completion(completion).
+ 7. If innerResult.[[Type]] is throw, return Completion(innerResult).
+
+ GetMethod ( V, P )
+
+ [...]
+ 2. Let func be ? GetV(V, P).
+features: [async-iteration]
+flags: [async]
+---*/
+
+const asyncIterable = {};
+asyncIterable[Symbol.asyncIterator] = function() {
+ return {
+ next: function() {
+ return { done: false, value: null };
+ },
+ get return() {
+ throw { name: "inner error" };
+ },
+ };
+};
+
+let iterationCount = 0;
+const promise = (async function() {
+ for await (const x of asyncIterable) {
+ iterationCount += 1;
+ throw new Test262Error("should not be overriden");
+ }
+})();
+
+promise.then(function(value) {
+ throw new Test262Error("Promise should be rejected, got: " + value);
+}, function(error) {
+ assert.sameValue(error.constructor, Test262Error);
+ assert.sameValue(iterationCount, 1, "The loop body is evaluated");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/iterator-close-throw-get-method-non-callable.js b/js/src/tests/test262/language/statements/for-await-of/iterator-close-throw-get-method-non-callable.js
new file mode 100644
index 0000000000..17cef4c6a7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/iterator-close-throw-get-method-non-callable.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-asynciteratorclose
+description: >
+ If retrieving an iterator's `return` method generates an error while
+ closing the iterator with throw completion, this error should be suppressed.
+info: |
+ AsyncIteratorClose ( iteratorRecord, completion )
+
+ [...]
+ 4. Let innerResult be GetMethod(iterator, "return").
+ 5. If innerResult.[[Type]] is normal,
+ [...]
+ 6. If completion.[[Type]] is throw, return Completion(completion).
+ 7. If innerResult.[[Type]] is throw, return Completion(innerResult).
+
+ GetMethod ( V, P )
+
+ [...]
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+features: [async-iteration]
+flags: [async]
+---*/
+
+const asyncIterable = {};
+asyncIterable[Symbol.asyncIterator] = function() {
+ return {
+ next: function() {
+ return { done: false, value: null };
+ },
+ return: true,
+ };
+};
+
+let iterationCount = 0;
+const promise = (async function() {
+ for await (const x of asyncIterable) {
+ iterationCount += 1;
+ throw new Test262Error("should not be overriden");
+ }
+})();
+
+promise.then(function(value) {
+ throw new Test262Error("Promise should be rejected, got: " + value);
+}, function(error) {
+ assert.sameValue(error.constructor, Test262Error);
+ assert.sameValue(iterationCount, 1, "The loop body is evaluated");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/for-await-of/let-array-with-newline.js b/js/src/tests/test262/language/statements/for-await-of/let-array-with-newline.js
new file mode 100644
index 0000000000..c020f663bd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/let-array-with-newline.js
@@ -0,0 +1,25 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-for-in-and-for-of-statements
+description: >
+ ExpressionStatement has a lookahead restriction for `let [`.
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+negative:
+ phase: parse
+ type: SyntaxError
+flags: [noStrict]
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+async function* f() {
+ for await (var x of []) let
+ [a] = 0;
+}
diff --git a/js/src/tests/test262/language/statements/for-await-of/let-block-with-newline.js b/js/src/tests/test262/language/statements/for-await-of/let-block-with-newline.js
new file mode 100644
index 0000000000..0fb7820ac7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/let-block-with-newline.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-for-in-and-for-of-statements
+description: >
+ ExpressionStatement doesn't have a lookahead restriction for `let {`.
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+flags: [noStrict]
+features: [async-iteration]
+---*/
+
+async function* f() {
+ for await (var x of []) let // ASI
+ {}
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for-await-of/let-identifier-with-newline.js b/js/src/tests/test262/language/statements/for-await-of/let-identifier-with-newline.js
new file mode 100644
index 0000000000..ab6887a8be
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/let-identifier-with-newline.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-for-in-and-for-of-statements
+description: >
+ ExpressionStatement doesn't have a lookahead restriction for `let <binding-identifier>`.
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+flags: [noStrict]
+features: [async-iteration]
+---*/
+
+async function* f() {
+ for await (var x of []) let // ASI
+ x = 1;
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/for-await-of/shell.js b/js/src/tests/test262/language/statements/for-await-of/shell.js
new file mode 100644
index 0000000000..ae18ad584d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/shell.js
@@ -0,0 +1,113 @@
+// GENERATED, DO NOT EDIT
+// file: asyncHelpers.js
+// Copyright (C) 2022 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ A collection of assertion and wrapper functions for testing asynchronous built-ins.
+defines: [asyncTest]
+---*/
+
+function asyncTest(testFunc) {
+ if (!Object.hasOwn(globalThis, "$DONE")) {
+ throw new Test262Error("asyncTest called without async flag");
+ }
+ if (typeof testFunc !== "function") {
+ $DONE(new Test262Error("asyncTest called with non-function argument"));
+ return;
+ }
+ try {
+ testFunc().then(
+ function () {
+ $DONE();
+ },
+ function (error) {
+ $DONE(error);
+ }
+ );
+ } catch (syncError) {
+ $DONE(syncError);
+ }
+}
+
+assert.throwsAsync = async function (expectedErrorConstructor, func, message) {
+ var innerThenable;
+ if (message === undefined) {
+ message = "";
+ } else {
+ message += " ";
+ }
+ if (typeof func === "function") {
+ try {
+ innerThenable = func();
+ if (
+ innerThenable === null ||
+ typeof innerThenable !== "object" ||
+ typeof innerThenable.then !== "function"
+ ) {
+ message +=
+ "Expected to obtain an inner promise that would reject with a" +
+ expectedErrorConstructor.name +
+ " but result was not a thenable";
+ throw new Test262Error(message);
+ }
+ } catch (thrown) {
+ message +=
+ "Expected a " +
+ expectedErrorConstructor.name +
+ " to be thrown asynchronously but an exception was thrown synchronously while obtaining the inner promise";
+ throw new Test262Error(message);
+ }
+ } else {
+ message +=
+ "assert.throwsAsync called with an argument that is not a function";
+ throw new Test262Error(message);
+ }
+
+ try {
+ return innerThenable.then(
+ function () {
+ message +=
+ "Expected a " +
+ expectedErrorConstructor.name +
+ " to be thrown asynchronously but no exception was thrown at all";
+ throw new Test262Error(message);
+ },
+ function (thrown) {
+ var expectedName, actualName;
+ if (typeof thrown !== "object" || thrown === null) {
+ message += "Thrown value was not an object!";
+ throw new Test262Error(message);
+ } else if (thrown.constructor !== expectedErrorConstructor) {
+ expectedName = expectedErrorConstructor.name;
+ actualName = thrown.constructor.name;
+ if (expectedName === actualName) {
+ message +=
+ "Expected a " +
+ expectedName +
+ " but got a different error constructor with the same name";
+ } else {
+ message +=
+ "Expected a " + expectedName + " but got a " + actualName;
+ }
+ throw new Test262Error(message);
+ }
+ }
+ );
+ } catch (thrown) {
+ if (typeof thrown !== "object" || thrown === null) {
+ message +=
+ "Expected a " +
+ expectedErrorConstructor.name +
+ " to be thrown asynchronously but innerThenable synchronously threw a value that was not an object ";
+ } else {
+ message +=
+ "Expected a " +
+ expectedErrorConstructor.name +
+ " to be thrown asynchronously but a " +
+ thrown.constructor.name +
+ " was thrown synchronously";
+ }
+ throw new Test262Error(message);
+ }
+};
diff --git a/js/src/tests/test262/language/statements/for-await-of/ticks-with-async-iter-resolved-promise-and-constructor-lookup-two.js b/js/src/tests/test262/language/statements/for-await-of/ticks-with-async-iter-resolved-promise-and-constructor-lookup-two.js
new file mode 100644
index 0000000000..d584a0b824
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/ticks-with-async-iter-resolved-promise-and-constructor-lookup-two.js
@@ -0,0 +1,92 @@
+// |reftest| async
+// Copyright (C) 2019 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset
+description: >
+ Ensure the number of ticks and Promise constructor lookups is correct with custom async iterator.
+info: |
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation ( lhs, stmt, iteratorRecord, iterationKind,
+ lhsKind, labelSet [ , iteratorKind ] )
+ 25.6.4.5.1 PromiseResolve
+ 6.2.3.1 Await
+
+includes: [compareArray.js]
+flags: [async]
+features: [async-iteration]
+---*/
+
+// The expected event log.
+var expected = [
+ // Before entering loop.
+ "pre",
+
+ // Await
+ // -> PromiseResolve
+ "constructor",
+
+ // Await promise resolved.
+ "tick 1",
+
+ // In loop body.
+ "loop",
+
+ // Await
+ // -> PromiseResolve
+ "constructor",
+
+ // Await promise resolved
+ "tick 2",
+
+ // After exiting loop.
+ "post",
+];
+
+// The actual event log.
+var actual = [];
+
+// Custom async iterator returning the result of the synchronous iterator wrapped in a Promise.
+function toAsyncIterator(iterable) {
+ return {
+ [Symbol.asyncIterator]() {
+ var iter = iterable[Symbol.iterator]();
+ return {
+ next() {
+ return Promise.resolve(iter.next());
+ }
+ };
+ }
+ };
+}
+
+// Test function using for-await with a single, already resolved Promise.
+async function f() {
+ var p = Promise.resolve(0);
+ actual.push("pre");
+ for await (var x of toAsyncIterator([p])) {
+ actual.push("loop");
+ }
+ actual.push("post");
+}
+
+// Count the number of ticks needed to complete the loop and compare the actual log.
+Promise.resolve(0)
+ .then(() => actual.push("tick 1"))
+ .then(() => actual.push("tick 2"))
+ .then(() => {
+ assert.compareArray(actual, expected, "Ticks and constructor lookups");
+}).then($DONE, $DONE);
+
+// Redefine `Promise.constructor` in order to intercept "constructor" lookups from PromiseResolve.
+// (Perform last so that the lookups from SpeciesConstructor in `then` aren't logged.)
+Object.defineProperty(Promise.prototype, "constructor", {
+ get() {
+ actual.push("constructor");
+ return Promise;
+ },
+ configurable: true,
+});
+
+// Start the asynchronous function.
+f();
diff --git a/js/src/tests/test262/language/statements/for-await-of/ticks-with-async-iter-resolved-promise-and-constructor-lookup.js b/js/src/tests/test262/language/statements/for-await-of/ticks-with-async-iter-resolved-promise-and-constructor-lookup.js
new file mode 100644
index 0000000000..3253713c99
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/ticks-with-async-iter-resolved-promise-and-constructor-lookup.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// Copyright (C) 2019 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset
+description: >
+ Ensure the number of ticks and Promise constructor lookups is correct with custom async iterator.
+info: |
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation ( lhs, stmt, iteratorRecord, iterationKind,
+ lhsKind, labelSet [ , iteratorKind ] )
+ 6.2.3.1 Await
+
+includes: [compareArray.js]
+flags: [async]
+features: [async-iteration]
+---*/
+
+// The expected event log.
+var expected = [
+ // Before entering loop.
+ "pre",
+
+ // Await promise resolved.
+ "tick 1",
+
+ // In loop body.
+ "loop",
+
+ // Await promise resolved
+ "tick 2",
+
+ // After exiting loop.
+ "post",
+];
+
+// The actual event log.
+var actual = [];
+
+// Custom async iterator directly using a synchronous iterator.
+function toAsyncIterator(iterable) {
+ return {
+ [Symbol.asyncIterator]() {
+ return iterable[Symbol.iterator]();
+ }
+ };
+}
+
+// Test function using for-await with a single, already resolved Promise.
+async function f() {
+ var p = Promise.resolve(0);
+ actual.push("pre");
+ for await (var x of toAsyncIterator([p])) {
+ actual.push("loop");
+ }
+ actual.push("post");
+}
+
+// Count the number of ticks needed to complete the loop and compare the actual log.
+Promise.resolve(0)
+ .then(() => actual.push("tick 1"))
+ .then(() => actual.push("tick 2"))
+ .then(() => {
+ assert.compareArray(actual, expected, "Ticks and constructor lookups");
+}).then($DONE, $DONE);
+
+// Redefine `Promise.constructor` in order to intercept "constructor" lookups from PromiseResolve.
+// (Perform last so that the lookups from SpeciesConstructor in `then` aren't logged.)
+Object.defineProperty(Promise.prototype, "constructor", {
+ get() {
+ actual.push("constructor");
+ return Promise;
+ },
+ configurable: true,
+});
+
+// Start the asynchronous function.
+f();
diff --git a/js/src/tests/test262/language/statements/for-await-of/ticks-with-sync-iter-resolved-promise-and-constructor-lookup.js b/js/src/tests/test262/language/statements/for-await-of/ticks-with-sync-iter-resolved-promise-and-constructor-lookup.js
new file mode 100644
index 0000000000..6ca844b232
--- /dev/null
+++ b/js/src/tests/test262/language/statements/for-await-of/ticks-with-sync-iter-resolved-promise-and-constructor-lookup.js
@@ -0,0 +1,93 @@
+// |reftest| async
+// Copyright (C) 2019 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset
+description: >
+ Ensure the number of ticks and Promise constructor lookups is correct with a Async-from-Sync iterator.
+info: |
+ 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation ( lhs, stmt, iteratorRecord, iterationKind,
+ lhsKind, labelSet [ , iteratorKind ] )
+ 25.1.4.2.1 %AsyncFromSyncIteratorPrototype%.next
+ 25.1.4.4 AsyncFromSyncIteratorContinuation
+ 25.6.4.5.1 PromiseResolve
+ 6.2.3.1 Await
+
+includes: [compareArray.js]
+flags: [async]
+features: [async-iteration]
+---*/
+
+// The expected event log.
+var expected = [
+ // Before entering loop.
+ "pre",
+
+ // %AsyncFromSyncIteratorPrototype%.next
+ // -> AsyncFromSyncIteratorContinuation
+ // -> PromiseResolve
+ "constructor",
+
+ // Await
+ // -> PromiseResolve
+ "constructor",
+
+ // Async-from-Sync Iterator promise resolved.
+ "tick 1",
+
+ // Await promise resolved.
+ "tick 2",
+
+ // In loop body.
+ "loop",
+
+ // Await
+ // -> PromiseResolve
+ "constructor",
+
+ // Async-from-Sync Iterator promise resolved.
+ "tick 3",
+
+ // Await promise resolved
+ "tick 4",
+
+ // After exiting loop.
+ "post",
+];
+
+// The actual event log.
+var actual = [];
+
+// Test function using for-await with a single, already resolved Promise.
+async function f() {
+ var p = Promise.resolve(0);
+ actual.push("pre");
+ for await (var x of [p]) {
+ actual.push("loop");
+ }
+ actual.push("post");
+}
+
+// Count the number of ticks needed to complete the loop and compare the actual log.
+Promise.resolve(0)
+ .then(() => actual.push("tick 1"))
+ .then(() => actual.push("tick 2"))
+ .then(() => actual.push("tick 3"))
+ .then(() => actual.push("tick 4"))
+ .then(() => {
+ assert.compareArray(actual, expected, "Ticks and constructor lookups");
+}).then($DONE, $DONE);
+
+// Redefine `Promise.constructor` in order to intercept "constructor" lookups from PromiseResolve.
+// (Perform last so that the lookups from SpeciesConstructor in `then` aren't logged.)
+Object.defineProperty(Promise.prototype, "constructor", {
+ get() {
+ actual.push("constructor");
+ return Promise;
+ },
+ configurable: true,
+});
+
+// Start the asynchronous function.
+f();