11cb0ef41Sopenharmony_ci<!DOCTYPE html> 21cb0ef41Sopenharmony_ci<html> 31cb0ef41Sopenharmony_ci<head> 41cb0ef41Sopenharmony_ci <title>time origin value manual test</title> 51cb0ef41Sopenharmony_ci <link rel="help" href="https://w3c.github.io/hr-time/#time-origin-1"> 61cb0ef41Sopenharmony_ci <link rel="prefetch" href="./resources/unload-a.html"> 71cb0ef41Sopenharmony_ci <link rel="prefetch" href="./resources/unload-b.html"> 81cb0ef41Sopenharmony_ci <link rel="prefetch" href="./resources/unload-c.html"> 91cb0ef41Sopenharmony_ci</head> 101cb0ef41Sopenharmony_ci<body> 111cb0ef41Sopenharmony_ci <script src="/resources/testharness.js"></script> 121cb0ef41Sopenharmony_ci <script src="/resources/testharnessreport.js"></script> 131cb0ef41Sopenharmony_ci <script> 141cb0ef41Sopenharmony_ci setup({ explicit_timeout: true }); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci const ACCEPTABLE_VARIANCE = 400; // ms 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci const isRoughlyEqual = (a, b) => Math.abs(a - b) < ACCEPTABLE_VARIANCE; 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci const timings = { a: {}, b: {}, c: {} }; 211cb0ef41Sopenharmony_ci const t = async_test("hr-time time origin"); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci window.mark = msg => { 241cb0ef41Sopenharmony_ci timings[msg.docName][msg.lifecycleEventName] = { 251cb0ef41Sopenharmony_ci performanceNow: msg.performanceNow, 261cb0ef41Sopenharmony_ci dateNow: msg.dateNow 271cb0ef41Sopenharmony_ci }; 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci if (msg.docName === "c" && msg.lifecycleEventName === "unload") { 301cb0ef41Sopenharmony_ci setTimeout(makeAssertions, 0); 311cb0ef41Sopenharmony_ci } 321cb0ef41Sopenharmony_ci }; 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci function makeAssertions () { 351cb0ef41Sopenharmony_ci t.step(() => { 361cb0ef41Sopenharmony_ci const loadTimeBetweenAandB = timings.b.load.dateNow - timings.a.unload.dateNow; 371cb0ef41Sopenharmony_ci const loadTimeBetweenBandC = timings.c.load.dateNow - timings.b.unload.dateNow; 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci assert_true( 401cb0ef41Sopenharmony_ci isRoughlyEqual(loadTimeBetweenAandB, timings.b.load.performanceNow), 411cb0ef41Sopenharmony_ci "Document in reused window's time origin should be time of close of pop-up box." 421cb0ef41Sopenharmony_ci ); 431cb0ef41Sopenharmony_ci assert_true( 441cb0ef41Sopenharmony_ci isRoughlyEqual(loadTimeBetweenBandC, timings.c.load.performanceNow), 451cb0ef41Sopenharmony_ci "Document in reused window's time origin should be time of close of pop-up box." 461cb0ef41Sopenharmony_ci ); 471cb0ef41Sopenharmony_ci assert_true( 481cb0ef41Sopenharmony_ci !isRoughlyEqual(timings.a.unload.performanceNow, 0), 491cb0ef41Sopenharmony_ci "Time origin during unload event should match that of rest of document." 501cb0ef41Sopenharmony_ci ); 511cb0ef41Sopenharmony_ci assert_true( 521cb0ef41Sopenharmony_ci !isRoughlyEqual(timings.b.unload.performanceNow, 0), 531cb0ef41Sopenharmony_ci "Time origin during unload event should match that of rest of document." 541cb0ef41Sopenharmony_ci ); 551cb0ef41Sopenharmony_ci assert_true( 561cb0ef41Sopenharmony_ci !isRoughlyEqual(timings.c.unload.performanceNow, 0), 571cb0ef41Sopenharmony_ci "Time origin during unload event should match that of rest of document." 581cb0ef41Sopenharmony_ci ); 591cb0ef41Sopenharmony_ci }); 601cb0ef41Sopenharmony_ci t.done(); 611cb0ef41Sopenharmony_ci } 621cb0ef41Sopenharmony_ci </script> 631cb0ef41Sopenharmony_ci 641cb0ef41Sopenharmony_ci <h2>Description</h2> 651cb0ef41Sopenharmony_ci <p>This test validates the behavior of <code>performance.now()</code> with respect to its time origin.</p> 661cb0ef41Sopenharmony_ci <div id="log"> 671cb0ef41Sopenharmony_ci <h2>Manual Test Steps</h2> 681cb0ef41Sopenharmony_ci <ol> 691cb0ef41Sopenharmony_ci <li><a href="resources/unload-a.html" target="_blank">Click here</a> 701cb0ef41Sopenharmony_ci </ol> 711cb0ef41Sopenharmony_ci </div> 721cb0ef41Sopenharmony_ci</body> 731cb0ef41Sopenharmony_ci<html> 74