mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 17:24:48 -05:00
LibWeb: Use relevant principal settings for HighResolutionTime
Fixes a crash when setting the timestamps when creating a DOM event within a ShadowRealm.
This commit is contained in:
parent
6a668f27c7
commit
218ac86b67
Notes:
github-actions[bot]
2024-11-30 11:07:10 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/218ac86b67e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2631
3 changed files with 15 additions and 2 deletions
|
@ -59,10 +59,14 @@ DOMHighResTimeStamp current_high_resolution_time(JS::Object const& global)
|
|||
}
|
||||
|
||||
// https://w3c.github.io/hr-time/#dfn-relative-high-resolution-time
|
||||
// https://pr-preview.s3.amazonaws.com/w3c/hr-time/pull/168.html#dfn-relative-high-resolution-time
|
||||
DOMHighResTimeStamp relative_high_resolution_time(DOMHighResTimeStamp time, JS::Object const& global)
|
||||
{
|
||||
// 1. Let coarse time be the result of calling coarsen time with time and global's relevant settings object's cross-origin isolated capability.
|
||||
auto coarse_time = coarsen_time(time, HTML::relevant_settings_object(global).cross_origin_isolated_capability() == HTML::CanUseCrossOriginIsolatedAPIs::Yes);
|
||||
// 1. Let settings be the global's relevant principal settings object.
|
||||
auto& settings = HTML::relevant_principal_settings_object(global);
|
||||
|
||||
// 2. Let coarse time be the result of calling coarsen time with time and settings's cross-origin isolated capability.
|
||||
auto coarse_time = coarsen_time(time, settings.cross_origin_isolated_capability() == HTML::CanUseCrossOriginIsolatedAPIs::Yes);
|
||||
|
||||
// 2. Return the relative high resolution coarse time for coarse time and global.
|
||||
return relative_high_resolution_coarsen_time(coarse_time, global);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
My DOM Event
|
8
Tests/LibWeb/Text/input/HTML/ShadowRealm-DOM-event.html
Normal file
8
Tests/LibWeb/Text/input/HTML/ShadowRealm-DOM-event.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const shadowRealm = new ShadowRealm();
|
||||
const result = shadowRealm.evaluate(`() => new Event("My DOM Event").type;`)();
|
||||
println(result);
|
||||
});
|
||||
</script>
|
Loading…
Reference in a new issue