test_structuredclone_error.html (715B)
1 <!DOCTYPE HTML> 2 <script src="/tests/SimpleTest/SimpleTest.js"></script> 3 <link rel="stylesheet" href="/tests/SimpleTest/test.css"> 4 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=XXX">Mozilla Bug XXX</a> 5 6 <script> 7 const tests = [ 8 {obj: (() => {}), msg: "Function object could not be cloned."}, 9 {obj: document.body, msg: "HTMLBodyElement object could not be cloned."}, 10 {obj: {foo: new Audio()}, msg: "HTMLAudioElement object could not be cloned."}, 11 ] 12 13 for (const test of tests) { 14 let message = undefined; 15 try { 16 structuredClone(test.obj); 17 } catch (e) { 18 message = e.message; 19 } 20 21 is(message, test.msg, 'Threw correct DataCloneError'); 22 } 23 </script>