11cb0ef41Sopenharmony_citest(function() { 21cb0ef41Sopenharmony_ci performance.clearMarks(); 31cb0ef41Sopenharmony_ci const detail = { randomInfo: 123 } 41cb0ef41Sopenharmony_ci const markEntry = new PerformanceMark("A", { detail }); 51cb0ef41Sopenharmony_ci assert_equals(markEntry.detail.randomInfo, detail.randomInfo); 61cb0ef41Sopenharmony_ci assert_not_equals(markEntry.detail, detail); 71cb0ef41Sopenharmony_ci}, "The detail property in the mark constructor should be structured-clone."); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_citest(function() { 101cb0ef41Sopenharmony_ci performance.clearMarks(); 111cb0ef41Sopenharmony_ci const detail = { randomInfo: 123 } 121cb0ef41Sopenharmony_ci const markEntry = performance.mark("A", { detail }); 131cb0ef41Sopenharmony_ci assert_equals(markEntry.detail.randomInfo, detail.randomInfo); 141cb0ef41Sopenharmony_ci assert_not_equals(markEntry.detail, detail); 151cb0ef41Sopenharmony_ci}, "The detail property in the mark method should be structured-clone."); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_citest(function() { 181cb0ef41Sopenharmony_ci performance.clearMarks(); 191cb0ef41Sopenharmony_ci const markEntry = performance.mark("A"); 201cb0ef41Sopenharmony_ci assert_equals(markEntry.detail, null); 211cb0ef41Sopenharmony_ci}, "When accessing detail from a mark entry and the detail is not provided, just return a null value."); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_citest(function() { 241cb0ef41Sopenharmony_ci performance.clearMarks(); 251cb0ef41Sopenharmony_ci const detail = { unserializable: Symbol() }; 261cb0ef41Sopenharmony_ci assert_throws_dom("DataCloneError", ()=>{ 271cb0ef41Sopenharmony_ci new PerformanceMark("A", { detail }); 281cb0ef41Sopenharmony_ci }, "Trying to structured-serialize a Symbol."); 291cb0ef41Sopenharmony_ci}, "Mark: Throw an exception when the detail property cannot be structured-serialized."); 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_citest(function() { 321cb0ef41Sopenharmony_ci performance.clearMeasures(); 331cb0ef41Sopenharmony_ci const detail = { randomInfo: 123 } 341cb0ef41Sopenharmony_ci const measureEntry = performance.measure("A", { start: 0, detail }); 351cb0ef41Sopenharmony_ci assert_equals(measureEntry.detail.randomInfo, detail.randomInfo); 361cb0ef41Sopenharmony_ci assert_not_equals(measureEntry.detail, detail); 371cb0ef41Sopenharmony_ci}, "The detail property in the measure method should be structured-clone."); 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_citest(function() { 401cb0ef41Sopenharmony_ci performance.clearMeasures(); 411cb0ef41Sopenharmony_ci const detail = { randomInfo: 123 } 421cb0ef41Sopenharmony_ci const measureEntry = performance.measure("A", { start: 0, detail }); 431cb0ef41Sopenharmony_ci assert_equals(measureEntry.detail, measureEntry.detail); 441cb0ef41Sopenharmony_ci}, "The detail property in the measure method should be the same reference."); 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_citest(function() { 471cb0ef41Sopenharmony_ci performance.clearMeasures(); 481cb0ef41Sopenharmony_ci const measureEntry = performance.measure("A"); 491cb0ef41Sopenharmony_ci assert_equals(measureEntry.detail, null); 501cb0ef41Sopenharmony_ci}, "When accessing detail from a measure entry and the detail is not provided, just return a null value."); 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_citest(function() { 531cb0ef41Sopenharmony_ci performance.clearMeasures(); 541cb0ef41Sopenharmony_ci const detail = { unserializable: Symbol() }; 551cb0ef41Sopenharmony_ci assert_throws_dom("DataCloneError", ()=>{ 561cb0ef41Sopenharmony_ci performance.measure("A", { start: 0, detail }); 571cb0ef41Sopenharmony_ci }, "Trying to structured-serialize a Symbol."); 581cb0ef41Sopenharmony_ci}, "Measure: Throw an exception when the detail property cannot be structured-serialized."); 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_citest(function() { 611cb0ef41Sopenharmony_ci const bar = { 1: 2 }; 621cb0ef41Sopenharmony_ci const detail = { foo: 1, bar }; 631cb0ef41Sopenharmony_ci const mark = performance.mark("m", { detail }); 641cb0ef41Sopenharmony_ci detail.foo = 2; 651cb0ef41Sopenharmony_ci assert_equals(mark.detail.foo, 1); 661cb0ef41Sopenharmony_ci}, "The detail object is cloned when passed to mark API."); 67