Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fill DOMException names #43615

Merged
Merged
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
5 changes: 4 additions & 1 deletion test/parallel/test-abortcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ const { setTimeout: sleep } = require('timers/promises');

{
// Test abortSignal.throwIfAborted()
throws(() => AbortSignal.abort().throwIfAborted(), { code: 20 });
throws(() => AbortSignal.abort().throwIfAborted(), {
code: 20,
name: 'AbortError',
});

// Does not throw because it's not aborted.
const ac = new AbortController();
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-filehandle-readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ const check = readFileSync(__filename, { encoding: 'utf8' });
const mc = new MessageChannel();
mc.port1.onmessage = common.mustNotCall();
assert.throws(() => mc.port2.postMessage(file, [file]), {
code: 25 // DataCloneError
code: 25,
name: 'DataCloneError',
});
mc.port1.close();
await file.close();
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-fs-promises-file-handle-read-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if (isMainThread || !workerData) {
});
}, {
code: 25,
name: 'DataCloneError',
});
} finally {
await handle.close();
Expand Down
7 changes: 4 additions & 3 deletions test/parallel/test-webcrypto-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ for (const ctor of intTypedConstructors) {
}

if (kData !== undefined) {
assert.throws(() => webcrypto.getRandomValues(kData), {
code: 22
});
assert.throws(
() => webcrypto.getRandomValues(kData),
{ name: 'QuotaExceededError', code: 22 },
);
}
}
31 changes: 22 additions & 9 deletions test/parallel/test-whatwg-webstreams-transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,16 @@ const theData = 'hello';
start(c) { controller = c; },

cancel: common.mustCall((error) => {
assert.strictEqual(error.code, 25); // DataCloneError
assert.strictEqual(error.code, 25);
assert.strictEqual(error.name, 'DataCloneError');
}),
});

port1.onmessage = ({ data }) => {
const reader = data.getReader();
assert.rejects(reader.read(), {
code: 25, // DataCloneError
code: 25,
name: 'DataCloneError',
});
port1.close();
};
Expand Down Expand Up @@ -354,7 +356,10 @@ const theData = 'hello';

const source = {
abort: common.mustCall((error) => {
process.nextTick(() => assert.strictEqual(error.code, 25));
process.nextTick(() => {
assert.strictEqual(error.code, 25);
assert.strictEqual(error.name, 'DataCloneError');
});
})
};

Expand All @@ -366,7 +371,8 @@ const theData = 'hello';
const m = new WebAssembly.Memory({ initial: 1 });

assert.rejects(writer.abort(m), {
code: 25
code: 25,
name: 'DataCloneError',
});
port1.close();
});
Expand Down Expand Up @@ -437,7 +443,10 @@ const theData = 'hello';
{
const source = {
cancel: common.mustCall((error) => {
process.nextTick(() => assert(error.code, 25));
process.nextTick(() => {
assert.strictEqual(error.code, 25);
assert.strictEqual(error.name, 'DataCloneError');
});
}),
};

Expand All @@ -455,7 +464,8 @@ const theData = 'hello';
reader.closed.then(common.mustCall());

assert.rejects(cancel, {
code: 25
code: 25,
name: 'DataCloneError',
});

port1.close();
Expand All @@ -469,6 +479,7 @@ const theData = 'hello';
abort: common.mustCall((error) => {
process.nextTick(() => {
assert.strictEqual(error.code, 25);
assert.strictEqual(error.name, 'DataCloneError');
});
}),
};
Expand All @@ -481,7 +492,7 @@ const theData = 'hello';
const m = new WebAssembly.Memory({ initial: 1 });
const writer = data.getWriter();
const write = writer.write(m);
assert.rejects(write, { code: 25 });
assert.rejects(write, { code: 25, name: 'DataCloneError' });
port1.close();
});

Expand All @@ -492,12 +503,14 @@ const theData = 'hello';
const readable = new ReadableStream();
readable.getReader();
assert.throws(() => readable[kTransfer](), {
code: 25
code: 25,
name: 'DataCloneError',
});

const writable = new WritableStream();
writable.getWriter();
assert.throws(() => writable[kTransfer](), {
code: 25
code: 25,
name: 'DataCloneError',
});
}