1// Copyright 2017 the V8 project authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5// Flags: --allow-natives-syntax --harmony-dynamic-import 6 7globalThis.ran = false; 8globalThis.x = undefined; 9 10let body = "import('modules-skip-1.mjs').then(ns => { x = ns.life();" + 11 " ran = true;} ).catch(err => %AbortJS(err))" 12let func = new Function(body); 13func(); 14 15%PerformMicrotaskCheckpoint(); 16assertEquals(42, globalThis.x); 17assertTrue(globalThis.ran); 18 19globalThis.ran = false; 20body = "import('modules-skip-1.mjs').then(ns => { x = ns.life();" + 21 " ran = true;} ).catch(err => %AbortJS(err))" 22eval("var func = new Function(body); func();"); 23 24%PerformMicrotaskCheckpoint(); 25assertEquals(42, globalThis.x); 26assertTrue(globalThis.ran); 27 28globalThis.ran = false; 29body = "eval(import('modules-skip-1.mjs').then(ns => { x = ns.life();" + 30 " ran = true;} ).catch(err => %AbortJS(err)))" 31func = new Function(body); 32func(); 33 34%PerformMicrotaskCheckpoint(); 35assertEquals(42, globalThis.x); 36assertTrue(globalThis.ran); 37