зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1451913 P2 Update websocket state on the inner window when rebinding. r=smaug
This commit is contained in:
Родитель
4763ab4066
Коммит
39a5ac2cec
|
@ -954,6 +954,30 @@ WebSocket::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
|
|||
return WebSocketBinding::Wrap(cx, this, aGivenProto);
|
||||
}
|
||||
|
||||
void
|
||||
WebSocket::BindToOwner(nsIGlobalObject* aNew)
|
||||
{
|
||||
auto scopeExit = MakeScopeExit([&] {
|
||||
DOMEventTargetHelper::BindToOwner(aNew);
|
||||
});
|
||||
|
||||
// If we're disconnected, then there is no state to update.
|
||||
if (!mImpl || mImpl->mDisconnectingOrDisconnected) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update state on the old window.
|
||||
if (GetOwner()) {
|
||||
GetOwner()->UpdateWebSocketCount(-1);
|
||||
}
|
||||
|
||||
// Update state on the new window
|
||||
nsCOMPtr<nsPIDOMWindowInner> newWindow = do_QueryInterface(aNew);
|
||||
if (newWindow) {
|
||||
newWindow->UpdateWebSocketCount(1);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// WebIDL
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -65,6 +65,9 @@ public:
|
|||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// DOMEventTargetHelper
|
||||
void BindToOwner(nsIGlobalObject* aNew) override;
|
||||
|
||||
public: // static helpers:
|
||||
|
||||
// Determine if preferences allow WebSocket
|
||||
|
|
Загрузка…
Ссылка в новой задаче