summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/paint-timing/supported-paint-type.window.js
blob: 518faff5cfb2240a0ab70c5729be77b456ebef93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
test(() => {
  assert_implements(typeof PerformanceObserver.supportedEntryTypes !== "undefined", 'supportedEntryTypes is not supported');
  assert_true(PerformanceObserver.supportedEntryTypes.includes("paint"),
    "There should be an entry 'paint' in PerformanceObserver.supportedEntryTypes");
}, "supportedEntryTypes contains 'paint'.");

const entryType = 'paint';
promise_test(async() => {
  assert_implements(typeof PerformanceObserver.supportedEntryTypes !== "undefined", 'supportedEntryTypes is not supported');
  assert_implements(typeof PerformanceObserver.supportedEntryTypes.includes(entryType), `supportedEntryTypes does not include '${entryType}'`);
  await new Promise((resolve) => {
    new PerformanceObserver(function (list, observer) {
      observer.disconnect();
      resolve();
    }).observe({entryTypes: [entryType]});

    // Force the PerformanceEntry.
    // Use `self` for Workers.
    if (self.document)
      document.head.parentNode.appendChild(document.createTextNode('foo'));
  })
}, `'${entryType}' entries should be observable.`)