Skip to content

Commit c32db76

Browse files
committed
[import-defer] adding new test cases to validate evaluation trigger
1 parent 61d0eb9 commit c32db76

16 files changed

+627
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (C) 2025 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]] when namespace object is in the prototype chain
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+
const obj = Object.create(ns);
18+
obj[key];
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (C) 2025 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]] when namespace object is in the prototype chain
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+
const obj = Object.create(ns);
18+
key in obj;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (C) 2025 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-privateget
6+
desc: PrivateGet and PrivateSet in a namespace object
7+
info: |
8+
PrivateGet ( O, P )
9+
1. Let entry be PrivateElementFind(O, P).
10+
1. If entry is EMPTY, throw a TypeError exception.
11+
1. If entry.[[Kind]] is either FIELD or METHOD, then
12+
a. Return entry.[[Value]].
13+
...
14+
15+
PrivateSet ( O, P, value )
16+
1. Let entry be PrivateElementFind(O, P).
17+
1. If entry is EMPTY, throw a TypeError exception.
18+
1. If entry.[[Kind]] is FIELD, then
19+
a. Set entry.[[Value]] to value.
20+
...
21+
22+
template: ignore
23+
---*/
24+
25+
//- body
26+
class Marker extends function (x) { return x } {
27+
#mark = "bar";
28+
29+
static mark(obj) {
30+
new Marker(obj);
31+
}
32+
33+
static getMark(obj) {
34+
return obj.#mark;
35+
}
36+
}
37+
38+
Marker.mark(ns);
39+
assert.sameValue(Marker.getMark(ns), "bar");
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// This file was procedurally generated from the following sources:
2+
// - src/import-defer/get-in-prototype.case
3+
// - src/import-defer/trigger-on-possible-export/then-exported.template
4+
/*---
5+
description: _ [[Get]] when namespace object is in the prototype chain (of 'then' when it is an exported name, does not trigger execution)
6+
esid: sec-module-namespace-exotic-objects
7+
features: [import-defer]
8+
flags: [generated, module]
9+
info: |
10+
IsSymbolLikeNamespaceKey ( _P_, _O_ )
11+
1. If _P_ is a Symbol, return *true*.
12+
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
13+
1. Return *false*.
14+
15+
GetModuleExportsList ( _O_ )
16+
1. If _O_.[[Deferred]] is *true*, then
17+
1. Let _m_ be _O_.[[Module]].
18+
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
19+
1. Perform ? EvaluateSync(_m_).
20+
1. Return _O_.[[Exports]].
21+
22+
23+
[[Get]] ( _P_, _Receiver_ )
24+
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGet(_O_, _P_, _Receiver_).
25+
1. Let _exports_ be ? GetModuleExportsList(_O_).
26+
1. ...
27+
28+
---*/
29+
30+
31+
import "./setup_FIXTURE.js";
32+
33+
import defer * as ns from "./dep-then_FIXTURE.js";
34+
35+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
36+
37+
var key = "then";
38+
39+
const obj = Object.create(ns);
40+
obj[key];
41+
42+
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// This file was procedurally generated from the following sources:
2+
// - src/import-defer/hasProperty-in-prototype.case
3+
// - src/import-defer/trigger-on-possible-export/then-exported.template
4+
/*---
5+
description: _ [[HasProperty]] when namespace object is in the prototype chain (of 'then' when it is an exported name, does not trigger execution)
6+
esid: sec-module-namespace-exotic-objects
7+
features: [import-defer]
8+
flags: [generated, module]
9+
info: |
10+
IsSymbolLikeNamespaceKey ( _P_, _O_ )
11+
1. If _P_ is a Symbol, return *true*.
12+
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
13+
1. Return *false*.
14+
15+
GetModuleExportsList ( _O_ )
16+
1. If _O_.[[Deferred]] is *true*, then
17+
1. Let _m_ be _O_.[[Module]].
18+
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
19+
1. Perform ? EvaluateSync(_m_).
20+
1. Return _O_.[[Exports]].
21+
22+
23+
[[HasProperty]] ( _P_, _Receiver_ )
24+
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGet(_O_, _P_, _Receiver_).
25+
1. Let _exports_ be ? GetModuleExportsList(_O_).
26+
1. ...
27+
28+
---*/
29+
30+
31+
import "./setup_FIXTURE.js";
32+
33+
import defer * as ns from "./dep-then_FIXTURE.js";
34+
35+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
36+
37+
var key = "then";
38+
39+
const obj = Object.create(ns);
40+
key in obj;
41+
42+
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// This file was procedurally generated from the following sources:
2+
// - src/import-defer/get-in-prototype.case
3+
// - src/import-defer/trigger-on-possible-export/then-not-exported.template
4+
/*---
5+
description: _ [[Get]] when namespace object is in the prototype chain (of 'then' when it is not an exported name, does not trigger execution)
6+
esid: sec-module-namespace-exotic-objects
7+
features: [import-defer]
8+
flags: [generated, module]
9+
info: |
10+
IsSymbolLikeNamespaceKey ( _P_, _O_ )
11+
1. If _P_ is a Symbol, return *true*.
12+
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
13+
1. Return *false*.
14+
15+
GetModuleExportsList ( _O_ )
16+
1. If _O_.[[Deferred]] is *true*, then
17+
1. Let _m_ be _O_.[[Module]].
18+
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
19+
1. Perform ? EvaluateSync(_m_).
20+
1. Return _O_.[[Exports]].
21+
22+
23+
[[Get]] ( _P_, _Receiver_ )
24+
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGet(_O_, _P_, _Receiver_).
25+
1. Let _exports_ be ? GetModuleExportsList(_O_).
26+
1. ...
27+
28+
---*/
29+
30+
31+
import "./setup_FIXTURE.js";
32+
33+
import defer * as ns from "./dep_FIXTURE.js";
34+
35+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
36+
37+
var key = "then";
38+
39+
const obj = Object.create(ns);
40+
obj[key];
41+
42+
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// This file was procedurally generated from the following sources:
2+
// - src/import-defer/hasProperty-in-prototype.case
3+
// - src/import-defer/trigger-on-possible-export/then-not-exported.template
4+
/*---
5+
description: _ [[HasProperty]] when namespace object is in the prototype chain (of 'then' when it is not an exported name, does not trigger execution)
6+
esid: sec-module-namespace-exotic-objects
7+
features: [import-defer]
8+
flags: [generated, module]
9+
info: |
10+
IsSymbolLikeNamespaceKey ( _P_, _O_ )
11+
1. If _P_ is a Symbol, return *true*.
12+
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
13+
1. Return *false*.
14+
15+
GetModuleExportsList ( _O_ )
16+
1. If _O_.[[Deferred]] is *true*, then
17+
1. Let _m_ be _O_.[[Module]].
18+
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
19+
1. Perform ? EvaluateSync(_m_).
20+
1. Return _O_.[[Exports]].
21+
22+
23+
[[HasProperty]] ( _P_, _Receiver_ )
24+
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGet(_O_, _P_, _Receiver_).
25+
1. Let _exports_ be ? GetModuleExportsList(_O_).
26+
1. ...
27+
28+
---*/
29+
30+
31+
import "./setup_FIXTURE.js";
32+
33+
import defer * as ns from "./dep_FIXTURE.js";
34+
35+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
36+
37+
var key = "then";
38+
39+
const obj = Object.create(ns);
40+
key in obj;
41+
42+
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// This file was procedurally generated from the following sources:
2+
// - src/import-defer/private-name-access.case
3+
// - src/import-defer/ignore/ignore.template
4+
/*---
5+
description: PrivateGet and PrivateSet in a namespace object (does not trigger execution)
6+
esid: sec-module-namespace-exotic-objects
7+
features: [import-defer]
8+
flags: [generated, module]
9+
info: |
10+
PrivateGet ( O, P )
11+
1. Let entry be PrivateElementFind(O, P).
12+
1. If entry is EMPTY, throw a TypeError exception.
13+
1. If entry.[[Kind]] is either FIELD or METHOD, then
14+
a. Return entry.[[Value]].
15+
...
16+
17+
PrivateSet ( O, P, value )
18+
1. Let entry be PrivateElementFind(O, P).
19+
1. If entry is EMPTY, throw a TypeError exception.
20+
1. If entry.[[Kind]] is FIELD, then
21+
a. Set entry.[[Value]] to value.
22+
...
23+
24+
---*/
25+
26+
27+
import "./setup_FIXTURE.js";
28+
29+
import defer * as ns from "./dep_FIXTURE.js";
30+
31+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
32+
33+
class Marker extends function (x) { return x } {
34+
#mark = "bar";
35+
36+
static mark(obj) {
37+
new Marker(obj);
38+
}
39+
40+
static getMark(obj) {
41+
return obj.#mark;
42+
}
43+
}
44+
45+
Marker.mark(ns);
46+
assert.sameValue(Marker.getMark(ns), "bar");
47+
48+
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// This file was procedurally generated from the following sources:
2+
// - src/import-defer/get-in-prototype.case
3+
// - src/import-defer/trigger-on-possible-export/symbol-other.template
4+
/*---
5+
description: _ [[Get]] when namespace object is in the prototype chain (of a symbol that is not a property of the namespace object, does not trigger execution)
6+
esid: sec-module-namespace-exotic-objects
7+
features: [import-defer]
8+
flags: [generated, module]
9+
info: |
10+
IsSymbolLikeNamespaceKey ( _P_, _O_ )
11+
1. If _P_ is a Symbol, return *true*.
12+
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
13+
1. Return *false*.
14+
15+
GetModuleExportsList ( _O_ )
16+
1. If _O_.[[Deferred]] is *true*, then
17+
1. Let _m_ be _O_.[[Module]].
18+
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
19+
1. Perform ? EvaluateSync(_m_).
20+
1. Return _O_.[[Exports]].
21+
22+
23+
[[Get]] ( _P_, _Receiver_ )
24+
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGet(_O_, _P_, _Receiver_).
25+
1. Let _exports_ be ? GetModuleExportsList(_O_).
26+
1. ...
27+
28+
---*/
29+
30+
31+
import "./setup_FIXTURE.js";
32+
33+
import defer * as ns from "./dep_FIXTURE.js";
34+
35+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
36+
37+
var key = Symbol();
38+
39+
const obj = Object.create(ns);
40+
obj[key];
41+
42+
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// This file was procedurally generated from the following sources:
2+
// - src/import-defer/hasProperty-in-prototype.case
3+
// - src/import-defer/trigger-on-possible-export/symbol-other.template
4+
/*---
5+
description: _ [[HasProperty]] when namespace object is in the prototype chain (of a symbol that is not a property of the namespace object, does not trigger execution)
6+
esid: sec-module-namespace-exotic-objects
7+
features: [import-defer]
8+
flags: [generated, module]
9+
info: |
10+
IsSymbolLikeNamespaceKey ( _P_, _O_ )
11+
1. If _P_ is a Symbol, return *true*.
12+
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
13+
1. Return *false*.
14+
15+
GetModuleExportsList ( _O_ )
16+
1. If _O_.[[Deferred]] is *true*, then
17+
1. Let _m_ be _O_.[[Module]].
18+
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
19+
1. Perform ? EvaluateSync(_m_).
20+
1. Return _O_.[[Exports]].
21+
22+
23+
[[HasProperty]] ( _P_, _Receiver_ )
24+
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGet(_O_, _P_, _Receiver_).
25+
1. Let _exports_ be ? GetModuleExportsList(_O_).
26+
1. ...
27+
28+
---*/
29+
30+
31+
import "./setup_FIXTURE.js";
32+
33+
import defer * as ns from "./dep_FIXTURE.js";
34+
35+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
36+
37+
var key = Symbol();
38+
39+
const obj = Object.create(ns);
40+
key in obj;
41+
42+
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");

0 commit comments

Comments
 (0)