Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

百度中引入该脚本,onReport无效 #26

Open
thomasyxy opened this issue Aug 29, 2019 · 1 comment
Open

百度中引入该脚本,onReport无效 #26

thomasyxy opened this issue Aug 29, 2019 · 1 comment

Comments

@thomasyxy
Copy link

你好,请教一个问题
我使用puppeteer打开了一个页面,然后引入了你的脚本,在我自己的测试页面可以成功打印出结果,但是百度却不行,可能是什么原因?

      const result = await tab.evaluate(async() => {
        const loadPromise = new Promise((resolve, reject) => {
          let pageData = window.performance
          let entries = pageData.getEntries()
          // 获取首屏时间
          window.autoComputeFirstScreenTime({
            onReport: function (result) {
              alert(12)
              if (result.success) {
                let firstScreenTime = result.firstScreenTime
                let data = JSON.stringify({ pageData, entries, firstScreenTime })
                window.alert(firstScreenTime)
                resolve(data);
              } else {
                console.log(result);
              }
            }
          });
        }).then(result => result).catch(e => e);
        return loadPromise
      })

image
image

@thomasyxy
Copy link
Author

测试过程中有不少页面是不会触发onReport的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant