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

Code before:
        let event = DomRoot::upcast::<Event>(DebuggerSetBreakpointEvent::new(
            self.upcast(),
            spidermonkey_id,
            script_id,
            offset,
            can_gc,
        ));
        assert!(
            DomRoot::upcast::<Event>(event).fire(self.upcast(), can_gc),
            "Guaranteed by DebuggerSetBreakpointEvent::new"
        );
    }

    pub(crate) fn fire_pause(
        &self,
        can_gc: CanGc,
        result_sender: GenericSender<devtools_traits::PauseFrameResult>,
    ) {
        assert!(
            self.get_frame_result_sender
                .replace(Some(result_sender))
                .is_none()
        );
        let event = DomRoot::upcast::<Event>(DebuggerPauseEvent::new(self.upcast(), can_gc));
        assert!(
            DomRoot::upcast::<Event>(event).fire(self.upcast(), can_gc),
            "Guaranteed by DebuggerPauseEvent::new"
        );
    }
}

impl DebuggerGlobalScopeMethods<crate::DomTypeHolder> for DebuggerGlobalScope {
    // check-tidy: no specs after this line
    fn NotifyNewSource(&self, args: &NotifyNewSource) {
        let Some(devtools_chan) = self.as_global_scope().devtools_chan() else {
            return;
        };
        let pipeline_id = PipelineId {
            namespace_id: PipelineNamespaceId(args.pipelineId.namespaceId),
            index: Index::new(args.pipelineId.index).expect("`pipelineId.index` must not be zero"),
        };

        if let Some(introduction_type) = args.introductionType.as_ref() {
            // Check the `introductionType` and `url`, decide whether or not to create a source actor, and if so,
            // tell the devtools server to create a source actor. Based on the Firefox impl in:
            // - getDebuggerSourceURL() <https://searchfox.org/mozilla-central/rev/85667ab51e4b2a3352f7077a9ee43513049ed2d6/devtools/server/actors/utils/source-url.js#7-42>
            // - getSourceURL() <https://searchfox.org/mozilla-central/rev/85667ab51e4b2a3352f7077a9ee43513049ed2d6/devtools/server/actors/source.js#67-109>
            // - resolveSourceURL() <https://searchfox.org/mozilla-central/rev/85667ab51e4b2a3352f7077a9ee43513049ed2d6/devtools/server/actors/source.js#48-66>
            // - SourceActor#_isInlineSource <https://searchfox.org/mozilla-central/rev/85667ab51e4b2a3352f7077a9ee43513049ed2d6/devtools/server/actors/source.js#130-143>
            // - SourceActor#url <https://searchfox.org/mozilla-central/rev/85667ab51e4b2a3352f7077a9ee43513049ed2d6/devtools/server/actors/source.js#157-162>


Review comment (suggestion):
```suggestion
            event.fire(self.upcast(), can_gc),
```

Code after:
        let event = DomRoot::upcast::<Event>(DebuggerSetBreakpointEvent::new(
            self.upcast(),
            spidermonkey_id,
            script_id,
            offset,
            can_gc,
        ));
        assert!(
            event.fire(self.upcast(), can_gc),
            "Guaranteed by DebuggerSetBreakpointEvent::new"
        );
    }

    pub(crate) fn fire_pause(
        &self,
        can_gc: CanGc,
        result_sender: GenericSender<devtools_traits::PauseFrameResult>,
    ) {
        assert!(
            self.get_frame_result_sender
                .replace(Some(result_sender))
                .is_none()
        );
        let event = DomRoot::upcast::<Event>(DebuggerPauseEvent::new(self.upcast(), can_gc));
        assert!(
            event.fire(self.upcast(), can_gc),
            "Guaranteed by DebuggerPauseEvent::new"
        );
    }
}

impl DebuggerGlobalScopeMethods<crate::DomTypeHolder> for DebuggerGlobalScope {
    // check-tidy: no specs after this line
    fn NotifyNewSource(&self, args: &NotifyNewSource) {
        let Some(devtools_chan) = self.as_global_scope().devtools_chan() else {
            return;
        };
        let pipeline_id = PipelineId {
            namespace_id: PipelineNamespaceId(args.pipelineId.namespaceId),
            index: Index::new(args.pipelineId.index).expect("`pipelineId.index` must not be zero"),
        };

        if let Some(introduction_type) = args.introductionType.as_ref() {
            // Check the `introductionType` and `url`, decide whether or not to create a source actor, and if so,
            // tell the devtools server to create a source actor. Based on the Firefox impl in:
            // - getDebuggerSourceURL() <https://searchfox.org/mozilla-central/rev/85667ab51e4b2a3352f7077a9ee43513049ed2d6/devtools/server/actors/utils/source-url.js#7-42>
            // - getSourceURL() <https://searchfox.org/mozilla-central/rev/85667ab51e4b2a3352f7077a9ee43513049ed2d6/devtools/server/actors/source.js#67-109>
            // - resolveSourceURL() <https://searchfox.org/mozilla-central/rev/85667ab51e4b2a3352f7077a9ee43513049ed2d6/devtools/server/actors/source.js#48-66>
            // - SourceActor#_isInlineSource <https://searchfox.org/mozilla-central/rev/85667ab51e4b2a3352f7077a9ee43513049ed2d6/devtools/server/actors/source.js#130-143>
            // - SourceActor#url <https://searchfox.org/mozilla-central/rev/85667ab51e4b2a3352f7077a9ee43513049ed2d6/devtools/server/actors/source.js#157-162>