зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1387894 - Fix the WPT and mochitest test_document-timeline.html for unconditional clamping. r=birtles
We fix this by clamping the requestAnimationFrame timestamp in the test before comparing it. We don't clamp the requestAnimationFrame timestamp normally because it would be meaningless: rAF fires on a regular frequency and someone perfoming a fine-grained timing attack will be able to determine the timestamp from when it fires. We need to use parseFloat to knock off any extra epislon we gain. This shouldn't cause any major blow-ups because timelines are disabled in release and beta, so at least any potential fallout would be constrained. Differential Revision: https://phabricator.services.mozilla.com/D38807 Depends on D38806 --HG-- extra : rebase_source : d6f6170ae3082022d422f925e8d5619400e845ed
This commit is contained in:
Родитель
86568bf421
Коммит
8285198060
|
@ -10,6 +10,10 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
function matchUnconditionalClamping(timestamp) {
|
||||
return parseFloat((Math.floor(timestamp / .02) * .02).toPrecision(8), 10);
|
||||
}
|
||||
|
||||
test(function() {
|
||||
assert_equals(document.timeline, document.timeline,
|
||||
'document.timeline returns the same object every time');
|
||||
|
@ -43,7 +47,7 @@ async_test(function(t) {
|
|||
// window.performance.now() because currentTime is only updated on a sample
|
||||
// so we use requestAnimationFrame instead.
|
||||
window.requestAnimationFrame(t.step_func(function(rafTime) {
|
||||
assert_equals(document.timeline.currentTime, rafTime,
|
||||
assert_equals(document.timeline.currentTime, matchUnconditionalClamping(rafTime),
|
||||
'document.timeline.currentTime matches' +
|
||||
' requestAnimationFrame time');
|
||||
t.done();
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
function matchUnconditionalClamping(timestamp) {
|
||||
return parseFloat((Math.floor(timestamp / .02) * .02).toPrecision(8), 10);
|
||||
}
|
||||
|
||||
async_test(t => {
|
||||
assert_greater_than_equal(document.timeline.currentTime, 0,
|
||||
'The current time is initially is positive or zero');
|
||||
|
@ -28,7 +32,7 @@ async_test(t => {
|
|||
// so we use requestAnimationFrame instead.
|
||||
window.requestAnimationFrame(rafTime => {
|
||||
t.step(() => {
|
||||
assert_equals(document.timeline.currentTime, rafTime,
|
||||
assert_equals(document.timeline.currentTime, matchUnconditionalClamping(rafTime),
|
||||
'The current time matches requestAnimationFrame time');
|
||||
});
|
||||
t.done();
|
||||
|
|
Загрузка…
Ссылка в новой задаче