Files
Ms2ger 1f65f0874e Bug 2041334 [wpt PR 60043] - Split {Blob,File}-constructor-endings.html, a=testonly
Automatic update from web-platform-tests
Split {Blob,File}-constructor-endings.html

The tests that don't rely on the system OS can easily be run more widely.
In particular I'd like to run them against non-web runtimes, which is easier if they're not wrapped in HTML.

--

wpt-commits: 5f18f630e8489e1f8c2755f6f07b6b081d672004
wpt-pr: 60043
2026-05-27 07:27:22 +00:00

35 lines
1.1 KiB
JavaScript

// META: title=File constructor: endings option
[
'transparent',
'native'
].forEach(value => test(t => {
assert_class_string(new File([], "name", {endings: value}), 'File',
`Constructor should allow "${value}" endings`);
}, `Valid "endings" value: ${JSON.stringify(value)}`));
[
null,
'',
'invalidEnumValue',
'Transparent',
'NATIVE',
0,
{}
].forEach(value => test(t => {
assert_throws_js(TypeError, () => new File([], "name", {endings: value}),
'File constructor should throw');
}, `Invalid "endings" value: ${JSON.stringify(value)}`));
test(t => {
const test_error = {name: 'test'};
assert_throws_exactly(
test_error,
() => new File([], "name", { get endings() { throw test_error; }}),
'File constructor should propagate exceptions from "endings" property');
}, 'Exception propagation from options');
test(t => {
let got = false;
new File([], "name", { get endings() { got = true; } });
assert_true(got, 'The "endings" property was accessed during construction.');
}, 'The "endings" options property is used');