tor-browser

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

structured-serialize-detail.any.js (2691B)


      1 test(function() {
      2  performance.clearMarks();
      3  const detail = { randomInfo: 123 }
      4  const markEntry = new PerformanceMark("A", { detail });
      5  assert_equals(markEntry.detail.randomInfo, detail.randomInfo);
      6  assert_not_equals(markEntry.detail, detail);
      7 }, "The detail property in the mark constructor should be structured-clone.");
      8 
      9 test(function() {
     10  performance.clearMarks();
     11  const detail = { randomInfo: 123 }
     12  const markEntry = performance.mark("A", { detail });
     13  assert_equals(markEntry.detail.randomInfo, detail.randomInfo);
     14  assert_not_equals(markEntry.detail, detail);
     15 }, "The detail property in the mark method should be structured-clone.");
     16 
     17 test(function() {
     18  performance.clearMarks();
     19  const markEntry = performance.mark("A");
     20  assert_equals(markEntry.detail, null);
     21 }, "When accessing detail from a mark entry and the detail is not provided, just return a null value.");
     22 
     23 test(function() {
     24  performance.clearMarks();
     25  const detail = { unserializable: Symbol() };
     26  assert_throws_dom("DataCloneError", ()=>{
     27    new PerformanceMark("A", { detail });
     28  }, "Trying to structured-serialize a Symbol.");
     29 }, "Mark: Throw an exception when the detail property cannot be structured-serialized.");
     30 
     31 test(function() {
     32  performance.clearMeasures();
     33  const detail = { randomInfo: 123 }
     34  const measureEntry = performance.measure("A", { start: 0, detail });
     35  assert_equals(measureEntry.detail.randomInfo, detail.randomInfo);
     36  assert_not_equals(measureEntry.detail, detail);
     37 }, "The detail property in the measure method should be structured-clone.");
     38 
     39 test(function() {
     40  performance.clearMeasures();
     41  const detail = { randomInfo: 123 }
     42  const measureEntry = performance.measure("A", { start: 0, detail });
     43  assert_equals(measureEntry.detail, measureEntry.detail);
     44 }, "The detail property in the measure method should be the same reference.");
     45 
     46 test(function() {
     47  performance.clearMeasures();
     48  const measureEntry = performance.measure("A");
     49  assert_equals(measureEntry.detail, null);
     50 }, "When accessing detail from a measure entry and the detail is not provided, just return a null value.");
     51 
     52 test(function() {
     53  performance.clearMeasures();
     54  const detail = { unserializable: Symbol() };
     55  assert_throws_dom("DataCloneError", ()=>{
     56    performance.measure("A", { start: 0, detail });
     57  }, "Trying to structured-serialize a Symbol.");
     58 }, "Measure: Throw an exception when the detail property cannot be structured-serialized.");
     59 
     60 test(function() {
     61  const bar = { 1: 2 };
     62  const detail = { foo: 1, bar };
     63  const mark = performance.mark("m", { detail });
     64  detail.foo = 2;
     65  assert_equals(mark.detail.foo, 1);
     66 }, "The detail object is cloned when passed to mark API.");