mirror of
https://github.com/servo/servo
synced 2026-04-26 01:25:32 +02:00
script: Drop ModuleTree network_error and simplify pending fetches logic (#42127)
Since we use `NetworkError` just for logging reasons, we don't really need to pass it around; instead lets follow spec more closely and pass a `None` on network failures. Make more explicit if a `modulemap` entry is currently fetching or ready. Testing: No functional change, covered by existing tests --------- Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
@@ -42,7 +42,6 @@ use crate::dom::bindings::reflector::DomGlobal;
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::settings_stack::AutoEntryScript;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::bindings::trace::NoTrace;
|
||||
use crate::dom::csp::{CspReporting, GlobalCspReporting, InlineCheckType, Violation};
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{
|
||||
@@ -292,7 +291,7 @@ fn finish_fetching_a_classic_script(
|
||||
document.finish_load(LoadType::Script(url), can_gc);
|
||||
}
|
||||
|
||||
pub(crate) type ScriptResult = Result<Script, NoTrace<NetworkError>>;
|
||||
pub(crate) type ScriptResult = Result<Script, ()>;
|
||||
|
||||
// TODO merge classic and module scripts
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
@@ -380,12 +379,13 @@ impl FetchResponseListener for ClassicContext {
|
||||
) {
|
||||
match (response.as_ref(), self.status.as_ref()) {
|
||||
(Err(error), _) | (_, Err(error)) => {
|
||||
error!("Fetching classic script failed {:?}", error);
|
||||
// Step 6, response is an error.
|
||||
finish_fetching_a_classic_script(
|
||||
&self.elem.root(),
|
||||
self.kind,
|
||||
self.url.clone(),
|
||||
Err(NoTrace(error.clone())),
|
||||
Err(()),
|
||||
CanGc::note(),
|
||||
);
|
||||
|
||||
@@ -956,8 +956,7 @@ impl HTMLScriptElement {
|
||||
// TODO: Step 3. Unblock rendering on el.
|
||||
let script = match result {
|
||||
// Step 4. If el's result is null, then fire an event named error at el, and return.
|
||||
Err(e) => {
|
||||
warn!("error loading script {:?}", e);
|
||||
Err(_) => {
|
||||
self.dispatch_error_event(can_gc);
|
||||
return;
|
||||
},
|
||||
@@ -1049,8 +1048,7 @@ impl HTMLScriptElement {
|
||||
// Step 6.
|
||||
{
|
||||
let module_error = module_tree.get_rethrow_error().borrow();
|
||||
let network_error = module_tree.get_network_error();
|
||||
if module_error.is_some() && network_error.is_none() {
|
||||
if module_error.is_some() {
|
||||
module_tree.report_error(global, can_gc);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user