PerformanceObserver在Firefox中抛出错误,在Chrome中工作

时间:2018-04-12 07:09:29

标签: performance pagespeed observers mutation-observers

我正在实施PerformanceObserver来追踪'first-paint'& '第一contentful漆'。

const observer = new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) {
    if (typeof(Storage) !== 'undefined') {

      if (entry.name === 'first-paint') {
        localStorage.setItem(rumMetrics.RUM_METRICS_FIRST_PAINT, entry.startTime);
      }
      else if (entry.name === 'first-contentful-paint') {
        localStorage.setItem(rumMetrics.RUM_METRICS_FIRST_CONTENTFUL_PAINT, entry.startTime);
      }
    }
    else {
      console.log('local storage is not supported here. RUM metrics won\'t be recorded.');
    }
  }
});

observer.observe({ entryTypes: ['paint'] });

这在Chrome 中非常有效,但在Firefox中引发错误

TypeError: The expression cannot be converted to return the specified type. (line: observer.observe({ entryTypes: ['paint'] });)

1 个答案:

答案 0 :(得分:3)

更新-1:2018年4月20日

Mozilla已经确认了这个错误,它也正在影响FF61 NIGHT

Confirmed

原始答案

确认即使在开发人员版本中这也是一个错误。

FF Deve

Bug

以下是相同

的错误

https://bugzilla.mozilla.org/show_bug.cgi?id=1454581