| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <meta charset="UTF-8" /> | 4 <meta charset="UTF-8" /> |
| 5 <title>window.performance User Timing measure() method is working proper
ly</title> | 5 <title>window.performance User Timing measure() method is working proper
ly</title> |
| 6 <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> | 6 <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> |
| 7 <link rel="help" href="http://127.0.0.1:8000/webperf/specs/UserTiming/#d
om-performance-measure"/> | 7 <link rel="help" href="http://www.w3.org/TR/user-timing/#dom-performance
-measure"/> |
| 8 <script src="/w3c/resources/testharness.js"></script> | 8 <script src="../../../resources/testharness.js"></script> |
| 9 <script src="/w3c/resources/testharnessreport.js"></script> | 9 <script src="../../../resources/testharnessreport.js"></script> |
| 10 <script src="/w3c/webperf/resources/webperftestharness.js"></script> | 10 <script src="resources/webperftestharness.js"></script> |
| 11 | 11 |
| 12 <script type="text/javascript"> | 12 <script type="text/javascript"> |
| 13 // test data | 13 // test data |
| 14 var startMarkName = "mark_start"; | 14 var startMarkName = "mark_start"; |
| 15 var startMarkValue; | 15 var startMarkValue; |
| 16 var endMarkName = "mark_end"; | 16 var endMarkName = "mark_end"; |
| 17 var endMarkValue; | 17 var endMarkValue; |
| 18 var measures; | 18 var measures; |
| 19 var testThreshold = 20; | 19 var testThreshold = 20; |
| 20 | 20 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 endMark: undefined, | 61 endMark: undefined, |
| 62 startTime: undefined, | 62 startTime: undefined, |
| 63 duration: undefined, | 63 duration: undefined, |
| 64 entryType: "measure", | 64 entryType: "measure", |
| 65 entryMatch: undefined, | 65 entryMatch: undefined, |
| 66 order: undefined, | 66 order: undefined, |
| 67 found: false | 67 found: false |
| 68 } | 68 } |
| 69 ]; | 69 ]; |
| 70 | 70 |
| 71 setup({timeout:1000, explicit_done: true}); | 71 setup({explicit_done: true}); |
| 72 | 72 |
| 73 test_namespace(); | 73 test_namespace(); |
| 74 | 74 |
| 75 function onload_test() | 75 function onload_test() |
| 76 { | 76 { |
| 77 // test for existance of User Timing and Performance Timeline interf
ace | 77 // test for existance of User Timing and Performance Timeline interf
ace |
| 78 if (window.performance.mark == undefined || | 78 if (window.performance.mark == undefined || |
| 79 window.performance.clearMarks == undefined || | 79 window.performance.clearMarks == undefined || |
| 80 window.performance.measure == undefined || | 80 window.performance.measure == undefined || |
| 81 window.performance.clearMeasures == undefined || | 81 window.performance.clearMeasures == undefined || |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 226 } |
| 227 | 227 |
| 228 function test_measure(measureEntry, measureEntryCommand, expectedName, e
xpectedStartTime, expectedDuration) | 228 function test_measure(measureEntry, measureEntryCommand, expectedName, e
xpectedStartTime, expectedDuration) |
| 229 { | 229 { |
| 230 // test name | 230 // test name |
| 231 test_true(measureEntry.name == expectedName, measureEntryCommand + "
.name == \"" + expectedName + "\""); | 231 test_true(measureEntry.name == expectedName, measureEntryCommand + "
.name == \"" + expectedName + "\""); |
| 232 | 232 |
| 233 // test startTime; since for a mark, the startTime is always equal t
o a mark's value or the value of a | 233 // test startTime; since for a mark, the startTime is always equal t
o a mark's value or the value of a |
| 234 // navigation timing attribute, the actual startTime should match th
e expected value exactly | 234 // navigation timing attribute, the actual startTime should match th
e expected value exactly |
| 235 test_true(Math.abs(measureEntry.startTime - expectedStartTime) == 0, | 235 test_true(Math.abs(measureEntry.startTime - expectedStartTime) == 0, |
| 236 measureEntryCommand + ".startTime == " ); | 236 measureEntryCommand + ".startTime == " + expectedStartTime
); |
| 237 | 237 |
| 238 // test entryType | 238 // test entryType |
| 239 test_true(measureEntry.entryType == "measure", measureEntryCommand +
".entryType == \"measure\""); | 239 test_true(measureEntry.entryType == "measure", measureEntryCommand +
".entryType == \"measure\""); |
| 240 | 240 |
| 241 // test duration, allow for an acceptable threshold in the differenc
e between the actual duration and the | 241 // test duration, allow for an acceptable threshold in the differenc
e between the actual duration and the |
| 242 // expected value for the duration | 242 // expected value for the duration |
| 243 test_true(Math.abs(measureEntry.duration - expectedDuration) <= test
Threshold, measureEntryCommand + | 243 test_true(Math.abs(measureEntry.duration - expectedDuration) <= test
Threshold, measureEntryCommand + |
| 244 ".duration ~== " + " (up to " + testThreshold + "ms diffe
rence allowed)"); | 244 ".duration ~== " + expectedDuration + " (up to " + testThr
eshold + "ms difference allowed)"); |
| 245 } | 245 } |
| 246 | 246 |
| 247 function test_measure_list(measureEntryList, measureEntryListCommand, me
asureScenarios) | 247 function test_measure_list(measureEntryList, measureEntryListCommand, me
asureScenarios) |
| 248 { | 248 { |
| 249 // give all entries a "found" property that can be set to ensure it
isn't tested twice | 249 // give all entries a "found" property that can be set to ensure it
isn't tested twice |
| 250 for (var i in measureEntryList) | 250 for (var i in measureEntryList) |
| 251 { | 251 { |
| 252 measureEntryList[i].found = false; | 252 measureEntryList[i].found = false; |
| 253 } | 253 } |
| 254 | 254 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 <li>"measure_no_start_no_end": duplicate of the first measure, u
sed to confirm names can be re-used</li> | 325 <li>"measure_no_start_no_end": duplicate of the first measure, u
sed to confirm names can be re-used</li> |
| 326 </ul> | 326 </ul> |
| 327 After creating each measure, the existence of these measures is valid
ated by calling | 327 After creating each measure, the existence of these measures is valid
ated by calling |
| 328 performance.getEntriesByName() (both with and without the entryType p
arameter provided), | 328 performance.getEntriesByName() (both with and without the entryType p
arameter provided), |
| 329 performance.getEntriesByType(), and performance.getEntries() | 329 performance.getEntriesByType(), and performance.getEntries() |
| 330 </p> | 330 </p> |
| 331 | 331 |
| 332 <div id="log"></div> | 332 <div id="log"></div> |
| 333 </body> | 333 </body> |
| 334 </html> | 334 </html> |
| OLD | NEW |