Auto merge of #25659 - pshaughn:timingresolution, r=jdm,nox

Expose DOMHighResTimeStamps at lower res

As explained in https://www.w3.org/TR/hr-time-2/#clock-resolution and tested in a few WPT tests, we're not supposed to show Javascript the full resolution of OS timestamps. This fixes that on all the DOMHighResTimeStamp interfaces that weren't already limiting themselves to integer milliseconds.

The specific choice of how to coarsen the resolution is extremely bikesheddable; I commented the reasoning for my arbitrary choice but I admit it's arbitrary.

A couple tests of timing resolution still fail, but because they're seeing undefined and NaN values due to unimplemented attributes (#25658).

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25656 fix #25296 fix #21276

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
bors-servo 2020-02-10 13:50:42 -05:00 committed by GitHub
commit c0ee7594c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 46 additions and 51 deletions

View file

@ -1,6 +0,0 @@
[Event-timestamp-safe-resolution.html]
type: testharness
[Event timestamp should not have a resolution better than 5 microseconds]
expected: FAIL

View file

@ -1,15 +0,0 @@
[webtiming-resolution.any.html]
[Verifies the resolution of performance.now() is at least 5 microseconds.]
expected: FAIL
[webtiming-resolution.any.worker.html]
[Verifies the resolution of performance.now() is at least 20 microseconds.]
expected: FAIL
[Verifies the resolution of entry.startTime is at least 20 microseconds.]
expected: TIMEOUT
[Verifies the resolution of performance.now() is at least 5 microseconds.]
expected: FAIL

View file

@ -19708,7 +19708,7 @@
"testharness"
],
"mozilla/window_performance.html": [
"302073e8041763102d678326509d7ef0a1fb5c79",
"c1e38a1e00147caf82492dc82f1cb5e85759f8e3",
"testharness"
],
"mozilla/window_performance_topLevelDomComplete.html": [

View file

@ -27,12 +27,15 @@ test(function() {
var last = window.performance.now();
assert_greater_than(last, 0);
// Check that window.performance.now() is monotonically increasing
// Check that window.performance.now() is monotonically nondecreasing
// and eventually increases
var before_loop = window.performance.now();
for (var i = 0; i < 100; i++) {
var next = window.performance.now();
assert_greater_than(next, last);
assert_greater_than_equal(next, last);
last = next;
}
assert_greater_than(last, before_loop, "If this fails, either performance timing is broken, or Servo JS execution has gotten much faster since this test was written.");
});
</script>
</body>