Repository: servo/servo
File: components/script/dom/globalscope.rs (Rust)

Code before:
    }

    pub(crate) fn append_report(&self, report: Report) {
        if let Some(window) = self.downcast::<Window>() {
            return window.append_report(report);
        }
        if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
            return worker.append_report(report);
        }
        unreachable!();
    }

    pub(crate) fn buffered_reports(&self) -> Vec<Report> {
        if let Some(window) = self.downcast::<Window>() {
            return window.buffered_reports();
        }
        if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
            return worker.buffered_reports();
        }
        unreachable!();
    }

    pub(crate) fn append_deferred_fetch(&self, deferred_fetch: QueuedDeferredFetchRecord) {
        if let Some(window) = self.downcast::<Window>() {
            let doc = window.Document();
            return doc.append_deferred_fetch(deferred_fetch);
        }
        unreachable!();
    }

    pub(crate) fn import_map(&self) -> Ref<'_, ImportMap> {
        self.import_map.borrow()
    }

    pub(crate) fn import_map_mut(&self) -> RefMut<'_, ImportMap> {
        self.import_map.borrow_mut()
    }

    pub(crate) fn resolved_module_set(&self) -> Ref<'_, HashSet<ResolvedModule>> {
        self.resolved_module_set.borrow()
    }

    pub(crate) fn resolved_module_set_mut(&self) -> RefMut<'_, HashSet<ResolvedModule>> {
        self.resolved_module_set.borrow_mut()
    }

    /// <https://html.spec.whatwg.org/multipage/#add-module-to-resolved-module-set>
    pub(crate) fn add_module_to_resolved_module_set(
        &self,
        base_url: &str,
        specifier: &str,

Review comment (suggestion):
```suggestion
            return window.Document().append_deferred_fetch(deferred_fetch);
```

Code after:
    }

    pub(crate) fn append_report(&self, report: Report) {
        if let Some(window) = self.downcast::<Window>() {
            return window.append_report(report);
        }
        if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
            return worker.append_report(report);
        }
        unreachable!();
    }

    pub(crate) fn buffered_reports(&self) -> Vec<Report> {
        if let Some(window) = self.downcast::<Window>() {
            return window.buffered_reports();
        }
        if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
            return worker.buffered_reports();
        }
        unreachable!();
    }

    pub(crate) fn append_deferred_fetch(&self, deferred_fetch: QueuedDeferredFetchRecord) {
        if let Some(window) = self.downcast::<Window>() {
            return window.Document().append_deferred_fetch(deferred_fetch);
        }
        unreachable!("Deferred fetches (e.g. `fetchLater`) are only available on window");
    }

    pub(crate) fn import_map(&self) -> Ref<'_, ImportMap> {
        self.import_map.borrow()
    }

    pub(crate) fn import_map_mut(&self) -> RefMut<'_, ImportMap> {
        self.import_map.borrow_mut()
    }

    pub(crate) fn resolved_module_set(&self) -> Ref<'_, HashSet<ResolvedModule>> {
        self.resolved_module_set.borrow()
    }

    pub(crate) fn resolved_module_set_mut(&self) -> RefMut<'_, HashSet<ResolvedModule>> {
        self.resolved_module_set.borrow_mut()
    }

    /// <https://html.spec.whatwg.org/multipage/#add-module-to-resolved-module-set>
    pub(crate) fn add_module_to_resolved_module_set(
        &self,
        base_url: &str,
        specifier: &str,
        specifier_url: Option<ServoUrl>,