serialization-via-notifications-api.any.js (1127B)
1 "use strict"; 2 3 test(() => { 4 assert_throws_dom("DataCloneError", () => { 5 // See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()` 6 const sab = new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer; 7 new Notification("Bob: Hi", { data: sab }); 8 }) 9 }, "SharedArrayBuffer cloning via the Notifications API's data member: basic case"); 10 11 test(() => { 12 // See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()` 13 const sab = new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer; 14 15 let getter1Called = false; 16 let getter2Called = false; 17 18 assert_throws_dom("DataCloneError", () => { 19 new Notification("Bob: Hi", { data: [ 20 { get x() { getter1Called = true; return 5; } }, 21 sab, 22 { get x() { getter2Called = true; return 5; } } 23 ]}); 24 }); 25 26 assert_true(getter1Called, "The getter before the SAB must have been called"); 27 assert_false(getter2Called, "The getter after the SAB must not have been called"); 28 }, "SharedArrayBuffer cloning via the Notifications API's data member: is interleaved correctly");