11cb0ef41Sopenharmony_ci<!doctype html> 21cb0ef41Sopenharmony_ci<meta charset="utf-8"> 31cb0ef41Sopenharmony_ci<title>event.timeStamp is initialized using event's relevant global object</title> 41cb0ef41Sopenharmony_ci<link rel="help" href="https://dom.spec.whatwg.org/#ref-for-dom-event-timestamp%E2%91%A1"> 51cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script> 61cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script> 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci<body> 91cb0ef41Sopenharmony_ci<script> 101cb0ef41Sopenharmony_ciconst t = async_test(); 111cb0ef41Sopenharmony_cit.step_timeout(() => { 121cb0ef41Sopenharmony_ci const iframeDelayed = document.createElement("iframe"); 131cb0ef41Sopenharmony_ci iframeDelayed.onload = t.step_func_done(() => { 141cb0ef41Sopenharmony_ci // Use eval() to eliminate false-positive test result for WebKit builds before r280256, 151cb0ef41Sopenharmony_ci // which invoked WebIDL accessors in context of lexical (caller) global object. 161cb0ef41Sopenharmony_ci const timeStampExpected = iframeDelayed.contentWindow.eval(`new Event("foo").timeStamp`); 171cb0ef41Sopenharmony_ci const eventDelayed = new iframeDelayed.contentWindow.Event("foo"); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci const {get} = Object.getOwnPropertyDescriptor(Event.prototype, "timeStamp"); 201cb0ef41Sopenharmony_ci assert_approx_equals(get.call(eventDelayed), timeStampExpected, 5, "via Object.getOwnPropertyDescriptor"); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci Object.setPrototypeOf(eventDelayed, Event.prototype); 231cb0ef41Sopenharmony_ci assert_approx_equals(eventDelayed.timeStamp, timeStampExpected, 5, "via Object.setPrototypeOf"); 241cb0ef41Sopenharmony_ci }); 251cb0ef41Sopenharmony_ci document.body.append(iframeDelayed); 261cb0ef41Sopenharmony_ci}, 1000); 271cb0ef41Sopenharmony_ci</script> 28