Backed out 4 changesets (bug 1743329) for causing failures at browser_popupNotification_security_delay.js. CLOSED TREE

Backed out changeset 6d33ea38cd14 (bug 1743329)
Backed out changeset 0f9bffa357a5 (bug 1743329)
Backed out changeset cd96c48488eb (bug 1743329)
Backed out changeset 209a41c449e1 (bug 1743329)
This commit is contained in:
Butkovits Atila
2024-05-29 15:47:23 +03:00
parent 74e0e80e31
commit 3a56b9800d
10 changed files with 31 additions and 109 deletions

View File

@@ -17,10 +17,8 @@
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/PointerEventHandler.h"
#include "mozilla/dom/WindowContext.h"
#include "nsCOMPtr.h"
#include "nsMenuPopupFrame.h"
#include "nsSandboxFlags.h"
namespace mozilla {
@@ -88,25 +86,6 @@ static void DispatchPointerLockError(Document* aTarget, const char* aMessage) {
aMessage);
}
static bool IsPopupOpened() {
// Check if any popup is open.
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (!pm) {
return false;
}
nsTArray<nsMenuPopupFrame*> popups;
pm->GetVisiblePopups(popups, true);
for (nsMenuPopupFrame* popup : popups) {
if (popup->GetPopupType() != widget::PopupType::Tooltip) {
return true;
}
}
return false;
}
static const char* GetPointerLockError(Element* aElement, Element* aCurrentLock,
bool aNoFocusCheck = false) {
// Check if pointer lock pref is enabled
@@ -157,10 +136,6 @@ static const char* GetPointerLockError(Element* aElement, Element* aCurrentLock,
}
}
if (IsPopupOpened()) {
return "PointerLockDeniedFailedToLock";
}
return nullptr;
}
@@ -192,14 +167,6 @@ void PointerLockManager::RequestLock(Element* aElement,
/* static */
void PointerLockManager::Unlock(Document* aDoc) {
if (sLockedRemoteTarget) {
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(!sIsLocked);
Unused << sLockedRemoteTarget->SendReleasePointerLock();
sLockedRemoteTarget = nullptr;
return;
}
if (!sIsLocked) {
return;
}
@@ -344,24 +311,14 @@ bool PointerLockManager::IsInLockContext(BrowsingContext* aContext) {
}
/* static */
void PointerLockManager::SetLockedRemoteTarget(BrowserParent* aBrowserParent,
nsACString& aError) {
bool PointerLockManager::SetLockedRemoteTarget(BrowserParent* aBrowserParent) {
MOZ_ASSERT(XRE_IsParentProcess());
if (sLockedRemoteTarget) {
if (sLockedRemoteTarget != aBrowserParent) {
aError = "PointerLockDeniedInUse"_ns;
}
return;
}
// Check if any popup is open.
if (IsPopupOpened()) {
aError = "PointerLockDeniedFailedToLock"_ns;
return;
return sLockedRemoteTarget == aBrowserParent;
}
sLockedRemoteTarget = aBrowserParent;
PointerEventHandler::ReleaseAllPointerCaptureRemoteTarget();
return true;
}
/* static */

View File

@@ -47,8 +47,7 @@ class PointerLockManager final {
// Set/release pointer lock remote target. Should only be called in parent
// process.
static void SetLockedRemoteTarget(dom::BrowserParent* aBrowserParent,
nsACString& aError);
static bool SetLockedRemoteTarget(dom::BrowserParent* aBrowserParent);
static void ReleaseLockedRemoteTarget(dom::BrowserParent* aBrowserParent);
private:

View File

@@ -30,7 +30,6 @@
#include "mozilla/MouseEvents.h"
#include "mozilla/NativeKeyBindingsType.h"
#include "mozilla/NullPrincipal.h"
#include "mozilla/PointerLockManager.h"
#include "mozilla/PresShell.h"
#include "mozilla/ProcessHangMonitor.h"
#include "mozilla/ProfilerLabels.h"
@@ -3195,11 +3194,6 @@ mozilla::ipc::IPCResult BrowserChild::RecvReleaseAllPointerCapture() {
return IPC_OK();
}
mozilla::ipc::IPCResult BrowserChild::RecvReleasePointerLock() {
PointerLockManager::Unlock();
return IPC_OK();
}
PPaymentRequestChild* BrowserChild::AllocPPaymentRequestChild() {
MOZ_CRASH(
"We should never be manually allocating PPaymentRequestChild actors");

View File

@@ -673,8 +673,6 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
mozilla::ipc::IPCResult RecvReleaseAllPointerCapture();
mozilla::ipc::IPCResult RecvReleasePointerLock();
private:
void HandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers,
const ScrollableLayerGuid& aGuid,

View File

@@ -4086,14 +4086,15 @@ static BrowserParent* GetTopLevelBrowserParent(BrowserParent* aBrowserParent) {
mozilla::ipc::IPCResult BrowserParent::RecvRequestPointerLock(
RequestPointerLockResolver&& aResolve) {
if (sTopLevelWebFocus != GetTopLevelBrowserParent(this)) {
aResolve("PointerLockDeniedNotFocused"_ns);
return IPC_OK();
}
nsCString error;
PointerLockManager::SetLockedRemoteTarget(this, error);
aResolve(std::move(error));
if (sTopLevelWebFocus != GetTopLevelBrowserParent(this)) {
error = "PointerLockDeniedNotFocused";
} else if (!PointerLockManager::SetLockedRemoteTarget(this)) {
error = "PointerLockDeniedInUse";
} else {
PointerEventHandler::ReleaseAllPointerCaptureRemoteTarget();
}
aResolve(error);
return IPC_OK();
}

View File

@@ -553,23 +553,18 @@ parent:
async ImageLoadComplete(nsresult aResult);
/**
* Child informs the parent that a pointer lock has requested/released.
*/
async RequestPointerLock() returns (nsCString error);
async ReleasePointerLock();
/**
* Child informs the parent that a pointer capture has requested/released.
*/
async RequestPointerCapture(uint32_t aPointerId) returns (bool aSuccess);
async ReleasePointerCapture(uint32_t aPointerId);
/**
* Child informs the parent that a pointer lock has requested.
*/
async RequestPointerLock() returns (nsCString error);
both:
/**
* informs that a pointer lock has released.
*/
async ReleasePointerLock();
child:
async NativeSynthesisResponse(uint64_t aObserverId, nsCString aResponse);
async UpdateSHistory();

View File

@@ -8692,19 +8692,15 @@ void PresShell::EventHandler::MaybeHandleKeyboardEventBeforeDispatch(
}
}
if (XRE_IsParentProcess() &&
!mPresShell->mIsLastChromeOnlyEscapeKeyConsumed) {
if (PointerLockManager::GetLockedRemoteTarget() ||
PointerLockManager::IsLocked()) {
// XXX See above comment to understand the reason why this needs
// to claim that the Escape key event is consumed by content
// even though it will be dispatched only into chrome.
aKeyboardEvent->PreventDefaultBeforeDispatch(
CrossProcessForwarding::eStop);
aKeyboardEvent->mFlags.mOnlyChromeDispatch = true;
if (aKeyboardEvent->mMessage == eKeyUp) {
PointerLockManager::Unlock();
}
nsCOMPtr<Document> pointerLockedDoc = PointerLockManager::GetLockedDocument();
if (!mPresShell->mIsLastChromeOnlyEscapeKeyConsumed && pointerLockedDoc) {
// XXX See above comment to understand the reason why this needs
// to claim that the Escape key event is consumed by content
// even though it will be dispatched only into chrome.
aKeyboardEvent->PreventDefaultBeforeDispatch(CrossProcessForwarding::eStop);
aKeyboardEvent->mFlags.mOnlyChromeDispatch = true;
if (aKeyboardEvent->mMessage == eKeyUp) {
PointerLockManager::Unlock();
}
}
}

View File

@@ -142,7 +142,6 @@
#include "nsIScrollableFrame.h"
#include "nsIWidget.h"
#include "nsListControlFrame.h"
#include "nsMenuPopupFrame.h"
#include "nsPIDOMWindow.h"
#include "nsPlaceholderFrame.h"
#include "nsPresContext.h"
@@ -1638,10 +1637,10 @@ nsIFrame* nsLayoutUtils::GetPopupFrameForPoint(
if (!pm) {
return nullptr;
}
nsTArray<nsMenuPopupFrame*> popups;
nsTArray<nsIFrame*> popups;
pm->GetVisiblePopups(popups);
// Search from top to bottom
for (nsMenuPopupFrame* popup : popups) {
for (nsIFrame* popup : popups) {
if (popup->PresContext()->GetRootPresContext() != aRootPresContext) {
continue;
}

View File

@@ -54,7 +54,6 @@
#include "mozilla/EventStateManager.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/PointerLockManager.h"
#include "mozilla/PresShell.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPrefs_ui.h"
@@ -988,7 +987,6 @@ bool nsXULPopupManager::ShowPopupAsNativeMenu(Element* aPopup, int32_t aXPos,
EventStateManager::ClearGlobalActiveContent(activeESM);
activeESM->StopTrackingDragGesture(true);
}
PointerLockManager::Unlock();
PresShell::ReleaseCapturingContent();
return true;
@@ -1203,10 +1201,6 @@ void nsXULPopupManager::ShowPopupCallback(Element* aPopup,
// Caret visibility may have been affected, ensure that
// the caret isn't now drawn when it shouldn't be.
CheckCaretDrawingState();
if (popupType != PopupType::Tooltip) {
PointerLockManager::Unlock();
}
}
nsMenuChainItem* nsXULPopupManager::FindPopup(Element* aPopup) const {
@@ -1856,17 +1850,8 @@ nsIContent* nsXULPopupManager::GetTopActiveMenuItemContent() {
return nullptr;
}
void nsXULPopupManager::GetVisiblePopups(nsTArray<nsMenuPopupFrame*>& aPopups,
bool aIncludeNativeMenu) {
void nsXULPopupManager::GetVisiblePopups(nsTArray<nsIFrame*>& aPopups) {
aPopups.Clear();
if (aIncludeNativeMenu && mNativeMenu) {
nsCOMPtr<nsIContent> popup = mNativeMenu->Element();
nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(popup, true);
if (popupFrame && popupFrame->IsVisible() &&
!popupFrame->IsMouseTransparent()) {
aPopups.AppendElement(popupFrame);
}
}
for (nsMenuChainItem* item = mPopups.get(); item; item = item->GetParent()) {
// Skip panels which are not visible as well as popups that are transparent
// to mouse events.

View File

@@ -601,10 +601,8 @@ class nsXULPopupManager final : public nsIDOMEventListener,
/**
* Return an array of all the open and visible popup frames for
* menus, in order from top to bottom.
* XXX should we always include native menu?
*/
void GetVisiblePopups(nsTArray<nsMenuPopupFrame*>& aPopups,
bool aIncludeNativeMenu = false);
void GetVisiblePopups(nsTArray<nsIFrame*>& aPopups);
/**
* Get the node that last triggered a popup or tooltip in the document