blob: 702e3d5f87f39e3b188f0190d7e5f3339f1ac704 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>functionality test of window.performance.measure</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<link rel="help" href="http://www.w3.org/TR/user-timing/#extensions-performance-interface"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/performance-timeline-utils.js"></script>
<script src="resources/webperftestharness.js"></script>
<script src="resources/webperftestharnessextension.js"></script>
<script>
setup({ explicit_done: true });
function onload_test()
{
const measures_for_timing_order = [
['nav2now', 'navigationStart'],
['loadTime', 'navigationStart', 'loadEventEnd'],
['loadEventEnd2a', 'loadEventEnd', 'abc'],
['nav2a', 'navigationStart', 'abc'],
['domComplete2a', 'domComplete', 'abc'],
['negativeValue', 1, 'navigationStart'],
];
const context = new PerformanceContext(window.performance);
mark_names.forEach(function(name) {
context.mark(name);
});
measures_for_timing_order.forEach(context.initialMeasures, context);
test_greater_than(context.getEntriesByName('nav2now', 'measure')[0].duration, 0, 'Measure of navigationStart to now should be positive value.');
test_greater_than(context.getEntriesByName('loadTime', 'measure')[0].duration, 0, 'Measure of navigationStart to loadEventEnd should be positive value.');
test_greater_than(0, context.getEntriesByName('negativeValue', 'measure')[0].duration, 'Measure of current mark to navigationStart should be negative value.');
test_equals(context.getEntriesByName('loadTime', 'measure')[0].duration + context.getEntriesByName('loadEventEnd2a', 'measure')[0].duration, context.getEntriesByName('nav2a', 'measure')[0].duration, 'loadTime plus loadEventEnd to a mark "a" should equal to navigationStart to "a".');
// Following cases test for scenarios that measure names are tied twice.
mark_names.forEach(function(name) {
context.mark(name);
});
measures_for_timing_order.forEach(context.initialMeasures, context);
test_greater_than(context.getEntriesByName('nav2now', 'measure')[1].duration, context.getEntriesByName('nav2now', 'measure')[0].duration, 'Second measure of current mark to navigationStart should be negative value.');
test_equals(context.getEntriesByName('loadTime', 'measure')[0].duration, context.getEntriesByName('loadTime', 'measure')[1].duration, 'Measures of loadTime should have same duration.');
test_greater_than(context.getEntriesByName('domComplete2a', 'measure')[1].duration, context.getEntriesByName('domComplete2a', 'measure')[0].duration, 'Measure from domComplete event to most recent mark "a" should have longer duration.');
test_greater_than(context.getEntriesByName('negativeValue', 'measure')[0].duration, context.getEntriesByName('negativeValue', 'measure')[1].duration, 'Measure from most recent mark to navigationStart should have longer duration.');
done();
}
</script>
</head>
<body onload="setTimeout(onload_test,0)">
<h1>Description</h1>
<p>This test validates functionality of the interface window.performance.measure using keywords from the Navigation Timing spec.</p>
<div id="log"></div>
</body>
</html>