Use performance.now over Date.now in performance metrics#16119
Use performance.now over Date.now in performance metrics#16119alabiaga merged 16 commits intoampproject:masterfrom alabiaga:16042
Conversation
|
|
||
|
|
||
| describes.fakeWin('AccessService multiple sources', { | ||
| describes.realWin('AccessService multiple sources', { |
There was a problem hiding this comment.
amp-access tests were failing because performance is not present in a fakeWin
|
PTAL. updated broken test in amp-access and polyfilled performance.now as opposed to using realWin. Thanks |
|
|
||
| // Polyfill performance.now() method as it is not available in fakeWin | ||
| // environment. | ||
| win.performance = {now: () => Date.now()}; |
There was a problem hiding this comment.
You could also just add it to fake-dom.js#FakeWindow.
There was a problem hiding this comment.
Looks like there are still a bunch of these in this file.
There was a problem hiding this comment.
right..my editor cache needed to be cleared..for some reason it was showing my updated changes but this file wasn't actually edited. Fixed.
|
|
||
| // Polyfill performance.now() method as it is not available in fakeWin | ||
| // environment. | ||
| win.performance = {now: () => Date.now()}; |
There was a problem hiding this comment.
Since it ended up needing to be polyfilled in so many places, does it make sense to move this polyfill to env.win so each test doesn't need to repeat the polyfill?
There was a problem hiding this comment.
Thanks for your feedback Kris. Will actually commented on that as well and I made the changes and moved this to fake-dom.js
testing/fake-dom.js
Outdated
| }); | ||
| // Polyfill performance.now() method as it would normally not be available | ||
| // in a non document environment. Used for tests using fakeWin that rely on | ||
| // the performance-impl service. |
There was a problem hiding this comment.
This comment is slightly out of context and can be updated.
There was a problem hiding this comment.
what would you suggest?
There was a problem hiding this comment.
How about just // Polyfill performance.now with Date.now.. I think most of the current comment is obvious since it's living in FakeWindow.
| * @param {function(!Event)} handler | ||
| * @param {(boolean|!Object)=} captureOrOpts | ||
| */ | ||
| /** polyfill addEventListener. */ |
There was a problem hiding this comment.
Why replace the type declarations? Were they causing errors?
There was a problem hiding this comment.
I think you can just remove these "polyfill X" comments. They don't add much.
| * @param {function(!Event)} handler | ||
| * @param {(boolean|!Object)=} captureOrOpts | ||
| */ | ||
| /** polyfill addEventListener. */ |
There was a problem hiding this comment.
I think you can just remove these "polyfill X" comments. They don't add much.
testing/fake-dom.js
Outdated
| }); | ||
| // Polyfill performance.now() method as it would normally not be available | ||
| // in a non document environment. Used for tests using fakeWin that rely on | ||
| // the performance-impl service. |
There was a problem hiding this comment.
How about just // Polyfill performance.now with Date.now.. I think most of the current comment is obvious since it's living in FakeWindow.
| /** @const */ | ||
| this.Date = window.Date; | ||
|
|
||
| this.setTimeout = function() { |
There was a problem hiding this comment.
The JSDoc below doesn't seem useful when switching the order like this. We can either add the missing params (prefixed with unused) or remove the JSDoc outright. I think it's fine to remove since they're just standard window APIs.
Ditto below.
|
@choumx @alabiaga @zhangsu @raywainman Thanks for addressing the bug so quickly. However, is it okay to just replace A potential solution could be to return |
|
|
||
| // Tick the "messaging ready" signal. | ||
| this.tickDelta('msr', this.win.Date.now() - this.initTime_); | ||
| this.tickDelta('msr', this.win.performance.now() - this.initTime_); |
There was a problem hiding this comment.
Oh man, this needs to be normalized to an int.
There was a problem hiding this comment.
i'll follow up in a separate PR. good point.
)" This reverts commit 0d2b567.
…6227) * Revert "Revert "Update dependencies for default 🌴 (#16221)" This reverts commit f8da39e. * Revert "Mark 4 more visual diff tests as flaky (#16214)" This reverts commit 867e903. * Revert "Update dependencies for default 🌴 (#16195)" This reverts commit 34d1977. * Revert "Fix selector (#16197)" This reverts commit f741868. * Revert "🐛 Position offscreen amp-story-pages using viewport widths (#16092)" This reverts commit fa85965. * Revert "Use performance.now over Date.now in performance metrics (#16119)" This reverts commit 0d2b567. * fix lint errors * fix lint error in constructor * Update performance-impl.js fix more lint errors * Update url-replacements-impl.js more lint.. * Update test-amp-access.js fix test error. * Update test-amp-access-source.js fix more tests...
Fixes #16042