Skip to content

Commit

Permalink
test: fill DOMException names
Browse files Browse the repository at this point in the history
  • Loading branch information
LiviaMedeiros committed Jun 29, 2022
1 parent ea99431 commit f02e01e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
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',
});
}

0 comments on commit f02e01e

Please sign in to comment.