Skip to content

Commit

Permalink
Fix pointer_binding_test in Firefox.
Browse files Browse the repository at this point in the history
  • Loading branch information
ditman committed Dec 6, 2022
1 parent bd133fa commit 4f2708b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/web_ui/lib/src/engine/pointer_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ class _PointerAdapter extends _BaseAdapter with _WheelEventListenerMixin {
}
}, useCapture: false, checkModifiers: false);

// TODO(dit): This must happen in the glassPane, https://github.com/flutter/flutter/issues/116561
_addPointerEventListener(domWindow, 'pointerup', (DomPointerEvent event) {
final int device = _getPointerId(event);
if (_hasSanitizer(device)) {
Expand All @@ -703,6 +704,8 @@ class _PointerAdapter extends _BaseAdapter with _WheelEventListenerMixin {
}
});

// TODO(dit): Synthesize a "cancel" event when 'pointerup' happens outside of the glassPane, https://github.com/flutter/flutter/issues/116561

// A browser fires cancel event if it concludes the pointer will no longer
// be able to generate events (example: device is deactivated)
_addPointerEventListener(glassPaneElement, 'pointercancel', (DomPointerEvent event) {
Expand Down Expand Up @@ -1039,6 +1042,7 @@ class _MouseAdapter extends _BaseAdapter with _WheelEventListenerMixin {
}
}, useCapture: false);

// TODO(dit): This must happen in the glassPane, https://github.com/flutter/flutter/issues/116561
_addMouseEventListener(domWindow, 'mouseup', (DomMouseEvent event) {
final List<ui.PointerData> pointerData = <ui.PointerData>[];
final _SanitizedDetails? sanitizedDetails = _sanitizer.sanitizeUpEvent(buttons: event.buttons?.toInt());
Expand Down
10 changes: 7 additions & 3 deletions lib/web_ui/test/engine/pointer_binding_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ typedef _ContextTestBody<T> = void Function(T);
void _testEach<T extends _BasicEventContext>(
Iterable<T> contexts,
String description,
_ContextTestBody<T> body,
_ContextTestBody<T> body, {
Object? skip,
}
) {
for (final T context in contexts) {
if (context.isSupported) {
test('${context.name} $description', () {
body(context);
});
}, skip: skip);
}
}
}
Expand Down Expand Up @@ -867,6 +869,7 @@ void testMain() {

semanticsPlaceholder.remove();
},
skip: isFirefox, // https://bugzilla.mozilla.org/show_bug.cgi?id=1804190
);

// BUTTONED ADAPTERS
Expand Down Expand Up @@ -2263,7 +2266,7 @@ void testMain() {
packets.clear();

// Release outside the glasspane.
domWindow.dispatchEvent(context.primaryUp(
glassPane.dispatchEvent(context.primaryUp(
clientX: 1000.0,
clientY: 2000.0,
));
Expand Down Expand Up @@ -3328,6 +3331,7 @@ class _PointerEventContext extends _BasicEventContext
String? pointerType,
}) {
return createDomPointerEvent('pointerup', <String, dynamic>{
'bubbles': true,
'pointerId': pointer,
'button': button,
'buttons': buttons,
Expand Down

0 comments on commit 4f2708b

Please sign in to comment.