tor-browser

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

test_SpecialPowersStructuredClone.html (1159B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test for structured clone of SpecialPowers methods</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      7 </head>
      8 <body>
      9 
     10 <script>
     11  add_task(async function test_findUnexpectedCrashDumpFiles() {
     12    let retval = await SpecialPowers.findUnexpectedCrashDumpFiles();
     13 
     14    ok(SpecialPowers.isWrapper(retval), "Returns wrapper");
     15 
     16    let realValue = SpecialPowers.unwrap(retval);
     17    ok(Array.isArray(realValue), "Unwrapped value is array");
     18 
     19    is(
     20      SpecialPowers.unwrap(SpecialPowers.Cu.getGlobalForObject(realValue)),
     21      window,
     22      "Value part of current global"
     23    );
     24 
     25    // Now the part of interest: Can we clone? Regression test for bug 2007587:
     26    structuredClone(realValue);
     27 
     28    let actualError;
     29    try {
     30      structuredClone(retval);
     31      actualError = "(no error thrown)";
     32    } catch (e) {
     33      actualError = e.toString();
     34    }
     35    is(
     36      actualError,
     37      "DataCloneError: Proxy object could not be cloned.",
     38      "Wrapped value cannot be structured cloned"
     39    );
     40  });
     41 </script>
     42 </body>
     43 </html>