Skip to content
Open
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
17 changes: 17 additions & 0 deletions IndexedDB/structured-clone.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,23 @@ cloneObjectTest(new Set([1,2,3,4]), (orig, clone) => {
assert_equals(orig.message, clone.message);
}));

[
new SuppressedError(),
new SuppressedError(new Error('resulted'), new Error('suppressed')),
].forEach(value => cloneObjectTest(value, (orig, clone) => {
assert_equals(orig.name, clone.name);
assert_equals(orig.error.message, clone.error.message);
assert_equals(orig.suppressed.message, clone.suppressed.message);
}));

[
new AggregateError([]),
new AggregateError([new Error('hello')], 'abc'),
].forEach(value => cloneObjectTest(value, (orig, clone) => {
assert_equals(orig.name, clone.name);
assert_equals(orig.errors[0].message, clone.errors[0].message);
}));

// Arrays
[
[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
// 15.1.4 Constructor Properties of the Global Object
["Object", "Function", "Array", "String", "Boolean", "Number", "Date",
"RegExp", "Error", "EvalError", "RangeError", "ReferenceError",
"SyntaxError", "TypeError", "URIError"].forEach(function(id) {
"SyntaxError", "TypeError", "URIError", "AggregateError", "SuppressedError"].forEach(function(id) {
test(function() {
assert_true(id in window, id + " in window");
assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,39 @@
assert_unreached("Window must not be clonable");
});
},
function() {
var t = async_test("SuppressedError objects can be cloned");
t.id = 41;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), SuppressedError.prototype, "Checking prototype");
assert_equals(e.data.constructor, SuppressedError, "Checking constructor");
assert_equals(e.data.name, "SuppressedError", "Checking name");
assert_equals(e.data.error.message, "resulted", "Checking resulted error message");
assert_equals(e.data.suppressed.message, "suppressed", "Checking suppressed error message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = SuppressedError(new Error('resulted'), new Error('suppressed'));
error.foo = "bar";
worker.postMessage(error);
});
},
function() {
var t = async_test("AggregateError objects can be cloned");
t.id = 42;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), AggregateErro.[prototype, "Checking prototype");
assert_equals(e.data.constructor, AggregateError, "Checking constructor");
assert_equals(e.data.name, "AggregateError", "Checking name");
assert_equals(e.data.errors[0].message, "some message", "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = AggregateError([new Error('some message')]);
error.foo = "bar";
worker.postMessage(error);
});
},
];
}, {explicit_done:true});

Expand Down