Bug 1695185 - Use the WindowId of the owner document instead r=valentin,necko-reviewers,baku
The websocket uses the innerWindowId of the window where the script lives when triggering events for devtools. This is may not be the same as the websocket owner window as mentioned here https://searchfox.org/mozilla-central/rev/f1159268add2fd0959e9f91b474f5da74c90f305/dom/websocket/WebSocket.cpp#206-207,212 This seems to be the case when we have iframes within a page. The devtools do not get the events for the websockets channels opened within iframes as the innerWindowId is that of the top-level window. `...->TopWindowContext()->InnerWindowId()` also always point to the top-level window. This patch fixes these issues by switching to use the websocket owner window which the iframe. Note: The parent revsion contains the changes for the devtools fission work that depends on this fix. i did this to make it easy to test and review. Differential Revision: https://phabricator.services.mozilla.com/D106607
This commit is contained in:
@@ -203,8 +203,9 @@ class WebSocketImpl final : public nsIInterfaceRequestor,
|
||||
// - the script file name, UTF8 encoded.
|
||||
// - source code line number and column number where the Web Socket object
|
||||
// was constructed.
|
||||
// - the ID of the inner window where the script lives. Note that this may not
|
||||
// be the same as the Web Socket owner window.
|
||||
// - the ID of the Web Socket owner window. Note that this may not
|
||||
// be the same as the inner window where the script lives.
|
||||
// e.g within iframes
|
||||
// These attributes are used for error reporting.
|
||||
nsCString mScriptFile;
|
||||
uint32_t mScriptLine;
|
||||
@@ -1159,7 +1160,7 @@ class AsyncOpenRunnable final : public WebSocketMainThreadRunnable {
|
||||
|
||||
uint64_t windowID = 0;
|
||||
if (WindowContext* wc = aWindow->GetWindowContext()) {
|
||||
windowID = wc->TopWindowContext()->InnerWindowId();
|
||||
windowID = wc->InnerWindowId();
|
||||
}
|
||||
|
||||
mErrorCode = mImpl->AsyncOpen(principal, windowID, nullptr, ""_ns,
|
||||
@@ -1374,7 +1375,7 @@ already_AddRefed<WebSocket> WebSocket::ConstructorCommon(
|
||||
|
||||
uint64_t windowID = 0;
|
||||
if (WindowContext* wc = ownerWindow->GetWindowContext()) {
|
||||
windowID = wc->TopWindowContext()->InnerWindowId();
|
||||
windowID = wc->InnerWindowId();
|
||||
}
|
||||
|
||||
aRv = webSocket->mImpl->AsyncOpen(principal, windowID, aTransportProvider,
|
||||
@@ -1521,7 +1522,9 @@ nsresult WebSocketImpl::Init(JSContext* aCx, nsIPrincipal* aLoadingPrincipal,
|
||||
// inner-windowID. This can happen in sharedWorkers and ServiceWorkers or in
|
||||
// DedicateWorkers created by JSM.
|
||||
if (aCx) {
|
||||
mInnerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(aCx);
|
||||
if (nsPIDOMWindowInner* ownerWindow = mWebSocket->GetOwner()) {
|
||||
mInnerWindowID = ownerWindow->WindowID();
|
||||
}
|
||||
}
|
||||
|
||||
mPrivateBrowsing = !!aPrincipal->OriginAttributesRef().mPrivateBrowsingId;
|
||||
|
||||
Reference in New Issue
Block a user