Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update import defer tests for evaluation triggers #4341

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/import-defer/evaluation-triggers/defineOwnProperty.case
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-defineownproperty-p-desc
desc: _ [[DefineOwnProperty]]
info: |
[[DefineOwnProperty]] ( _P_, _Desc_ )
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryDefineOwnProperty(_O_, _Desc_).
1. Let _current_ be ? _O_.[[GetOwnProperty]](_P_).
1. NOTE: If _O_.[[Deferred]] is *true*, the step above will ensure that the module is evaluated.
1. ...

template: trigger-on-possible-export
---*/

//- body
try {
Object.defineProperty(ns, key, { value: "hi" });
} catch (_) {}
19 changes: 19 additions & 0 deletions src/import-defer/evaluation-triggers/delete.case
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-delete-p
desc: _ [[Delete]]
info: |
[[Delete]] ( _P_ )
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryDelete(_O_, _P_).
1. Let _exports_ be ? GetModuleExportsList(_O_).
1. ...

template: trigger-on-possible-export
---*/

//- body
try {
delete ns[key];
} catch (_) {}
17 changes: 17 additions & 0 deletions src/import-defer/evaluation-triggers/get.case
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-get-p-receiver
desc: _ [[Get]]
info: |
[[Get]] ( _P_, _Receiver_ )
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGet(_O_, _P_, _Receiver_).
1. Let _exports_ be ? GetModuleExportsList(_O_).
1. ...

template: trigger-on-possible-export
---*/

//- body
ns[key];
17 changes: 17 additions & 0 deletions src/import-defer/evaluation-triggers/getOwnProperty.case
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-getownproperty-p
desc: _ [[GetOwnProperty]]
info: |
[[GetOwnProperty]] ( _P_ )
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGetOwnProperty(_O_, _P_).
1. Let _exports_ be ? GetModuleExportsList(_O_).
1. ...

template: trigger-on-possible-export
---*/

//- body
Object.getOwnPropertyDescriptor(ns, key);
15 changes: 15 additions & 0 deletions src/import-defer/evaluation-triggers/getPrototypeOf.case
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-getprototypeof
desc: _ [[GetPrototypeOf]]
info: |
[[GetPrototypeOf]] ( )
1. Return **null**.

template: ignore
---*/

//- body
Object.getPrototypeOf(ns);
17 changes: 17 additions & 0 deletions src/import-defer/evaluation-triggers/hasProperty.case
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-hasproperty-p
desc: _ [[HasProperty]]
info: |
[[HasProperty]] ( _P_, _Receiver_ )
1. If IsSymbolLikeNamespaceKey(_P_, _O_), return ! OrdinaryGet(_O_, _P_, _Receiver_).
1. Let _exports_ be ? GetModuleExportsList(_O_).
1. ...

template: trigger-on-possible-export
---*/

//- body
key in ns;
21 changes: 21 additions & 0 deletions src/import-defer/evaluation-triggers/ignore/ignore.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
path: language/import/import-defer/evaluation-triggers/ignore-
name: does not trigger execution
esid: sec-module-namespace-exotic-objects

flags: [module]
features: [import-defer]
---*/

import "./setup_FIXTURE.js";

import defer * as ns from "./dep_FIXTURE.js";

assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");

/*{ body }*/

assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");
15 changes: 15 additions & 0 deletions src/import-defer/evaluation-triggers/isExtensible.case
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-isextensible
desc: _ [[IsExtensible]]
info: |
[[IsExtensible]] ( )
1. Return **false**.

template: ignore
---*/

//- body
Object.isExtensible(ns);
16 changes: 16 additions & 0 deletions src/import-defer/evaluation-triggers/ownPropertyKey-names.case
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-ownpropertykeys
desc: _ [[OwnPropertyKeys]]
info: |
[[OwnPropertyKeys]] ( )
1. Let _exports_ be ? GetModuleExportsList(_O_).
1. ...

template: trigger
---*/

//- body
Object.getOwnPropertyNames(ns);
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-ownpropertykeys
desc: _ [[OwnPropertyKeys]]
info: |
[[OwnPropertyKeys]] ( )
1. Let _exports_ be ? GetModuleExportsList(_O_).
1. ...

template: trigger
---*/

