diff --git a/test/staging/source-phase-imports/import-source-source-text-module.js b/test/staging/source-phase-imports/import-source-source-text-module.js new file mode 100644 index 00000000000..b0743969795 --- /dev/null +++ b/test/staging/source-phase-imports/import-source-source-text-module.js @@ -0,0 +1,24 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +/*--- +description: > + GetModuleSource of SourceTextModule throws a ReferenceError. +esid: sec-source-text-module-record-getmodulesource +features: [source-phase-imports] +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + await assert.throwsAsync( + ReferenceError, + () => import.source('./modules-simple_FIXTURE.js'), + "Promise should be rejected with ReferenceError"); + + // Import a module that has a source phase import. + await assert.throwsAsync( + ReferenceError, + () => import('./modules-import-source_FIXTURE.js'), + "Promise should be rejected with ReferenceError in indirect import source"); +}); diff --git a/test/staging/source-phase-imports/modules-import-source_FIXTURE.js b/test/staging/source-phase-imports/modules-import-source_FIXTURE.js new file mode 100644 index 00000000000..31b931019b0 --- /dev/null +++ b/test/staging/source-phase-imports/modules-import-source_FIXTURE.js @@ -0,0 +1,5 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import source x from './modules-simple_FIXTURE.js'; diff --git a/test/staging/source-phase-imports/modules-simple_FIXTURE.js b/test/staging/source-phase-imports/modules-simple_FIXTURE.js new file mode 100644 index 00000000000..00ecf07ccc7 --- /dev/null +++ b/test/staging/source-phase-imports/modules-simple_FIXTURE.js @@ -0,0 +1,6 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Just a module file that does nothing. +export const x = 42;