Skip to content

Commit e7a84b0

Browse files
Update import defer tests for evaluation triggers (#4341)
1 parent 82ebbb4 commit e7a84b0

File tree

71 files changed

+1985
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1985
-181
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-defineownproperty-p-desc
6+
desc: _ [[DefineOwnProperty]]
7+
info: |
8+
[[DefineOwnProperty]] ( _P_, _Desc_ )
9+
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryDefineOwnProperty(_O_, _Desc_).
10+
1. Let _current_ be ? _O_.[[GetOwnProperty]](_P_).
11+
1. NOTE: If _O_.[[Deferred]] is *true*, the step above will ensure that the module is evaluated.
12+
1. ...
13+
14+
template: trigger-on-possible-export
15+
---*/
16+
17+
//- body
18+
try {
19+
Object.defineProperty(ns, key, { value: "hi" });
20+
} catch (_) {}

src/import-defer/delete.case

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-delete-p
6+
desc: _ [[Delete]]
7+
info: |
8+
[[Delete]] ( _P_ )
9+
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryDelete(_O_, _P_).
10+
1. Let _exports_ be ? GetModuleExportsList(_O_).
11+
1. ...
12+
13+
template: trigger-on-possible-export
14+
---*/
15+
16+
//- body
17+
try {
18+
delete ns[key];
19+
} catch (_) {}

src/import-defer/get.case

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-get-p-receiver
6+
desc: _ [[Get]]
7+
info: |
8+
[[Get]] ( _P_, _Receiver_ )
9+
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGet(_O_, _P_, _Receiver_).
10+
1. Let _exports_ be ? GetModuleExportsList(_O_).
11+
1. ...
12+
13+
template: trigger-on-possible-export
14+
---*/
15+
16+
//- body
17+
ns[key];

src/import-defer/getOwnProperty.case

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-getownproperty-p
6+
desc: _ [[GetOwnProperty]]
7+
info: |
8+
[[GetOwnProperty]] ( _P_ )
9+
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGetOwnProperty(_O_, _P_).
10+
1. Let _exports_ be ? GetModuleExportsList(_O_).
11+
1. ...
12+
13+
template: trigger-on-possible-export
14+
---*/
15+
16+
//- body
17+
Object.getOwnPropertyDescriptor(ns, key);

src/import-defer/getPrototypeOf.case

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-getprototypeof
6+
desc: _ [[GetPrototypeOf]]
7+
info: |
8+
[[GetPrototypeOf]] ( )
9+
1. Return **null**.
10+
11+
template: ignore
12+
---*/
13+
14+
//- body
15+
Object.getPrototypeOf(ns);

src/import-defer/hasProperty.case

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-hasproperty-p
6+
desc: _ [[HasProperty]]
7+
info: |
8+
[[HasProperty]] ( _P_, _Receiver_ )
9+
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGet(_O_, _P_, _Receiver_).
10+
1. Let _exports_ be ? GetModuleExportsList(_O_).
11+
1. ...
12+
13+
template: trigger-on-possible-export
14+
---*/
15+
16+
//- body
17+
key in ns;
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
path: language/import/import-defer/evaluation-triggers/ignore-
6+
name: does not trigger execution
7+
esid: sec-module-namespace-exotic-objects
8+
9+
flags: [module]
10+
features: [import-defer]
11+
---*/
12+
13+
import "./setup_FIXTURE.js";
14+
15+
import defer * as ns from "./dep_FIXTURE.js";
16+
17+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
18+
19+
/*{ body }*/
20+
21+
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");

src/import-defer/isExtensible.case

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-isextensible
6+
desc: _ [[IsExtensible]]
7+
info: |
8+
[[IsExtensible]] ( )
9+
1. Return **false**.
10+
11+
template: ignore
12+
---*/
13+
14+
//- body
15+
Object.isExtensible(ns);
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-ownpropertykeys
6+
desc: _ [[OwnPropertyKeys]]
7+
info: |
8+
[[OwnPropertyKeys]] ( )
9+
1. Let _exports_ be ? GetModuleExportsList(_O_).
10+
1. ...
11+
12+
template: trigger
13+
---*/
14+
15+
//- body
16+
Object.getOwnPropertyNames(ns);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-ownpropertykeys
6+
desc: _ [[OwnPropertyKeys]]
7+
info: |
8+
[[OwnPropertyKeys]] ( )
9+
1. Let _exports_ be ? GetModuleExportsList(_O_).
10+
1. ...
11+
12+
template: trigger
13+
---*/
14+
15+
//- body
16+
Object.getOwnPropertySymbols(ns);

src/import-defer/ownPropertyKeys.case

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-ownpropertykeys
6+
desc: _ [[OwnPropertyKeys]]
7+
info: |
8+
[[OwnPropertyKeys]] ( )
9+
1. Let _exports_ be ? GetModuleExportsList(_O_).
10+
1. ...
11+
12+
template: trigger
13+
---*/
14+
15+
//- body
16+
Reflect.ownKeys(ns);
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-preventextensions
6+
desc: _ [[IsExtensible]]
7+
info: |
8+
[[IsExtensible]] ( )
9+
1. Return **false**.
10+
11+
template: ignore
12+
---*/
13+
14+
//- body
15+
Object.preventExtensions(ns);
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-set-p-v-receiver
6+
desc: _ [[Set]] of a string which is an export name
7+
info: |
8+
[[Set]] ( _P_, _V_, _Receiver_ )
9+
1. Return **false**.
10+
11+
template: ignore
12+
---*/
13+
14+
//- body
15+
try {
16+
ns.exported = "hi";
17+
} catch (_) {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-set-p-v-receiver
6+
desc: _ [[Set]] of a string which is not an export name
7+
info: |
8+
[[Set]] ( _P_, _V_, _Receiver_ )
9+
1. Return **false**.
10+
11+
template: ignore
12+
---*/
13+
14+
//- body
15+
try {
16+
ns.notExported = "hi";
17+
} catch (_) {}

src/import-defer/setPrototypeOf.case

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-module-namespace-exotic-objects-setprototypeof
6+
desc: _ [[PreventExtensions]]
7+
info: |
8+
[[PreventExtensions]] ( )
9+
1. Return **true**.
10+
11+
template: ignore
12+
---*/
13+
14+
//- body
15+
Reflect.setPrototypeOf(ns, null);
16+
Reflect.setPrototypeOf(ns, {});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
path: language/import/import-defer/evaluation-triggers/trigger-exported-string-
6+
name: of a string that is an exported name, triggers execution
7+
esid: sec-module-namespace-exotic-objects
8+
info: |
9+
IsSymbolLikeNamespaceKey ( _P_, _O_ )
10+
1. If _P_ is a Symbol, return *true*.
11+
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
12+
1. Return *false*.
13+
14+
GetModuleExportsList ( _O_ )
15+
1. If _O_.[[Deferred]] is *true*, then
16+
1. Let _m_ be _O_.[[Module]].
17+
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
18+
1. Perform ? EvaluateSync(_m_).
19+
1. Return _O_.[[Exports]].
20+
21+
flags: [module]
22+
features: [import-defer]
23+
---*/
24+
25+
import "./setup_FIXTURE.js";
26+
27+
import defer * as ns from "./dep_FIXTURE.js";
28+
29+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
30+
31+
var key = "exported";
32+
33+
/*{ body }*/
34+
35+
assert(globalThis.evaluations.length > 0, "It triggers evaluation");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
path: language/import/import-defer/evaluation-triggers/trigger-not-exported-string-
6+
name: of a string that is not an exported name, triggers execution
7+
esid: sec-module-namespace-exotic-objects
8+
info: |
9+
IsSymbolLikeNamespaceKey ( _P_, _O_ )
10+
1. If _P_ is a Symbol, return *true*.
11+
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
12+
1. Return *false*.
13+
14+
GetModuleExportsList ( _O_ )
15+
1. If _O_.[[Deferred]] is *true*, then
16+
1. Let _m_ be _O_.[[Module]].
17+
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
18+
1. Perform ? EvaluateSync(_m_).
19+
1. Return _O_.[[Exports]].
20+
21+
flags: [module]
22+
features: [import-defer]
23+
---*/
24+
25+
import "./setup_FIXTURE.js";
26+
27+
import defer * as ns from "./dep_FIXTURE.js";
28+
29+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
30+
31+
var key = "notExported";
32+
33+
/*{ body }*/
34+
35+
assert(globalThis.evaluations.length > 0, "It triggers evaluation");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
path: language/import/import-defer/evaluation-triggers/ignore-symbol-other-
6+
name: of a symbol that is not a property of the namespace object, does not trigger execution
7+
esid: sec-module-namespace-exotic-objects
8+
info: |
9+
IsSymbolLikeNamespaceKey ( _P_, _O_ )
10+
1. If _P_ is a Symbol, return *true*.
11+
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
12+
1. Return *false*.
13+
14+
GetModuleExportsList ( _O_ )
15+
1. If _O_.[[Deferred]] is *true*, then
16+
1. Let _m_ be _O_.[[Module]].
17+
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
18+
1. Perform ? EvaluateSync(_m_).
19+
1. Return _O_.[[Exports]].
20+
21+
flags: [module]
22+
features: [import-defer]
23+
---*/
24+
25+
import "./setup_FIXTURE.js";
26+
27+
import defer * as ns from "./dep_FIXTURE.js";
28+
29+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
30+
31+
var key = Symbol();
32+
33+
/*{ body }*/
34+
35+
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");

0 commit comments

Comments
 (0)