Bug 1772634 - part 2: Make BrowserParent::RecvSynthesizeNativeTouchPoint relax in the responsive design mode r=smaug

It's used by the DevTools to emulate touch events from mouse events in the
responsive design mode.  Therefore, we should make it accept IPC messages
even if it's not in the automation mode, but it's in the responsive design mode.

Differential Revision: https://phabricator.services.mozilla.com/D148365
This commit is contained in:
Masayuki Nakano
2022-06-06 14:30:42 +00:00
parent 98b4f88856
commit 243a3b9e44
3 changed files with 17 additions and 1 deletions

View File

@@ -1080,6 +1080,10 @@ nsDOMWindowUtils::SendNativeTouchPoint(uint32_t aPointerId,
int32_t aScreenY, double aPressure,
uint32_t aOrientation,
nsIObserver* aObserver) {
// FYI: This was designed for automated tests, but currently, this is used by
// DevTools to emulate touch events from mouse events in the responsive
// design mode.
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget) {
return NS_ERROR_FAILURE;

View File

@@ -1960,7 +1960,16 @@ mozilla::ipc::IPCResult BrowserParent::RecvSynthesizeNativeTouchPoint(
const uint32_t& aPointerId, const TouchPointerState& aPointerState,
const LayoutDeviceIntPoint& aPoint, const double& aPointerPressure,
const uint32_t& aPointerOrientation, const uint64_t& aObserverId) {
NS_ENSURE_TRUE(xpc::IsInAutomation(), IPC_FAIL(this, "Unexpected event"));
// This is used by DevTools to emulate touch events from mouse events in the
// responsive design mode. Therefore, we should accept the IPC messages even
// if it's not in the automation mode but the browsing context is in RDM pane.
// And the IPC message could be just delayed after closing the responsive
// design mode. Therefore, we shouldn't return IPC_FAIL since doing it makes
// the tab crash.
if (!xpc::IsInAutomation()) {
NS_ENSURE_TRUE(mBrowsingContext, IPC_OK());
NS_ENSURE_TRUE(mBrowsingContext->Top()->GetInRDMPane(), IPC_OK());
}
AutoSynthesizedEventResponder responder(this, aObserverId, "touchpoint");
nsCOMPtr<nsIWidget> widget = GetWidget();

View File

@@ -1921,6 +1921,9 @@ void nsIWidget::OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure) {
nsresult nsIWidget::ClearNativeTouchSequence(nsIObserver* aObserver) {
AutoObserverNotifier notifier(aObserver, "cleartouch");
// XXX This is odd. This is called by the constructor of nsIWidget. However,
// at that point, nsIWidget::mLongTapTimer must be nullptr. Therefore,
// this must do nothing at initializing the instance.
if (!mLongTapTimer) {
return NS_OK;
}