//- body
Object.getOwnPropertySymbols(ns);
16 changes: 16 additions & 0 deletions src/import-defer/evaluation-triggers/ownPropertyKeys.case
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-ownpropertykeys
desc: _ [[OwnPropertyKeys]]
info: |
[[OwnPropertyKeys]] ( )
1. Let _exports_ be ? GetModuleExportsList(_O_).
1. ...

template: trigger
---*/

//- body
Reflect.ownKeys(ns);
15 changes: 15 additions & 0 deletions src/import-defer/evaluation-triggers/preventExtensions.case
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-preventextensions
desc: _ [[IsExtensible]]
info: |
[[IsExtensible]] ( )
1. Return **false**.

template: ignore
---*/

//- body
Object.preventExtensions(ns);
17 changes: 17 additions & 0 deletions src/import-defer/evaluation-triggers/set-string-exported.case
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-set-p-v-receiver
desc: _ [[Set]] of a string which is an export name
info: |
[[Set]] ( _P_, _V_, _Receiver_ )
1. Return **false**.

template: ignore
---*/

//- body
try {
ns.exported = "hi";
} catch (_) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-set-p-v-receiver
desc: _ [[Set]] of a string which is not an export name
info: |
[[Set]] ( _P_, _V_, _Receiver_ )
1. Return **false**.

template: ignore
---*/

//- body
try {
ns.notExported = "hi";
} catch (_) {}
16 changes: 16 additions & 0 deletions src/import-defer/evaluation-triggers/setPrototypeOf.case
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-module-namespace-exotic-objects-setprototypeof
desc: _ [[PreventExtensions]]
info: |
[[PreventExtensions]] ( )
1. Return **true**.

template: ignore
---*/

//- body
Reflect.setPrototypeOf(ns, null);
Reflect.setPrototypeOf(ns, {});
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
path: language/import/import-defer/evaluation-triggers/trigger-exported-string-
name: of a string that is an exported name, triggers execution
esid: sec-module-namespace-exotic-objects
info: |
IsSymbolLikeNamespaceKey ( _P_, _O_ )
1. If _P_ is a Symbol, return *true*.
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
1. Return *false*.

GetModuleExportsList ( _O_ )
1. If _O_.[[Deferred]] is *true*, then
1. Let _m_ be _O_.[[Module]].
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
1. Perform ? EvaluateSync(_m_).
1. Return _O_.[[Exports]].

flags: [module]
features: [import-defer]
---*/

import "./setup_FIXTURE.js";

import defer * as ns from "./dep_FIXTURE.js";

assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");

var key = "exported";

/*{ body }*/

assert(globalThis.evaluations.length > 0, "It triggers evaluation");
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
path: language/import/import-defer/evaluation-triggers/trigger-not-exported-string-
name: of a string that is not an exported name, triggers execution
esid: sec-module-namespace-exotic-objects
info: |
IsSymbolLikeNamespaceKey ( _P_, _O_ )
1. If _P_ is a Symbol, return *true*.
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
1. Return *false*.

GetModuleExportsList ( _O_ )
1. If _O_.[[Deferred]] is *true*, then
1. Let _m_ be _O_.[[Module]].
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
1. Perform ? EvaluateSync(_m_).
1. Return _O_.[[Exports]].

flags: [module]
features: [import-defer]
---*/

import "./setup_FIXTURE.js";

import defer * as ns from "./dep_FIXTURE.js";

assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");

var key = "notExported";

/*{ body }*/

assert(globalThis.evaluations.length > 0, "It triggers evaluation");
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
path: language/import/import-defer/evaluation-triggers/ignore-symbol-other-
name: of a symbol that is not a property of the namespace object, does not trigger execution
esid: sec-module-namespace-exotic-objects
info: |
IsSymbolLikeNamespaceKey ( _P_, _O_ )
1. If _P_ is a Symbol, return *true*.
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
1. Return *false*.

GetModuleExportsList ( _O_ )
1. If _O_.[[Deferred]] is *true*, then
1. Let _m_ be _O_.[[Module]].
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
1. Perform ? EvaluateSync(_m_).
1. Return _O_.[[Exports]].

flags: [module]
features: [import-defer]
---*/

import "./setup_FIXTURE.js";

import defer * as ns from "./dep_FIXTURE.js";

assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");

var key = Symbol();

/*{ body }*/

assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");
Loading
Loading