[source-phase-imports] Dynamic import source call

Add source phase import support in import calls with necessary
embedder APIs. When a imported module does not support source phase
representation, a ReferenceError is thrown in d8.

Bug: 42204365
Change-Id: If40cadfcdf0a547f24d20c67149bba559480341d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5878343
Commit-Queue: Chengzhong Wu (legendecas) <legendecas@gmail.com>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#96473}
This commit is contained in:
Chengzhong Wu 2024-10-08 22:19:25 -07:00 committed by test262-merge-bot
parent 6c967a8bbb
commit 0596ff6981
3 changed files with 35 additions and 0 deletions

View File

@ -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");
});

View File

@ -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';

View File

@ -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;