v8/test/mjsunit/harmony/modules-import-15.mjs
Shu-yu Guo 1cb0fac0a7 [top-level-await] Ship top-level await
Note that top-level await is already on-by-default in blink. This flips
the flag in V8 only for other embedders.

Bug: v8:9344
Change-Id: Ic860b22316718b353a0493799fdf95200a71acc1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2746843
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Auto-Submit: Shu-yu Guo <syg@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73416}
2021-03-15 23:34:34 +00:00

42 lines
952 B
JavaScript

// Copyright 2017 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.
// Flags: --allow-natives-syntax --harmony-dynamic-import
var ran = false;
async function test2() {
try {
let x = await import('modules-skip-9.mjs');
%AbortJS('failure: should be unreachable');
} catch(e) {
assertInstanceof(e, SyntaxError);
assertEquals(
"The requested module 'modules-skip-empty.mjs' does not provide an " +
"export named 'default'",
e.message);
ran = true;
}
}
test2();
%PerformMicrotaskCheckpoint();
assertTrue(ran);
ran = false;
async function test3() {
try {
let x = await import('nonexistent-file.mjs');
%AbortJS('failure: should be unreachable');
} catch(e) {
assertTrue(e.message.startsWith('d8: Error reading'));
ran = true;
}
}
test3();
%PerformMicrotaskCheckpoint();
assertTrue(ran);