mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +00:00
LibWeb: Add Web Worker Origin Inheritance
Fetch requests from web workers fail CORS checks because the origin is not inherited from the outside settings. Ensure web worker origin is correctly inherited from outside settings
This commit is contained in:
parent
176e3ba16a
commit
24adb1c452
Notes:
sideshowbarker
2024-07-16 20:39:14 +09:00
Author: https://github.com/braydnm 🔰
Commit: 24adb1c452
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/408
Issue: https://github.com/LadybirdBrowser/ladybird/issues/189
Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 18 additions and 5 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h>
|
||||
#include <LibWeb/HTML/WorkerDebugConsoleClient.h>
|
||||
#include <LibWeb/HTML/WorkerGlobalScope.h>
|
||||
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <WebWorker/DedicatedWorkerHost.h>
|
||||
|
||||
|
@ -33,6 +34,9 @@ void DedicatedWorkerHost::run(JS::NonnullGCPtr<Web::Page> page, Web::HTML::Trans
|
|||
{
|
||||
bool const is_shared = false;
|
||||
|
||||
// 3. Let unsafeWorkerCreationTime be the unsafe shared current time.
|
||||
auto unsafe_worker_creation_time = Web::HighResolutionTime::unsafe_shared_current_time();
|
||||
|
||||
// 7. Let realm execution context be the result of creating a new JavaScript realm given agent and the following customizations:
|
||||
auto realm_execution_context = Web::Bindings::create_a_new_javascript_realm(
|
||||
Web::Bindings::main_thread_vm(),
|
||||
|
@ -52,7 +56,7 @@ void DedicatedWorkerHost::run(JS::NonnullGCPtr<Web::Page> page, Web::HTML::Trans
|
|||
|
||||
// 9. Set up a worker environment settings object with realm execution context,
|
||||
// outside settings, and unsafeWorkerCreationTime, and let inside settings be the result.
|
||||
auto inner_settings = Web::HTML::WorkerEnvironmentSettingsObject::setup(page, move(realm_execution_context));
|
||||
auto inner_settings = Web::HTML::WorkerEnvironmentSettingsObject::setup(page, move(realm_execution_context), outside_settings_snapshot, unsafe_worker_creation_time);
|
||||
|
||||
auto& console_object = *inner_settings->realm().intrinsics().console_object();
|
||||
m_console = console_object.heap().allocate_without_realm<Web::HTML::WorkerDebugConsoleClient>(console_object.console());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue