blob: 1fe214f78c894383796da98e08684363b9aece2f [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>window.performance User Timing mark() method is throwing the proper exceptions</title>
<link rel="author" title="Microsoft" href="http://www.microsoft.com/" />
<link rel="help" href="http://www.w3.org/TR/user-timing/#dom-performance-mark"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/webperftestharness.js"></script>
<script type="text/javascript">
// navigation timing attributes
var timingAttributes = [
'connectEnd',
'connectStart',
'domComplete',
'domContentLoadedEventEnd',
'domContentLoadedEventStart',
'domInteractive',
'domLoading',
'domainLookupEnd',
'domainLookupStart',
'fetchStart',
'loadEventEnd',
'loadEventStart',
'navigationStart',
'redirectEnd',
'redirectStart',
'requestStart',
'responseEnd',
'responseStart',
'unloadEventEnd',
'unloadEventStart'
];
// test data
var markExceptionThrown = false;
setup({explicit_done: true});
test_namespace();
function onload_test()
{
// test for existance of User Timing and Performance Timeline interface
if (window.performance.mark == undefined ||
window.performance.clearMarks == undefined ||
window.performance.measure == undefined ||
window.performance.clearMeasures == undefined ||
window.performance.getEntriesByName == undefined ||
window.performance.getEntriesByType == undefined ||
window.performance.getEntries == undefined)
{
test_true(false,
"The User Timing and Performance Timeline interfaces, which are required for this test, " +
"are defined.");
done();
}
else
{
test_mark_exceptions();
}
}
function test_mark_exceptions()
{
// loop through mark scenarios
for (var i in timingAttributes)
{
try
{
// create the mark
window.performance.mark(timingAttributes[i]);
test_true(false,
"window.performance.mark(\"" + timingAttributes[i] + "\") threw an exception.");
}
catch(e)
{
test_true(true,
"window.performance.mark(\"" + timingAttributes[i] + "\") threw an exception.");
// confirm that a SYNTAX_ERR exception is thrown and not any other exception
test_equals(e.code,
e.SYNTAX_ERR,
"window.performance.mark(\"" + timingAttributes[i] + "\") threw a SYNTAX_ERR " +
"exception.");
}
}
done();
}
</script>
</head>
<body onload="onload_test();">
<h1>Description</h1>
<p>This test validates that the performance.mark() method throws a SYNTAX_ERR exception whenever a navigation
timing attribute is provided for the name parameter.
</p>
<div id="log"></div>
</body>
</html>