Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

1.2 KB
Raw Blame
use super::super::{ChildBrowsingContextBootstrap, JsContextHost};
use crate::document_runtime::DomHandle;
use url::Url;

impl JsContextHost {
    pub(in crate::native_bridge::context_host::child_documents) fn child_document_url_requires_async_load(
        &self,
        url: &Url,
    ) -> bool {
        matches!(url.scheme(), "http" | "https")
    }

    pub(in crate::native_bridge::context_host::child_documents) fn child_document_bootstrap_requires_async_load(
        &self,
        bootstrap: &ChildBrowsingContextBootstrap,
    ) -> bool {
        match bootstrap {
            ChildBrowsingContextBootstrap::Url(url)
                if self.child_document_url_requires_async_load(url) =>
            {
                true
            }
            ChildBrowsingContextBootstrap::Request(_) => true,
            _ => false,
        }
    }

    pub(crate) fn child_browsing_context_attribute_bootstrap_requires_async_load(
        &self,
        handle: DomHandle,
    ) -> bool {
        self.child_browsing_contexts
            .get(&handle)
            .is_some_and(|entry| {
                self.child_document_bootstrap_requires_async_load(entry.attribute_bootstrap())
            })
    }
}