diff --git a/src/import-defer/evaluation-triggers/defineOwnProperty.case b/src/import-defer/evaluation-triggers/defineOwnProperty.case new file mode 100644 index 0000000000..53a6e8d290 --- /dev/null +++ b/src/import-defer/evaluation-triggers/defineOwnProperty.case @@ -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 (_) {} diff --git a/src/import-defer/evaluation-triggers/delete.case b/src/import-defer/evaluation-triggers/delete.case new file mode 100644 index 0000000000..7c98eca4e2 --- /dev/null +++ b/src/import-defer/evaluation-triggers/delete.case @@ -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 (_) {} diff --git a/src/import-defer/evaluation-triggers/get.case b/src/import-defer/evaluation-triggers/get.case new file mode 100644 index 0000000000..26ab7d764e --- /dev/null +++ b/src/import-defer/evaluation-triggers/get.case @@ -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]; diff --git a/src/import-defer/evaluation-triggers/getOwnProperty.case b/src/import-defer/evaluation-triggers/getOwnProperty.case new file mode 100644 index 0000000000..835e75b2c9 --- /dev/null +++ b/src/import-defer/evaluation-triggers/getOwnProperty.case @@ -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); diff --git a/src/import-defer/evaluation-triggers/getPrototypeOf.case b/src/import-defer/evaluation-triggers/getPrototypeOf.case new file mode 100644 index 0000000000..39a403f4df --- /dev/null +++ b/src/import-defer/evaluation-triggers/getPrototypeOf.case @@ -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); diff --git a/src/import-defer/evaluation-triggers/hasProperty.case b/src/import-defer/evaluation-triggers/hasProperty.case new file mode 100644 index 0000000000..44bab78a4b --- /dev/null +++ b/src/import-defer/evaluation-triggers/hasProperty.case @@ -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; diff --git a/src/import-defer/evaluation-triggers/ignore/ignore.template b/src/import-defer/evaluation-triggers/ignore/ignore.template new file mode 100644 index 0000000000..e4ba090495 --- /dev/null +++ b/src/import-defer/evaluation-triggers/ignore/ignore.template @@ -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"); diff --git a/src/import-defer/evaluation-triggers/isExtensible.case b/src/import-defer/evaluation-triggers/isExtensible.case new file mode 100644 index 0000000000..429c796ab7 --- /dev/null +++ b/src/import-defer/evaluation-triggers/isExtensible.case @@ -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); diff --git a/src/import-defer/evaluation-triggers/ownPropertyKey-names.case b/src/import-defer/evaluation-triggers/ownPropertyKey-names.case new file mode 100644 index 0000000000..a4723edec2 --- /dev/null +++ b/src/import-defer/evaluation-triggers/ownPropertyKey-names.case @@ -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); diff --git a/src/import-defer/evaluation-triggers/ownPropertyKeys-symbols.case b/src/import-defer/evaluation-triggers/ownPropertyKeys-symbols.case new file mode 100644 index 0000000000..cbf7e39ff7 --- /dev/null +++ b/src/import-defer/evaluation-triggers/ownPropertyKeys-symbols.case @@ -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); diff --git a/src/import-defer/evaluation-triggers/ownPropertyKeys.case b/src/import-defer/evaluation-triggers/ownPropertyKeys.case new file mode 100644 index 0000000000..9716b0d808 --- /dev/null +++ b/src/import-defer/evaluation-triggers/ownPropertyKeys.case @@ -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); diff --git a/src/import-defer/evaluation-triggers/preventExtensions.case b/src/import-defer/evaluation-triggers/preventExtensions.case new file mode 100644 index 0000000000..66ef7b39ef --- /dev/null +++ b/src/import-defer/evaluation-triggers/preventExtensions.case @@ -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); diff --git a/src/import-defer/evaluation-triggers/set-string-exported.case b/src/import-defer/evaluation-triggers/set-string-exported.case new file mode 100644 index 0000000000..eedfefec7f --- /dev/null +++ b/src/import-defer/evaluation-triggers/set-string-exported.case @@ -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 (_) {} diff --git a/src/import-defer/evaluation-triggers/set-string-not-exported.case b/src/import-defer/evaluation-triggers/set-string-not-exported.case new file mode 100644 index 0000000000..fb92e61d79 --- /dev/null +++ b/src/import-defer/evaluation-triggers/set-string-not-exported.case @@ -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 (_) {} diff --git a/src/import-defer/evaluation-triggers/setPrototypeOf.case b/src/import-defer/evaluation-triggers/setPrototypeOf.case new file mode 100644 index 0000000000..1dd218f590 --- /dev/null +++ b/src/import-defer/evaluation-triggers/setPrototypeOf.case @@ -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, {}); diff --git a/src/import-defer/evaluation-triggers/trigger-on-possible-export/string-exported.template b/src/import-defer/evaluation-triggers/trigger-on-possible-export/string-exported.template new file mode 100644 index 0000000000..9011006fb7 --- /dev/null +++ b/src/import-defer/evaluation-triggers/trigger-on-possible-export/string-exported.template @@ -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"); diff --git a/src/import-defer/evaluation-triggers/trigger-on-possible-export/string-not-exported.template b/src/import-defer/evaluation-triggers/trigger-on-possible-export/string-not-exported.template new file mode 100644 index 0000000000..323fd59101 --- /dev/null +++ b/src/import-defer/evaluation-triggers/trigger-on-possible-export/string-not-exported.template @@ -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"); diff --git a/src/import-defer/evaluation-triggers/trigger-on-possible-export/symbol-other.template b/src/import-defer/evaluation-triggers/trigger-on-possible-export/symbol-other.template new file mode 100644 index 0000000000..3deeca09be --- /dev/null +++ b/src/import-defer/evaluation-triggers/trigger-on-possible-export/symbol-other.template @@ -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"); \ No newline at end of file diff --git a/src/import-defer/evaluation-triggers/trigger-on-possible-export/symbol-toStringTag.template b/src/import-defer/evaluation-triggers/trigger-on-possible-export/symbol-toStringTag.template new file mode 100644 index 0000000000..9fca1e672d --- /dev/null +++ b/src/import-defer/evaluation-triggers/trigger-on-possible-export/symbol-toStringTag.template @@ -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-toStringTag- +name: of Symbol.toStringTag, 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.toStringTag; + +/*{ body }*/ + +assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation"); \ No newline at end of file diff --git a/src/import-defer/evaluation-triggers/trigger-on-possible-export/then-exported.template b/src/import-defer/evaluation-triggers/trigger-on-possible-export/then-exported.template new file mode 100644 index 0000000000..d0359a1e17 --- /dev/null +++ b/src/import-defer/evaluation-triggers/trigger-on-possible-export/then-exported.template @@ -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-exported-then- +name: of 'then' when it is an exported name, 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-then_FIXTURE.js"; + +assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation"); + +var key = "then"; + +/*{ body }*/ + +assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation"); \ No newline at end of file diff --git a/src/import-defer/evaluation-triggers/trigger-on-possible-export/then-not-exported.template b/src/import-defer/evaluation-triggers/trigger-on-possible-export/then-not-exported.template new file mode 100644 index 0000000000..b13ddba12c --- /dev/null +++ b/src/import-defer/evaluation-triggers/trigger-on-possible-export/then-not-exported.template @@ -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-not-exported-then- +name: of 'then' when it is not an exported name, 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 = "then"; + +/*{ body }*/ + +assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation"); \ No newline at end of file diff --git a/src/import-defer/evaluation-triggers/trigger/trigger.template b/src/import-defer/evaluation-triggers/trigger/trigger.template new file mode 100644 index 0000000000..e7fbe80c83 --- /dev/null +++ b/src/import-defer/evaluation-triggers/trigger/trigger.template @@ -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/trigger- +name: triggers 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(globalThis.evaluations.length > 0, "It triggers evaluation");