Skip to content

Commit a19cb49

Browse files
committed
Bug 1966443: Make synthesizeMockDragAndDrop usable in plain mochitests r=edgar
Uses spawnChrome from a content process to initiate synthesizeMockDragAndDrop in the parent process. The checks in synthesizeMockDragAndDrop will not be run since communicating back to content requires SpecialPowers. So, in plain mochitests the function will only be useful for the plain test itself. (For example, tests can easily intercept expected drag/drop events and perform their own behaviors/checks there.) This patch also removes some cruft from the test framework's implementation and improves logging integration. Differential Revision: https://phabricator.services.mozilla.com/D259297
1 parent 7ca784b commit a19cb49

13 files changed

+325
-189
lines changed

dom/ipc/BrowserChild.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
#include "mozilla/layers/TouchActionHelper.h"
8181
#include "mozilla/layers/WebRenderLayerManager.h"
8282
#include "mozilla/widget/ScreenManager.h"
83+
#include "mozilla/widget/WidgetLogging.h"
8384
#include "nsCommandParams.h"
8485
#include "nsContentPermissionHelper.h"
8586
#include "nsContentUtils.h"
@@ -143,16 +144,6 @@ using namespace mozilla::layout;
143144
using namespace mozilla::widget;
144145
using mozilla::layers::GeckoContentController;
145146

146-
extern mozilla::LazyLogModule sWidgetDragServiceLog;
147-
#define __DRAGSERVICE_LOG__(logLevel, ...) \
148-
MOZ_LOG(sWidgetDragServiceLog, logLevel, __VA_ARGS__)
149-
#define DRAGSERVICE_LOGD(...) \
150-
__DRAGSERVICE_LOG__(mozilla::LogLevel::Debug, (__VA_ARGS__))
151-
#define DRAGSERVICE_LOGI(...) \
152-
__DRAGSERVICE_LOG__(mozilla::LogLevel::Info, (__VA_ARGS__))
153-
#define DRAGSERVICE_LOGE(...) \
154-
__DRAGSERVICE_LOG__(mozilla::LogLevel::Error, (__VA_ARGS__))
155-
156147
static const char BEFORE_FIRST_PAINT[] = "before-first-paint";
157148

158149
static uint32_t sConsecutiveTouchMoveCount = 0;
@@ -2135,10 +2126,11 @@ mozilla::ipc::IPCResult BrowserChild::RecvRealDragEvent(
21352126
nsCOMPtr<nsIDragSession> dragSession = GetDragSession();
21362127
DRAGSERVICE_LOGD(
21372128
"[%p] %s | aEvent.mMessage: %s | aDragAction: %u | aDropEffect: %u | "
2138-
"dragSession: %p",
2129+
"widgetRelativePt: (%d,%d) | dragSession: %p",
21392130
this, __FUNCTION__,
21402131
NS_ConvertUTF16toUTF8(dom::Event::GetEventName(aEvent.mMessage)).get(),
2141-
aDragAction, aDropEffect, dragSession.get());
2132+
aDragAction, aDropEffect, static_cast<int>(localEvent.mRefPoint.x),
2133+
static_cast<int>(localEvent.mRefPoint.y), dragSession.get());
21422134
if (dragSession) {
21432135
dragSession->SetDragAction(aDragAction);
21442136
dragSession->SetTriggeringPrincipal(aPrincipal);

testing/mochitest/tests/SimpleTest/DragParentContextBase.sys.mjs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,12 @@ export class DragParentContextBase {
1313
// Browsing context that the related element is in
1414
browsingContext = null;
1515

16-
constructor(
17-
aSubtypeName,
18-
aBrowsingContext,
19-
aParams,
20-
aSpecialPowers,
21-
aOk,
22-
aIs,
23-
aInfo
24-
) {
16+
constructor(aSubtypeName, aBrowsingContext, aParams, aSpecialPowers) {
2517
Object.assign(this, aParams);
2618
this.params = aParams;
2719
this.subtypeName = aSubtypeName;
2820
this.browsingContext = aBrowsingContext;
2921
this.specialPowers = aSpecialPowers;
30-
this.ok = aOk;
31-
this.is = aIs;
32-
this.info = aInfo;
3322
}
3423

3524
getElementPositions() {

testing/mochitest/tests/SimpleTest/DragSourceParentContext.sys.mjs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,8 @@ import { DragParentContextBase } from "./DragParentContextBase.sys.mjs";
77

88
/* global content */
99
export class DragSourceParentContext extends DragParentContextBase {
10-
constructor(aBrowsingContext, aParams, aSpecialPowers, aOk, aIs, aInfo) {
11-
super(
12-
"dragSource",
13-
aBrowsingContext,
14-
aParams,
15-
aSpecialPowers,
16-
aOk,
17-
aIs,
18-
aInfo
19-
);
10+
constructor(aBrowsingContext, aParams, aSpecialPowers) {
11+
super("dragSource", aBrowsingContext, aParams, aSpecialPowers);
2012
}
2113

2214
initialize() {

testing/mochitest/tests/SimpleTest/DragTargetParentContext.sys.mjs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,8 @@ import { DragParentContextBase } from "./DragParentContextBase.sys.mjs";
77

88
/* global content */
99
export class DragTargetParentContext extends DragParentContextBase {
10-
constructor(aBrowsingContext, aParams, aSpecialPowers, aOk, aIs, aInfo) {
11-
super(
12-
"dragTarget",
13-
aBrowsingContext,
14-
aParams,
15-
aSpecialPowers,
16-
aOk,
17-
aIs,
18-
aInfo
19-
);
10+
constructor(aBrowsingContext, aParams, aSpecialPowers) {
11+
super("dragTarget", aBrowsingContext, aParams, aSpecialPowers);
2012
}
2113

2214
initialize() {

0 commit comments

Comments
 (0)