Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ Atomics.pause
# https://tc39.es/proposal-defer-import-eval
import-defer

# Import Text
# https://github.com/tc39/proposal-import-text
import-text

# Iterator Sequencing
# https://github.com/tc39/proposal-iterator-sequencing
iterator-sequencing
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (C) 2025 Mozilla Foundation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-create-text-module
description: Dynamic import of text files
flags: [async]
features: [dynamic-import, import-attributes, import-text]
---*/

import('./2nd-param_FIXTURE.json', { with: { type: 'text' } })
.then((module) => {
assert.sameValue(module.default, '262\n');
})
.then($DONE, $DONE);
20 changes: 20 additions & 0 deletions test/language/import/import-attributes/text-empty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2025 Mozilla Foundation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-create-text-module
description: Correctly parses an empty file
info: |
# 16.2.1.8.x CreateTextModule ( source )

The abstract operation CreateTextModule takes argument source (a String) and
returns a normal completion containing a Synthetic Module Record.
It performs the following steps when called:

1. Return CreateDefaultExportSyntheticModule(source).
flags: [module]
features: [import-attributes, import-text]
---*/

import value from './text-valid_FIXTURE' with { type: 'text' };

assert.sameValue(value, '');
Empty file.
20 changes: 20 additions & 0 deletions test/language/import/import-attributes/text-javascript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2025 Mozilla Foundation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-create-text-module
description: Does not parse imported module as JavaScript
info: |
# 16.2.1.8.x CreateTextModule ( source )

The abstract operation CreateTextModule takes argument source (a String) and
returns a normal completion containing a Synthetic Module Record.
It performs the following steps when called:

1. Return CreateDefaultExportSyntheticModule(source).
flags: [module]
features: [import-attributes, import-text]
---*/

import value from './text-javascript_FIXTURE.js' with { type: 'text' };

assert(value.includes('throw "This should not be evaluated."'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (C) 2025 Mozilla Foundation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

throw "This should not be evaluated."
15 changes: 15 additions & 0 deletions test/language/import/import-attributes/text-self.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2025 Mozilla Foundation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-create-text-module
description: Supports self-referential text imports
flags: [module]
features: [import-attributes, import-text]
---*/

import value from './text-self.js' with { type: 'text' };

assert(value.startsWith('// Copyright (C) 2025 Mozilla Foundation.'));
assert(
value.includes("import value from './text-self.js' with { type: 'text' };")
);
20 changes: 20 additions & 0 deletions test/language/import/import-attributes/text-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2025 Mozilla Foundation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-create-text-module
description: Correctly parses a text file
info: |
# 16.2.1.8.x CreateTextModule ( source )

The abstract operation CreateTextModule takes argument source (a String) and
returns a normal completion containing a Synthetic Module Record.
It performs the following steps when called:

1. Return CreateDefaultExportSyntheticModule(source).
flags: [module]
features: [import-attributes, import-text]
---*/

import value from './text-string_FIXTURE' with { type: 'text' };

assert.sameValue(value, 'a string value\n');
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a string value
13 changes: 13 additions & 0 deletions test/language/import/import-attributes/text-via-namespace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (C) 2025 Mozilla Foundation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-create-text-module
description: May be imported via a module namespace object
flags: [module]
features: [import-attributes, import-text]
---*/

import * as ns from './text-via-namespace_FIXTURE' with { type: 'text' };

assert.sameValue(Object.getOwnPropertyNames(ns).length, 1);
assert.sameValue(ns.default, "262\n");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
262