diff --git a/dom/base/StructuredCloneHolder.cpp b/dom/base/StructuredCloneHolder.cpp index b22b0b32e58e..e441b7427315 100644 --- a/dom/base/StructuredCloneHolder.cpp +++ b/dom/base/StructuredCloneHolder.cpp @@ -500,7 +500,11 @@ bool StructuredCloneHolder::WriteFullySerializableObjects( } // Don't know what this is - xpc::Throw(aCx, NS_ERROR_DOM_DATA_CLONE_ERR); + ErrorResult rv; + const char* className = JS::GetClass(obj)->name; + rv.ThrowDataCloneError(nsDependentCString(className) + + " object could not be cloned."_ns); + MOZ_ALWAYS_TRUE(rv.MaybeSetPendingException(aCx)); return false; } diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini index 20d8cf4ee4f5..0f471dfad067 100644 --- a/dom/base/test/mochitest.ini +++ b/dom/base/test/mochitest.ini @@ -897,6 +897,7 @@ skip-if = debug == false [test_shared_compartment1.html] [test_shared_compartment2.html] [test_structuredclone_backref.html] +[test_structuredclone_error.html] [test_style_cssText.html] [test_suppressed_events_and_scrolling.html] support-files = diff --git a/dom/base/test/test_structuredclone_error.html b/dom/base/test/test_structuredclone_error.html new file mode 100644 index 000000000000..c682cff01d01 --- /dev/null +++ b/dom/base/test/test_structuredclone_error.html @@ -0,0 +1,23 @@ + + + +Mozilla Bug XXX + + diff --git a/dom/promise/tests/unit/test_promise_unhandled_rejection.js b/dom/promise/tests/unit/test_promise_unhandled_rejection.js index 8544dd55473f..c1576b152406 100644 --- a/dom/promise/tests/unit/test_promise_unhandled_rejection.js +++ b/dom/promise/tests/unit/test_promise_unhandled_rejection.js @@ -54,7 +54,7 @@ add_task(async function test_unhandled_dom_exception() { equal(msg.lineNumber, 2, "Got expected line number"); equal( msg.errorMessage, - "DataCloneError: The object could not be cloned.", + "DataCloneError: Function object could not be cloned.", "Got expected error message" ); }); diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js b/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js index a56c2fdc79aa..d78197f9e4b9 100644 --- a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js +++ b/toolkit/components/extensions/test/xpcshell/test_ext_runtime_sendMessage_errors.js @@ -31,8 +31,8 @@ add_task(async function test_sendMessage_error() { ], // Structured cloning doesn't work with DOM objects - [[null, location, null], "The object could not be cloned."], - [[null, [circ, location], null], "The object could not be cloned."], + [[null, location, null], "Location object could not be cloned."], + [[null, [circ, location], null], "Location object could not be cloned."], ]; // Repeat all tests with the undefined value instead of null.