Skip to content

Commit

Permalink
Bug 1743663 - Remove windowContext.hasActivePeerConnections. r=peterv
Browse files Browse the repository at this point in the history
TabUnloader.jsm can directly call windowGlobal.hasActivePeerConnections(),
so windowContext.hasActivePeerConnections is not needed.

Differential Revision: https://phabricator.services.mozilla.com/D132654
  • Loading branch information
Toshihito Kikuchi committed Dec 16, 2021
1 parent d0c8a06 commit baa43db
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion browser/modules/TabUnloader.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ let DefaultTabUnloaderMethods = {
// No need to iterate browser contexts for hasActivePeerConnection
// because hasActivePeerConnection is set only in the top window.
return webrtcUI.browserHasStreams(browser) ||
browser.browsingContext?.topWindowContext?.hasActivePeerConnections
browser.browsingContext?.currentWindowGlobal?.hasActivePeerConnections()
? weight
: 0;
},
Expand Down
6 changes: 0 additions & 6 deletions docshell/base/WindowContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ bool WindowContext::IsCurrent() const {
return mBrowsingContext->mCurrentWindowContext == this;
}

bool WindowContext::HasActivePeerConnections() {
MOZ_ASSERT(TopWindowContext() == this,
"HasActivePeerConnections is set only in the top window context");
return Canonical()->HasActivePeerConnections();
}

bool WindowContext::IsInBFCache() {
if (mozilla::SessionHistoryInParent()) {
return mBrowsingContext->IsInBFCache();
Expand Down
2 changes: 0 additions & 2 deletions docshell/base/WindowContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ class WindowContext : public nsISupports, public nsWrapperCache {

bool HadLazyLoadImage() const { return GetHadLazyLoadImage(); }

bool HasActivePeerConnections();

bool AllowJavascript() const { return GetAllowJavascript(); }
bool CanExecuteScripts() const { return mCanExecuteScripts; }

Expand Down
10 changes: 5 additions & 5 deletions dom/chrome-webidl/WindowGlobalActors.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ interface WindowContext {
// It won't become false if the image becomes non-lazy.
readonly attribute boolean hadLazyLoadImage;

// True if any of the windows in the subtree rooted at this window
// has active peer connections. If this is called for a non-top-level
// context, it always returns false.
readonly attribute boolean hasActivePeerConnections;

/**
* Partially determines whether script execution is allowed in this
* BrowsingContext. Script execution will be permitted only if this
Expand Down Expand Up @@ -162,6 +157,11 @@ interface WindowGlobalParent : WindowContext {
*/
[Throws]
Promise<nsITransportSecurityInfo> getSecurityInfo();

// True if any of the windows in the subtree rooted at this window
// has active peer connections. If this is called for a non-top-level
// context, it always returns false.
boolean hasActivePeerConnections();
};

[Exposed=Window, ChromeOnly]
Expand Down
14 changes: 7 additions & 7 deletions dom/tests/browser/browser_hasActivePeerConnections.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const TEST_URI2 =

add_task(async () => {
await BrowserTestUtils.withNewTab(TEST_URI1, async browser => {
const topWindow = browser.browsingContext.topWindowContext;
Assert.ok(topWindow);
const windowGlobal = browser.browsingContext.currentWindowGlobal;
Assert.ok(windowGlobal);

Assert.strictEqual(
topWindow.hasActivePeerConnections,
windowGlobal.hasActivePeerConnections(),
false,
"No active connections at the beginning"
);
Expand All @@ -30,7 +30,7 @@ add_task(async () => {
});

Assert.strictEqual(
topWindow.hasActivePeerConnections,
windowGlobal.hasActivePeerConnections(),
true,
"One connection in the top window"
);
Expand All @@ -48,7 +48,7 @@ add_task(async () => {
});

Assert.strictEqual(
topWindow.hasActivePeerConnections,
windowGlobal.hasActivePeerConnections(),
false,
"All connections have been closed"
);
Expand Down Expand Up @@ -106,7 +106,7 @@ add_task(async () => {
);

Assert.strictEqual(
topWindow.hasActivePeerConnections,
windowGlobal.hasActivePeerConnections(),
true,
"#iframe-cross-origin still has an active connection"
);
Expand All @@ -126,7 +126,7 @@ add_task(async () => {
});

Assert.strictEqual(
topWindow.hasActivePeerConnections,
windowGlobal.hasActivePeerConnections(),
false,
"All connections have been closed"
);
Expand Down

0 comments on commit baa43db

Please sign in to comment.