script: when fetching a worker script abort if response status is not ok (#39468)

According to
[spec](https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-script)
we should abort if the response status is not ok.

Testing: Check tests listed inside issue are not intermittent anymore
Fixes: #39413
Fixes: #22991

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
Gae24 2025-09-29 11:08:12 +02:00 committed by GitHub
parent af74db4e92
commit 7a7129edd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 11 deletions

View file

@ -506,6 +506,18 @@ impl DedicatedWorkerGlobalScope {
global_scope.set_https_state(current_global_https_state);
let send_error = || {
parent_event_loop_sender
.send(CommonScriptMsg::Task(
WorkerEvent,
Box::new(SimpleWorkerErrorHandler::new(worker.clone())),
Some(pipeline_id),
TaskSourceName::DOMManipulation,
))
.unwrap();
scope.clear_js_runtime();
};
let (metadata, bytes) = match load_whole_resource(
request,
&global_scope.resource_threads().sender(),
@ -518,18 +530,16 @@ impl DedicatedWorkerGlobalScope {
) {
Err(e) => {
error!("error loading script {} ({:?})", serialized_worker_url, e);
parent_event_loop_sender
.send(CommonScriptMsg::Task(
WorkerEvent,
Box::new(SimpleWorkerErrorHandler::new(worker)),
Some(pipeline_id),
TaskSourceName::DOMManipulation,
))
.unwrap();
scope.clear_js_runtime();
send_error();
return;
},
Ok((metadata, bytes)) => (metadata, bytes),
Ok((metadata, bytes)) => {
if !metadata.status.is_success() {
send_error();
return;
}
(metadata, bytes)
},
};
scope.set_url(metadata.final_url.clone());
Self::initialize_policy_container_for_worker_global_scope(

View file

@ -1,5 +1,4 @@
[workers.html]
expected: ERROR
[The initiator type for classic worker must be 'other']
expected: FAIL