mirror of
https://github.com/servo/servo.git
synced 2025-09-30 16:49:16 +01:00
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:
parent
af74db4e92
commit
7a7129edd7
2 changed files with 20 additions and 11 deletions
|
@ -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(
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
[workers.html]
|
||||
expected: ERROR
|
||||
[The initiator type for classic worker must be 'other']
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue