fix test in module/script modes

This commit is contained in:
Leo Balter 2018-10-04 15:56:22 -04:00 committed by Rick Waldron
parent 7f69f1c6bf
commit 292fd0c956
2 changed files with 42 additions and 1 deletions

View File

@ -11,8 +11,11 @@ info: |
a. Let requiredModule be ? HostResolveImportedModule(module, required).
b. Perform ? requiredModule.ModuleEvaluation().
[...]
This test is meant to be flagged as module code, it should not initially
run as script code or the result will not be the same.
includes: [fnGlobalObject.js]
flags: [async]
flags: [async, module]
features: [dynamic-import]
---*/

View File

@ -0,0 +1,38 @@
// Copyright (C) 2018 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Script is evaluated exactly once after loaded by import
esid: sec-hostimportmoduledynamically
info: |
Success path
The completion value of any subsequent call to HostResolveImportedModule after
FinishDynamicImport has completed, given the arguments referencingScriptOrModule
and specifier, must be a module which has already been evaluated, i.e. whose
Evaluate concrete method has already been called and returned a normal completion.
This test is meant to __not__ be flagged as module code, it should not initially
run as module code or the result will not be the same.
includes: [fnGlobalObject.js]
flags: [async]
features: [dynamic-import]
---*/
var global = fnGlobalObject();
if (typeof global.evaluated === 'undefined') {
global.evaluated = 0;
}
global.evaluated++;
Promise.all([
import('./eval-self-once-script.js'),
import('./eval-self-once-script.js'),
]).then(async () => {
// Use await to serialize imports
await import('./eval-self-once-script.js');
await import('./eval-self-once-script.js');
assert.sameValue(global.evaluated, 2, 'global property was defined and incremented only once');
}).then($DONE, $DONE);