11cb0ef41Sopenharmony_ci// META: script=performanceobservers.js 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci async_test(function (t) { 41cb0ef41Sopenharmony_ci var callbackCount = 0; 51cb0ef41Sopenharmony_ci var observer = new PerformanceObserver( 61cb0ef41Sopenharmony_ci t.step_func(function (entryList, obs) { 71cb0ef41Sopenharmony_ci callbackCount++; 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci if (callbackCount === 1) { 101cb0ef41Sopenharmony_ci checkEntries(entryList.getEntries(), [ 111cb0ef41Sopenharmony_ci {entryType: "measure", name: "measure1"}, 121cb0ef41Sopenharmony_ci ]); 131cb0ef41Sopenharmony_ci observer.observe({entryTypes: ["mark"]}); 141cb0ef41Sopenharmony_ci self.performance.mark("mark2"); 151cb0ef41Sopenharmony_ci self.performance.measure("measure2"); 161cb0ef41Sopenharmony_ci return; 171cb0ef41Sopenharmony_ci } 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci if (callbackCount === 2) { 201cb0ef41Sopenharmony_ci checkEntries(entryList.getEntries(), [ 211cb0ef41Sopenharmony_ci {entryType: "mark", name: "mark2"}, 221cb0ef41Sopenharmony_ci ]); 231cb0ef41Sopenharmony_ci self.performance.mark("mark-before-change-observe-state-to-measure"); 241cb0ef41Sopenharmony_ci self.performance.measure("measure-before-change-observe-state-to-measure"); 251cb0ef41Sopenharmony_ci observer.observe({entryTypes: ["measure"]}); 261cb0ef41Sopenharmony_ci self.performance.mark("mark3"); 271cb0ef41Sopenharmony_ci self.performance.measure("measure3"); 281cb0ef41Sopenharmony_ci return; 291cb0ef41Sopenharmony_ci } 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci if (callbackCount === 3) { 321cb0ef41Sopenharmony_ci checkEntries(entryList.getEntries(), [ 331cb0ef41Sopenharmony_ci {entryType: "measure", name: "measure3"}, 341cb0ef41Sopenharmony_ci {entryType: "mark", name: "mark-before-change-observe-state-to-measure"}, 351cb0ef41Sopenharmony_ci ]); 361cb0ef41Sopenharmony_ci self.performance.mark("mark-before-change-observe-state-to-both"); 371cb0ef41Sopenharmony_ci self.performance.measure("measure-before-change-observe-state-to-both"); 381cb0ef41Sopenharmony_ci observer.observe({entryTypes: ["mark", "measure"]}); 391cb0ef41Sopenharmony_ci self.performance.mark("mark4"); 401cb0ef41Sopenharmony_ci self.performance.measure("measure4"); 411cb0ef41Sopenharmony_ci return; 421cb0ef41Sopenharmony_ci } 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci if (callbackCount === 4) { 451cb0ef41Sopenharmony_ci checkEntries(entryList.getEntries(), [ 461cb0ef41Sopenharmony_ci {entryType: "measure", name: "measure-before-change-observe-state-to-both"}, 471cb0ef41Sopenharmony_ci {entryType: "measure", name: "measure4"}, 481cb0ef41Sopenharmony_ci {entryType: "mark", name: "mark4"}, 491cb0ef41Sopenharmony_ci ]); 501cb0ef41Sopenharmony_ci self.performance.mark("mark-before-disconnect"); 511cb0ef41Sopenharmony_ci self.performance.measure("measure-before-disconnect"); 521cb0ef41Sopenharmony_ci observer.disconnect(); 531cb0ef41Sopenharmony_ci self.performance.mark("mark-after-disconnect"); 541cb0ef41Sopenharmony_ci self.performance.measure("measure-after-disconnect"); 551cb0ef41Sopenharmony_ci t.done(); 561cb0ef41Sopenharmony_ci return; 571cb0ef41Sopenharmony_ci } 581cb0ef41Sopenharmony_ci 591cb0ef41Sopenharmony_ci assert_unreached("The callback must not be invoked after disconnecting"); 601cb0ef41Sopenharmony_ci }) 611cb0ef41Sopenharmony_ci ); 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci observer.observe({entryTypes: ["measure"]}); 641cb0ef41Sopenharmony_ci self.performance.mark("mark1"); 651cb0ef41Sopenharmony_ci self.performance.measure("measure1"); 661cb0ef41Sopenharmony_ci }, "PerformanceObserver modifications inside callback should update filtering and not clear buffer"); 67