https://github.com/web-platform-tests/wpt
Raw File
Tip revision: feeda08fb7c8a7c57afb1448d118942236ef6c94 authored by Coroiu Cristina on 26 November 2018, 20:19:20 UTC
Backed out changeset d32110a492f5 (bug 1383454) for did not disable the test
Tip revision: feeda08
idlharness.window.js
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js

// https://w3c.github.io/longtask-timing/

'use strict';

promise_test(async t => {
  const srcs = ['longtasks', 'performance-timeline'];
  const [idl, perf] = await Promise.all(
    srcs.map(i => fetch(`/interfaces/${i}.idl`).then(r => r.text())));

  const idl_array = new IdlArray();
  idl_array.add_idls(idl);
  idl_array.add_dependency_idls(perf);

  const testIdls = new Promise(resolve => {
    try {
      const observer = new PerformanceObserver(entryList => {
        const entries = Array.from(entryList.getEntries());
        const attribution = entries.reduce(
            (sum, e) => sum.concat(e.attribution || []), []);
        idl_array.add_objects({
          PerformanceLongTaskTiming: entries,
          TaskAttributionTiming: attribution,
        });
        idl_array.test();
        resolve();
      });
      observer.observe({entryTypes: ['longtask']});
    } catch (e) {
      // Will be surfaces in idlharness.js's test_object below.
    }
  });

  const longTask = () => {
    var begin = self.performance.now();
    while (self.performance.now() < begin + 100);
  }
  t.step_timeout(longTask, 0);

  const timeout = new Promise(
      (_, reject) => t.step_timeout(reject, 1000));
  return Promise.race([testIdls, timeout])
    .then(
        t.step_func_done(),
        () => {
          idl_array.test(); // Rejected, but test what we can.
          return Promise.reject('LongTask was not observed');
        });
}, 'longtasks interfaces');
back to top