【问题标题】:PerformanceObserver throwing error in Firefox, working in ChromePerformanceObserver 在 Firefox 中抛出错误,在 Chrome 中工作
【发布时间】:2018-04-12 07:09:28
【问题描述】:

我正在实施 PerformanceObserver 来跟踪“first-paint”和“first-contentful-paint”。

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'] });)

【问题讨论】:

标签: performance pagespeed observers mutation-observers


【解决方案1】:

更新 1:2018 年 4 月 20 日

Mozilla 已确认该错误,它也影响了 FF61 Nightly

原答案

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

以下是相同的错误

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

【讨论】:

    猜你喜欢
    • 2020-03-24
    • 1970-01-01
    • 1970-01-01
    • 2011-10-05
    • 2016-04-18
    • 2012-08-05
    • 2017-05-10
    • 2021-08-12
    • 2016-07-19
    相关资源
    最近更新 更多