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

Code before:
        if url.origin() != environment_origin {
            return Err(Error::Security);
        }
        // Step 7. Assert: the result of Is url potentially trustworthy? given urlRecord is "Potentially Trustworthy".
        assert!(url.is_potentially_trustworthy());
        // Step 8. Return (scheme, urlRecord).
        Ok((scheme, url))
    }

    fn send_protocol_update_registration_to_embedder(
        &self,
        registration: ProtocolHandlerUpdateRegistration,
    ) {
        let global = self.global();
        let window = global.as_window();
        let (sender, receiver) = generic_channel::channel().unwrap();
        let _ = global
            .script_to_embedder_chan()
            .send(EmbedderMsg::AllowProtocolHandlerRequest(
                window.webview_id(),
                registration,
                sender,
            ));
        let Ok(_allow_or_deny) = receiver.recv() else {
            return;
        };
    }
}

impl NavigatorMethods<crate::DomTypeHolder> for Navigator {
    /// <https://html.spec.whatwg.org/multipage/#dom-navigator-product>
    fn Product(&self) -> DOMString {
        navigatorinfo::Product()
    }

    /// <https://html.spec.whatwg.org/multipage/#dom-navigator-productsub>
    fn ProductSub(&self) -> DOMString {
        navigatorinfo::ProductSub()
    }

    /// <https://html.spec.whatwg.org/multipage/#dom-navigator-vendor>
    fn Vendor(&self) -> DOMString {
        navigatorinfo::Vendor()
    }

    /// <https://html.spec.whatwg.org/multipage/#dom-navigator-vendorsub>
    fn VendorSub(&self) -> DOMString {
        navigatorinfo::VendorSub()
    }

    /// <https://html.spec.whatwg.org/multipage/#dom-navigator-taintenabled>

Review comment (suggestion):
Maybe just ignore the result for now and skip the `recv` call? Do note though that this almost certainly should not be a synchronous call.

Code after:
        if url.origin() != environment_origin {
            return Err(Error::Security);
        }
        // Step 7. Assert: the result of Is url potentially trustworthy? given urlRecord is "Potentially Trustworthy".
        assert!(url.is_potentially_trustworthy());
        // Step 8. Return (scheme, urlRecord).
        Ok((scheme, url))
    }

    fn send_protocol_update_registration_to_embedder(
        &self,
        registration: ProtocolHandlerUpdateRegistration,
    ) {
        let global = self.global();
        let window = global.as_window();
        let (sender, _) = generic_channel::channel().unwrap();
        let _ = global
            .script_to_embedder_chan()
            .send(EmbedderMsg::AllowProtocolHandlerRequest(
                window.webview_id(),
                registration,
                sender,
            ));
    }
}

impl NavigatorMethods<crate::DomTypeHolder> for Navigator {
    /// <https://html.spec.whatwg.org/multipage/#dom-navigator-product>
    fn Product(&self) -> DOMString {
        navigatorinfo::Product()
    }

    /// <https://html.spec.whatwg.org/multipage/#dom-navigator-productsub>
    fn ProductSub(&self) -> DOMString {
        navigatorinfo::ProductSub()
    }

    /// <https://html.spec.whatwg.org/multipage/#dom-navigator-vendor>
    fn Vendor(&self) -> DOMString {
        navigatorinfo::Vendor()
    }

    /// <https://html.spec.whatwg.org/multipage/#dom-navigator-vendorsub>
    fn VendorSub(&self) -> DOMString {
        navigatorinfo::VendorSub()
    }

    /// <https://html.spec.whatwg.org/multipage/#dom-navigator-taintenabled>
    fn TaintEnabled(&self) -> bool {
        navigatorinfo::TaintEnabled()
    }