fix: loading dedicated/shared worker scripts over custom protocol (#20625)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
4829b0f816
commit
76e3ee6fe6
9 changed files with 136 additions and 5 deletions
|
@ -1263,6 +1263,16 @@ void ElectronBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
|
|||
URLLoaderFactoryType::kNavigation, factories);
|
||||
}
|
||||
|
||||
void ElectronBrowserClient::
|
||||
RegisterNonNetworkWorkerMainResourceURLLoaderFactories(
|
||||
content::BrowserContext* browser_context,
|
||||
NonNetworkURLLoaderFactoryMap* factories) {
|
||||
auto* protocol_registry =
|
||||
ProtocolRegistry::FromBrowserContext(browser_context);
|
||||
protocol_registry->RegisterURLLoaderFactories(
|
||||
URLLoaderFactoryType::kWorkerMainResource, factories);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
namespace {
|
||||
|
||||
|
|
|
@ -178,6 +178,9 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
|
|||
void RegisterNonNetworkNavigationURLLoaderFactories(
|
||||
int frame_tree_node_id,
|
||||
NonNetworkURLLoaderFactoryMap* factories) override;
|
||||
void RegisterNonNetworkWorkerMainResourceURLLoaderFactories(
|
||||
content::BrowserContext* browser_context,
|
||||
NonNetworkURLLoaderFactoryMap* factories) override;
|
||||
void RegisterNonNetworkSubresourceURLLoaderFactories(
|
||||
int render_process_id,
|
||||
int render_frame_id,
|
||||
|
|
|
@ -200,11 +200,11 @@ bool ElectronRendererClient::ShouldFork(blink::WebLocalFrame* frame,
|
|||
return http_method == "GET";
|
||||
}
|
||||
|
||||
void ElectronRendererClient::DidInitializeWorkerContextOnWorkerThread(
|
||||
void ElectronRendererClient::WorkerScriptReadyForEvaluationOnWorkerThread(
|
||||
v8::Local<v8::Context> context) {
|
||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kNodeIntegrationInWorker)) {
|
||||
WebWorkerObserver::GetCurrent()->ContextCreated(context);
|
||||
WebWorkerObserver::GetCurrent()->WorkerScriptReadyForEvaluation(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class ElectronRendererClient : public RendererClientBase {
|
|||
const std::string& http_method,
|
||||
bool is_initial_navigation,
|
||||
bool is_server_redirect) override;
|
||||
void DidInitializeWorkerContextOnWorkerThread(
|
||||
void WorkerScriptReadyForEvaluationOnWorkerThread(
|
||||
v8::Local<v8::Context> context) override;
|
||||
void WillDestroyWorkerContextOnWorkerThread(
|
||||
v8::Local<v8::Context> context) override;
|
||||
|
|
|
@ -42,7 +42,8 @@ WebWorkerObserver::~WebWorkerObserver() {
|
|||
asar::ClearArchives();
|
||||
}
|
||||
|
||||
void WebWorkerObserver::ContextCreated(v8::Local<v8::Context> worker_context) {
|
||||
void WebWorkerObserver::WorkerScriptReadyForEvaluation(
|
||||
v8::Local<v8::Context> worker_context) {
|
||||
v8::Context::Scope context_scope(worker_context);
|
||||
|
||||
// Start the embed thread.
|
||||
|
|
|
@ -21,7 +21,7 @@ class WebWorkerObserver {
|
|||
// Returns the WebWorkerObserver for current worker thread.
|
||||
static WebWorkerObserver* GetCurrent();
|
||||
|
||||
void ContextCreated(v8::Local<v8::Context> context);
|
||||
void WorkerScriptReadyForEvaluation(v8::Local<v8::Context> context);
|
||||
void ContextWillDestroy(v8::Local<v8::Context> context);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue