tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

serialization-via-notifications-api.any.js (960B)


      1 "use strict";
      2 
      3 function createEmptyWasmModule() {
      4  return new WebAssembly.Module(
      5      new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]));
      6 }
      7 
      8 test(() => {
      9  assert_throws_dom("DataCloneError", () => {
     10    new Notification("Bob: Hi", { data: createEmptyWasmModule() });
     11  })
     12 }, "WebAssembly.Module cloning via the Notifications API's data member: basic case");
     13 
     14 test(() => {
     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      createEmptyWasmModule(),
     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 }, "WebAssembly.Module cloning via the Notifications API's data member: is interleaved correctly");