| Index: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/performance-timeline-worker.js
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/workers/resources/performance-timeline-worker.js b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/performance-timeline-worker.js
|
| similarity index 75%
|
| copy from third_party/WebKit/LayoutTests/http/tests/workers/resources/performance-timeline-worker.js
|
| copy to third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/performance-timeline-worker.js
|
| index 1075d5bbd8c27e1e336592f278957850af5e469e..6f7df75e9217861087f0419e9849d4bc5893ab24 100644
|
| --- a/third_party/WebKit/LayoutTests/http/tests/workers/resources/performance-timeline-worker.js
|
| +++ b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/performance-timeline-worker.js
|
| @@ -1,24 +1,25 @@
|
| -importScripts('../../resources/testharness.js');
|
| +importScripts('/resources/testharness.js');
|
|
|
| promise_test(function(test) {
|
| var durationMsec = 100;
|
| -
|
| + // There are limits to our accuracy here. Timers may fire up to a
|
| + // millisecond early due to platform-dependent rounding. In addition
|
| + // the performance API introduces some rounding as well to prevent
|
| + // timing attacks.
|
| + var accuracy = 1.5;
|
| return new Promise(function(resolve) {
|
| performance.mark('startMark');
|
| setTimeout(resolve, durationMsec);
|
| }).then(function() {
|
| performance.mark('endMark');
|
| performance.measure('measure', 'startMark', 'endMark');
|
| -
|
| var startMark = performance.getEntriesByName('startMark')[0];
|
| var endMark = performance.getEntriesByName('endMark')[0];
|
| var measure = performance.getEntriesByType('measure')[0];
|
| -
|
| assert_equals(measure.startTime, startMark.startTime);
|
| assert_approx_equals(endMark.startTime - startMark.startTime,
|
| measure.duration, 0.001);
|
| - assert_greater_than(measure.duration, durationMsec);
|
| -
|
| + assert_greater_than(measure.duration, durationMsec - accuracy);
|
| assert_equals(performance.getEntriesByType('mark').length, 2);
|
| assert_equals(performance.getEntriesByType('measure').length, 1);
|
| performance.clearMarks('startMark');
|
| @@ -29,21 +30,12 @@ promise_test(function(test) {
|
| }, 'User Timing');
|
|
|
| promise_test(function(test) {
|
| - return fetch('../../resources/dummy.txt')
|
| + return fetch('dummy.txt')
|
| .then(function(resp) {
|
| return resp.text();
|
| })
|
| - .then(function(t) {
|
| - // TODO(hiroshige): The resource timing entry for dummy.txt is added
|
| - // about at the same time as, but not necessarily before,
|
| - // |resp.text()| is resolved. https://crbug.com/507169
|
| - // We add setTimeout() here as temporary fix.
|
| - return new Promise(function(resolve, reject) {
|
| - setTimeout(function() { resolve(t); }, 100);
|
| - });
|
| - })
|
| - .then(function(t) {
|
| - var expectedResources = ['/resources/testharness.js', '/resources/dummy.txt'];
|
| + .then(function(text) {
|
| + var expectedResources = ['testharness.js', 'dummy.txt'];
|
| assert_equals(performance.getEntriesByType('resource').length, expectedResources.length);
|
| for (var i = 0; i < expectedResources.length; i++) {
|
| var entry = performance.getEntriesByType('resource')[i];
|
|
|