• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1promise_test(() => {
2  // The first promise waits for one buffered flag observer to receive 3 entries.
3  const promise1 = new Promise(resolve1 => {
4    let numObserved1 = 0;
5    new PerformanceObserver((entryList, obs) => {
6      // This buffered flag observer is constructed after a regular observer detects a mark.
7      new PerformanceObserver(list => {
8        numObserved1 += list.getEntries().length;
9        if (numObserved1 == 3)
10          resolve1();
11      }).observe({type: 'mark', buffered: true});
12      obs.disconnect();
13    }).observe({entryTypes: ['mark']});
14    performance.mark('foo');
15  });
16  // The second promise waits for another buffered flag observer to receive 3 entries.
17  const promise2 = new Promise(resolve2 => {
18    step_timeout(() => {
19      let numObserved2 = 0;
20      // This buffered flag observer is constructed after a delay of 100ms.
21      new PerformanceObserver(list => {
22        numObserved2 += list.getEntries().length;
23        if (numObserved2 == 3)
24          resolve2();
25      }).observe({type: 'mark', buffered: true});
26    }, 100);
27    performance.mark('bar');
28  });
29  performance.mark('meow');
30  // Pass if and only if both buffered observers received all 3 mark entries.
31  return Promise.all([promise1, promise2]);
32}, 'Multiple PerformanceObservers with buffered flag see all entries');
33