Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: LayoutTests/http/tests/workers/resources/performance-timeline-worker.js

Issue 1100813004: Offer User Timing in workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/workers/resources/performance-timeline-worker.js
diff --git a/LayoutTests/http/tests/workers/resources/performance-timeline-worker.js b/LayoutTests/http/tests/workers/resources/performance-timeline-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..97cc588c7d19d9a35476e3671208b10e092472de
--- /dev/null
+++ b/LayoutTests/http/tests/workers/resources/performance-timeline-worker.js
@@ -0,0 +1,31 @@
+importScripts('../../resources/testharness.js');
+
+promise_test(function(test) {
+ var durationMsec = 100;
+
+ 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_equals(performance.getEntriesByType('mark').length, 2);
+ assert_equals(performance.getEntriesByType('measure').length, 1);
+ performance.clearMarks('startMark');
+ performance.clearMeasures('measure');
+ assert_equals(performance.getEntriesByType('mark').length, 1);
+ assert_equals(performance.getEntriesByType('measure').length, 0);
+ });
+ }, 'User Timing');
+
+done();

Powered by Google App Engine
This is Rietveld 408576698