1<!DOCTYPE html> 2<html> 3 <head> 4 <meta charset="UTF-8" /> 5 <title>window.performance User Timing measure() method is throwing the proper exceptions</title> 6 <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> 7 <link rel="help" href="https://w3c.github.io/user-timing/#dom-performance-measure"/> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="resources/webperftestharness.js"></script> 11 12 <script> 13// test data 14var zeroedNavTimingAtt = undefined; 15 16setup(function () { 17 // for testing the INVALID_ACCESS_ERR exception, find a navigation timing attribute with a value of zero 18 for (var i in timingAttributes) { 19 if (window.performance.timing[timingAttributes[i]] == 0) { 20 zeroedNavTimingAtt = timingAttributes[i]; 21 } 22 } 23 if (zeroedNavTimingAtt == undefined) { 24 throw new Error("A navigation timing attribute with a value of 0 was not found to test for the " + 25 "INVALID_ACCESS_ERR exception thrown by window.performance.measure().") 26 } 27}); 28 29test(function () { 30 assert_throws_dom("InvalidAccessError", function () { 31 window.performance.measure("measure", zeroedNavTimingAtt); 32 }); 33}, "window.performance.measure(\"measure\", \"" + zeroedNavTimingAtt + "\"), where \"" + 34 zeroedNavTimingAtt + "\" is a navigation timing attribute with a value of 0, throws a " + 35 "InvalidAccessError exception."); 36 37test(function () { 38 assert_throws_dom("InvalidAccessError", function () { 39 window.performance.measure("measure", zeroedNavTimingAtt, "responseEnd"); 40 }); 41}, "window.performance.measure(\"measure\", \"" + zeroedNavTimingAtt + "\", " + 42 "\"responseEnd\"), where \"" + zeroedNavTimingAtt + "\" is a navigation timing " + 43 "attribute with a value of 0, throws a InvalidAccessError exception."); 44 45test(function () { 46 assert_throws_dom("InvalidAccessError", function () { 47 window.performance.measure("measure", "navigationStart", zeroedNavTimingAtt); 48 }); 49}, "window.performance.measure(\"measure\", \"navigationStart\", \"" + zeroedNavTimingAtt + 50 "\"), where \"" + zeroedNavTimingAtt + "\" is a navigation timing attribute with a " + 51 "value of 0, throws a InvalidAccessError exception."); 52 53test(function () { 54 assert_throws_dom("InvalidAccessError", function () { 55 window.performance.measure("measure", zeroedNavTimingAtt, zeroedNavTimingAtt); 56 }); 57}, "window.performance.measure(\"measure\", \"" + zeroedNavTimingAtt + "\", \"" + 58 zeroedNavTimingAtt + "\"), where \"" + zeroedNavTimingAtt + "\" is a navigation timing " + 59 "attribute with a value of 0, throws a InvalidAccessError exception."); 60 </script> 61 </head> 62 <body> 63 <h1>Description</h1> 64 <p><code>window.performance.measure()</code> method throws a InvalidAccessError 65 whenever a navigation timing attribute with a value of zero is provided as the startMark or endMark. 66 </p> 67 68 <div id="log"></div> 69 </body> 70</html> 71