Index: LayoutTests/fast/workers/resources/worker-performance.js |
diff --git a/LayoutTests/fast/workers/resources/worker-performance.js b/LayoutTests/fast/workers/resources/worker-performance.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..49e2ca276a1343d631615f5dabbe0fd08734711a |
--- /dev/null |
+++ b/LayoutTests/fast/workers/resources/worker-performance.js |
@@ -0,0 +1,34 @@ |
+var port = self.port || self; |
+ |
+function assert_equals(actual, expected, description) { |
+ if (actual == expected) |
+ port.postMessage('PASS: ' + description); |
+ else |
+ port.postMessage('FAIL: ' + description + ': ' + actual + ' != ' + expected); |
+} |
+ |
+function assert_true(actual, description) { |
+ if (actual) |
+ port.postMessage('PASS: ' + description); |
+ else |
+ port.postMessage('FAIL: ' + description); |
+} |
kinuko
2015/06/04 08:21:22
Could we also importScript LayoutTests/resources/t
Kunihiko Sakamoto
2015/06/05 03:43:56
Done, and merged into single testharness.js-based
|
+ |
+performance.mark('startMark'); |
+setTimeout(timerFunc, 100); |
+ |
+function timerFunc() { |
+ 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, 'startTime should match'); |
+ assert_true(measure.duration >= 100, 'measure.duration should be no less than 100ms'); |
+ assert_equals(performance.getEntriesByType('mark').length, 2, "getEntriesByType('mark')"); |
+ assert_equals(performance.getEntriesByType('measure').length, 1, "getEntriesByType('measure')"); |
+ |
+ port.postMessage('DONE'); |
+} |