mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
ECMA262 allows for an arbitrary number of "ScriptJob"s to run in a given realm. Although there is no standard mechanism for enqueuing these jobs, many implementations offer this functionality through custom APIs. In those hosts, the semantics describing script interactions are directly observable. In order to guarantee conformance to the specification in advance of a standardized API, Test262 now requires that hosts provide a $.evalScript function whose behavior is defined in the project's "INTERPRETING.md" file. Use this host-provided API to ensure that implementations correctly observe the specification text that dictates script interactions. (In writing these tests, I noticed some gaps in coverage that are observable from a single script execution. This patch includes a dedicated commit for these tests that do not require $.evalScript.) * Improve coverage of GlobalDeclarationInstantiation * Add tests for script interactions Use the host-provied `$.evalScript` method to assert conformance to the specification text that defines script interactions. * fixup! Improve coverage of GlobalDeclarationInstantiation
43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
/*---
|
|
esid: sec-globaldeclarationinstantiation
|
|
es6id: 15.1.8
|
|
description: Declaration of variable where permissible
|
|
info: |
|
|
[...]
|
|
11. Let declaredVarNames be a new empty List.
|
|
12. For each d in varDeclarations, do
|
|
a. If d is a VariableDeclaration or a ForBinding, then
|
|
i. For each String vn in the BoundNames of d, do
|
|
1. If vn is not an element of declaredFunctionNames, then
|
|
a. Let vnDefinable be ? envRec.CanDeclareGlobalVar(vn).
|
|
b. If vnDefinable is false, throw a TypeError exception.
|
|
c. If vn is not an element of declaredVarNames, then
|
|
i. Append vn to declaredVarNames.
|
|
[...]
|
|
18. For each String vn in declaredVarNames, in list order do
|
|
a. Perform ? envRec.CreateGlobalVarBinding(vn, false).
|
|
[...]
|
|
|
|
8.1.1.4.15 CanDeclareGlobalVar
|
|
|
|
1. Let envRec be the global Environment Record for which the method was
|
|
invoked.
|
|
2. Let ObjRec be envRec.[[ObjectRecord]].
|
|
3. Let globalObject be the binding object for ObjRec.
|
|
4. Let hasProperty be ? HasOwnProperty(globalObject, N).
|
|
5. If hasProperty is true, return true.
|
|
6. Return ? IsExtensible(globalObject).
|
|
includes: [propertyHelper.js]
|
|
---*/
|
|
|
|
assert.sameValue(
|
|
this.brandNew, undefined, 'new binding on an extensible global object'
|
|
);
|
|
verifyEnumerable(this, 'brandNew');
|
|
verifyWritable(this, 'brandNew');
|
|
verifyNotConfigurable(this, 'brandNew');
|
|
|
|
var brandNew;
|