├── .npmignore ├── .eslintignore ├── .gitignore ├── test └── fixtures │ └── fake-test262 │ ├── test │ └── language │ │ ├── module-code │ │ ├── import-assertion-3_FIXTURE.js │ │ ├── import-assertion-4_FIXTURE.js │ │ ├── import-assertion-1_FIXTURE.js │ │ ├── import-assertion-2_FIXTURE.js │ │ ├── json-module_FIXTURE.json │ │ ├── module_FIXTURE.mjs │ │ ├── realm-importvalue_FIXTURE.js │ │ ├── instn-iee-err-not-found-empty_FIXTURE.js │ │ ├── instn-named-err-not-found-empty_FIXTURE.js │ │ ├── instn-resolve-empty-export_FIXTURE.js │ │ ├── instn-resolve-empty-import_FIXTURE.js │ │ ├── instn-resolve-err-reference_FIXTURE.js │ │ ├── instn-resolve-err-syntax_FIXTURE.js │ │ ├── instn-resolve-order-src-valid_FIXTURE.js │ │ ├── instn-star-err-not-found-empty_FIXTURE.js │ │ ├── instn-iee-err-ambiguous-1_FIXTURE.js │ │ ├── instn-iee-err-ambiguous-2_FIXTURE.js │ │ ├── instn-resolve-order-depth-syntax_FIXTURE.js │ │ ├── instn-resolve-order-src-reference_FIXTURE.js │ │ ├── instn-resolve-order-src-syntax_FIXTURE.js │ │ ├── eval-rqstd-abrupt-err-uri_FIXTURE.js │ │ ├── instn-iee-trlng-comma_FIXTURE.js │ │ ├── instn-named-err-ambiguous-1_FIXTURE.js │ │ ├── instn-named-err-ambiguous-2_FIXTURE.js │ │ ├── instn-resolve-order-depth-reference_FIXTURE.js │ │ ├── dynamic-import-returns-promise_FIXTURE.js │ │ ├── eval-rqstd-abrupt-err-type_FIXTURE.js │ │ ├── eval-gtbndng-indirect-trlng-comma_FIXTURE.js │ │ ├── instn-star-props-dflt-keep-local-prod_FIXTURE.js │ │ ├── eval-rqstd-order-1_FIXTURE.js │ │ ├── eval-rqstd-order-2_FIXTURE.js │ │ ├── eval-rqstd-order-3_FIXTURE.js │ │ ├── eval-rqstd-order-5_FIXTURE.js │ │ ├── eval-rqstd-order-7_FIXTURE.js │ │ ├── instn-star-props-dflt-keep-indirect-def_FIXTURE.js │ │ ├── instn-iee-err-dflt-thru-star-dflt_FIXTURE.js │ │ ├── instn-same-global-set_FIXTURE.js │ │ ├── instn-named-err-dflt-thru-star-dflt_FIXTURE.js │ │ ├── instn-star-ambiguous-1_FIXTURE.js │ │ ├── instn-star-ambiguous-2_FIXTURE.js │ │ ├── instn-iee-star-cycle-2_FIXTURE.js │ │ ├── instn-star-props-dflt-keep-local-named_FIXTURE.js │ │ ├── instn-named-star-cycle-2_FIXTURE.js │ │ ├── instn-star-star-cycle-2_FIXTURE.js │ │ ├── eval-rqstd-order-4_FIXTURE.js │ │ ├── eval-rqstd-order-6_FIXTURE.js │ │ ├── eval-rqstd-order-8_FIXTURE.js │ │ ├── instn-resolve-order-depth-child_FIXTURE.js │ │ ├── instn-star-props-dflt-skip-prod_FIXTURE.js │ │ ├── instn-star-props-nrml-indirect_FIXTURE.js │ │ ├── instn-iee-err-dflt-thru-star-int_FIXTURE.js │ │ ├── instn-star-err-not-found-faulty_FIXTURE.js │ │ ├── instn-star-props-dflt-skip-star-prod_FIXTURE.js │ │ ├── eval-gtbndng-indirect-update-dflt_FIXTURE.js │ │ ├── instn-named-err-dflt-thru-star-int_FIXTURE.js │ │ ├── instn-star-equality-other_FIXTURE.js │ │ ├── instn-star-props-dflt-skip-named_FIXTURE.js │ │ ├── instn-star-props-dflt-skip-star-named_FIXTURE.js │ │ ├── instn-star-props-circular-a_FIXTURE.js │ │ ├── instn-star-props-circular-b_FIXTURE.js │ │ ├── instn-star-props-dflt-keep-indirect-reexport_FIXTURE.js │ │ ├── instn-star-ambiguous_FIXTURE.js │ │ ├── instn-iee-err-ambiguous_FIXTURE.js │ │ ├── instn-named-err-ambiguous_FIXTURE.js │ │ ├── dynamic-import-attempts-non-existant.js │ │ ├── eval-gtbndng-indirect-update_FIXTURE.js │ │ ├── eval-gtbndng-indirect-update-as_FIXTURE.js │ │ ├── module.mjs │ │ ├── instn-iee-star-cycle-indirect-x_FIXTURE.js │ │ ├── instn-named-star-cycle-indirect-x_FIXTURE.js │ │ ├── instn-star-star-cycle-indirect-x_FIXTURE.js │ │ ├── instn-uniq-env-rec-other_FIXTURE.js │ │ ├── eval-rqstd-once_FIXTURE.js │ │ ├── instn-resolve-order-depth.js │ │ ├── instn-resolve-order-src.js │ │ ├── instn-same-global.js │ │ ├── import-assertion-dynamic.js │ │ ├── instn-iee-bndng-cls_FIXTURE.js │ │ ├── instn-iee-bndng-fun_FIXTURE.js │ │ ├── instn-iee-bndng-gen_FIXTURE.js │ │ ├── instn-iee-bndng-let_FIXTURE.js │ │ ├── instn-iee-bndng-var_FIXTURE.js │ │ ├── instn-iee-bndng-const_FIXTURE.js │ │ ├── import-assertion-static.js │ │ ├── instn-resolve-err-syntax.js │ │ ├── instn-resolve-err-reference.js │ │ ├── json-module.js │ │ ├── eval-export-dflt-expr-in.js │ │ ├── eval-rqstd-abrupt.js │ │ ├── instn-named-bndng-dflt-named.js │ │ ├── instn-named-bndng-dflt-star.js │ │ ├── instn-iee-trlng-comma.js │ │ ├── instn-star-props-nrml-star_FIXTURE.js │ │ ├── instn-iee-iee-cycle-2_FIXTURE.js │ │ ├── instn-star-iee-cycle-2_FIXTURE.js │ │ ├── instn-local-bndng-var-dup.js │ │ ├── instn-named-iee-cycle-2_FIXTURE.js │ │ ├── eval-gtbndng-indirect-trlng-comma.js │ │ ├── instn-star-props-nrml-1_FIXTURE.js │ │ ├── instn-local-bndng-for-dup.js │ │ ├── eval-gtbndng-indirect-update-dflt.js │ │ ├── instn-iee-err-not-found.js │ │ ├── parse-export-empty.js │ │ ├── instn-iee-err-not-found-as.js │ │ ├── instn-local-bndng-export-let.js │ │ ├── instn-local-bndng-export-const.js │ │ ├── instn-local-bndng-export-cls.js │ │ ├── eval-export-dflt-expr-err-get-value.js │ │ ├── instn-local-bndng-export-var.js │ │ ├── instn-local-bndng-export-fun.js │ │ ├── instn-iee-err-dflt-thru-star.js │ │ ├── instn-local-bndng-export-gen.js │ │ ├── instn-iee-err-dflt-thru-star-as.js │ │ ├── instn-star-binding.js │ │ ├── instn-star-err-not-found.js │ │ ├── early-import-eval.js │ │ ├── early-import-as-eval.js │ │ ├── instn-named-err-not-found-dflt.js │ │ ├── instn-named-err-not-found.js │ │ ├── instn-named-err-not-found-as.js │ │ ├── eval-rqstd-once.js │ │ ├── dynamic-import-returns-promise.js │ │ ├── eval-gtbndng-indirect-update.js │ │ ├── eval-export-dflt-expr-fn-anon.js │ │ ├── eval-export-dflt-expr-fn-named.js │ │ ├── eval-rqstd-order.js │ │ ├── eval-self-once.js │ │ ├── instn-named-err-dflt-thru-star-dflt.js │ │ ├── eval-export-dflt-expr-cls-anon.js │ │ ├── eval-export-dflt-expr-cls-named.js │ │ ├── instn-named-err-dflt-thru-star-as.js │ │ ├── instn-star-props-dflt-keep-indirect.js │ │ ├── eval-export-dflt-cls-anon.js │ │ ├── eval-export-dflt-cls-named.js │ │ ├── eval-export-dflt-cls-name-meth.js │ │ ├── eval-export-dflt-expr-gen-named.js │ │ ├── eval-this.js │ │ ├── instn-once.js │ │ ├── eval-export-dflt-expr-gen-anon.js │ │ ├── eval-gtbndng-indirect-update-as.js │ │ ├── instn-resolve-empty-export.js │ │ ├── instn-named-id-name.js │ │ ├── eval-export-dflt-expr-cls-name-meth.js │ │ ├── instn-local-bndng-for.js │ │ ├── instn-local-bndng-let.js │ │ ├── instn-local-bndng-cls.js │ │ ├── instn-local-bndng-var.js │ │ ├── instn-local-bndng-const.js │ │ ├── instn-named-bndng-dflt-cls.js │ │ ├── instn-star-id-name.js │ │ ├── instn-named-bndng-dflt-expr.js │ │ ├── instn-star-props-dflt-keep-local.js │ │ ├── instn-star-ambiguous.js │ │ ├── instn-resolve-empty-import.js │ │ ├── instn-star-props-dflt-skip.js │ │ ├── instn-star-props-circular.js │ │ ├── instn-local-bndng-gen.js │ │ ├── instn-iee-err-ambiguous.js │ │ ├── instn-iee-err-ambiguous-as.js │ │ ├── instn-star-equality.js │ │ ├── instn-local-bndng-fun.js │ │ ├── instn-named-err-ambiguous.js │ │ ├── instn-named-bndng-cls.js │ │ ├── instn-named-err-ambiguous-as.js │ │ ├── instn-named-bndng-dflt-fun-anon.js │ │ ├── instn-named-bndng-dflt-fun-named.js │ │ ├── instn-named-bndng-let.js │ │ └── instn-named-bndng-const.js │ │ └── comments │ │ └── hashbang │ │ └── escaped-hashbang.js │ ├── harness │ ├── features.yml │ ├── fnGlobalObject.js │ ├── isConstructor.js │ ├── atomicsHelper.js │ ├── tcoHelper.js │ ├── doneprintHandle.js │ ├── detachArrayBuffer.js │ ├── dateConstants.js │ ├── nans.js │ ├── sta.js │ ├── decimalToHexString.js │ ├── promiseHelper.js │ ├── arrayContains.js │ ├── compareArray.js │ ├── assertRelativeDateMs.js │ ├── timer.js │ ├── testBigIntTypedArray.js │ ├── nativeFunctionMatcher.js │ ├── compareIterator.js │ ├── proxyTrapsHelper.js │ └── regExpUtils.js │ └── package.json ├── lib ├── inception.js ├── agents │ ├── chrome.js │ ├── edge.js │ ├── safari.js │ ├── firefox.js │ ├── xs.js │ ├── nashorn.js │ ├── chakra.js │ ├── qjs.js │ ├── remote.js │ ├── d8.js │ └── BrowserAgent.js ├── runtime-path.js ├── write-sources.js ├── Agent.js ├── parse-error.js ├── eshost.js ├── supported-hosts.js └── WebdriverAgent.js ├── .editorconfig ├── bin └── compileRuntime.js ├── .eslintrc.json ├── runtimes ├── hermes.js ├── engine262.js ├── libjs.js ├── xs.js ├── qjs.js ├── graaljs.js ├── node.js ├── nashorn.js ├── browser.html └── jsc.js ├── jest.config.js ├── package.json ├── LICENSE.v8 └── LICENSE /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | test/ 3 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | test/fixtures/**/*.js 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | node_modules/ 3 | hosts/* -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/import-assertion-3_FIXTURE.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/import-assertion-4_FIXTURE.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/import-assertion-1_FIXTURE.js: -------------------------------------------------------------------------------- 1 | export default 1; 2 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/import-assertion-2_FIXTURE.js: -------------------------------------------------------------------------------- 1 | export default 2; 2 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/json-module_FIXTURE.json: -------------------------------------------------------------------------------- 1 | "This file is valid JSON and valid JavaScript." 2 | -------------------------------------------------------------------------------- /lib/inception.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(runtime) { 4 | return runtime.replace('$SOURCE', JSON.stringify(runtime.replace('$SOURCE', '""'))); 5 | }; 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | trim_trailing_whitespace = true 7 | charset = utf-8 8 | indent_style = space 9 | indent_size = 2 10 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/module_FIXTURE.mjs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Bocoup LLC. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | export var x = 1; 4 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/realm-importvalue_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Rick Waldron. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export var x = 1; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-err-not-found-empty_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | ; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-not-found-empty_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | ; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-empty-export_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | 0++; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-empty-import_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | 0++; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-err-reference_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | 0++; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-err-syntax_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | break; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-order-src-valid_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | ; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-err-not-found-empty_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | ; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-err-ambiguous-1_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export var x; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-err-ambiguous-2_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export var x; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-order-depth-syntax_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | break; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-order-src-reference_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | 0++; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-order-src-syntax_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | break; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-abrupt-err-uri_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | throw new Error(); 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-trlng-comma_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export var a = 333; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-ambiguous-1_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export var x; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-ambiguous-2_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export var x; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-order-depth-reference_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | 0++; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/dynamic-import-returns-promise_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export var x = 1; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-abrupt-err-type_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | throw new TypeError(); 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-gtbndng-indirect-trlng-comma_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export var x = 1; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-dflt-keep-local-prod_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export default null; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-order-1_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | Function('return this;')().test262 = '1'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-order-2_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | Function('return this;')().test262 += '2'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-order-3_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | Function('return this;')().test262 += '3'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-order-5_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | Function('return this;')().test262 += '5'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-order-7_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | Function('return this;')().test262 += '7'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-dflt-keep-indirect-def_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export default null; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-err-dflt-thru-star-dflt_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | var x; 5 | export { x as default }; 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-same-global-set_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | new Function('return this;')().test262 = 262; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-dflt-thru-star-dflt_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | var x; 5 | export { x as default }; 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-ambiguous-1_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export var first = null; 5 | export var both = null; 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-ambiguous-2_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export var second = null; 5 | export var both = null; 6 | -------------------------------------------------------------------------------- /bin/compileRuntime.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const runtime = process.argv[2]; 5 | 6 | let file = fs.readFileSync(runtime, 'utf-8'); 7 | let src = file.replace(/\$SOURCE/, '""'); 8 | src = file.replace('$SOURCE', JSON.stringify(src)); 9 | console.log(src); 10 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-star-cycle-2_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export * from './instn-iee-star-cycle-indirect-x_FIXTURE.js'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-dflt-keep-local-named_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | var x = null; 5 | export { x as default }; 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-star-cycle-2_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export * from './instn-named-star-cycle-indirect-x_FIXTURE.js'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-star-cycle-2_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export * from './instn-star-star-cycle-indirect-x_FIXTURE.js'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-order-4_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | Function('return this;')().test262 += '4'; 5 | 6 | export default null; 7 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-order-6_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | Function('return this;')().test262 += '6'; 5 | 6 | export default null; 7 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-order-8_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | Function('return this;')().test262 += '8'; 5 | 6 | export default null; 7 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-order-depth-child_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | import './instn-resolve-order-depth-reference_FIXTURE.js'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-dflt-skip-prod_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export var productionOther = null; 5 | export default null; 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-nrml-indirect_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export var indirectIdName; 5 | export var starIndirectIdName; 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-err-dflt-thru-star-int_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export * from './instn-iee-err-dflt-thru-star-dflt_FIXTURE.js'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-err-not-found-faulty_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export { x } from './instn-star-err-not-found-empty_FIXTURE.js'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-dflt-skip-star-prod_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export * from './instn-star-props-dflt-skip-prod_FIXTURE.js'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-gtbndng-indirect-update-dflt_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export default function fn() { 5 | fn = 2; 6 | return 1; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-dflt-thru-star-int_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export * from './instn-named-err-dflt-thru-star-dflt_FIXTURE.js'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-equality-other_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | import * as testNs from './instn-star-equality.js'; 5 | export { testNs }; 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-dflt-skip-named_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | var x; 5 | export var namedOther = null; 6 | export { x as default }; 7 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-dflt-skip-star-named_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export * from './instn-star-props-dflt-skip-named_FIXTURE.js'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/features.yml: -------------------------------------------------------------------------------- 1 | typeCoercion.js: [Symbol.toPrimitive, BigInt] 2 | testAtomics.js: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, arrow-function, let, for-of] 3 | testBigIntTypedArray.js: [BigInt, TypedArray] 4 | testTypedArray.js: [TypedArray] 5 | isConstructor.js: [Reflect.construct] 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-circular-a_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export * from './instn-star-props-circular-b_FIXTURE.js'; 5 | export var fromA; 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-circular-b_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export * from './instn-star-props-circular-a_FIXTURE.js'; 5 | export var fromB; 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-dflt-keep-indirect-reexport_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export { default } from './instn-star-props-dflt-keep-indirect-def_FIXTURE.js'; 5 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-ambiguous_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export * from './instn-star-ambiguous-1_FIXTURE.js'; 5 | export * from './instn-star-ambiguous-2_FIXTURE.js'; 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-err-ambiguous_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export * from './instn-iee-err-ambiguous-1_FIXTURE.js'; 5 | export * from './instn-iee-err-ambiguous-2_FIXTURE.js'; 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-ambiguous_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export * from './instn-named-err-ambiguous-1_FIXTURE.js'; 5 | export * from './instn-named-err-ambiguous-2_FIXTURE.js'; 6 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/dynamic-import-attempts-non-existant.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Attempt to import a file that does not exist 3 | features: [dynamic-import] 4 | flags: [async] 5 | ---*/ 6 | 7 | import('./THIS_FILE_DOES_NOT_EXIST.js').catch(error => { 8 | assert(typeof error !== 'undefined'); 9 | }).then($DONE, $DONE); 10 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-gtbndng-indirect-update_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | var x = 1; 5 | export { x }; 6 | 7 | Function('return this;')().test262update = function() { 8 | x = 2; 9 | }; 10 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-gtbndng-indirect-update-as_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | var x = 1; 5 | export { x }; 6 | 7 | Function('return this;')().test262update = function() { 8 | x = 2; 9 | }; 10 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/module.mjs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Bocoup LLC. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: This is just an .mjs test 5 | esid: sec-parsemodule 6 | flags: [module] 7 | ---*/ 8 | import { x } from './module_FIXTURE.mjs'; 9 | assert(x === 1); 10 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/fnGlobalObject.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | Produce a reliable global object 6 | ---*/ 7 | 8 | var __globalObject = Function("return this;")(); 9 | function fnGlobalObject() { 10 | return __globalObject; 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test262", 3 | "version": "3.0.0", 4 | "description": "This is a fake test262", 5 | "repository": { 6 | "type": "git", 7 | "url": "git+https://github.com/tc39/test262.git" 8 | }, 9 | "license": "BSD", 10 | "bugs": { 11 | "url": "https://github.com/tc39/test262/issues" 12 | }, 13 | "private": true, 14 | "homepage": "https://github.com/tc39/test262#readme" 15 | } 16 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-star-cycle-indirect-x_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | // This module is visited two times: 5 | // First when resolving the "x" binding and then another time to resolve the 6 | // "y" binding. 7 | export { y as x } from './instn-iee-star-cycle-2_FIXTURE.js'; 8 | export var y = 45; 9 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-star-cycle-indirect-x_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | // This module is visited two times: 5 | // First when resolving the "x" binding and then another time to resolve the 6 | // "y" binding. 7 | export { y as x } from './instn-named-star-cycle-2_FIXTURE.js'; 8 | export var y = 45; 9 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-star-cycle-indirect-x_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | // This module is visited two times: 5 | // First when resolving the "x" binding and then another time to resolve the 6 | // "y" binding. 7 | export { y as x } from './instn-star-star-cycle-2_FIXTURE.js'; 8 | export var y = 45; 9 | -------------------------------------------------------------------------------- /lib/agents/chrome.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const WebdriverAgent = require('../WebdriverAgent.js'); 4 | const chrome = require('selenium-webdriver/chrome') 5 | 6 | class ChromeAgent extends WebdriverAgent { 7 | getDriver() { 8 | return chrome.Driver; 9 | } 10 | 11 | getOptions() { 12 | return chrome.Options; 13 | } 14 | 15 | setBinaryPath(options, path) { 16 | options.setChromeBinaryPath(path); 17 | } 18 | } 19 | 20 | module.exports = ChromeAgent; 21 | -------------------------------------------------------------------------------- /lib/agents/edge.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const WebdriverAgent = require('../WebdriverAgent.js'); 4 | const edge = require('selenium-webdriver/edge') 5 | 6 | class EdgeAgent extends WebdriverAgent { 7 | getDriver() { 8 | return edge.Driver; 9 | } 10 | 11 | getOptions() { 12 | return edge.Options; 13 | } 14 | 15 | setBinaryPath() { 16 | throw new Error('Cannot set binary path for edge driver'); 17 | } 18 | } 19 | 20 | module.exports = EdgeAgent; 21 | 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/isConstructor.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 André Bargull. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | /*--- 5 | description: | 6 | Test if a given function is a constructor function. 7 | ---*/ 8 | 9 | function isConstructor(f) { 10 | try { 11 | Reflect.construct(function(){}, [], f); 12 | } catch (e) { 13 | return false; 14 | } 15 | return true; 16 | } 17 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/atomicsHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | The amount of slack allowed for testing time-related Atomics methods (i.e. 6 | wait and wake). The absolute value of the difference of the observed time 7 | and the expected time must be epsilon-close. 8 | ---*/ 9 | var $ATOMICS_MAX_TIME_EPSILON = 100; 10 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/tcoHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 André Bargull. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | This defines the number of consecutive recursive function calls that must be 6 | made in order to prove that stack frames are properly destroyed according to 7 | ES2015 tail call optimization semantics. 8 | ---*/ 9 | 10 | 11 | 12 | 13 | var $MAX_ITERATIONS = 100000; 14 | -------------------------------------------------------------------------------- /lib/agents/safari.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const WebdriverAgent = require('../WebdriverAgent.js'); 4 | const safari = require('selenium-webdriver/safari') 5 | 6 | class SafariAgent extends WebdriverAgent { 7 | getDriver() { 8 | return safari.Driver; 9 | } 10 | 11 | getOptions() { 12 | return safari.Options; 13 | } 14 | 15 | setBinaryPath() { 16 | throw new Error("Safari agent does not support custom binary paths"); 17 | } 18 | } 19 | 20 | 21 | module.exports = SafariAgent; 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-uniq-env-rec-other_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | var first = 4; 5 | let second = 5; 6 | const third = 6; 7 | class fourth {} 8 | function fifth() {} 9 | function* sixth() {} 10 | 11 | var seventh = 7; 12 | let eighth = 8; 13 | const ninth = 9; 14 | class tenth {} 15 | function eleventh() {} 16 | function *twelfth() {} 17 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/doneprintHandle.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | 6 | ---*/ 7 | 8 | function __consolePrintHandle__(msg){ 9 | print(msg); 10 | } 11 | 12 | function $DONE(){ 13 | if(!arguments[0]) 14 | __consolePrintHandle__('Test262:AsyncTestComplete'); 15 | else 16 | __consolePrintHandle__('Test262:AsyncTestFailure:' + arguments[0]); 17 | } 18 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-once_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export default null; 5 | var global = Function('return this;')(); 6 | 7 | if (global.test262) { 8 | throw new Error('Module was evaluated more than once.'); 9 | } 10 | 11 | global.test262 = 262; 12 | 13 | if (global.test262 !== 262) { 14 | throw new Error('Module was unable to signal evaluation.'); 15 | } 16 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2021": true, 5 | "jest": true, 6 | "jasmine": true, 7 | "node": true 8 | }, 9 | "extends": "eslint:recommended", 10 | "parserOptions": { 11 | "sourceType": "module", 12 | "ecmaVersion": 2021 13 | }, 14 | "globals": { 15 | "Test262Error": true, 16 | "gc": true, 17 | "$SOURCE": true, 18 | "fixture": true, 19 | "sandbox": true, 20 | "sinon": true 21 | }, 22 | "rules": { 23 | "no-console": [0], 24 | "no-empty-pattern": [0] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/agents/firefox.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const WebdriverAgent = require('../WebdriverAgent.js'); 4 | const firefox = require('selenium-webdriver/firefox'); 5 | 6 | class FirefoxAgent extends WebdriverAgent { 7 | setCapabilities(options) { 8 | options.set('marionette', true); 9 | } 10 | 11 | getDriver() { 12 | return firefox.Driver; 13 | } 14 | 15 | getOptions() { 16 | return firefox.Options; 17 | } 18 | 19 | setBinaryPath(options, path) { 20 | options.setBinary(path); 21 | } 22 | } 23 | 24 | 25 | module.exports = FirefoxAgent; 26 | -------------------------------------------------------------------------------- /lib/runtime-path.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const path = require('path'); 3 | const { supportedHostsMap } = require('./supported-hosts'); 4 | const RUNTIMES_PATH = path.join(__dirname, '../runtimes'); 5 | 6 | const browsers = [ 7 | 'BrowserAgent', 8 | 'chrome', 9 | 'edge', 10 | 'firefox', 11 | 'remote', 12 | 'safari', 13 | ]; 14 | 15 | exports.for = hostType => { 16 | if (browsers.includes(hostType)) { 17 | return path.join(RUNTIMES_PATH, 'browser.js'); 18 | } 19 | 20 | return path.join(RUNTIMES_PATH, `${supportedHostsMap[hostType]}.js`); 21 | }; 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/comments/hashbang/escaped-hashbang.js: -------------------------------------------------------------------------------- 1 | \u0023\u0021 2 | 3 | // Copyright (C) 2019 Leo Balter. All rights reserved. 4 | // This code is governed by the BSD license found in the LICENSE file. 5 | 6 | /*--- 7 | esid: pending 8 | description: > 9 | Hashbang comments should not be allowed to have encoded characters 10 | info: | 11 | HashbangComment:: 12 | #! SingleLineCommentChars[opt] 13 | flags: [raw] 14 | negative: 15 | phase: parse 16 | type: SyntaxError 17 | features: [hashbang] 18 | ---*/ 19 | 20 | throw "Test262: This statement should not be evaluated."; 21 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/detachArrayBuffer.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | A function used in the process of asserting correctness of TypedArray objects. 6 | 7 | $262.detachArrayBuffer is defined by a host. 8 | 9 | ---*/ 10 | 11 | function $DETACHBUFFER(buffer) { 12 | if (!$262 || typeof $262.detachArrayBuffer !== "function") { 13 | throw new Test262Error("No method available to detach an ArrayBuffer"); 14 | } 15 | $262.detachArrayBuffer(buffer); 16 | } 17 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/dateConstants.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 the Sputnik authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | Collection of date-centric values 6 | ---*/ 7 | 8 | var date_1899_end = -2208988800001; 9 | var date_1900_start = -2208988800000; 10 | var date_1969_end = -1; 11 | var date_1970_start = 0; 12 | var date_1999_end = 946684799999; 13 | var date_2000_start = 946684800000; 14 | var date_2099_end = 4102444799999; 15 | var date_2100_start = 4102444800000; 16 | 17 | var start_of_time = -8.64e15; 18 | var end_of_time = 8.64e15; 19 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-order-depth.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Module dependencies are resolved following a depth-first strategy 5 | esid: sec-moduledeclarationinstantiation 6 | negative: 7 | phase: resolution 8 | type: ReferenceError 9 | flags: [module] 10 | ---*/ 11 | 12 | throw "Test262: This statement should not be evaluated."; 13 | 14 | import './instn-resolve-order-depth-child_FIXTURE.js'; 15 | import './instn-resolve-order-depth-syntax_FIXTURE.js'; 16 | -------------------------------------------------------------------------------- /runtimes/hermes.js: -------------------------------------------------------------------------------- 1 | var $262 = { 2 | global: globalThis, 3 | gc() { 4 | return gc(); 5 | }, 6 | createRealm(options) { 7 | throw new Test262Error('createRealm() not yet supported.'); 8 | }, 9 | evalScript(code) { 10 | throw new Test262Error('evalScript() not yet supported.'); 11 | }, 12 | getGlobal(name) { 13 | return this.global[name]; 14 | }, 15 | setGlobal(name, value) { 16 | this.global[name] = value; 17 | }, 18 | destroy() { /* noop */ }, 19 | IsHTMLDDA() { return {}; }, 20 | source: $SOURCE, 21 | get agent() { 22 | throw new Test262Error('agent.* not yet supported.'); 23 | } 24 | }; 25 | 26 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-order-src.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Modules dependencies are resolved in source text order 5 | esid: sec-moduledeclarationinstantiation 6 | negative: 7 | phase: resolution 8 | type: ReferenceError 9 | flags: [module] 10 | ---*/ 11 | 12 | throw "Test262: This statement should not be evaluated."; 13 | 14 | import './instn-resolve-order-src-valid_FIXTURE.js'; 15 | import './instn-resolve-order-src-reference_FIXTURE.js'; 16 | import './instn-resolve-order-src-syntax_FIXTURE.js'; 17 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-same-global.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Modules share the same global `this` value 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 6. Let env be NewModuleEnvironment(realm.[[GlobalEnv]]). 9 | 7. Set module.[[Environment]] to env. 10 | [...] 11 | includes: [fnGlobalObject.js] 12 | flags: [module] 13 | ---*/ 14 | 15 | import './instn-same-global-set_FIXTURE.js'; 16 | 17 | var global = fnGlobalObject(); 18 | 19 | assert.sameValue(global.test262, 262); 20 | -------------------------------------------------------------------------------- /runtimes/engine262.js: -------------------------------------------------------------------------------- 1 | { 2 | const { createRealm } = $262; 3 | $262.createRealm = (options) => { 4 | options = options || {}; 5 | options.globals = options.globals || {}; 6 | 7 | const realm = createRealm(); 8 | realm.evalScript($262.source); 9 | 10 | for (const glob in options.globals) { 11 | realm.global[glob] = options.globals[glob]; 12 | } 13 | if (options.destroy) { 14 | realm.destroy = options.destroy; 15 | } 16 | 17 | return realm; 18 | }; 19 | $262.getGlobal = (name) => $262.global[name]; 20 | $262.setGlobal = (name, value) => { 21 | $262.global[name] = value; 22 | }; 23 | $262.destroy = () => {}; 24 | $262.source = $SOURCE; 25 | } 26 | -------------------------------------------------------------------------------- /runtimes/libjs.js: -------------------------------------------------------------------------------- 1 | function print(...args) { 2 | console.log(...args); 3 | } 4 | var $262 = { 5 | global: globalThis, 6 | gc() { 7 | return gc(); 8 | }, 9 | createRealm(options) { 10 | throw new InternalError('createRealm() not yet supported.'); 11 | }, 12 | evalScript(code) { 13 | throw new InternalError('evalScript() not yet supported.'); 14 | }, 15 | getGlobal(name) { 16 | return this.global[name]; 17 | }, 18 | setGlobal(name, value) { 19 | this.global[name] = value; 20 | }, 21 | destroy() { /* noop */ }, 22 | IsHTMLDDA() { return {}; }, 23 | source: $SOURCE, 24 | get agent() { 25 | throw new InternalError('agent.* not yet supported.'); 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/nans.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | A collection of NaN values produced from expressions that have been observed 6 | to create distinct bit representations on various platforms. These provide a 7 | weak basis for assertions regarding the consistent canonicalization of NaN 8 | values in Array buffers. 9 | ---*/ 10 | 11 | var NaNs = [ 12 | NaN, 13 | Number.NaN, 14 | NaN * 0, 15 | 0/0, 16 | Infinity/Infinity, 17 | -(0/0), 18 | Math.pow(-1, 0.5), 19 | -Math.pow(-1, 0.5), 20 | Number("Not-a-Number"), 21 | ]; 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/sta.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | Provides both: 6 | 7 | - An error class to avoid false positives when testing for thrown exceptions 8 | - A function to explicitly throw an exception using the Test262Error class 9 | ---*/ 10 | 11 | 12 | function Test262Error(message) { 13 | this.message = message || ""; 14 | } 15 | 16 | Test262Error.prototype.toString = function () { 17 | return "Test262Error: " + this.message; 18 | }; 19 | 20 | var $ERROR; 21 | $ERROR = function $ERROR(message) { 22 | throw new Test262Error(message); 23 | }; 24 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/decimalToHexString.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 André Bargull. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | Collection of functions used to assert the correctness of various encoding operations. 6 | ---*/ 7 | 8 | function decimalToHexString(n) { 9 | var hex = "0123456789ABCDEF"; 10 | n >>>= 0; 11 | var s = ""; 12 | while (n) { 13 | s = hex[n & 0xf] + s; 14 | n >>>= 4; 15 | } 16 | while (s.length < 4) { 17 | s = "0" + s; 18 | } 19 | return s; 20 | } 21 | 22 | function decimalToPercentHexString(n) { 23 | var hex = "0123456789ABCDEF"; 24 | return "%" + hex[(n >> 4) & 0xf] + hex[n & 0xf]; 25 | } 26 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/promiseHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | Check that an array contains a numeric sequence starting at 1 6 | and incrementing by 1 for each entry in the array. Used by 7 | Promise tests to assert the order of execution in deep Promise 8 | resolution pipelines. 9 | ---*/ 10 | 11 | function checkSequence(arr, message) { 12 | arr.forEach(function(e, i) { 13 | if (e !== (i+1)) { 14 | $ERROR((message ? message : "Steps in unexpected sequence:") + 15 | " '" + arr.join(',') + "'"); 16 | } 17 | }); 18 | 19 | return true; 20 | } 21 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/import-assertion-dynamic.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Dynamic import assertions 3 | info: | 4 | This test approximates the "import assertions" syntax using code comments in 5 | order to support improvements to ESHost's dependency inferrence logic while 6 | still passing in runtimes which do not yet support the proposed language 7 | extension. 8 | esid: sec-moduleevaluation 9 | flags: [module, async] 10 | ---*/ 11 | 12 | Promise.all([ 13 | import('./import-assertion-1_FIXTURE.js'),//, {'':''}) 14 | import("./import-assertion-2_FIXTURE.js"),//, {"":""}) 15 | ]).then(function(values) { 16 | assert.sameValue(values[0].default, 1); 17 | assert.sameValue(values[1].default, 2); 18 | }).then($DONE, $DONE); 19 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/arrayContains.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | Verify that a subArray is contained within an array. 6 | ---*/ 7 | 8 | /** 9 | * @param {Array} array 10 | * @param {Array} subArray 11 | */ 12 | 13 | function arrayContains(array, subArray) { 14 | var found; 15 | for (var i = 0; i < subArray.length; i++) { 16 | found = false; 17 | for (var j = 0; j < array.length; j++) { 18 | if (subArray[i] === array[j]) { 19 | found = true; 20 | break; 21 | } 22 | } 23 | if (!found) { 24 | return false; 25 | } 26 | } 27 | return true; 28 | } 29 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/compareArray.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | Compare the contents of two arrays 6 | ---*/ 7 | 8 | function compareArray(a, b) { 9 | if (b.length !== a.length) { 10 | return false; 11 | } 12 | 13 | for (var i = 0; i < a.length; i++) { 14 | if (b[i] !== a[i]) { 15 | return false; 16 | } 17 | } 18 | return true; 19 | } 20 | 21 | assert.compareArray = function(actual, expected, message) { 22 | assert(compareArray(actual, expected), 23 | 'Expected [' + actual.join(', ') + '] and [' + expected.join(', ') + '] to have the same contents. ' + message); 24 | }; 25 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-bndng-cls_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export { A as B } from './instn-iee-bndng-cls.js'; 5 | 6 | // Taken together, the following two assertions demonstrate that there is no 7 | // entry in the environment record for ImportName: 8 | export const results = []; 9 | try { 10 | A; 11 | } catch (error) { 12 | results.push(error.name, typeof A); 13 | } 14 | 15 | // Taken together, the following two assertions demonstrate that there is no 16 | // entry in the environment record for ExportName: 17 | try { 18 | B; 19 | } catch (error) { 20 | results.push(error.name, typeof B); 21 | } 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-bndng-fun_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export { A as B } from './instn-iee-bndng-fun.js'; 5 | 6 | // Taken together, the following two assertions demonstrate that there is no 7 | // entry in the environment record for ImportName: 8 | export const results = []; 9 | try { 10 | A; 11 | } catch (error) { 12 | results.push(error.name, typeof A); 13 | } 14 | 15 | // Taken together, the following two assertions demonstrate that there is no 16 | // entry in the environment record for ExportName: 17 | try { 18 | B; 19 | } catch (error) { 20 | results.push(error.name, typeof B); 21 | } 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-bndng-gen_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export { A as B } from './instn-iee-bndng-gen.js'; 5 | 6 | // Taken together, the following two assertions demonstrate that there is no 7 | // entry in the environment record for ImportName: 8 | export const results = []; 9 | try { 10 | A; 11 | } catch (error) { 12 | results.push(error.name, typeof A); 13 | } 14 | 15 | // Taken together, the following two assertions demonstrate that there is no 16 | // entry in the environment record for ExportName: 17 | try { 18 | B; 19 | } catch (error) { 20 | results.push(error.name, typeof B); 21 | } 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-bndng-let_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export { A as B } from './instn-iee-bndng-let.js'; 5 | 6 | // Taken together, the following two assertions demonstrate that there is no 7 | // entry in the environment record for ImportName: 8 | export const results = []; 9 | try { 10 | A; 11 | } catch (error) { 12 | results.push(error.name, typeof A); 13 | } 14 | 15 | // Taken together, the following two assertions demonstrate that there is no 16 | // entry in the environment record for ExportName: 17 | try { 18 | B; 19 | } catch (error) { 20 | results.push(error.name, typeof B); 21 | } 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-bndng-var_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export { A as B } from './instn-iee-bndng-var.js'; 5 | 6 | // Taken together, the following two assertions demonstrate that there is no 7 | // entry in the environment record for ImportName: 8 | export const results = []; 9 | try { 10 | A; 11 | } catch (error) { 12 | results.push(error.name, typeof A); 13 | } 14 | 15 | // Taken together, the following two assertions demonstrate that there is no 16 | // entry in the environment record for ExportName: 17 | try { 18 | B; 19 | } catch (error) { 20 | results.push(error.name, typeof B); 21 | } 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-bndng-const_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export { A as B } from './instn-iee-bndng-const.js'; 5 | 6 | // Taken together, the following two assertions demonstrate that there is no 7 | // entry in the environment record for ImportName: 8 | export const results = []; 9 | try { 10 | A; 11 | } catch (error) { 12 | results.push(error.name, typeof A); 13 | } 14 | 15 | // Taken together, the following two assertions demonstrate that there is no 16 | // entry in the environment record for ExportName: 17 | try { 18 | B; 19 | } catch (error) { 20 | results.push(error.name, typeof B); 21 | } 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/import-assertion-static.js: -------------------------------------------------------------------------------- 1 | /*--- 2 | description: Static import assertions 3 | info: | 4 | This test approximates the "import assertions" syntax using code comments in 5 | order to support improvements to ESHost's dependency inferrence logic while 6 | still passing in runtimes which do not yet support the proposed language 7 | extension. 8 | esid: sec-moduleevaluation 9 | flags: [module] 10 | ---*/ 11 | 12 | import one from './import-assertion-1_FIXTURE.js'// assert {'':''}; 13 | import two from "./import-assertion-2_FIXTURE.js"// assert {"":""}; 14 | import './import-assertion-3_FIXTURE.js'// assert {'':''}; 15 | import "./import-assertion-4_FIXTURE.js"// assert {"":""}; 16 | 17 | assert.sameValue(one, 1); 18 | assert.sameValue(two, 2); 19 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-err-syntax.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Requested modules that produce an early SyntaxError 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 8. For each String required that is an element of 9 | module.[[RequestedModules]] do, 10 | [...] 11 | b. Let requiredModule be ? HostResolveImportedModule(module, required). 12 | [...] 13 | negative: 14 | phase: resolution 15 | type: SyntaxError 16 | flags: [module] 17 | ---*/ 18 | 19 | throw "Test262: This statement should not be evaluated."; 20 | 21 | import './instn-resolve-err-syntax_FIXTURE.js'; 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-err-reference.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Requested modules that produce an early ReferenceError 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 8. For each String required that is an element of 9 | module.[[RequestedModules]] do, 10 | [...] 11 | b. Let requiredModule be ? HostResolveImportedModule(module, required). 12 | [...] 13 | negative: 14 | phase: resolution 15 | type: ReferenceError 16 | flags: [module] 17 | ---*/ 18 | 19 | throw "Test262: This statement should not be evaluated."; 20 | 21 | import './instn-resolve-err-reference_FIXTURE.js'; 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/json-module.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: This is a test for loading files with a `.json` extension. 5 | esid: sec-parsemodule 6 | flags: [module] 7 | ---*/ 8 | 9 | import './json-module_FIXTURE.json'; 10 | 11 | /** 12 | * At the time of this writing, neither the "import assertions" proposal [1] 13 | * nor the "JSON modules" proposal [2] are widely implemented. In order to 14 | * verify that the harness correctly identifies JSON dependencies without 15 | * requiring the new semantics, this test simply loads a JSON file which 16 | * happens to parse as JavaScript, and it does not validate the exported value. 17 | */ 18 | -------------------------------------------------------------------------------- /lib/write-sources.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let fs; 4 | 5 | try { 6 | fs = require('fs/promises'); 7 | } catch(error) { 8 | fs = require('fs').promises; 9 | } 10 | 11 | const path = require('path'); 12 | 13 | module.exports = async function(sources) { 14 | let {0: [file]} = sources; 15 | let dir = path.dirname(file); 16 | 17 | await safeMkdir(dir); 18 | /* 19 | first: path to output file 20 | second: contents 21 | */ 22 | return Promise.all( 23 | sources.map(args => fs.writeFile(...args)) 24 | ); 25 | }; 26 | 27 | async function safeMkdir(dir) { 28 | try { 29 | await fs.stat(dir); 30 | } catch (error) { 31 | if (error.code === 'ENOENT') { 32 | try { 33 | await fs.mkdir(dir); 34 | } catch ({}) { 35 | // suppressed? 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-export-dflt-expr-in.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | The `in` operator may occur within an exported AssignmentExpression 6 | esid: sec-moduleevaluation 7 | info: | 8 | [...] 9 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 10 | [...] 11 | 12 | 15.2.3 Exports 13 | 14 | Syntax 15 | 16 | ExportDeclaration : 17 | 18 | export default [lookahead ∉ { function, class }] AssignmentExpression[In]; 19 | flags: [module] 20 | ---*/ 21 | 22 | var x = { x: true }; 23 | 24 | export default 'x' in x; 25 | import f from './eval-export-dflt-expr-in.js'; 26 | 27 | assert.sameValue(f, true); 28 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-abrupt.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Abrupt completion during module evaluation precludes further evaluation 6 | esid: sec-moduleevaluation 7 | info: | 8 | [...] 9 | 6. For each String required that is an element of 10 | module.[[RequestedModules]] do, 11 | a. Let requiredModule be ? HostResolveImportedModule(module, required). 12 | b. Perform ? requiredModule.ModuleEvaluation(). 13 | negative: 14 | phase: runtime 15 | type: TypeError 16 | flags: [module] 17 | ---*/ 18 | 19 | import './eval-rqstd-abrupt-err-type_FIXTURE.js'; 20 | import './eval-rqstd-abrupt-err-uri_FIXTURE.js'; 21 | 22 | throw new RangeError(); 23 | -------------------------------------------------------------------------------- /lib/agents/xs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const runtimePath = require('../runtime-path'); 5 | const ConsoleAgent = require('../ConsoleAgent'); 6 | 7 | const errorRe = /^(\w+):? ?(.*)$/m; 8 | 9 | class XSAgent extends ConsoleAgent { 10 | async evalScript(code, options = {}) { 11 | this.args[0] = '-s'; 12 | 13 | if (options.module && this.args[0] !== '-m') { 14 | this.args[0] = '-m'; 15 | } 16 | 17 | return super.evalScript(code, options); 18 | } 19 | 20 | parseError(str) { 21 | let match = str.match(errorRe); 22 | if (match) { 23 | return { 24 | name: match[1], 25 | message: match[2], 26 | stack: [], 27 | }; 28 | } 29 | return null; 30 | } 31 | } 32 | XSAgent.runtime = fs.readFileSync(runtimePath.for('xs'), 'utf8'); 33 | 34 | module.exports = XSAgent; 35 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-bndng-dflt-named.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | An ImportClause may contain both an ImportedDefaultBinding and NamedImports 6 | esid: sec-imports 7 | info: | 8 | Syntax 9 | 10 | ImportClause: 11 | ImportedDefaultBinding 12 | NameSpaceImport 13 | NamedImports 14 | ImportedDefaultBinding , NameSpaceImport 15 | ImportedDefaultBinding , NamedImports 16 | flags: [module] 17 | ---*/ 18 | 19 | assert.throws(ReferenceError, function() { 20 | typeof x; 21 | }); 22 | 23 | assert.sameValue(y, undefined); 24 | 25 | export default 3; 26 | export var attr; 27 | import x, { attr as y } from './instn-named-bndng-dflt-named.js'; 28 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-bndng-dflt-star.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | An ImportClause may contain both an ImportedDefaultBinding and a 6 | NameSpaceImport 7 | esid: sec-imports 8 | info: | 9 | Syntax 10 | 11 | ImportClause: 12 | ImportedDefaultBinding 13 | NameSpaceImport 14 | NamedImports 15 | ImportedDefaultBinding , NameSpaceImport 16 | ImportedDefaultBinding , NamedImports 17 | flags: [module] 18 | ---*/ 19 | 20 | assert.throws(ReferenceError, function() { 21 | typeof x; 22 | }); 23 | 24 | assert('attr' in ns); 25 | 26 | export default 3; 27 | export var attr; 28 | import x, * as ns from './instn-named-bndng-dflt-star.js'; 29 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/assertRelativeDateMs.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | Verify that the given date object's Number representation describes the 6 | correct number of milliseconds since the Unix epoch relative to the local 7 | time zone (as interpreted at the specified date). 8 | ---*/ 9 | 10 | /** 11 | * @param {Date} date 12 | * @param {Number} expectedMs 13 | */ 14 | function assertRelativeDateMs(date, expectedMs) { 15 | var actualMs = date.valueOf(); 16 | var localOffset = date.getTimezoneOffset() * 60000; 17 | 18 | if (actualMs - localOffset !== expectedMs) { 19 | $ERROR( 20 | 'Expected ' + date + ' to be ' + expectedMs + 21 | ' milliseconds from the Unix epoch' 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-trlng-comma.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | ExportsList in ExportDeclaration may include a trailing comma 6 | esid: sec-moduledeclarationinstantiation 7 | info: | 8 | [...] 9 | 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do 10 | a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). 11 | [...] 12 | flags: [module] 13 | ---*/ 14 | 15 | export { a , } from './instn-iee-trlng-comma_FIXTURE.js'; 16 | export { a as b , } from './instn-iee-trlng-comma_FIXTURE.js'; 17 | 18 | import { a, b } from './instn-iee-trlng-comma.js'; 19 | 20 | assert.sameValue(a, 333, 'comma following named export'); 21 | assert.sameValue(b, 333, 'comma following re-named export'); 22 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-nrml-star_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | var notExportedVar2; 5 | let notExportedLet2; 6 | const notExportedConst2 = null; 7 | function notExportedFunc2() {} 8 | function* notExportedGen2() {} 9 | class notExportedClass2 {} 10 | 11 | var starBindingId; 12 | 13 | export var starVarDecl; 14 | export let starLetDecl; 15 | export const starConstDecl = null; 16 | export function starFuncDecl() {} 17 | export function* starGenDecl() {} 18 | export class starClassDecl {} 19 | export { starBindingId }; 20 | export { starBindingId as starIdName }; 21 | export { starIndirectIdName } from './instn-star-props-nrml-indirect_FIXTURE.js'; 22 | export { starIndirectIdName as starIndirectIdName2 } from './instn-star-props-nrml-indirect_FIXTURE.js'; 23 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-iee-cycle-2_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export { b as a } from './instn-iee-iee-cycle.js'; 5 | export { d as c } from './instn-iee-iee-cycle.js'; 6 | export { f as e } from './instn-iee-iee-cycle.js'; 7 | export { h as g } from './instn-iee-iee-cycle.js'; 8 | export { j as i } from './instn-iee-iee-cycle.js'; 9 | export { l as k } from './instn-iee-iee-cycle.js'; 10 | export { n as m } from './instn-iee-iee-cycle.js'; 11 | export { p as o } from './instn-iee-iee-cycle.js'; 12 | export { r as q } from './instn-iee-iee-cycle.js'; 13 | export { t as s } from './instn-iee-iee-cycle.js'; 14 | export { v as u } from './instn-iee-iee-cycle.js'; 15 | export { x as w } from './instn-iee-iee-cycle.js'; 16 | export { z as y } from './instn-iee-iee-cycle.js'; 17 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-iee-cycle-2_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export { b as a } from './instn-star-iee-cycle.js'; 5 | export { d as c } from './instn-star-iee-cycle.js'; 6 | export { f as e } from './instn-star-iee-cycle.js'; 7 | export { h as g } from './instn-star-iee-cycle.js'; 8 | export { j as i } from './instn-star-iee-cycle.js'; 9 | export { l as k } from './instn-star-iee-cycle.js'; 10 | export { n as m } from './instn-star-iee-cycle.js'; 11 | export { p as o } from './instn-star-iee-cycle.js'; 12 | export { r as q } from './instn-star-iee-cycle.js'; 13 | export { t as s } from './instn-star-iee-cycle.js'; 14 | export { v as u } from './instn-star-iee-cycle.js'; 15 | export { x as w } from './instn-star-iee-cycle.js'; 16 | export { z as y } from './instn-star-iee-cycle.js'; 17 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-var-dup.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Only one attempt is made to create a binding for any number of variable 6 | declarations 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 13. Let varDeclarations be the VarScopedDeclarations of code. 11 | 14. Let declaredVarNames be a new empty List. 12 | 15. For each element d in varDeclarations do 13 | a. For each element dn of the BoundNames of d do 14 | i. If dn is not an element of declaredVarNames, then 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | [...] 17 | 3. Append dn to declaredVarNames. 18 | [...] 19 | flags: [module] 20 | ---*/ 21 | 22 | var test262; 23 | var test262; 24 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | const jestConfig = { 2 | collectCoverage: true, 3 | collectCoverageFrom: [ 4 | '/lib/**/*.js', 5 | ], 6 | coverageDirectory: './coverage', 7 | // coverageThreshold: { 8 | // global: { 9 | // branches: 25, 10 | // functions: 25, 11 | // lines: 30, 12 | // statements: 30, 13 | // }, 14 | // }, 15 | rootDir: './', 16 | testMatch: ['/test/*.js'], 17 | testPathIgnorePatterns: [], 18 | verbose: true, 19 | }; 20 | 21 | if (!process.env.CI) { 22 | jestConfig.collectCoverageFrom.push( 23 | '!/lib/Server.js', 24 | '!/lib/WebdriverAgent.js', 25 | '!/lib/agents/BrowserAgent.js', 26 | '!/lib/agents/chrome.js', 27 | '!/lib/agents/edge.js', 28 | '!/lib/agents/firefox.js', 29 | '!/lib/agents/remote.js', 30 | '!/lib/agents/safari.js' 31 | ); 32 | 33 | } 34 | 35 | module.exports = jestConfig; -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-iee-cycle-2_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | export { b as a } from './instn-named-iee-cycle.js'; 5 | export { d as c } from './instn-named-iee-cycle.js'; 6 | export { f as e } from './instn-named-iee-cycle.js'; 7 | export { h as g } from './instn-named-iee-cycle.js'; 8 | export { j as i } from './instn-named-iee-cycle.js'; 9 | export { l as k } from './instn-named-iee-cycle.js'; 10 | export { n as m } from './instn-named-iee-cycle.js'; 11 | export { p as o } from './instn-named-iee-cycle.js'; 12 | export { r as q } from './instn-named-iee-cycle.js'; 13 | export { t as s } from './instn-named-iee-cycle.js'; 14 | export { v as u } from './instn-named-iee-cycle.js'; 15 | export { x as w } from './instn-named-iee-cycle.js'; 16 | export { z as y } from './instn-named-iee-cycle.js'; 17 | -------------------------------------------------------------------------------- /lib/Agent.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | class Agent { 4 | constructor(options = {}) { 5 | this.options = options; 6 | this.hostPath = options.hostPath; 7 | this.args = options.hostArguments || []; 8 | this.transform = options.transform || (x => x); 9 | this.out = options.out || ''; 10 | 11 | if (typeof this.args === 'string') { 12 | this.args = this.args.includes(' ') ? 13 | this.args.split(' ').filter(v => v.trim()) : 14 | [this.args]; 15 | } 16 | 17 | this.shortName = options.shortName || '$262'; 18 | } 19 | 20 | compile(code, options) { 21 | options = options || {}; 22 | 23 | code = this.transform(code); 24 | 25 | if (options.async) { 26 | return code; 27 | } else { 28 | return `${code}\n;${this.shortName}.destroy();`; 29 | } 30 | } 31 | 32 | // defaults that do nothing 33 | async initialize() { return this; } 34 | async destroy() {} 35 | stop() {} 36 | } 37 | 38 | module.exports = Agent; 39 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-gtbndng-indirect-trlng-comma.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | NamedImports in ImportDeclaration may contain a trailing comma 6 | esid: sec-moduleevaluation 7 | info: | 8 | 8.1.1.5.1 GetBindingValue (N, S) 9 | 10 | [...] 11 | 3. If the binding for N is an indirect binding, then 12 | a. Let M and N2 be the indirection values provided when this binding for 13 | N was created. 14 | b. Let targetEnv be M.[[Environment]]. 15 | c. If targetEnv is undefined, throw a ReferenceError exception. 16 | d. Let targetER be targetEnv's EnvironmentRecord. 17 | e. Return ? targetER.GetBindingValue(N2, S). 18 | flags: [module] 19 | ---*/ 20 | 21 | import { x , } from './eval-gtbndng-indirect-trlng-comma_FIXTURE.js'; 22 | 23 | assert.sameValue(x, 1); 24 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-nrml-1_FIXTURE.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | 4 | var notExportedVar1; 5 | let notExportedLet1; 6 | const notExportedConst1 = null; 7 | function notExportedFunc1() {} 8 | function* notExportedGen1() {} 9 | class notExportedClass1 {} 10 | 11 | var localBindingId; 12 | 13 | export var localVarDecl; 14 | export let localLetDecl; 15 | export const localConstDecl = null; 16 | export function localFuncDecl() {} 17 | export function* localGenDecl() {} 18 | export class localClassDecl {} 19 | export { localBindingId }; 20 | export { localBindingId as localIdName }; 21 | export { indirectIdName } from './instn-star-props-nrml-indirect_FIXTURE.js'; 22 | export { indirectIdName as indirectIdName2 } from './instn-star-props-nrml-indirect_FIXTURE.js'; 23 | 24 | export * from './instn-star-props-nrml-star_FIXTURE.js'; 25 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/timer.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | Used in website/scripts/sth.js 6 | ---*/ 7 | //setTimeout is not available, hence this script was loaded 8 | if (Promise === undefined && this.setTimeout === undefined) { 9 | if(/\$DONE()/.test(code)) 10 | $ERROR("Async test capability is not supported in your test environment"); 11 | } 12 | 13 | if (Promise !== undefined && this.setTimeout === undefined) { 14 | (function(that) { 15 | that.setTimeout = function(callback, delay) { 16 | var p = Promise.resolve(); 17 | var start = Date.now(); 18 | var end = start + delay; 19 | function check(){ 20 | var timeLeft = end - Date.now(); 21 | if(timeLeft > 0) 22 | p.then(check); 23 | else 24 | callback(); 25 | } 26 | p.then(check); 27 | } 28 | })(this); 29 | } 30 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-for-dup.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Only one attempt is made to create a binding for any number of variable 6 | declarations within `for` statements 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 13. Let varDeclarations be the VarScopedDeclarations of code. 11 | 14. Let declaredVarNames be a new empty List. 12 | 15. For each element d in varDeclarations do 13 | a. For each element dn of the BoundNames of d do 14 | i. If dn is not an element of declaredVarNames, then 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | [...] 17 | 3. Append dn to declaredVarNames. 18 | [...] 19 | flags: [module] 20 | ---*/ 21 | 22 | for (var test262; false; ) {} 23 | for (var test262; false; ) {} 24 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-gtbndng-indirect-update-dflt.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Modifications to default binding that occur after dependency has been 6 | evaluated are reflected in local binding 7 | info: | 8 | 8.1.1.5.1 GetBindingValue (N, S) 9 | 10 | [...] 11 | 3. If the binding for N is an indirect binding, then 12 | a. Let M and N2 be the indirection values provided when this binding for 13 | N was created. 14 | b. Let targetEnv be M.[[Environment]]. 15 | c. If targetEnv is undefined, throw a ReferenceError exception. 16 | d. Let targetER be targetEnv's EnvironmentRecord. 17 | e. Return ? targetER.GetBindingValue(N2, S). 18 | flags: [module] 19 | ---*/ 20 | 21 | import val from './eval-gtbndng-indirect-update-dflt_FIXTURE.js'; 22 | 23 | assert.sameValue(val(), 1); 24 | assert.sameValue(val, 2); 25 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-err-not-found.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: IndirectExportEntries validation - undefined imported bindings 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do 9 | a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). 10 | b. If resolution is null or resolution is "ambiguous", throw a 11 | SyntaxError exception. 12 | [...] 13 | 14 | 15.2.1.16.3 ResolveExport 15 | 16 | [...] 17 | 9. Let starResolution be null. 18 | 10. For each ExportEntry Record e in module.[[StarExportEntries]], do 19 | [...] 20 | 11. Return starResolution. 21 | negative: 22 | phase: runtime 23 | type: SyntaxError 24 | flags: [module] 25 | ---*/ 26 | 27 | export { x } from './instn-iee-err-not-found-empty_FIXTURE.js'; 28 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/parse-export-empty.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: An ExportClause does not require an ExportsList. 5 | esid: sec-parsemodule 6 | info: | 7 | ExportDeclaration: 8 | export * FromClause; 9 | export ExportClause FromClause; 10 | export ExportClause; 11 | export VariableStatement 12 | export Declaration 13 | export default HoistableDeclaration[Default] 14 | export default ClassDeclaration[Default] 15 | export default [lookahead ∉ { function, class }] AssignmentExpression[In]; 16 | 17 | ExportClause: 18 | { } 19 | { ExportsList } 20 | { ExportsList , } 21 | 22 | NOTE: This form has no observable side effects. 23 | flags: [module] 24 | ---*/ 25 | 26 | export{}; 27 | export {}; 28 | export {} 29 | export { }; 30 | export 31 | { 32 | 33 | }; 34 | export//- 35 | {//- 36 | //- 37 | }; 38 | export/**/{/**/}; 39 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-err-not-found-as.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: IndirectExportEntries validation - undefined imported bindings 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do 9 | a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). 10 | b. If resolution is null or resolution is "ambiguous", throw a 11 | SyntaxError exception. 12 | [...] 13 | 14 | 15.2.1.16.3 ResolveExport 15 | 16 | [...] 17 | 9. Let starResolution be null. 18 | 10. For each ExportEntry Record e in module.[[StarExportEntries]], do 19 | [...] 20 | 11. Return starResolution. 21 | negative: 22 | phase: runtime 23 | type: SyntaxError 24 | flags: [module] 25 | ---*/ 26 | 27 | export { x as y } from './instn-iee-err-not-found-empty_FIXTURE.js'; 28 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-export-let.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Binding is created but not initialized for exported `let` statements 6 | esid: sec-moduledeclarationinstantiation 7 | info: | 8 | [...] 9 | 17. For each element d in lexDeclarations do 10 | a. For each element dn of the BoundNames of d do 11 | i. If IsConstantDeclaration of d is true, then 12 | [...] 13 | ii. Else, 14 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 15 | [...] 16 | includes: [fnGlobalObject.js] 17 | flags: [module] 18 | ---*/ 19 | 20 | var global = fnGlobalObject(); 21 | 22 | assert.throws(ReferenceError, function() { 23 | typeof test262; 24 | }, 'Binding is created but not initialized.'); 25 | assert.sameValue( 26 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 27 | ); 28 | 29 | export let test262 = 23; 30 | -------------------------------------------------------------------------------- /lib/agents/nashorn.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const runtimePath = require('../runtime-path'); 5 | const ConsoleAgent = require('../ConsoleAgent'); 6 | 7 | const errorRe = /^(.*?):(\d+):(\d+)(?: (\w+):)? (.*)$/m; 8 | 9 | class NashornAgent extends ConsoleAgent { 10 | async evalScript(code, options = {}) { 11 | if (!this.args.includes('--language=es6')) { 12 | this.args.unshift('--language=es6'); 13 | } 14 | return super.evalScript(code, options); 15 | } 16 | 17 | parseError(str) { 18 | const error = {}; 19 | const match = str.match(errorRe); 20 | 21 | if (!match) { 22 | return null; 23 | } 24 | 25 | error.name = match[4] || 'SyntaxError'; 26 | error.message = match[5]; 27 | 28 | error.stack = [{ 29 | source: match[0], 30 | fileName: match[1], 31 | lineNumber: match[2], 32 | columnNumber: match[3] 33 | }]; 34 | 35 | return error; 36 | } 37 | } 38 | NashornAgent.runtime = fs.readFileSync(runtimePath.for('nashorn'), 'utf8'); 39 | 40 | module.exports = NashornAgent; 41 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-export-const.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Binding is created but not initialized for exported `const` statements 6 | esid: sec-moduledeclarationinstantiation 7 | info: | 8 | [...] 9 | 17. For each element d in lexDeclarations do 10 | a. For each element dn of the BoundNames of d do 11 | i. If IsConstantDeclaration of d is true, then 12 | [...] 13 | ii. Else, 14 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 15 | [...] 16 | includes: [fnGlobalObject.js] 17 | flags: [module] 18 | ---*/ 19 | 20 | var global = fnGlobalObject(); 21 | 22 | assert.throws(ReferenceError, function() { 23 | typeof test262; 24 | }, 'Binding is created but not initialized.'); 25 | assert.sameValue( 26 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 27 | ); 28 | 29 | export const test262 = 23; 30 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-export-cls.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Binding is created and initialized to `undefined` for exported `class` 6 | declarations 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 17. For each element d in lexDeclarations do 11 | a. For each element dn of the BoundNames of d do 12 | i. If IsConstantDeclaration of d is true, then 13 | [...] 14 | ii. Else, 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | [...] 17 | includes: [fnGlobalObject.js] 18 | flags: [module] 19 | ---*/ 20 | 21 | var global = fnGlobalObject(); 22 | 23 | assert.throws(ReferenceError, function() { 24 | typeof test262; 25 | }, 'Binding is created but not initialized.'); 26 | assert.sameValue( 27 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 28 | ); 29 | 30 | export class test262 {} 31 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-export-dflt-expr-err-get-value.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Abrupt completions resulting from value retrieval are forwarded to the 6 | runtime. 7 | esid: sec-moduleevaluation 8 | info: | 9 | [...] 10 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 11 | [...] 12 | 13 | 15.2.3.11 Runtime Semantics: Evaluation 14 | 15 | ExportDeclaration : export default AssignmentExpression; 16 | 17 | [...] 18 | 1. Let rhs be the result of evaluating AssignmentExpression. 19 | 2. Let value be ? GetValue(rhs). 20 | 21 | 6.2.3.1 GetValue (V) 22 | 23 | 1. ReturnIfAbrupt(V). 24 | 2. If Type(V) is not Reference, return V. 25 | 3. Let base be GetBase(V). 26 | 4. If IsUnresolvableReference(V) is true, throw a ReferenceError exception. 27 | negative: 28 | phase: runtime 29 | type: ReferenceError 30 | flags: [module] 31 | ---*/ 32 | 33 | export default unresolvable; 34 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-export-var.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Binding is created and initialized to `undefined` for exported `var` 6 | declarations 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 17. For each element d in lexDeclarations do 11 | a. For each element dn of the BoundNames of d do 12 | i. If IsConstantDeclaration of d is true, then 13 | [...] 14 | ii. Else, 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | [...] 17 | includes: [fnGlobalObject.js] 18 | flags: [module] 19 | ---*/ 20 | 21 | var global = fnGlobalObject(); 22 | 23 | assert.sameValue(test262, undefined, 'initialized value'); 24 | assert.sameValue( 25 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 26 | ); 27 | 28 | test262 = null; 29 | 30 | assert.sameValue(test262, null, 'binding is mutable'); 31 | 32 | export var test262 = 23; 33 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-export-fun.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Binding is created and initialized to `undefined` for exported function 6 | declarations 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 17. For each element d in lexDeclarations do 11 | a. For each element dn of the BoundNames of d do 12 | i. If IsConstantDeclaration of d is true, then 13 | [...] 14 | ii. Else, 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | [...] 17 | includes: [fnGlobalObject.js] 18 | flags: [module] 19 | ---*/ 20 | 21 | var global = fnGlobalObject(); 22 | 23 | assert.sameValue(test262(), 23, 'initialized value'); 24 | assert.sameValue( 25 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 26 | ); 27 | 28 | test262 = null; 29 | 30 | assert.sameValue(test262, null, 'binding is mutable'); 31 | 32 | export function test262() { return 23; } 33 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/testBigIntTypedArray.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 André Bargull. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | Collection of functions used to assert the correctness of BigInt TypedArray objects. 6 | ---*/ 7 | 8 | /** 9 | * The %TypedArray% intrinsic constructor function. 10 | */ 11 | var TypedArray = Object.getPrototypeOf(Int8Array); 12 | 13 | /** 14 | * Calls the provided function for every typed array constructor. 15 | * 16 | * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. 17 | */ 18 | function testWithBigIntTypedArrayConstructors(f) { 19 | /** 20 | * Array containing every BigInt typed array constructor. 21 | */ 22 | var constructors = [ 23 | BigInt64Array, 24 | BigUint64Array 25 | ]; 26 | 27 | for (var i = 0; i < constructors.length; ++i) { 28 | var constructor = constructors[i]; 29 | try { 30 | f(constructor); 31 | } catch (e) { 32 | e.message += " (Testing with " + constructor.name + ".)"; 33 | throw e; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-err-dflt-thru-star.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: IndirectExportEntries validation - default not found (excluding *) 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do 9 | a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). 10 | b. If resolution is null or resolution is "ambiguous", throw a 11 | SyntaxError exception. 12 | [...] 13 | 14 | 15.2.1.16.3 ResolveExport 15 | 16 | [...] 17 | 6. If SameValue(exportName, "default") is true, then 18 | a. Assert: A default export was not explicitly defined by this module. 19 | b. Throw a SyntaxError exception. 20 | c. NOTE A default export cannot be provided by an export *. 21 | negative: 22 | phase: runtime 23 | type: SyntaxError 24 | flags: [module] 25 | ---*/ 26 | 27 | export { default } from './instn-iee-err-dflt-thru-star-int_FIXTURE.js'; 28 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-export-gen.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Binding is created and initialized to `undefined` for exported generator 6 | function declarations 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 17. For each element d in lexDeclarations do 11 | a. For each element dn of the BoundNames of d do 12 | i. If IsConstantDeclaration of d is true, then 13 | [...] 14 | ii. Else, 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | [...] 17 | includes: [fnGlobalObject.js] 18 | flags: [module] 19 | ---*/ 20 | 21 | var global = fnGlobalObject(); 22 | 23 | assert.sameValue(test262().next().value, 23, 'initialized value'); 24 | assert.sameValue( 25 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 26 | ); 27 | 28 | test262 = null; 29 | 30 | assert.sameValue(test262, null, 'binding is mutable'); 31 | 32 | export function* test262() { return 23; } 33 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-err-dflt-thru-star-as.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: IndirectExportEntries validation - default not found (excluding *) 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do 9 | a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). 10 | b. If resolution is null or resolution is "ambiguous", throw a 11 | SyntaxError exception. 12 | [...] 13 | 14 | 15.2.1.16.3 ResolveExport 15 | 16 | [...] 17 | 6. If SameValue(exportName, "default") is true, then 18 | a. Assert: A default export was not explicitly defined by this module. 19 | b. Throw a SyntaxError exception. 20 | c. NOTE A default export cannot be provided by an export *. 21 | negative: 22 | phase: runtime 23 | type: SyntaxError 24 | flags: [module] 25 | ---*/ 26 | 27 | export { default as x } from './instn-iee-err-dflt-thru-star-int_FIXTURE.js'; 28 | -------------------------------------------------------------------------------- /lib/parse-error.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const errorRe = /^[\w\d]+(:.*)?(?:(\r?\n\s+at.*)+|\r?\n$)/m; 4 | const errorPropsRe = /^([\w\d]+)(: (.*))?\r?\n/; 5 | const frameRe = /^\s+at(.*)\(?(.*):(\d+):(\d+(?:-\d+)?)\)?/; 6 | 7 | exports.parse = parse; 8 | exports.parseStack = parseStack; 9 | 10 | function parse(str) { 11 | let match = str.match(errorRe); 12 | 13 | if (!match) return null; 14 | 15 | 16 | const errorStr = match[0]; 17 | match = errorStr.match(errorPropsRe); 18 | if (!match) return null; 19 | 20 | return { 21 | name: match[1], 22 | message: match[3], 23 | stack: parseStack(errorStr.slice(match[0].length)) 24 | }; 25 | } 26 | 27 | function parseStack(stackStr) { 28 | const stack = []; 29 | 30 | const lines = stackStr.split(/\r?\n/g); 31 | lines.forEach(entry => { 32 | const match = entry.match(frameRe); 33 | if (match === null) { 34 | return; 35 | } 36 | 37 | stack.push({ 38 | source: entry, 39 | functionName: match[1].trim(), 40 | fileName: match[2], 41 | lineNumber: Number(match[3]), 42 | columnNumber: Number(match[4]) 43 | }); 44 | }); 45 | 46 | return stack; 47 | } 48 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eshost", 3 | "version": "9.0.0", 4 | "description": "Invoke ECMAScript scripts in any command line JS engine.", 5 | "main": "lib/eshost.js", 6 | "scripts": { 7 | "build:env": "./node_modules/.bin/esvu", 8 | "test": "jest --runInBand --config=./jest.config.js", 9 | "lint": "eslint lib/* bin/* test/*.js" 10 | }, 11 | "author": "Brian Terlson", 12 | "license": "MIT", 13 | "devDependencies": { 14 | "common-tags": "^1.8.0", 15 | "eslint": "^7.17.0", 16 | "esvu": "^1.2.3", 17 | "hasbin": "^1.2.3", 18 | "jasmine": "^3.7.0", 19 | "jest": "^26.6.3", 20 | "mocha": "^2.3.4", 21 | "prettier": "^2.2.1", 22 | "sinon": "^6.1.3", 23 | "test262-stream": "^1.3.0" 24 | }, 25 | "repository": { 26 | "type": "git", 27 | "url": "https://github.com/bterlson/eshost" 28 | }, 29 | "dependencies": { 30 | "error-stack-parser": "^1.3.3", 31 | "is-symlink": "^0.1.1", 32 | "recast": "^0.17.5", 33 | "selenium-webdriver": "^4.0.0-alpha.1", 34 | "server-destroy": "^1.0.1", 35 | "socket.io": "^2.3.0", 36 | "unique-temp-dir": "^1.0.0" 37 | }, 38 | "homepage": "https://github.com/bterlson/eshost" 39 | } 40 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/nativeFunctionMatcher.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Assert _NativeFunction_ Syntax 5 | info: | 6 | This regex makes a best-effort determination that the tested string matches 7 | the NativeFunction grammar production without requiring a correct tokeniser. 8 | 9 | NativeFunction : 10 | function _IdentifierName_ opt ( _FormalParameters_ ) { [ native code ] } 11 | 12 | ---*/ 13 | const NATIVE_FUNCTION_RE = /\bfunction\b[\s\S]*\([\s\S]*\)[\s\S]*\{[\s\S]*\[[\s\S]*\bnative\b[\s\S]+\bcode\b[\s\S]*\][\s\S]*\}/; 14 | 15 | const assertToStringOrNativeFunction = function(fn, expected) { 16 | const actual = "" + fn; 17 | try { 18 | assert.sameValue(actual, expected); 19 | } catch (unused) { 20 | assertNativeFunction(fn, expected); 21 | } 22 | }; 23 | 24 | const assertNativeFunction = function(fn, special) { 25 | const actual = "" + fn; 26 | assert( 27 | NATIVE_FUNCTION_RE.test(actual), 28 | "Conforms to NativeFunction Syntax: '" + actual + "'." + (special ? "(" + special + ")" : "") 29 | ); 30 | }; 31 | -------------------------------------------------------------------------------- /lib/eshost.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const { 4 | getDependencies, 5 | hasModuleSpecifier, 6 | rawSource 7 | } = require('./dependencies'); 8 | const writeSources = require('./write-sources'); 9 | const {supportedHosts, supportedHostsMap} = require('./supported-hosts'); 10 | const normalizeHostForVU = hostType => supportedHostsMap[hostType] || hostType; 11 | 12 | exports.createAgent = function(type, options) { 13 | const hostType = normalizeHostForVU(type); 14 | const reqPath = `./agents/${hostType}.js`; 15 | 16 | try { 17 | const Agent = require(reqPath); 18 | const a = new Agent(options); 19 | return a.initialize(); 20 | } catch (error) { 21 | if (error.message.indexOf(`Cannot find module '${reqPath}'`) > -1) { 22 | throw new Error(`Agent for '${hostType}' not supported. Supported host type names are '${supportedHosts.join(', ')}'`); 23 | } else { 24 | throw error; 25 | } 26 | } 27 | }; 28 | 29 | exports.supportedHosts = supportedHosts; 30 | exports.normalizeHostForVU = normalizeHostForVU; 31 | 32 | exports.source = { 33 | getDependencies, 34 | hasModuleSpecifier, 35 | writeSources, 36 | getSource(fileName) { 37 | return rawSource.get(fileName); 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-binding.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Immutable binding is created for module namespace object 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 9 | a. Let importedModule be ? HostResolveImportedModule(module, 10 | in.[[ModuleRequest]]). 11 | b. If in.[[ImportName]] is "*", then 12 | i. Let namespace be ? GetModuleNamespace(importedModule). 13 | ii. Perform ! envRec.CreateImmutableBinding(in.[[LocalName]], true). 14 | iii. Call envRec.InitializeBinding(in.[[LocalName]], namespace). 15 | [...] 16 | flags: [module] 17 | ---*/ 18 | 19 | assert.sameValue( 20 | typeof ns, 'object', 'binding is initialized prior to module evaluation' 21 | ); 22 | 23 | var original = ns; 24 | 25 | assert.throws(TypeError, function() { 26 | ns = null; 27 | }, 'binding rejects assignment'); 28 | 29 | assert.sameValue(ns, original, 'binding value is immutable'); 30 | 31 | import * as ns from './instn-star-binding.js'; 32 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-err-not-found.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Importing a namespace for a module which contains an unresolvable named 6 | export 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 11 | a. Let importedModule be ? HostResolveImportedModule(module, 12 | in.[[ModuleRequest]]). 13 | b. If in.[[ImportName]] is "*", then 14 | i. Let namespace be ? GetModuleNamespace(importedModule). 15 | [...] 16 | 17 | 15.2.1.18 Runtime Semantics: GetModuleNamespace 18 | 19 | [...] 20 | 3. If namespace is undefined, then 21 | [...] 22 | c. For each name that is an element of exportedNames, 23 | i. Let resolution be ? module.ResolveExport(name, « », « »). 24 | ii. If resolution is null, throw a SyntaxError exception. 25 | negative: 26 | phase: runtime 27 | type: SyntaxError 28 | flags: [module] 29 | ---*/ 30 | 31 | import * as ns from './instn-star-err-not-found-faulty_FIXTURE.js'; 32 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/compareIterator.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Peter Wong. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Compare the values of an iterator with an array of expected values 5 | ---*/ 6 | 7 | // Example: 8 | // 9 | // function* numbers() { 10 | // yield 1; 11 | // yield 2; 12 | // yield 3; 13 | // } 14 | // 15 | // compareIterator(numbers(), [ 16 | // v => assert.sameValue(v, 1), 17 | // v => assert.sameValue(v, 2), 18 | // v => assert.sameValue(v, 3), 19 | // ]); 20 | // 21 | assert.compareIterator = function(iter, validators, message) { 22 | message = message || ''; 23 | 24 | var i, result; 25 | for (i = 0; i < validators.length; i++) { 26 | result = iter.next(); 27 | assert(!result.done, 'Expected ' + i + ' values(s). Instead iterator only produced ' + (i - 1) + ' value(s). ' + message); 28 | validators[i](result.value); 29 | } 30 | 31 | result = iter.next(); 32 | assert(result.done, 'Expected only ' + i + ' values(s). Instead iterator produced more. ' + message); 33 | assert.sameValue(result.value, undefined, 'Expected value of `undefined` when iterator completes. ' + message); 34 | } 35 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/early-import-eval.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: ImportedBinding is a BindingIdentifier and cannot be "eval" 5 | esid: sec-imports 6 | info: | 7 | ImportSpecifier : 8 | ImportedBinding 9 | IdentifierName as ImportedBinding 10 | 11 | ImportedBinding : 12 | BindingIdentifier 13 | 14 | 12.1.1 Static Semantics : Early Errors 15 | 16 | BindingIdentifier : Identifier 17 | 18 | - It is a Syntax Error if the code matched by this production is contained 19 | in strict mode code and the StringValue of Identifier is "arguments" or 20 | "eval". 21 | negative: 22 | phase: parse 23 | type: SyntaxError 24 | flags: [module] 25 | ---*/ 26 | 27 | throw "Test262: This statement should not be evaluated."; 28 | 29 | // Create an appropriately-named ExportEntry in order to avoid false positives 30 | // (e.g. cases where the implementation does not generate the expected early 31 | // error but does produce a SyntaxError for unresolvable bindings). 32 | var x; 33 | export { x as eval }; 34 | 35 | import { eval } from './early-import-eval.js'; 36 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/early-import-as-eval.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: ImportedBinding is a BindingIdentifier and cannot be "eval" 5 | esid: sec-imports 6 | info: | 7 | ImportSpecifier : 8 | ImportedBinding 9 | IdentifierName as ImportedBinding 10 | 11 | ImportedBinding : 12 | BindingIdentifier 13 | 14 | 12.1.1 Static Semantics : Early Errors 15 | 16 | BindingIdentifier : Identifier 17 | 18 | - It is a Syntax Error if the code matched by this production is contained 19 | in strict mode code and the StringValue of Identifier is "arguments" or 20 | "eval". 21 | negative: 22 | phase: parse 23 | type: SyntaxError 24 | flags: [module] 25 | ---*/ 26 | 27 | throw "Test262: This statement should not be evaluated."; 28 | 29 | // Create an appropriately-named ExportEntry in order to avoid false positives 30 | // (e.g. cases where the implementation does not generate the expected early 31 | // error but does produce a SyntaxError for unresolvable bindings). 32 | var x; 33 | export { x }; 34 | 35 | import { x as eval } from './early-import-as-eval.js'; 36 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-not-found-dflt.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Named import binding - resolution failure (not found) 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 9 | a. Let importedModule be ? HostResolveImportedModule(module, 10 | in.[[ModuleRequest]]). 11 | b. If in.[[ImportName]] is "*", then 12 | [...] 13 | c. Else, 14 | i. Let resolution be ? 15 | importedModule.ResolveExport(in.[[ImportName]], « », « »). 16 | ii. If resolution is null or resolution is "ambiguous", throw a 17 | SyntaxError exception. 18 | 19 | 15.2.1.16.3 ResolveExport 20 | 21 | [...] 22 | 9. Let starResolution be null. 23 | 10. For each ExportEntry Record e in module.[[StarExportEntries]], do 24 | [...] 25 | 11. Return starResolution. 26 | negative: 27 | phase: runtime 28 | type: SyntaxError 29 | flags: [module] 30 | ---*/ 31 | 32 | import x from './instn-named-err-not-found-empty_FIXTURE.js'; 33 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-not-found.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Named import binding - resolution failure (not found) 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 9 | a. Let importedModule be ? HostResolveImportedModule(module, 10 | in.[[ModuleRequest]]). 11 | b. If in.[[ImportName]] is "*", then 12 | [...] 13 | c. Else, 14 | i. Let resolution be ? 15 | importedModule.ResolveExport(in.[[ImportName]], « », « »). 16 | ii. If resolution is null or resolution is "ambiguous", throw a 17 | SyntaxError exception. 18 | 19 | 15.2.1.16.3 ResolveExport 20 | 21 | [...] 22 | 9. Let starResolution be null. 23 | 10. For each ExportEntry Record e in module.[[StarExportEntries]], do 24 | [...] 25 | 11. Return starResolution. 26 | negative: 27 | phase: runtime 28 | type: SyntaxError 29 | flags: [module] 30 | ---*/ 31 | 32 | import { x } from './instn-named-err-not-found-empty_FIXTURE.js'; 33 | -------------------------------------------------------------------------------- /lib/supported-hosts.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | const agents = fs.readdirSync(path.join(__dirname, "agents")); 4 | const hostAgents = agents.reduce((accum, agent) => { 5 | const host = agent.slice(0, -3); 6 | accum[host] = host; 7 | return accum; 8 | }, {}); 9 | 10 | // Inline commented hosts are here to document the 11 | // hosts that are created by scanning the ./agents 12 | // directory. 13 | const supportedHostsMap = Object.assign({ 14 | /* Shells */ 15 | // chakra: 'chakra', 16 | ch: 'chakra', 17 | engine262: 'engine262', 18 | // graaljs: 'graaljs', 19 | javascriptcore: 'jsc', 20 | // jsc: 'jsc', 21 | // jsshell: 'jsshell', 22 | // libjs: 'libjs', 23 | 'serenity-js': 'libjs', 24 | // nashorn: 'nashorn', 25 | // node: 'node', 26 | // qjs: 'qjs', 27 | sm: 'jsshell', 28 | spidermonkey: 'jsshell', 29 | // d8: 'd8', 30 | v8: 'd8', 31 | // xs: 'xs', 32 | graaljs: 'graaljs', 33 | 34 | /* Browsers */ 35 | // chrome: 'chrome', 36 | // edge: 'edge', 37 | // firefox: 'firefox', 38 | // remote: 'remote', 39 | // safari: 'safari', 40 | }, hostAgents); 41 | 42 | const supportedHosts = Object.keys(supportedHostsMap); 43 | 44 | module.exports = { 45 | supportedHostsMap, 46 | supportedHosts, 47 | }; 48 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-not-found-as.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Named import binding - resolution failure (not found) 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 9 | a. Let importedModule be ? HostResolveImportedModule(module, 10 | in.[[ModuleRequest]]). 11 | b. If in.[[ImportName]] is "*", then 12 | [...] 13 | c. Else, 14 | i. Let resolution be ? 15 | importedModule.ResolveExport(in.[[ImportName]], « », « »). 16 | ii. If resolution is null or resolution is "ambiguous", throw a 17 | SyntaxError exception. 18 | 19 | 15.2.1.16.3 ResolveExport 20 | 21 | [...] 22 | 9. Let starResolution be null. 23 | 10. For each ExportEntry Record e in module.[[StarExportEntries]], do 24 | [...] 25 | 11. Return starResolution. 26 | negative: 27 | phase: runtime 28 | type: SyntaxError 29 | flags: [module] 30 | ---*/ 31 | 32 | import { x as y } from './instn-named-err-not-found-empty_FIXTURE.js'; 33 | -------------------------------------------------------------------------------- /runtimes/xs.js: -------------------------------------------------------------------------------- 1 | var $262 = globalThis.$262; 2 | 3 | if (!$262) { 4 | $262 = { 5 | global: globalThis, 6 | createRealm() { 7 | throw new Test262Error('createRealm() not yet supported.'); 8 | }, 9 | evalScript(code) { 10 | try { 11 | global.evalScript(code); 12 | return { type: 'normal', value: undefined }; 13 | } catch (e) { 14 | return { type: 'throw', value: e }; 15 | } 16 | }, 17 | gc() { 18 | throw new Test262Error('gc() not yet supported.'); 19 | }, 20 | getGlobal(name) { 21 | return global[name]; 22 | }, 23 | setGlobal(name, value) { 24 | global[name] = value; 25 | }, 26 | agent: (function() { 27 | function thrower() { 28 | throw new Test262Error('agent.* not yet supported.'); 29 | } 30 | return { 31 | start: thrower, 32 | broadcast: thrower, 33 | getReport: thrower, 34 | sleep: thrower, 35 | monotonicNow: thrower, 36 | }; 37 | })(), 38 | }; 39 | } 40 | $262.IsHTMLDDA = function() {}; 41 | $262.destroy = function() {}; 42 | $262.getGlobal = function(name) { 43 | return this.global[name]; 44 | }; 45 | $262.setGlobal = function(name, value) { 46 | this.global[name] = value; 47 | }; 48 | $262.source = $SOURCE; 49 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-once.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Requested modules are evaluated exactly once 5 | esid: sec-moduleevaluation 6 | info: | 7 | [...] 8 | 4. If module.[[Evaluated]] is true, return undefined. 9 | 5. Set module.[[Evaluated]] to true. 10 | 6. For each String required that is an element of module.[[RequestedModules]] do, 11 | a. Let requiredModule be ? HostResolveImportedModule(module, required). 12 | b. Perform ? requiredModule.ModuleEvaluation(). 13 | [...] 14 | includes: [fnGlobalObject.js] 15 | flags: [module] 16 | ---*/ 17 | 18 | import {} from './eval-rqstd-once_FIXTURE.js'; 19 | import './eval-rqstd-once_FIXTURE.js'; 20 | import * as ns1 from './eval-rqstd-once_FIXTURE.js'; 21 | import dflt1 from './eval-rqstd-once_FIXTURE.js'; 22 | export {} from './eval-rqstd-once_FIXTURE.js'; 23 | import dflt2, {} from './eval-rqstd-once_FIXTURE.js'; 24 | export * from './eval-rqstd-once_FIXTURE.js'; 25 | import dflt3, * as ns from './eval-rqstd-once_FIXTURE.js'; 26 | export default null; 27 | 28 | var global = fnGlobalObject(); 29 | 30 | assert.sameValue(global.test262, 262, 'global property was defined'); 31 | -------------------------------------------------------------------------------- /runtimes/qjs.js: -------------------------------------------------------------------------------- 1 | /* run-test262 exposes a $262 object, so we need to redfine it for safe shortName mapping */ 2 | const qjs = globalThis["\x24262"]; 3 | const DollarCreateRealm = qjs.createRealm; 4 | const DollarEvalScript = qjs.evalScript.bind(qjs); 5 | 6 | var $262 = Object.assign({}, qjs); 7 | $262.source = $SOURCE; 8 | $262.destroy = function() {}; 9 | $262.gc = function() { 10 | throw new Test262Error('gc() not yet supported.'); 11 | }; 12 | $262.getGlobal = function(name) { 13 | return this.global[name]; 14 | }; 15 | $262.setGlobal = function(name, value) { 16 | this.global[name] = value; 17 | }; 18 | $262.evalScript = function(code) { 19 | try { 20 | DollarEvalScript(code); 21 | return { type: 'normal', value: undefined }; 22 | } catch (e) { 23 | return { type: 'throw', value: e }; 24 | } 25 | }; 26 | $262.createRealm = function (options = {}) { 27 | const realm = DollarCreateRealm(options); 28 | realm.evalScript($262.source); 29 | realm.source = $262.source; 30 | realm.getGlobal = $262.getGlobal; 31 | realm.setGlobal = $262.setGlobal; 32 | realm.destroy = () => { 33 | if (options.destroy) { 34 | options.destroy(); 35 | } 36 | }; 37 | const globals = options.globals || {}; 38 | for (let glob in globals) { 39 | realm.global[glob] = globals[glob]; 40 | } 41 | return realm; 42 | }; 43 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/dynamic-import-returns-promise.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Dynamic import() returns a Promise object. (top level dynamic import call) 5 | esid: sec-import-call-runtime-semantics-evaluation 6 | features: [dynamic-import] 7 | flags: [generated, async] 8 | info: | 9 | ImportCall : 10 | import( AssignmentExpression ) 11 | 12 | 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). 13 | 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). 14 | 3. Let argRef be the result of evaluating AssignmentExpression. 15 | 4. Let specifier be ? GetValue(argRef). 16 | 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). 17 | 6. Let specifierString be ToString(specifier). 18 | 7. IfAbruptRejectPromise(specifierString, promiseCapability). 19 | 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). 20 | 9. Return promiseCapability.[[Promise]]. 21 | 22 | ---*/ 23 | 24 | import('./dynamic-import-returns-promise_FIXTURE.js').then(exported => { 25 | 26 | assert.sameValue(exported.x, 1); 27 | 28 | }).then($DONE, $DONE); 29 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-gtbndng-indirect-update.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Modifications to named bindings that occur after dependency has been 6 | evaluated are reflected in local binding 7 | esid: sec-moduleevaluation 8 | info: | 9 | 8.1.1.5.1 GetBindingValue (N, S) 10 | 11 | [...] 12 | 3. If the binding for N is an indirect binding, then 13 | a. Let M and N2 be the indirection values provided when this binding for 14 | N was created. 15 | b. Let targetEnv be M.[[Environment]]. 16 | c. If targetEnv is undefined, throw a ReferenceError exception. 17 | d. Let targetER be targetEnv's EnvironmentRecord. 18 | e. Return ? targetER.GetBindingValue(N2, S). 19 | includes: [fnGlobalObject.js] 20 | flags: [module] 21 | ---*/ 22 | 23 | import { x } from './eval-gtbndng-indirect-update_FIXTURE.js'; 24 | 25 | assert.sameValue(x, 1); 26 | 27 | // This function is exposed on the global scope (instead of as an exported 28 | // binding) in order to avoid possible false positives from assuming correct 29 | // behavior of the semantics under test. 30 | fnGlobalObject().test262update(); 31 | 32 | assert.sameValue(x, 2); 33 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-export-dflt-expr-fn-anon.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Default AssignmentExpression (which can be recognized as an "anonymous" 6 | function declaration) is correctly initialized upon evaluation 7 | esid: sec-moduleevaluation 8 | info: | 9 | [...] 10 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 11 | [...] 12 | 13 | 15.2.3.11 Runtime Semantics: Evaluation 14 | 15 | ExportDeclaration : export default AssignmentExpression; 16 | 17 | [...] 18 | 3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then 19 | a. Let hasNameProperty be ? HasOwnProperty(value, "name"). 20 | b. If hasNameProperty is false, perform SetFunctionName(value, 21 | "default"). 22 | 4. Let env be the running execution context's LexicalEnvironment. 23 | 5. Perform ? InitializeBoundName("*default*", value, env). 24 | [...] 25 | flags: [module] 26 | ---*/ 27 | 28 | export default (function() { return 99; }); 29 | import f from './eval-export-dflt-expr-fn-anon.js'; 30 | 31 | assert.sameValue(f(), 99, 'binding initialized'); 32 | assert.sameValue(f.name, 'default', 'correct name is assigned'); 33 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-export-dflt-expr-fn-named.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Default AssignmentExpression (which can be recognized as a "named" function 6 | declaration) is correctly initialized upon evaluation 7 | esid: sec-moduleevaluation 8 | info: | 9 | [...] 10 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 11 | [...] 12 | 13 | 15.2.3.11 Runtime Semantics: Evaluation 14 | 15 | ExportDeclaration : export default AssignmentExpression; 16 | 17 | [...] 18 | 3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then 19 | a. Let hasNameProperty be ? HasOwnProperty(value, "name"). 20 | b. If hasNameProperty is false, perform SetFunctionName(value, 21 | "default"). 22 | 4. Let env be the running execution context's LexicalEnvironment. 23 | 5. Perform ? InitializeBoundName("*default*", value, env). 24 | [...] 25 | flags: [module] 26 | ---*/ 27 | 28 | export default (function fName() { return 7; }); 29 | import f from './eval-export-dflt-expr-fn-named.js'; 30 | 31 | assert.sameValue(f(), 7, 'binding initialized'); 32 | assert.sameValue(f.name, 'fName', 'correct name is assigned'); 33 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-rqstd-order.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Requested modules are evaluated prior to the requesting module in source 6 | code order 7 | esid: sec-moduleevaluation 8 | info: | 9 | [...] 10 | 6. For each String required that is an element of 11 | module.[[RequestedModules]] do, 12 | a. Let requiredModule be ? HostResolveImportedModule(module, required). 13 | b. Perform ? requiredModule.ModuleEvaluation(). 14 | [...] 15 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 16 | [...] 17 | includes: [fnGlobalObject.js] 18 | flags: [module] 19 | ---*/ 20 | 21 | assert.sameValue(fnGlobalObject().test262, '12345678'); 22 | 23 | import {} from './eval-rqstd-order-1_FIXTURE.js'; 24 | 25 | import './eval-rqstd-order-2_FIXTURE.js'; 26 | 27 | import * as ns1 from './eval-rqstd-order-3_FIXTURE.js'; 28 | 29 | import dflt1 from './eval-rqstd-order-4_FIXTURE.js'; 30 | 31 | export {} from './eval-rqstd-order-5_FIXTURE.js'; 32 | 33 | import dflt2, {} from './eval-rqstd-order-6_FIXTURE.js'; 34 | 35 | export * from './eval-rqstd-order-7_FIXTURE.js'; 36 | 37 | import dflt3, * as ns from './eval-rqstd-order-8_FIXTURE.js'; 38 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-self-once.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Module is evaluated exactly once 5 | esid: sec-moduleevaluation 6 | info: | 7 | [...] 8 | 4. If module.[[Evaluated]] is true, return undefined. 9 | 5. Set module.[[Evaluated]] to true. 10 | 6. For each String required that is an element of module.[[RequestedModules]] do, 11 | a. Let requiredModule be ? HostResolveImportedModule(module, required). 12 | b. Perform ? requiredModule.ModuleEvaluation(). 13 | [...] 14 | includes: [fnGlobalObject.js] 15 | flags: [module] 16 | ---*/ 17 | 18 | import {} from './eval-self-once.js'; 19 | import './eval-self-once.js'; 20 | import * as ns1 from './eval-self-once.js'; 21 | import dflt1 from './eval-self-once.js'; 22 | export {} from './eval-self-once.js'; 23 | import dflt2, {} from './eval-self-once.js'; 24 | export * from './eval-self-once.js'; 25 | import dflt3, * as ns from './eval-self-once.js'; 26 | export default null; 27 | 28 | var global = fnGlobalObject(); 29 | 30 | assert.sameValue(global.test262, undefined, 'global property initially unset'); 31 | 32 | global.test262 = 262; 33 | 34 | assert.sameValue(global.test262, 262, 'global property was defined'); 35 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-dflt-thru-star-dflt.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Named import binding - default not found (excluding *) 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 9 | a. Let importedModule be ? HostResolveImportedModule(module, 10 | in.[[ModuleRequest]]). 11 | b. If in.[[ImportName]] is "*", then 12 | [...] 13 | c. Else, 14 | i. Let resolution be ? 15 | importedModule.ResolveExport(in.[[ImportName]], « », « »). 16 | ii. If resolution is null or resolution is "ambiguous", throw a 17 | SyntaxError exception. 18 | 19 | 15.2.1.16.3 ResolveExport 20 | 21 | [...] 22 | 6. If SameValue(exportName, "default") is true, then 23 | a. Assert: A default export was not explicitly defined by this module. 24 | b. Throw a SyntaxError exception. 25 | c. NOTE A default export cannot be provided by an export *. 26 | negative: 27 | phase: runtime 28 | type: SyntaxError 29 | flags: [module] 30 | ---*/ 31 | 32 | import x from './instn-named-err-dflt-thru-star-int_FIXTURE.js'; 33 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-export-dflt-expr-cls-anon.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Default AssignmentExpression (which can be recognized as an "anonymous" 6 | class declaration) is correctly initialized upon evaluation 7 | esid: sec-moduleevaluation 8 | info: | 9 | [...] 10 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 11 | [...] 12 | 13 | 15.2.3.11 Runtime Semantics: Evaluation 14 | 15 | ExportDeclaration : export default AssignmentExpression; 16 | 17 | [...] 18 | 3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then 19 | a. Let hasNameProperty be ? HasOwnProperty(value, "name"). 20 | b. If hasNameProperty is false, perform SetFunctionName(value, 21 | "default"). 22 | 4. Let env be the running execution context's LexicalEnvironment. 23 | 5. Perform ? InitializeBoundName("*default*", value, env). 24 | [...] 25 | flags: [module] 26 | ---*/ 27 | 28 | export default (class { valueOf() { return 45; } }); 29 | import C from './eval-export-dflt-expr-cls-anon.js'; 30 | 31 | assert.sameValue(new C().valueOf(), 45, 'binding initialized'); 32 | assert.sameValue(C.name, 'default', 'correct name is assigned'); 33 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-export-dflt-expr-cls-named.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Default AssignmentExpression (which can be recognized as a "named" class 6 | declaration) is correctly initialized upon evaluation 7 | esid: sec-moduleevaluation 8 | info: | 9 | [...] 10 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 11 | [...] 12 | 13 | 15.2.3.11 Runtime Semantics: Evaluation 14 | 15 | ExportDeclaration : export default AssignmentExpression; 16 | 17 | [...] 18 | 3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then 19 | a. Let hasNameProperty be ? HasOwnProperty(value, "name"). 20 | b. If hasNameProperty is false, perform SetFunctionName(value, 21 | "default"). 22 | 4. Let env be the running execution context's LexicalEnvironment. 23 | 5. Perform ? InitializeBoundName("*default*", value, env). 24 | [...] 25 | flags: [module] 26 | ---*/ 27 | 28 | export default (class cName { valueOf() { return 45; } }); 29 | import C from './eval-export-dflt-expr-cls-named.js'; 30 | 31 | assert.sameValue(new C().valueOf(), 45, 'binding initialized'); 32 | assert.sameValue(C.name, 'cName', 'correct name is assigned'); 33 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-dflt-thru-star-as.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Named import binding - default not found (excluding *) 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 9 | a. Let importedModule be ? HostResolveImportedModule(module, 10 | in.[[ModuleRequest]]). 11 | b. If in.[[ImportName]] is "*", then 12 | [...] 13 | c. Else, 14 | i. Let resolution be ? 15 | importedModule.ResolveExport(in.[[ImportName]], « », « »). 16 | ii. If resolution is null or resolution is "ambiguous", throw a 17 | SyntaxError exception. 18 | 19 | 15.2.1.16.3 ResolveExport 20 | 21 | [...] 22 | 6. If SameValue(exportName, "default") is true, then 23 | a. Assert: A default export was not explicitly defined by this module. 24 | b. Throw a SyntaxError exception. 25 | c. NOTE A default export cannot be provided by an export *. 26 | negative: 27 | phase: runtime 28 | type: SyntaxError 29 | flags: [module] 30 | ---*/ 31 | 32 | import { default as x } from './instn-named-err-dflt-thru-star-int_FIXTURE.js'; 33 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-dflt-keep-indirect.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Indirect default exports are included in the module namespace object 6 | esid: sec-moduledeclarationinstantiation 7 | info: | 8 | [...] 9 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 10 | a. Let importedModule be ? HostResolveImportedModule(module, 11 | in.[[ModuleRequest]]). 12 | b. If in.[[ImportName]] is "*", then 13 | i. Let namespace be ? GetModuleNamespace(importedModule). 14 | [...] 15 | 16 | 15.2.1.18 Runtime Semantics: GetModuleNamespace 17 | 18 | [...] 19 | 3. If namespace is undefined, then 20 | a. Let exportedNames be ? module.GetExportedNames(« »). 21 | [...] 22 | 23 | 15.2.1.16.2 GetExportedNames 24 | 25 | [...] 26 | 6. For each ExportEntry Record e in module.[[IndirectExportEntries]], do 27 | a. Assert: module imports a specific binding for this export. 28 | b. Append e.[[ExportName]] to exportedNames. 29 | [...] 30 | flags: [module] 31 | ---*/ 32 | 33 | import * as ns from './instn-star-props-dflt-keep-indirect-reexport_FIXTURE.js'; 34 | 35 | assert.sameValue('default' in ns, true); 36 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-export-dflt-cls-anon.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Default "anonymous" class declaration is correctly initialized upon 6 | evaluation 7 | esid: sec-moduleevaluation 8 | info: | 9 | [...] 10 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 11 | [...] 12 | 13 | 15.2.3.11 Runtime Semantics: Evaluation 14 | 15 | ExportDeclaration : export default ClassDeclaration 16 | 17 | [...] 18 | 3. Let className be the sole element of BoundNames of ClassDeclaration. 19 | 4. If className is "*default*", then 20 | a. Let hasNameProperty be ? HasOwnProperty(value, "name"). 21 | b. If hasNameProperty is false, perform SetFunctionName(value, 22 | "default"). 23 | c. Let env be the running execution context's LexicalEnvironment. 24 | d. Perform ? InitializeBoundName("*default*", value, env). 25 | 5. Return NormalCompletion(empty). 26 | flags: [module] 27 | ---*/ 28 | 29 | export default class { valueOf() { return 45; } } 30 | import C from './eval-export-dflt-cls-anon.js'; 31 | 32 | assert.sameValue(new C().valueOf(), 45, 'binding initialized'); 33 | assert.sameValue(C.name, 'default', 'correct name is assigned'); 34 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-export-dflt-cls-named.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Default "named" class declaration is correctly initialized upon 6 | evaluation 7 | esid: sec-moduleevaluation 8 | info: | 9 | [...] 10 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 11 | [...] 12 | 13 | 15.2.3.11 Runtime Semantics: Evaluation 14 | 15 | ExportDeclaration : export default ClassDeclaration 16 | 17 | [...] 18 | 3. Let className be the sole element of BoundNames of ClassDeclaration. 19 | 4. If className is "*default*", then 20 | a. Let hasNameProperty be ? HasOwnProperty(value, "name"). 21 | b. If hasNameProperty is false, perform SetFunctionName(value, 22 | "default"). 23 | c. Let env be the running execution context's LexicalEnvironment. 24 | d. Perform ? InitializeBoundName("*default*", value, env). 25 | 5. Return NormalCompletion(empty). 26 | flags: [module] 27 | ---*/ 28 | 29 | export default class cName { valueOf() { return 45; } } 30 | import C from './eval-export-dflt-cls-named.js'; 31 | 32 | assert.sameValue(new C().valueOf(), 45, 'binding initialized'); 33 | assert.sameValue(C.name, 'cName', 'correct name is assigned'); 34 | -------------------------------------------------------------------------------- /lib/agents/chakra.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const runtimePath = require('../runtime-path'); 5 | const ConsoleAgent = require('../ConsoleAgent'); 6 | 7 | class ChakraAgent extends ConsoleAgent { 8 | constructor(options) { 9 | super(options); 10 | // This is disabled until we can guarantee that 11 | // the build of ChakraCore is --test-build 12 | // this.args.push('-Test262'); 13 | } 14 | 15 | async evalScript(code, options = {}) { 16 | if (options.module && this.args[0] !== '-module') { 17 | this.args.unshift('-module'); 18 | } 19 | 20 | if (!options.module && this.args[0] === '-module') { 21 | this.args.shift(); 22 | } 23 | 24 | return super.evalScript(code, options); 25 | } 26 | 27 | parseError(str) { 28 | const error = super.parseError(str); 29 | 30 | if (!error) { return error } 31 | 32 | if (error.name === 'JavascriptError') { 33 | error.name = 'Error'; 34 | } 35 | 36 | if (error.name === 'CustomError') { 37 | const match = error.message.match(/\w+: /); 38 | if (match) { 39 | error.name = match[0].slice(0, -2); 40 | error.message = error.message.slice(match[0].length); 41 | } 42 | } 43 | 44 | return error; 45 | } 46 | } 47 | 48 | ChakraAgent.runtime = fs.readFileSync(runtimePath.for('chakra'), 'utf8'); 49 | 50 | module.exports = ChakraAgent; 51 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-export-dflt-cls-name-meth.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Default "anonymous" class declaration containing a static `name` method is 6 | correctly initialized upon evaluation 7 | esid: sec-moduleevaluation 8 | info: | 9 | [...] 10 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 11 | [...] 12 | 13 | 15.2.3.11 Runtime Semantics: Evaluation 14 | 15 | ExportDeclaration : export default ClassDeclaration 16 | 17 | [...] 18 | 3. Let className be the sole element of BoundNames of ClassDeclaration. 19 | 4. If className is "*default*", then 20 | a. Let hasNameProperty be ? HasOwnProperty(value, "name"). 21 | b. If hasNameProperty is false, perform SetFunctionName(value, 22 | "default"). 23 | c. Let env be the running execution context's LexicalEnvironment. 24 | d. Perform ? InitializeBoundName("*default*", value, env). 25 | 5. Return NormalCompletion(empty). 26 | flags: [module] 27 | ---*/ 28 | 29 | export default class { static name() { return 'name method'; } } 30 | import C from './eval-export-dflt-cls-name-meth.js'; 31 | 32 | assert.sameValue( 33 | C.name(), 'name method', '`name` property is not over-written' 34 | ); 35 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-export-dflt-expr-gen-named.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Default AssignmentExpression (which can be recognized as a "named" 6 | generator function declaration) is correctly initialized upon evaluation 7 | esid: sec-moduleevaluation 8 | info: | 9 | [...] 10 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 11 | [...] 12 | 13 | 15.2.3.11 Runtime Semantics: Evaluation 14 | 15 | ExportDeclaration : export default AssignmentExpression; 16 | 17 | [...] 18 | 3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then 19 | a. Let hasNameProperty be ? HasOwnProperty(value, "name"). 20 | b. If hasNameProperty is false, perform SetFunctionName(value, 21 | "default"). 22 | 4. Let env be the running execution context's LexicalEnvironment. 23 | 5. Perform ? InitializeBoundName("*default*", value, env). 24 | [...] 25 | flags: [module] 26 | features: [generators] 27 | ---*/ 28 | 29 | export default (function* gName() { return 88; }); 30 | import g from './eval-export-dflt-expr-gen-named.js'; 31 | 32 | assert.sameValue(g().next().value, 88, 'binding initialized'); 33 | assert.sameValue(g.name, 'gName', 'correct name is assigned'); 34 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-this.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Module Environment Records provide a this binding, and the value is 6 | `undefined`. 7 | esid: sec-moduleevaluation 8 | info: | 9 | [...] 10 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 11 | [...] 12 | 13 | 12.2.2 The this Keyword 14 | 12.2.2.1 Runtime Semantics: Evaluation 15 | 16 | PrimaryExpression : this 17 | 18 | 1. Return ? ResolveThisBinding( ). 19 | 20 | 8.3.4 ResolveThisBinding ( ) 21 | 22 | 1. Let envRec be GetThisEnvironment( ). 23 | 2. Return ? envRec.GetThisBinding(). 24 | 25 | 8.3.3 GetThisEnvironment ( ) 26 | 27 | 1. Let lex be the running execution context's LexicalEnvironment. 28 | 2. Repeat 29 | a. Let envRec be lex's EnvironmentRecord. 30 | b. Let exists be envRec.HasThisBinding(). 31 | c. If exists is true, return envRec. 32 | d. Let outer be the value of lex's outer environment reference. 33 | e. Let lex be outer. 34 | 35 | 8.1.1.5.3 HasThisBinding () 36 | 37 | 1. Return true. 38 | 39 | 8.1.1.5.4 GetThisBinding () 40 | 41 | 1. Return undefined. 42 | flags: [module] 43 | ---*/ 44 | 45 | assert.sameValue(this, undefined); 46 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-once.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Module is instantiated exactly once 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 5. If module.[[Environment]] is not undefined, return 9 | NormalCompletion(empty). 10 | 6. Let env be NewModuleEnvironment(realm.[[GlobalEnv]]). 11 | 7. Set module.[[Environment]] to env. 12 | 8. For each String required that is an element of 13 | module.[[RequestedModules]] do, 14 | a. NOTE: Before instantiating a module, all of the modules it requested 15 | must be available. An implementation may perform this test at any 16 | time prior to this point. 17 | b. Let requiredModule be ? HostResolveImportedModule(module, required). 18 | c. Perform ? requiredModule.ModuleDeclarationInstantiation(). 19 | [...] 20 | flags: [module] 21 | ---*/ 22 | 23 | import {} from './instn-once.js'; 24 | import './instn-once.js'; 25 | import * as ns1 from './instn-once.js'; 26 | import dflt1 from './instn-once.js'; 27 | export {} from './instn-once.js'; 28 | import dflt2, {} from './instn-once.js'; 29 | export * from './instn-once.js'; 30 | import dflt3, * as ns from './instn-once.js'; 31 | export default null; 32 | 33 | let x; 34 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-export-dflt-expr-gen-anon.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Default AssignmentExpression (which can be recognized as an "anonymous" 6 | generator function declaration) is correctly initialized upon evaluation 7 | esid: sec-moduleevaluation 8 | info: | 9 | [...] 10 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 11 | [...] 12 | 13 | 15.2.3.11 Runtime Semantics: Evaluation 14 | 15 | ExportDeclaration : export default AssignmentExpression; 16 | 17 | [...] 18 | 3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then 19 | a. Let hasNameProperty be ? HasOwnProperty(value, "name"). 20 | b. If hasNameProperty is false, perform SetFunctionName(value, 21 | "default"). 22 | 4. Let env be the running execution context's LexicalEnvironment. 23 | 5. Perform ? InitializeBoundName("*default*", value, env). 24 | [...] 25 | flags: [module] 26 | features: [generators] 27 | ---*/ 28 | 29 | export default (function* () { return 24601; }); 30 | import g from './eval-export-dflt-expr-gen-anon.js'; 31 | 32 | assert.sameValue(g().next().value, 24601, 'binding initialized'); 33 | assert.sameValue(g.name, 'default', 'correct name is assigned'); 34 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-gtbndng-indirect-update-as.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Modifications to named bindings that occur after dependency has been 6 | evaluated are reflected in local binding 7 | esid: sec-moduleevaluation 8 | info: | 9 | 8.1.1.5.1 GetBindingValue (N, S) 10 | 11 | [...] 12 | 3. If the binding for N is an indirect binding, then 13 | a. Let M and N2 be the indirection values provided when this binding for 14 | N was created. 15 | b. Let targetEnv be M.[[Environment]]. 16 | c. If targetEnv is undefined, throw a ReferenceError exception. 17 | d. Let targetER be targetEnv's EnvironmentRecord. 18 | e. Return ? targetER.GetBindingValue(N2, S). 19 | includes: [fnGlobalObject.js] 20 | flags: [module] 21 | ---*/ 22 | 23 | import { x as y, x as z } from './eval-gtbndng-indirect-update-as_FIXTURE.js'; 24 | 25 | assert.sameValue(y, 1); 26 | assert.sameValue(z, 1); 27 | 28 | // This function is exposed on the global scope (instead of as an exported 29 | // binding) in order to avoid possible false positives from assuming correct 30 | // behavior of the semantics under test. 31 | fnGlobalObject().test262update(); 32 | 33 | assert.sameValue(y, 2); 34 | assert.sameValue(z, 2); 35 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-empty-export.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | An ExportClause without an ExportsList contributes to the list of requested 6 | modules 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 8. For each String required that is an element of 11 | module.[[RequestedModules]] do, 12 | a. NOTE: Before instantiating a module, all of the modules it requested 13 | must be available. An implementation may perform this test at any 14 | time prior to this point. 15 | b. Let requiredModule be ? HostResolveImportedModule(module, required). 16 | c. Perform ? requiredModule.ModuleDeclarationInstantiation(). 17 | 18 | 15.2.2.5 Static Semantics: ModuleRequests 19 | 20 | ImportDeclaration : import ImportClause FromClause; 21 | 22 | 1. Return ModuleRequests of FromClause. 23 | 24 | 15.2.3 Exports 25 | 26 | Syntax 27 | 28 | ExportClause: 29 | { } 30 | { ExportsList } 31 | { ExportsList , } 32 | negative: 33 | phase: resolution 34 | type: ReferenceError 35 | flags: [module] 36 | ---*/ 37 | 38 | throw "Test262: This statement should not be evaluated."; 39 | 40 | export {} from './instn-resolve-empty-export_FIXTURE.js'; 41 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-id-name.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | The first identifier in an ImportSpecifier containing `as` may be any valid 6 | IdentifierName 7 | esid: sec-imports 8 | info: | 9 | ImportSpecifier: 10 | ImportedBinding 11 | IdentifierName as ImportedBinding 12 | flags: [module] 13 | ---*/ 14 | 15 | var _if = 1; 16 | var _import = 2; 17 | var _export = 3; 18 | var _await = 4; 19 | var _arguments = 5; 20 | var _eval = 6; 21 | var _default = 7; 22 | var _as = 8; 23 | 24 | export { 25 | _if as if, 26 | _import as import, 27 | _export as export, 28 | _await as await, 29 | _arguments as arguments, 30 | _eval as eval, 31 | _default as default, 32 | _as as as 33 | }; 34 | 35 | import { 36 | if as if_, 37 | import as import_, 38 | export as export_, 39 | await as await_, 40 | arguments as arguments_, 41 | eval as eval_, 42 | default as default_, 43 | as as as 44 | } from './instn-named-id-name.js'; 45 | 46 | assert.sameValue(if_, 1); 47 | assert.sameValue(import_, 2); 48 | assert.sameValue(export_, 3); 49 | assert.sameValue(await_, 4); 50 | assert.sameValue(arguments_, 5); 51 | assert.sameValue(eval_, 6); 52 | assert.sameValue(default_, 7); 53 | assert.sameValue(as, 8); 54 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/eval-export-dflt-expr-cls-name-meth.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Default AssignmentExpression (which can be recognized as an "anonymous" 6 | class declaration with a static `name` method) is correctly initialized 7 | upon evaluation 8 | esid: sec-moduleevaluation 9 | info: | 10 | [...] 11 | 16. Let result be the result of evaluating module.[[ECMAScriptCode]]. 12 | [...] 13 | 14 | 15.2.3.11 Runtime Semantics: Evaluation 15 | 16 | ExportDeclaration : export default ClassDeclaration 17 | 18 | [...] 19 | 3. Let className be the sole element of BoundNames of ClassDeclaration. 20 | 4. If className is "*default*", then 21 | a. Let hasNameProperty be ? HasOwnProperty(value, "name"). 22 | b. If hasNameProperty is false, perform SetFunctionName(value, 23 | "default"). 24 | c. Let env be the running execution context's LexicalEnvironment. 25 | d. Perform ? InitializeBoundName("*default*", value, env). 26 | 5. Return NormalCompletion(empty). 27 | flags: [module] 28 | ---*/ 29 | 30 | export default (class { static name() { return 'name method'; } }); 31 | import C from './eval-export-dflt-expr-cls-name-meth.js'; 32 | 33 | assert.sameValue( 34 | C.name(), 'name method', '`name` property is not over-written' 35 | ); 36 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-for.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Mutable bindings are initialized in the lexical environment record prior to 6 | execution for variable declarations within `for` statements 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 13. Let varDeclarations be the VarScopedDeclarations of code. 11 | 14. Let declaredVarNames be a new empty List. 12 | 15. For each element d in varDeclarations do 13 | a. For each element dn of the BoundNames of d do 14 | i. If dn is not an element of declaredVarNames, then 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | 2. Call envRec.InitializeBinding(dn, undefined). 17 | [...] 18 | includes: [fnGlobalObject.js] 19 | flags: [module] 20 | ---*/ 21 | 22 | var global = fnGlobalObject(); 23 | 24 | assert.sameValue(test262, undefined, 'value is initialized to `undefined`'); 25 | assert.sameValue( 26 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 27 | ); 28 | 29 | for (var test262 = null; false; ) {} 30 | 31 | assert.sameValue(test262, null, 'binding is mutable'); 32 | assert.sameValue( 33 | Object.getOwnPropertyDescriptor(global, 'test262'), 34 | undefined, 35 | 'global binding is not effected by evaluation of declaration' 36 | ); 37 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-let.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Mutable bindings are created in the lexical environment record prior to 6 | execution for `let` declarations 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 17. For each element d in lexDeclarations do 11 | a. For each element dn of the BoundNames of d do 12 | i. If IsConstantDeclaration of d is true, then 13 | [...] 14 | ii. Else, 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | [...] 17 | includes: [fnGlobalObject.js] 18 | flags: [module] 19 | ---*/ 20 | 21 | var global = fnGlobalObject(); 22 | 23 | assert.throws(ReferenceError, function() { 24 | typeof test262; 25 | }, 'Binding is created but not initialized.'); 26 | assert.sameValue( 27 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 28 | ); 29 | 30 | let test262; 31 | 32 | assert.sameValue(test262, undefined); 33 | assert.sameValue( 34 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 35 | ); 36 | 37 | test262 = null; 38 | 39 | assert.sameValue(test262, null, 'binding is mutable'); 40 | assert.sameValue( 41 | Object.getOwnPropertyDescriptor(global, 'test262'), 42 | undefined, 43 | 'global binding is not effected by modification' 44 | ); 45 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-cls.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Mutable bindings are created in the lexical environment record prior to 6 | execution for class declarations 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 17. For each element d in lexDeclarations do 11 | a. For each element dn of the BoundNames of d do 12 | i. If IsConstantDeclaration of d is true, then 13 | [...] 14 | ii. Else, 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | [...] 17 | includes: [fnGlobalObject.js] 18 | flags: [module] 19 | ---*/ 20 | 21 | var global = fnGlobalObject(); 22 | 23 | assert.throws(ReferenceError, function() { 24 | typeof test262; 25 | }, 'Binding is created but not initialized.'); 26 | assert.sameValue( 27 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 28 | ); 29 | 30 | class test262 {} 31 | 32 | assert.sameValue(typeof test262, 'function'); 33 | assert.sameValue( 34 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 35 | ); 36 | 37 | test262 = null; 38 | 39 | assert.sameValue(test262, null, 'binding is mutable'); 40 | assert.sameValue( 41 | Object.getOwnPropertyDescriptor(global, 'test262'), 42 | undefined, 43 | 'global binding is not effected by modification' 44 | ); 45 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-var.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Mutable bindings are initialized in the lexical environment record prior to 6 | execution for variable declarations 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 13. Let varDeclarations be the VarScopedDeclarations of code. 11 | 14. Let declaredVarNames be a new empty List. 12 | 15. For each element d in varDeclarations do 13 | a. For each element dn of the BoundNames of d do 14 | i. If dn is not an element of declaredVarNames, then 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | 2. Call envRec.InitializeBinding(dn, undefined). 17 | 3. Append dn to declaredVarNames. 18 | [...] 19 | includes: [fnGlobalObject.js] 20 | flags: [module] 21 | ---*/ 22 | 23 | var global = fnGlobalObject(); 24 | 25 | assert.sameValue(test262, undefined, 'value is initialized to `undefined`'); 26 | assert.sameValue( 27 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 28 | ); 29 | 30 | var test262 = null; 31 | 32 | assert.sameValue(test262, null, 'binding is mutable'); 33 | assert.sameValue( 34 | Object.getOwnPropertyDescriptor(global, 'test262'), 35 | undefined, 36 | 'global binding is not effected by evaluation of declaration' 37 | ); 38 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-const.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Mutable bindings are created in the lexical environment record prior to 6 | execution for `const` declarations 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 17. For each element d in lexDeclarations do 11 | a. For each element dn of the BoundNames of d do 12 | i. If IsConstantDeclaration of d is true, then 13 | 1. Perform ! envRec.CreateImmutableBinding(dn, true). 14 | [...] 15 | includes: [fnGlobalObject.js] 16 | flags: [module] 17 | ---*/ 18 | 19 | var global = fnGlobalObject(); 20 | 21 | assert.throws(ReferenceError, function() { 22 | typeof test262; 23 | }, 'Binding is created but not initialized.'); 24 | assert.sameValue( 25 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 26 | ); 27 | 28 | const test262 = 23; 29 | 30 | assert.sameValue(test262, 23); 31 | assert.sameValue( 32 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 33 | ); 34 | 35 | assert.throws(TypeError, function() { 36 | test262 = null; 37 | }); 38 | 39 | assert.sameValue(test262, 23, 'binding is not mutable'); 40 | assert.sameValue( 41 | Object.getOwnPropertyDescriptor(global, 'test262'), 42 | undefined, 43 | 'global binding is not effected by attempts to modify' 44 | ); 45 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-bndng-dflt-cls.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Imported binding reflects state of exported default binding ("anonymous" 6 | class declaration) 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 17. For each element d in lexDeclarations do 11 | a. For each element dn of the BoundNames of d do 12 | i. If IsConstantDeclaration of d is true, then 13 | [...] 14 | ii. Else, 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | iii. If d is a GeneratorDeclaration production or a 17 | FunctionDeclaration production, then 18 | 1. Let fo be the result of performing InstantiateFunctionObject 19 | for d with argument env. 20 | 2. Call envRec.InitializeBinding(dn, fo). 21 | [...] 22 | 23 | 14.5 Class Definitions 24 | 25 | Syntax 26 | 27 | ClassDeclaration[Yield, Default]: 28 | 29 | class BindingIdentifier[?Yield] ClassTail[?Yield] 30 | [+Default] class ClassTail[?Yield] 31 | flags: [module] 32 | ---*/ 33 | 34 | assert.throws(ReferenceError, function() { 35 | typeof C; 36 | }, 'Binding is created but not initialized.'); 37 | 38 | export default class {}; 39 | import C from './instn-named-bndng-dflt-cls.js'; 40 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-id-name.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Namespace object reports properties for any valid exported IdentifierName. 6 | esid: sec-imports 7 | info: | 8 | [...] 9 | 5. For each ExportEntry Record e in module.[[LocalExportEntries]], do 10 | a. Assert: module provides the direct binding for this export. 11 | b. Append e.[[ExportName]] to exportedNames. 12 | [...] 13 | flags: [module] 14 | ---*/ 15 | 16 | var _if = null; 17 | var _import = null; 18 | var _export = null; 19 | var _await = null; 20 | var _arguments = null; 21 | var _eval = null; 22 | var _default = null; 23 | var as = null; 24 | 25 | export { 26 | _if as if, 27 | _import as import, 28 | _export as export, 29 | _await as await, 30 | _arguments as arguments, 31 | _eval as eval, 32 | _default as default, 33 | as as as 34 | }; 35 | 36 | import * as ns from './instn-star-id-name.js'; 37 | 38 | assert('if' in ns, 'property name: if'); 39 | assert('import' in ns, 'property name: import'); 40 | assert('export' in ns, 'property name: export'); 41 | assert('await' in ns, 'property name: await'); 42 | assert('arguments' in ns, 'property name: arguments'); 43 | assert('eval' in ns, 'property name: eval'); 44 | assert('default' in ns, 'property name: default'); 45 | assert('as' in ns, 'property name: as'); 46 | -------------------------------------------------------------------------------- /runtimes/graaljs.js: -------------------------------------------------------------------------------- 1 | // $262 object is provided, however the shortName options 2 | // requires redefinition to prevent regeference error. 3 | // (behind --experimental-options --js.test262-mode=true flags) 4 | const graaljs = globalThis["\x24262"]; 5 | const DollarCreateRealm = graaljs.createRealm; 6 | const DollarEvalScript = graaljs.evalScript; 7 | const $262 = Object.assign({}, graaljs); 8 | 9 | $262.global = globalThis; 10 | $262.gc = function() { 11 | throw new Test262Error('gc() not yet supported.'); 12 | }; 13 | $262.getGlobal = function(name) { 14 | return this.global[name]; 15 | }; 16 | $262.setGlobal = function(name, value) { 17 | this.global[name] = value; 18 | }; 19 | $262.destroy = function () { /* noop */ }; 20 | $262.IsHTMLDDA = function() { return {}; }; 21 | $262.source = $SOURCE; 22 | 23 | $262.evalScript = function(code) { 24 | try { 25 | DollarEvalScript(code); 26 | return { type: 'normal', value: undefined }; 27 | } catch (e) { 28 | return { type: 'throw', value: e }; 29 | } 30 | }; 31 | $262.createRealm = function (options = {}) { 32 | const realm = DollarCreateRealm(options); 33 | realm.evalScript($262.source); 34 | realm.source = $262.source; 35 | realm.getGlobal = $262.getGlobal; 36 | realm.setGlobal = $262.setGlobal; 37 | realm.destroy = () => { 38 | if (options.destroy) { 39 | options.destroy(); 40 | } 41 | }; 42 | const globals = options.globals || {}; 43 | for (let glob in globals) { 44 | realm.global[glob] = globals[glob]; 45 | } 46 | return realm; 47 | }; -------------------------------------------------------------------------------- /runtimes/node.js: -------------------------------------------------------------------------------- 1 | function print(...args) { 2 | console.log(...args); 3 | } 4 | var vm = require('vm'); 5 | var $262 = { 6 | global: Function('return this')(), 7 | gc() { 8 | return gc(); 9 | }, 10 | createRealm(options) { 11 | options = options || {}; 12 | options.globals = options.globals || {}; 13 | 14 | context = { 15 | console, 16 | require, 17 | print, 18 | }; 19 | 20 | for(var glob in options.globals) { 21 | context[glob] = options.globals[glob]; 22 | } 23 | 24 | var context = vm.createContext(context); 25 | vm.runInContext(this.source, context); 26 | context.$262.source = this.source; 27 | context.$262.context = context; 28 | context.$262.destroy = function () { 29 | if (options.destroy) { 30 | options.destroy(); 31 | } 32 | }; 33 | return context.$262; 34 | }, 35 | evalScript(code) { 36 | const displayErrors = false; 37 | try { 38 | if (this.context) { 39 | vm.runInContext(code, this.context, {displayErrors}); 40 | } else { 41 | vm.runInESHostContext(code, {displayErrors}); 42 | } 43 | 44 | return { type: 'normal', value: undefined }; 45 | } catch (e) { 46 | return { type: 'throw', value: e }; 47 | } 48 | }, 49 | getGlobal(name) { 50 | return this.global[name]; 51 | }, 52 | setGlobal(name, value) { 53 | this.global[name] = value; 54 | }, 55 | destroy() { /* noop */ }, 56 | IsHTMLDDA() { return {}; }, 57 | source: $SOURCE 58 | }; 59 | 60 | 61 | -------------------------------------------------------------------------------- /runtimes/nashorn.js: -------------------------------------------------------------------------------- 1 | var $262 = { 2 | global: Function('return this')(), 3 | gc() { 4 | throw new Test262Error('gc() not yet supported.'); 5 | }, 6 | createRealm: function(options) { 7 | options = options || {}; 8 | options.globals = options.globals || {}; 9 | 10 | var realm = loadWithNewGlobal({ script: 'this', name: 'createRealm' }); 11 | realm.eval(this.source); 12 | realm.$262.source = this.source; 13 | realm.$262.destroy = function () { 14 | if (options.destroy) { 15 | options.destroy(); 16 | } 17 | }; 18 | 19 | for(var glob in options.globals) { 20 | realm.$262.global[glob] = options.globals[glob]; 21 | } 22 | 23 | return realm.$262; 24 | }, 25 | evalScript: function(code) { 26 | try { 27 | load({ script: code, name: 'evalScript' }); 28 | return { type: 'normal', value: undefined } 29 | } catch (e) { 30 | return { type: 'throw', value: e } 31 | } 32 | }, 33 | getGlobal: function(name) { 34 | return this.global[name]; 35 | }, 36 | setGlobal: function(name, value) { 37 | this.global[name] = value; 38 | }, 39 | destroy: function() { /* noop */ }, 40 | IsHTMLDDA: function() { return {}; }, 41 | source: $SOURCE, 42 | agent: (function() { 43 | function thrower() { 44 | throw new Test262Error('agent.* not yet supported.'); 45 | }; 46 | return { 47 | start: thrower, 48 | broadcast: thrower, 49 | getReport: thrower, 50 | sleep: thrower, 51 | monotonicNow: thrower, 52 | }; 53 | })(), 54 | }; 55 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-bndng-dflt-expr.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Imported binding reflects state of exported default binding (expressions) 6 | esid: sec-moduledeclarationinstantiation 7 | info: | 8 | [...] 9 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 10 | a. Let importedModule be ? HostResolveImportedModule(module, 11 | in.[[ModuleRequest]]). 12 | b. If in.[[ImportName]] is "*", then 13 | [...] 14 | c. Else, 15 | i. Let resolution be ? 16 | importedModule.ResolveExport(in.[[ImportName]], « », « »). 17 | ii. If resolution is null or resolution is "ambiguous", throw a 18 | SyntaxError exception. 19 | iii. Call envRec.CreateImportBinding(in.[[LocalName]], 20 | resolution.[[Module]], resolution.[[BindingName]]). 21 | [...] 22 | 23 | 8.1.1.5.5 CreateImportBinding 24 | 25 | [...] 26 | 5. Create an immutable indirect binding in envRec for N that references M 27 | and N2 as its target binding and record that the binding is initialized. 28 | 6. Return NormalCompletion(empty). 29 | flags: [module] 30 | ---*/ 31 | 32 | assert.throws(ReferenceError, function() { 33 | typeof dflt; 34 | }, 'binding is created but not initialized'); 35 | 36 | import dflt from './instn-named-bndng-dflt-expr.js'; 37 | export default (function() {}); 38 | -------------------------------------------------------------------------------- /LICENSE.v8: -------------------------------------------------------------------------------- 1 | Copyright 2014, the V8 project authors. All rights reserved. 2 | Redistribution and use in source and binary forms, with or without 3 | modification, are permitted provided that the following conditions are 4 | met: 5 | * Redistributions of source code must retain the above copyright 6 | notice, this list of conditions and the following disclaimer. 7 | * Redistributions in binary form must reproduce the above 8 | copyright notice, this list of conditions and the following 9 | disclaimer in the documentation and/or other materials provided 10 | with the distribution. 11 | * Neither the name of Google Inc. nor the names of its 12 | contributors may be used to endorse or promote products derived 13 | from this software without specific prior written permission. 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-dflt-keep-local.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Local default exports are included in the module namespace object 6 | esid: sec-moduledeclarationinstantiation 7 | info: | 8 | [...] 9 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 10 | a. Let importedModule be ? HostResolveImportedModule(module, 11 | in.[[ModuleRequest]]). 12 | b. If in.[[ImportName]] is "*", then 13 | i. Let namespace be ? GetModuleNamespace(importedModule). 14 | [...] 15 | 16 | 15.2.1.18 Runtime Semantics: GetModuleNamespace 17 | 18 | [...] 19 | 3. If namespace is undefined, then 20 | a. Let exportedNames be ? module.GetExportedNames(« »). 21 | [...] 22 | 23 | 15.2.1.16.2 GetExportedNames 24 | 25 | [...] 26 | 5. For each ExportEntry Record e in module.[[LocalExportEntries]], do 27 | a. Assert: module provides the direct binding for this export. 28 | b. Append e.[[ExportName]] to exportedNames. 29 | [...] 30 | flags: [module] 31 | ---*/ 32 | 33 | import * as named from './instn-star-props-dflt-keep-local-named_FIXTURE.js'; 34 | import * as production from './instn-star-props-dflt-keep-local-prod_FIXTURE.js'; 35 | 36 | assert.sameValue('default' in named, true, 'default specified via identifier'); 37 | 38 | assert.sameValue( 39 | 'default' in production, true, 'default specified via dedicated production' 40 | ); 41 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-ambiguous.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Ambiguous exports are not reflected in module namespace objects, nor do 6 | they trigger an error upon resolution 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 11 | a. Let importedModule be ? HostResolveImportedModule(module, 12 | in.[[ModuleRequest]]). 13 | b. If in.[[ImportName]] is "*", then 14 | i. Let namespace be ? GetModuleNamespace(importedModule). 15 | [...] 16 | 17 | 15.2.1.18 Runtime Semantics: GetModuleNamespace 18 | 19 | [...] 20 | 3. If namespace is undefined, then 21 | [...] 22 | c. For each name that is an element of exportedNames, 23 | i. Let resolution be ? module.ResolveExport(name, « », « »). 24 | ii. If resolution is null, throw a SyntaxError exception. 25 | iii. If resolution is not "ambiguous", append name to 26 | unambiguousNames. 27 | d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). 28 | flags: [module] 29 | ---*/ 30 | 31 | import * as ns from './instn-star-ambiguous_FIXTURE.js'; 32 | 33 | assert('first' in ns, 'Non-ambiguous exports from first module are present'); 34 | assert('second' in ns, 'Non-ambiguous exports from second module are present'); 35 | assert.sameValue('both' in ns, false, 'Ambiguous export is not present'); 36 | -------------------------------------------------------------------------------- /runtimes/browser.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 42 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-resolve-empty-import.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | An ImportClause without an ImportsList contributes to the list of requested 6 | modules 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 8. For each String required that is an element of 11 | module.[[RequestedModules]] do, 12 | a. NOTE: Before instantiating a module, all of the modules it requested 13 | must be available. An implementation may perform this test at any 14 | time prior to this point. 15 | b. Let requiredModule be ? HostResolveImportedModule(module, required). 16 | c. Perform ? requiredModule.ModuleDeclarationInstantiation(). 17 | 18 | 15.2.2.5 Static Semantics: ModuleRequests 19 | 20 | ImportDeclaration : import ImportClause FromClause; 21 | 22 | 1. Return ModuleRequests of FromClause. 23 | 24 | 15.2.3 Exports 25 | 26 | Syntax 27 | ImportClause : 28 | ImportedDefaultBinding 29 | NameSpaceImport 30 | NamedImports 31 | ImportedDefaultBinding , NameSpaceImport 32 | ImportedDefaultBinding , NamedImports 33 | 34 | NamedImports : 35 | { } 36 | { ImportsList } 37 | { ImportsList , } 38 | negative: 39 | phase: resolution 40 | type: ReferenceError 41 | flags: [module] 42 | ---*/ 43 | 44 | throw "Test262: This statement should not be evaluated."; 45 | 46 | import {} from './instn-resolve-empty-import_FIXTURE.js'; 47 | -------------------------------------------------------------------------------- /lib/agents/qjs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const runtimePath = require('../runtime-path'); 5 | const ConsoleAgent = require('../ConsoleAgent'); 6 | const errorexp = /^(\w+): (.*)$/m; 7 | const nomessageexp = /^(\w+)(?:\n\s.+at\s<(.+)>)/gm; 8 | 9 | class QJSAgent extends ConsoleAgent { 10 | async evalScript(code, options = {}) { 11 | if (options.module && this.args[0] !== '--module') { 12 | this.args.unshift('--module'); 13 | } 14 | 15 | if (!options.module && this.args[0] === '--module') { 16 | this.args.shift(); 17 | } 18 | // -N run test prepared by test262-harness+eshost 19 | if (!this.args.includes('-N')) { 20 | this.args.push('-N'); 21 | } 22 | return super.evalScript(code, options); 23 | } 24 | 25 | parseError(str) { 26 | const match = str.match(errorexp); 27 | 28 | if (!match) { 29 | return null; 30 | } 31 | 32 | return { 33 | name: match[1], 34 | message: match[2], 35 | stack: [], 36 | }; 37 | } 38 | 39 | normalizeResult(result) { 40 | errorexp.lastIndex = 0; 41 | nomessageexp.lastIndex = 0; 42 | 43 | const ematch = errorexp.exec(result.stdout); 44 | const nmatch = nomessageexp.exec(result.stderr); 45 | 46 | let match; 47 | 48 | if (ematch) { 49 | match = ematch[0]; 50 | } 51 | 52 | if (nmatch) { 53 | match = `${nmatch[1]}: `; 54 | } 55 | 56 | if (match) { 57 | result.stdout = ''; 58 | result.stderr = match; 59 | } 60 | 61 | return result; 62 | } 63 | } 64 | 65 | QJSAgent.runtime = fs.readFileSync(runtimePath.for('qjs'), 'utf8'); 66 | 67 | module.exports = QJSAgent; 68 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2018 Brian Terlson. 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/bterlson/eshost. 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-dflt-skip.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Default exports are not included in the module namespace object 6 | esid: sec-moduledeclarationinstantiation 7 | info: | 8 | [...] 9 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 10 | a. Let importedModule be ? HostResolveImportedModule(module, 11 | in.[[ModuleRequest]]). 12 | b. If in.[[ImportName]] is "*", then 13 | i. Let namespace be ? GetModuleNamespace(importedModule). 14 | [...] 15 | 16 | 15.2.1.18 Runtime Semantics: GetModuleNamespace 17 | 18 | [...] 19 | 3. If namespace is undefined, then 20 | a. Let exportedNames be ? module.GetExportedNames(« »). 21 | [...] 22 | 23 | 15.2.1.16.2 GetExportedNames 24 | 25 | [...] 26 | 7. For each ExportEntry Record e in module.[[StarExportEntries]], do 27 | [...] 28 | c. For each element n of starNames, do 29 | i. If SameValue(n, "default") is false, then 30 | [...] 31 | flags: [module] 32 | ---*/ 33 | 34 | import * as named from './instn-star-props-dflt-skip-star-named_FIXTURE.js'; 35 | import * as production from './instn-star-props-dflt-skip-star-prod_FIXTURE.js'; 36 | 37 | assert('namedOther' in named); 38 | assert.sameValue( 39 | 'default' in named, false, 'default specified via identifier' 40 | ); 41 | 42 | assert('productionOther' in production); 43 | assert.sameValue( 44 | 'default' in production, false, 'default specified via dedicated production' 45 | ); 46 | -------------------------------------------------------------------------------- /runtimes/jsc.js: -------------------------------------------------------------------------------- 1 | /* JavaScriptCore exposes a $ & $262 object to its runtime */ 2 | const jsc = globalThis["\x24"]; 3 | const DollarCreateRealm = jsc.createRealm; 4 | const DollarEvalScript = jsc.evalScript.bind(jsc); 5 | 6 | var $262 = {}; 7 | // Copy "own" properties from the JSC-defined object to the normalized `$262` 8 | // object. Neither `Object.assign` nor the object "spread" syntax can be used 9 | // for this task because not all properties on the source object are 10 | // enumerable. 11 | Object.getOwnPropertyNames(jsc).forEach(function(name) { 12 | $262[name] = jsc[name]; 13 | }); 14 | $262.global = globalThis; 15 | $262.source = $SOURCE; 16 | $262.destroy = function() {}; 17 | $262.getGlobal = function(name) { 18 | return this.global[name]; 19 | }; 20 | $262.setGlobal = function(name, value) { 21 | this.global[name] = value; 22 | }; 23 | $262.gc = function() { 24 | return gc(); 25 | }; 26 | $262.evalScript = function(code) { 27 | try { 28 | DollarEvalScript(code); 29 | return { type: 'normal', value: undefined }; 30 | } catch (e) { 31 | return { type: 'throw', value: e }; 32 | } 33 | }; 34 | $262.createRealm = function (options = {}) { 35 | const realm = DollarCreateRealm(options); 36 | realm.evalScript($262.source); 37 | realm.source = $262.source; 38 | realm.getGlobal = $262.getGlobal; 39 | realm.setGlobal = $262.setGlobal; 40 | realm.destroy = () => { 41 | if (options.destroy) { 42 | options.destroy(); 43 | } 44 | }; 45 | const globals = options.globals || {}; 46 | for (let glob in globals) { 47 | realm.global[glob] = globals[glob]; 48 | } 49 | return realm; 50 | }; 51 | 52 | 53 | if (!$262.IsHTMLDDA) { 54 | $262.IsHTMLDDA = function() { return {}; }; 55 | } -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-props-circular.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Circular "star" imports do not trigger infinite recursion during name 6 | enumeration. 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 11 | a. Let importedModule be ? HostResolveImportedModule(module, 12 | in.[[ModuleRequest]]). 13 | b. If in.[[ImportName]] is "*", then 14 | i. Let namespace be ? GetModuleNamespace(importedModule). 15 | [...] 16 | 17 | 15.2.1.18 Runtime Semantics: GetModuleNamespace 18 | 19 | [...] 20 | 3. If namespace is undefined, then 21 | a. Let exportedNames be ? module.GetExportedNames(« »). 22 | [...] 23 | 24 | 15.2.1.16.2 GetExportedNames 25 | 26 | 1. Let module be this Source Text Module Record. 27 | 2. If exportStarSet contains module, then 28 | a. Assert: We've reached the starting point of an import * circularity. 29 | b. Return a new empty List. 30 | flags: [module] 31 | ---*/ 32 | 33 | import * as a from './instn-star-props-circular-a_FIXTURE.js'; 34 | import * as b from './instn-star-props-circular-b_FIXTURE.js'; 35 | 36 | assert('fromA' in a, 'entry for binding from "a" in namespace of module A'); 37 | assert('fromB' in a, 'entry for binding from "b" in namespace of module A'); 38 | 39 | assert('fromA' in b, 'entry for binding from "a" in namespace of module B'); 40 | assert('fromB' in b, 'entry for binding from "b" in namespace of module B'); 41 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-gen.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Mutable bindings are initialized in the lexical environment record prior to 6 | execution for generator function declarations 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 15. For each element d in varDeclarations do 11 | a. For each element dn of the BoundNames of d do 12 | i. If dn is not an element of declaredVarNames, then 13 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 14 | 2. Call envRec.InitializeBinding(dn, undefined). 15 | 3. Append dn to declaredVarNames. 16 | [...] 17 | includes: [fnGlobalObject.js] 18 | flags: [module] 19 | ---*/ 20 | 21 | var global = fnGlobalObject(); 22 | 23 | assert.sameValue( 24 | typeof test262, 'function', 'generator function value is hoisted' 25 | ); 26 | assert.sameValue( 27 | test262().next().value, 28 | 'test262', 29 | 'hoisted generator function value is correct' 30 | ); 31 | assert.sameValue( 32 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 33 | ); 34 | 35 | test262 = null; 36 | assert.sameValue(test262, null, 'binding is mutable'); 37 | assert.sameValue( 38 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 39 | ); 40 | 41 | function* test262() { return 'test262'; } 42 | 43 | assert.sameValue( 44 | test262, null, 'binding is not effected by evaluation of declaration' 45 | ); 46 | assert.sameValue( 47 | Object.getOwnPropertyDescriptor(global, 'test262'), 48 | undefined, 49 | 'global binding is not effected by evaluation of declaration' 50 | ); 51 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-err-ambiguous.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: IndirectExportEntries validation - ambiguous imported bindings 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do 9 | a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). 10 | b. If resolution is null or resolution is "ambiguous", throw a 11 | SyntaxError exception. 12 | [...] 13 | 14 | 15.2.1.16.3 ResolveExport 15 | 16 | [...] 17 | 9. Let starResolution be null. 18 | 10. For each ExportEntry Record e in module.[[StarExportEntries]], do 19 | a. Let importedModule be ? HostResolveImportedModule(module, 20 | e.[[ModuleRequest]]). 21 | b. Let resolution be ? importedModule.ResolveExport(exportName, 22 | resolveSet, exportStarSet). 23 | c. If resolution is "ambiguous", return "ambiguous". 24 | d. If resolution is not null, then 25 | i. If starResolution is null, let starResolution be resolution. 26 | ii. Else, 27 | 1. Assert: there is more than one * import that includes the 28 | requested name. 29 | 2. If resolution.[[Module]] and starResolution.[[Module]] are 30 | not the same Module Record or 31 | SameValue(resolution.[[BindingName]], 32 | starResolution.[[BindingName]]) is false, return "ambiguous". 33 | negative: 34 | phase: runtime 35 | type: SyntaxError 36 | flags: [module] 37 | ---*/ 38 | 39 | export { x } from './instn-iee-err-ambiguous_FIXTURE.js'; 40 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-iee-err-ambiguous-as.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: IndirectExportEntries validation - ambiguous imported bindings 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 9. For each ExportEntry Record e in module.[[IndirectExportEntries]], do 9 | a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « », « »). 10 | b. If resolution is null or resolution is "ambiguous", throw a 11 | SyntaxError exception. 12 | [...] 13 | 14 | 15.2.1.16.3 ResolveExport 15 | 16 | [...] 17 | 9. Let starResolution be null. 18 | 10. For each ExportEntry Record e in module.[[StarExportEntries]], do 19 | a. Let importedModule be ? HostResolveImportedModule(module, 20 | e.[[ModuleRequest]]). 21 | b. Let resolution be ? importedModule.ResolveExport(exportName, 22 | resolveSet, exportStarSet). 23 | c. If resolution is "ambiguous", return "ambiguous". 24 | d. If resolution is not null, then 25 | i. If starResolution is null, let starResolution be resolution. 26 | ii. Else, 27 | 1. Assert: there is more than one * import that includes the 28 | requested name. 29 | 2. If resolution.[[Module]] and starResolution.[[Module]] are 30 | not the same Module Record or 31 | SameValue(resolution.[[BindingName]], 32 | starResolution.[[BindingName]]) is false, return "ambiguous". 33 | negative: 34 | phase: runtime 35 | type: SyntaxError 36 | flags: [module] 37 | ---*/ 38 | 39 | export { x as y } from './instn-iee-err-ambiguous_FIXTURE.js'; 40 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/proxyTrapsHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | Used to assert the correctness of object behavior in the presence 6 | and context of Proxy objects. 7 | ---*/ 8 | 9 | function allowProxyTraps(overrides) { 10 | function throwTest262Error(msg) { 11 | return function () { throw new Test262Error(msg); }; 12 | } 13 | if (!overrides) { overrides = {}; } 14 | return { 15 | getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'), 16 | setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'), 17 | isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'), 18 | preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'), 19 | getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'), 20 | has: overrides.has || throwTest262Error('[[HasProperty]] trap called'), 21 | get: overrides.get || throwTest262Error('[[Get]] trap called'), 22 | set: overrides.set || throwTest262Error('[[Set]] trap called'), 23 | deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'), 24 | defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'), 25 | enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'), 26 | ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'), 27 | apply: overrides.apply || throwTest262Error('[[Call]] trap called'), 28 | construct: overrides.construct || throwTest262Error('[[Construct]] trap called') 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/harness/regExpUtils.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Ecma International. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: | 5 | Collection of functions used to assert the correctness of RegExp objects. 6 | ---*/ 7 | 8 | function buildString({ loneCodePoints, ranges }) { 9 | const CHUNK_SIZE = 10000; 10 | let result = String.fromCodePoint(...loneCodePoints); 11 | for (const [start, end] of ranges) { 12 | const codePoints = []; 13 | for (let length = 0, codePoint = start; codePoint <= end; codePoint++) { 14 | codePoints[length++] = codePoint; 15 | if (length === CHUNK_SIZE) { 16 | result += String.fromCodePoint(...codePoints); 17 | codePoints.length = length = 0; 18 | } 19 | } 20 | result += String.fromCodePoint(...codePoints); 21 | } 22 | return result; 23 | } 24 | 25 | function testPropertyEscapes(regex, string, expression) { 26 | if (!regex.test(string)) { 27 | for (const symbol of string) { 28 | const hex = symbol 29 | .codePointAt(0) 30 | .toString(16) 31 | .toUpperCase() 32 | .padStart(6, "0"); 33 | assert( 34 | regex.test(symbol), 35 | `\`${ expression }\` should match U+${ hex } (\`${ symbol }\`)` 36 | ); 37 | } 38 | } 39 | } 40 | 41 | // Returns a function that will validate RegExp match result 42 | // 43 | // Example: 44 | // 45 | // var validate = matchValidator(['b'], 1, 'abc'); 46 | // validate(/b/.exec('abc')); 47 | // 48 | function matchValidator(expectedEntries, expectedIndex, expectedInput) { 49 | return function(match) { 50 | assert.compareArray(match, expectedEntries, 'Match entries'); 51 | assert.sameValue(match.index, expectedIndex, 'Match index'); 52 | assert.sameValue(match.input, expectedInput, 'Match input'); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/agents/remote.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const WebDriverAgent = require('../WebdriverAgent'); 4 | const { WebDriver } = require('selenium-webdriver'); 5 | const swhttp = require('selenium-webdriver/http'); 6 | 7 | class UnspecifiedOptionError extends Error { 8 | constructor(...args) { 9 | const name = args[0]; 10 | 11 | super(...args); 12 | 13 | this.message = `RemoteAgent: '${name}' is required but was not specified.`; 14 | } 15 | } 16 | 17 | class RemoteAgent extends WebDriverAgent { 18 | constructor(options = {}) { 19 | super(options); 20 | 21 | if (typeof options.webdriverServer !== 'string') { 22 | throw new UnspecifiedOptionError('webdriverServer'); 23 | } 24 | this.webdriverServer = options.webdriverServer; 25 | 26 | if (!options.capabilities) { 27 | throw new UnspecifiedOptionError('capabilities'); 28 | } 29 | if (typeof options.capabilities.browserName !== 'string') { 30 | throw new UnspecifiedOptionError('capabilities.browserName'); 31 | } 32 | if (typeof options.capabilities.platform !== 'string') { 33 | throw new UnspecifiedOptionError('capabilities.platform'); 34 | } 35 | if (typeof options.capabilities.version !== 'string') { 36 | throw new UnspecifiedOptionError('capabilities.version'); 37 | } 38 | this.capabilities = Object.assign({}, options.capabilities); 39 | 40 | if (typeof options.hostPath === 'string') { 41 | throw new UnspecifiedOptionError('hostPath'); 42 | } 43 | } 44 | 45 | _createDriver() { 46 | const client = Promise.resolve(new swhttp.HttpClient(this.webdriverServer)); 47 | const executor = new swhttp.Executor(client); 48 | const expandedCaps = { 49 | desired: this.capabilities, 50 | required: this.capabilities 51 | }; 52 | 53 | return WebDriver.createSession(executor, expandedCaps); 54 | } 55 | } 56 | 57 | module.exports = RemoteAgent; 58 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-star-equality.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: A single namespace is created for each module 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 9 | a. Let importedModule be ? HostResolveImportedModule(module, 10 | in.[[ModuleRequest]]). 11 | b. If in.[[ImportName]] is "*", then 12 | i. Let namespace be ? GetModuleNamespace(importedModule). 13 | ii. Perform ! envRec.CreateImmutableBinding(in.[[LocalName]], true). 14 | iii. Call envRec.InitializeBinding(in.[[LocalName]], namespace). 15 | [...] 16 | 17 | 15.2.1.18 Runtime Semantics: GetModuleNamespace 18 | 19 | 1. Assert: module is an instance of a concrete subclass of Module Record. 20 | 2. Let namespace be module.[[Namespace]]. 21 | 3. If namespace is undefined, then 22 | [...] 23 | 4. Return namespace. 24 | flags: [module] 25 | ---*/ 26 | 27 | import * as self1 from './instn-star-equality.js'; 28 | import * as self2 from './instn-star-equality.js'; 29 | import * as other1 from './instn-star-equality-other_FIXTURE.js'; 30 | import * as self3 from './instn-star-equality.js'; 31 | import * as other2 from './instn-star-equality-other_FIXTURE.js'; 32 | import { testNs } from './instn-star-equality-other_FIXTURE.js'; 33 | 34 | assert.sameValue( 35 | self1, self2, 'Local namespace objects from consecutive declarations' 36 | ); 37 | assert.sameValue( 38 | self1, self3, 'Local namespace objects from non-consective declarations' 39 | ); 40 | assert.sameValue(other1, other2, 'External namespace objects'); 41 | assert.sameValue(self1, testNs, 'Re-exported namespace objects'); 42 | 43 | assert.notSameValue(self1, other1); 44 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-local-bndng-fun.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Mutable bindings are initialized in the lexical environment record prior to 6 | execution for function declarations 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 17. For each element d in lexDeclarations do 11 | a. For each element dn of the BoundNames of d do 12 | i. If IsConstantDeclaration of d is true, then 13 | [...] 14 | ii. Else, 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | iii. If d is a GeneratorDeclaration production or a 17 | FunctionDeclaration production, then 18 | 1. Let fo be the result of performing InstantiateFunctionObject 19 | for d with argument env. 20 | 2. Call envRec.InitializeBinding(dn, fo). 21 | [...] 22 | includes: [fnGlobalObject.js] 23 | flags: [module] 24 | ---*/ 25 | 26 | var global = fnGlobalObject(); 27 | 28 | assert.sameValue(typeof test262, 'function', 'function value is hoisted'); 29 | assert.sameValue(test262(), 'test262', 'hoisted function value is correct'); 30 | assert.sameValue( 31 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 32 | ); 33 | 34 | test262 = null; 35 | assert.sameValue(test262, null, 'binding is mutable'); 36 | assert.sameValue( 37 | Object.getOwnPropertyDescriptor(global, 'test262'), undefined 38 | ); 39 | 40 | function test262() { return 'test262'; } 41 | 42 | assert.sameValue( 43 | test262, null, 'binding is not effected by evaluation of declaration' 44 | ); 45 | assert.sameValue( 46 | Object.getOwnPropertyDescriptor(global, 'test262'), 47 | undefined, 48 | 'global binding is not effected by evaluation of declaration' 49 | ); 50 | -------------------------------------------------------------------------------- /lib/agents/d8.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const runtimePath = require('../runtime-path'); 5 | const ConsoleAgent = require('../ConsoleAgent'); 6 | const ErrorParser = require('../parse-error.js'); 7 | 8 | const experimentalNotice = 'V8 is running with experimental features enabled. Stability and security will suffer.\n'; 9 | const errorRe = /(.*?):(\d+): (([\w\d]+)(?:: (.*))?)[\w\W]*(\3((:?\s+at.*\r?\n)*)(\r?\n)+)?$/; 10 | 11 | class D8Agent extends ConsoleAgent { 12 | async evalScript(code, options = {}) { 13 | if (options.module && this.args[0] !== '--module') { 14 | this.args.unshift('--module'); 15 | } 16 | 17 | if (!options.module && this.args[0] === '--module') { 18 | this.args.shift(); 19 | } 20 | 21 | this.args.push('--expose-gc'); 22 | 23 | return super.evalScript(code, options); 24 | } 25 | 26 | parseError(str) { 27 | const match = str.match(errorRe); 28 | if(!match) { 29 | return null; 30 | } 31 | const stackStr = match[6] || ''; 32 | 33 | let stack; 34 | if (stackStr.trim().length > 0) { 35 | stack = ErrorParser.parseStack(stackStr); 36 | } else { 37 | stack = [{ 38 | source: match[0], 39 | fileName: match[1], 40 | lineNumber: match[2] 41 | }]; 42 | } 43 | 44 | return { 45 | name: match[4], 46 | message: match[5], 47 | stack: stack, 48 | }; 49 | } 50 | 51 | normalizeResult(result) { 52 | if (result.stderr.startsWith(experimentalNotice)) { 53 | result.stderr = result.stderr.slice(experimentalNotice.length); 54 | } 55 | 56 | const match = result.stdout.match(errorRe); 57 | 58 | if (match) { 59 | result.stdout = result.stdout.replace(errorRe, ''); 60 | result.stderr = match[0]; 61 | } 62 | 63 | return result; 64 | } 65 | } 66 | 67 | D8Agent.runtime = fs.readFileSync(runtimePath.for('d8'), 'utf8'); 68 | 69 | module.exports = D8Agent; 70 | -------------------------------------------------------------------------------- /lib/agents/BrowserAgent.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const Agent = require('../Agent.js'); 3 | const Server = require('../Server.js'); 4 | let agentId = 0; 5 | 6 | class BrowserAgent extends Agent { 7 | constructor (options) { 8 | super(options); 9 | 10 | this.webHost = options.webHost || 'localhost'; 11 | this.webPort = options.webPort || 1337; 12 | this.id = agentId++; 13 | } 14 | 15 | async initialize() { 16 | // A method for cancelling the current `evalScript` operation (if any) 17 | this._cancelEval = null; 18 | await Server.start(this.id); 19 | this._url = `http://${this.webHost}:${this.webPort}/?clientId=${this.id}&shortName=${this.shortName}`; 20 | return this; 21 | } 22 | 23 | async evalScript(code, options) { 24 | code = this.compile(code, options); 25 | let cancelled = false; 26 | const whenCancelled = new Promise(resolve => { 27 | this._cancelEval = () => { 28 | cancelled = true; 29 | resolve({ stdout: '', stderr: '', error: null }); 30 | }; 31 | }); 32 | 33 | const whenEvaluated = Server.waitForClientId(this.id).then(handler => { 34 | if (cancelled) { 35 | return; 36 | } 37 | 38 | handler._socket.emit('exec', code); 39 | return Server.waitForResult(this.id).then(result => { 40 | if (cancelled) { 41 | return; 42 | } 43 | 44 | // normalize empty string to undefined 45 | if (result.error) { 46 | result.error.message = result.error.message || undefined; 47 | } 48 | 49 | return result; 50 | }) 51 | }); 52 | 53 | return Promise.race([whenEvaluated, whenCancelled]); 54 | } 55 | 56 | stop() { 57 | if (this._cancelEval) { 58 | this._cancelEval(); 59 | } 60 | return Promise.resolve(true); 61 | } 62 | 63 | async destroy() { 64 | await super.destroy(); 65 | return Server.stop(this.id); 66 | } 67 | } 68 | 69 | module.exports = BrowserAgent; 70 | -------------------------------------------------------------------------------- /lib/WebdriverAgent.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const BrowserAgent = require('./agents/BrowserAgent.js'); 4 | const Server = require('./Server.js'); 5 | 6 | class WebdriverAgent extends BrowserAgent { 7 | setBinaryPath() { 8 | throw new Error('Cannot call abstract method setBinaryPath'); 9 | } 10 | 11 | setCapabilities() { /* default no-op */ } 12 | 13 | initialize() { 14 | return super.initialize() 15 | .then(() => { 16 | this._driver = this._createDriver() 17 | return this._driver.get(this._url); 18 | }) 19 | .then(() => Server.waitForClientId(this.id)) 20 | .then(() => this) 21 | .catch(err => { 22 | this.destroy(); 23 | throw err; 24 | }); 25 | } 26 | 27 | _createDriver() { 28 | const Options = this.getOptions(); 29 | const Driver = this.getDriver(); 30 | 31 | const options = new Options(); 32 | 33 | if (this.hostPath) { 34 | this.setBinaryPath(options, this.hostPath); 35 | } 36 | 37 | this.setCapabilities(options); 38 | 39 | return Driver.createSession(options); 40 | } 41 | 42 | stop() { 43 | const newDriver = this._createDriver(); 44 | const quitP = this._driver.quit(); 45 | this._driver = newDriver; 46 | const getP = newDriver.get(this._url); 47 | Server.clientIdStopped(this.id); 48 | this._restartP = super.stop() 49 | .then(() => Promise.all([quitP, getP])); 50 | return this._restartP.then(() => { 51 | this._restartP = null; 52 | return true; 53 | }); 54 | } 55 | 56 | async destroy() { 57 | let baseP = Promise.resolve(); 58 | if (this._restartP) { 59 | // selenium doesn't like to exit properly if you try to kill while it's doing something 60 | // so, let's wait. 61 | baseP = this._restartP; 62 | } 63 | await baseP; 64 | if (this._driver) { 65 | await this._driver.quit(); 66 | } 67 | return super.destroy(); 68 | } 69 | } 70 | 71 | 72 | module.exports = WebdriverAgent; 73 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-ambiguous.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Named import binding - resolution failure (ambiguous name) 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 9 | a. Let importedModule be ? HostResolveImportedModule(module, 10 | in.[[ModuleRequest]]). 11 | b. If in.[[ImportName]] is "*", then 12 | [...] 13 | c. Else, 14 | i. Let resolution be ? 15 | importedModule.ResolveExport(in.[[ImportName]], « », « »). 16 | ii. If resolution is null or resolution is "ambiguous", throw a 17 | SyntaxError exception. 18 | 19 | 15.2.1.16.3 ResolveExport 20 | 21 | [...] 22 | 9. Let starResolution be null. 23 | 10. For each ExportEntry Record e in module.[[StarExportEntries]], do 24 | a. Let importedModule be ? HostResolveImportedModule(module, 25 | e.[[ModuleRequest]]). 26 | b. Let resolution be ? importedModule.ResolveExport(exportName, 27 | resolveSet, exportStarSet). 28 | c. If resolution is "ambiguous", return "ambiguous". 29 | d. If resolution is not null, then 30 | i. If starResolution is null, let starResolution be resolution. 31 | ii. Else, 32 | 1. Assert: there is more than one * import that includes the 33 | requested name. 34 | 2. If resolution.[[Module]] and starResolution.[[Module]] are 35 | not the same Module Record or 36 | SameValue(resolution.[[BindingName]], 37 | starResolution.[[BindingName]]) is false, return "ambiguous". 38 | negative: 39 | phase: runtime 40 | type: SyntaxError 41 | flags: [module] 42 | ---*/ 43 | 44 | import { x } from './instn-named-err-ambiguous_FIXTURE.js'; 45 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-bndng-cls.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Imported binding reflects state of exported `class` binding 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 9 | a. Let importedModule be ? HostResolveImportedModule(module, 10 | in.[[ModuleRequest]]). 11 | b. If in.[[ImportName]] is "*", then 12 | [...] 13 | c. Else, 14 | i. Let resolution be ? 15 | importedModule.ResolveExport(in.[[ImportName]], « », « »). 16 | ii. If resolution is null or resolution is "ambiguous", throw a 17 | SyntaxError exception. 18 | iii. Call envRec.CreateImportBinding(in.[[LocalName]], 19 | resolution.[[Module]], resolution.[[BindingName]]). 20 | [...] 21 | 16. Let lexDeclarations be the LexicallyScopedDeclarations of code. 22 | 17. For each element d in lexDeclarations do 23 | a. For each element dn of the BoundNames of d do 24 | i, If IsConstantDeclaration of d is true, then 25 | [...] 26 | ii. Else, 27 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 28 | iii. If d is a GeneratorDeclaration production or a 29 | FunctionDeclaration production, then 30 | [...] 31 | 32 | 8.1.1.5.5 CreateImportBinding 33 | 34 | [...] 35 | 5. Create an immutable indirect binding in envRec for N that references M 36 | and N2 as its target binding and record that the binding is initialized. 37 | 6. Return NormalCompletion(empty). 38 | flags: [module] 39 | ---*/ 40 | 41 | assert.throws(ReferenceError, function() { 42 | typeof D; 43 | }, 'binding is created but not initialized'); 44 | 45 | import { C as D } from './instn-named-bndng-cls.js'; 46 | export class C {} 47 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-err-ambiguous-as.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Named import binding - resolution failure (ambiguous name) 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 9 | a. Let importedModule be ? HostResolveImportedModule(module, 10 | in.[[ModuleRequest]]). 11 | b. If in.[[ImportName]] is "*", then 12 | [...] 13 | c. Else, 14 | i. Let resolution be ? 15 | importedModule.ResolveExport(in.[[ImportName]], « », « »). 16 | ii. If resolution is null or resolution is "ambiguous", throw a 17 | SyntaxError exception. 18 | 19 | 15.2.1.16.3 ResolveExport 20 | 21 | [...] 22 | 9. Let starResolution be null. 23 | 10. For each ExportEntry Record e in module.[[StarExportEntries]], do 24 | a. Let importedModule be ? HostResolveImportedModule(module, 25 | e.[[ModuleRequest]]). 26 | b. Let resolution be ? importedModule.ResolveExport(exportName, 27 | resolveSet, exportStarSet). 28 | c. If resolution is "ambiguous", return "ambiguous". 29 | d. If resolution is not null, then 30 | i. If starResolution is null, let starResolution be resolution. 31 | ii. Else, 32 | 1. Assert: there is more than one * import that includes the 33 | requested name. 34 | 2. If resolution.[[Module]] and starResolution.[[Module]] are 35 | not the same Module Record or 36 | SameValue(resolution.[[BindingName]], 37 | starResolution.[[BindingName]]) is false, return "ambiguous". 38 | negative: 39 | phase: runtime 40 | type: SyntaxError 41 | flags: [module] 42 | ---*/ 43 | 44 | import { x as y } from './instn-named-err-ambiguous_FIXTURE.js'; 45 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-bndng-dflt-fun-anon.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Imported binding reflects state of exported default binding ("anonymous" 6 | function declaration) 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 17. For each element d in lexDeclarations do 11 | a. For each element dn of the BoundNames of d do 12 | i. If IsConstantDeclaration of d is true, then 13 | [...] 14 | ii. Else, 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | iii. If d is a GeneratorDeclaration production or a 17 | FunctionDeclaration production, then 18 | 1. Let fo be the result of performing InstantiateFunctionObject 19 | for d with argument env. 20 | 2. Call envRec.InitializeBinding(dn, fo). 21 | [...] 22 | 23 | 14.1.20 Runtime Semantics: InstantiateFunctionObject 24 | 25 | FunctionDeclaration : function ( FormalParameters ) { FunctionBody } 26 | 27 | 1. If the function code for FunctionDeclaration is strict mode code, let 28 | strict be true. Otherwise let strict be false. 29 | 2. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, scope, 30 | strict). 31 | 3. Perform MakeConstructor(F). 32 | 4. Perform SetFunctionName(F, "default"). 33 | 5. Return F. 34 | 35 | 14.1 Function Definitions 36 | 37 | Syntax 38 | 39 | FunctionDeclaration[Yield, Default] : 40 | 41 | function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody } 42 | [+Default] function ( FormalParameters ) { FunctionBody } 43 | flags: [module] 44 | ---*/ 45 | 46 | assert.sameValue(f(), 23, 'function value is hoisted'); 47 | assert.sameValue(f.name, 'default', 'correct name is assigned'); 48 | 49 | import f from './instn-named-bndng-dflt-fun-anon.js'; 50 | export default function() { return 23; }; 51 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-bndng-dflt-fun-named.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: > 5 | Imported binding reflects state of exported default binding ("named" 6 | function declaration) 7 | esid: sec-moduledeclarationinstantiation 8 | info: | 9 | [...] 10 | 17. For each element d in lexDeclarations do 11 | a. For each element dn of the BoundNames of d do 12 | i. If IsConstantDeclaration of d is true, then 13 | [...] 14 | ii. Else, 15 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 16 | iii. If d is a GeneratorDeclaration production or a 17 | FunctionDeclaration production, then 18 | 1. Let fo be the result of performing InstantiateFunctionObject 19 | for d with argument env. 20 | 2. Call envRec.InitializeBinding(dn, fo). 21 | [...] 22 | 23 | 14.1.20 Runtime Semantics: InstantiateFunctionObject 24 | 25 | FunctionDeclaration : function ( FormalParameters ) { FunctionBody } 26 | 27 | 1. If the function code for FunctionDeclaration is strict mode code, let 28 | strict be true. Otherwise let strict be false. 29 | 2. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, scope, 30 | strict). 31 | 3. Perform MakeConstructor(F). 32 | 4. Perform SetFunctionName(F, "default"). 33 | 5. Return F. 34 | 35 | 14.1 Function Definitions 36 | 37 | Syntax 38 | 39 | FunctionDeclaration[Yield, Default] : 40 | 41 | function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody } 42 | [+Default] function ( FormalParameters ) { FunctionBody } 43 | flags: [module] 44 | ---*/ 45 | 46 | assert.sameValue(f(), 23, 'function value is hoisted'); 47 | assert.sameValue(f.name, 'fName', 'correct name is assigned'); 48 | 49 | import f from './instn-named-bndng-dflt-fun-named.js'; 50 | export default function fName() { return 23; }; 51 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-bndng-let.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Imported binding reflects state of exported `const` binding 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 9 | a. Let importedModule be ? HostResolveImportedModule(module, 10 | in.[[ModuleRequest]]). 11 | b. If in.[[ImportName]] is "*", then 12 | [...] 13 | c. Else, 14 | i. Let resolution be ? 15 | importedModule.ResolveExport(in.[[ImportName]], « », « »). 16 | ii. If resolution is null or resolution is "ambiguous", throw a 17 | SyntaxError exception. 18 | iii. Call envRec.CreateImportBinding(in.[[LocalName]], 19 | resolution.[[Module]], resolution.[[BindingName]]). 20 | [...] 21 | 16. Let lexDeclarations be the LexicallyScopedDeclarations of code. 22 | 17. For each element d in lexDeclarations do 23 | a. For each element dn of the BoundNames of d do 24 | i, If IsConstantDeclaration of d is true, then 25 | 1. Perform ! envRec.CreateImmutableBinding(dn, true). 26 | ii. Else, 27 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 28 | iii. If d is a GeneratorDeclaration production or a 29 | FunctionDeclaration production, then 30 | [...] 31 | 32 | 8.1.1.5.5 CreateImportBinding 33 | 34 | [...] 35 | 5. Create an immutable indirect binding in envRec for N that references M 36 | and N2 as its target binding and record that the binding is initialized. 37 | 6. Return NormalCompletion(empty). 38 | flags: [module] 39 | ---*/ 40 | 41 | assert.throws(ReferenceError, function() { 42 | typeof y; 43 | }, 'binding is created but not initialized'); 44 | 45 | import { x as y } from './instn-named-bndng-let.js'; 46 | export let x = 23; 47 | -------------------------------------------------------------------------------- /test/fixtures/fake-test262/test/language/module-code/instn-named-bndng-const.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 | // This code is governed by the BSD license found in the LICENSE file. 3 | /*--- 4 | description: Imported binding reflects state of exported `const` binding 5 | esid: sec-moduledeclarationinstantiation 6 | info: | 7 | [...] 8 | 12. For each ImportEntry Record in in module.[[ImportEntries]], do 9 | a. Let importedModule be ? HostResolveImportedModule(module, 10 | in.[[ModuleRequest]]). 11 | b. If in.[[ImportName]] is "*", then 12 | [...] 13 | c. Else, 14 | i. Let resolution be ? 15 | importedModule.ResolveExport(in.[[ImportName]], « », « »). 16 | ii. If resolution is null or resolution is "ambiguous", throw a 17 | SyntaxError exception. 18 | iii. Call envRec.CreateImportBinding(in.[[LocalName]], 19 | resolution.[[Module]], resolution.[[BindingName]]). 20 | [...] 21 | 16. Let lexDeclarations be the LexicallyScopedDeclarations of code. 22 | 17. For each element d in lexDeclarations do 23 | a. For each element dn of the BoundNames of d do 24 | i, If IsConstantDeclaration of d is true, then 25 | 1. Perform ! envRec.CreateImmutableBinding(dn, true). 26 | ii. Else, 27 | 1. Perform ! envRec.CreateMutableBinding(dn, false). 28 | iii. If d is a GeneratorDeclaration production or a 29 | FunctionDeclaration production, then 30 | [...] 31 | 32 | 8.1.1.5.5 CreateImportBinding 33 | 34 | [...] 35 | 5. Create an immutable indirect binding in envRec for N that references M 36 | and N2 as its target binding and record that the binding is initialized. 37 | 6. Return NormalCompletion(empty). 38 | flags: [module] 39 | ---*/ 40 | 41 | assert.throws(ReferenceError, function() { 42 | typeof y; 43 | }, 'binding is created but not initialized'); 44 | 45 | import { x as y } from './instn-named-bndng-const.js'; 46 | export const x = 23; 47 | --------------------------------------------------------------------------------