Bug 1963956 - Check valid window when creating GeckoView's StreamListener. r=geckoview-reviewers,nika

When I added a check whether window is destroyed by bug 1957566, I found
new issue that `GeckoViewStreamListener` doesn't have valid window.

I think we should abort this stream due no valid window.

Differential Revision: https://phabricator.services.mozilla.com/D247567
This commit is contained in:
Makoto Kato
2025-05-07 01:17:08 +00:00
committed by m_kato@ga2.so-net.ne.jp
parent 434e3f6459
commit 4068d7a8cc

View File

@@ -19,7 +19,9 @@
class StreamListener final : public mozilla::GeckoViewStreamListener {
public:
explicit StreamListener(nsWindow* aWindow)
: GeckoViewStreamListener(), mWindow(aWindow) {}
: GeckoViewStreamListener(), mWindow(aWindow) {
MOZ_ASSERT(aWindow);
}
void SendWebResponse(mozilla::java::WebResponse::Param aResponse) {
mWindow->PassExternalResponse(aResponse);
@@ -77,7 +79,9 @@ NS_IMETHODIMP GeckoViewExternalAppService::CreateListener(
}
RefPtr<nsWindow> window = nsWindow::From(widget);
MOZ_ASSERT(window);
if (NS_WARN_IF(!window) || NS_WARN_IF(window->Destroyed())) {
return NS_ERROR_ABORT;
}
RefPtr<StreamListener> listener = new StreamListener(window);