[web] Migrate Flutter Web DOM usage to JS static interop - 43. (flutter/engine#33379)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:js/js.dart';
|
||||
@@ -98,6 +99,7 @@ extension DomDocumentExtension on DomDocument {
|
||||
external DomText createTextNode(String data);
|
||||
external DomEvent createEvent(String eventType);
|
||||
external DomElement? get activeElement;
|
||||
external DomElement? elementFromPoint(int x, int y);
|
||||
}
|
||||
|
||||
@JS()
|
||||
@@ -109,10 +111,12 @@ extension DomHTMLDocumentExtension on DomHTMLDocument {
|
||||
external DomHTMLHeadElement? get head;
|
||||
external DomHTMLBodyElement? get body;
|
||||
external set title(String? value);
|
||||
external String? get title;
|
||||
Iterable<DomElement> getElementsByTagName(String tag) =>
|
||||
createDomListWrapper<DomElement>(js_util
|
||||
.callMethod<_DomList>(this, 'getElementsByTagName', <Object>[tag]));
|
||||
external DomElement? get activeElement;
|
||||
external DomElement? getElementById(String id);
|
||||
}
|
||||
|
||||
@JS('document')
|
||||
@@ -265,6 +269,7 @@ extension DomElementExtension on DomElement {
|
||||
js_util.setProperty<num>(this, 'scrollLeft', value.round());
|
||||
external DomTokenList get classList;
|
||||
external set className(String value);
|
||||
external String get className;
|
||||
external void blur();
|
||||
List<DomNode> getElementsByTagName(String tag) =>
|
||||
js_util.callMethod<List<Object?>>(
|
||||
@@ -686,7 +691,7 @@ extension DomCanvasGradientExtension on DomCanvasGradient {
|
||||
@staticInterop
|
||||
class DomXMLHttpRequestEventTarget extends DomEventTarget {}
|
||||
|
||||
@JS('XMLHttpRequest')
|
||||
@JS()
|
||||
@staticInterop
|
||||
class DomXMLHttpRequest extends DomXMLHttpRequestEventTarget {}
|
||||
|
||||
@@ -696,18 +701,20 @@ DomXMLHttpRequest createDomXMLHttpRequest() =>
|
||||
|
||||
extension DomXMLHttpRequestExtension on DomXMLHttpRequest {
|
||||
external dynamic get response;
|
||||
external String? get responseText;
|
||||
external String get responseType;
|
||||
external int? get status;
|
||||
external set responseType(String value);
|
||||
void open(String method, String url, [bool? async]) => js_util.callMethod(
|
||||
this, 'open', <Object>[method, url, if (async != null) async]);
|
||||
external void send();
|
||||
void send([Object? bodyOrData]) => js_util
|
||||
.callMethod(this, 'send', <Object>[if (bodyOrData != null) bodyOrData]);
|
||||
}
|
||||
|
||||
Future<DomXMLHttpRequest> domHttpRequest(String url, {String? responseType}) {
|
||||
Future<DomXMLHttpRequest> domHttpRequest(String url,
|
||||
{String? responseType, String method = 'GET', dynamic sendData}) {
|
||||
final Completer<DomXMLHttpRequest> completer = Completer<DomXMLHttpRequest>();
|
||||
final DomXMLHttpRequest xhr = createDomXMLHttpRequest();
|
||||
const String method = 'GET';
|
||||
xhr.open(method, url, /* async */ true);
|
||||
if (responseType != null) {
|
||||
xhr.responseType = responseType;
|
||||
@@ -727,7 +734,7 @@ Future<DomXMLHttpRequest> domHttpRequest(String url, {String? responseType}) {
|
||||
}));
|
||||
|
||||
xhr.addEventListener('error', allowInterop(completer.completeError));
|
||||
xhr.send();
|
||||
xhr.send(sendData);
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
@@ -778,6 +785,15 @@ extension DomRectReadOnlyExtension on DomRectReadOnly {
|
||||
external num get left;
|
||||
}
|
||||
|
||||
DomRect createDomRectFromPoints(DomPoint a, DomPoint b) {
|
||||
final num left = math.min(a.x, b.x);
|
||||
final num width = math.max(a.x, b.x) - left;
|
||||
final num top = math.min(a.y, b.y);
|
||||
final num height = math.max(a.y, b.y) - top;
|
||||
return domCallConstructorString(
|
||||
'DOMRect', <Object>[left, top, width, height])! as DomRect;
|
||||
}
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class DomRect extends DomRectReadOnly {}
|
||||
@@ -836,6 +852,8 @@ extension DomHTMLTextAreaElementExtension on DomHTMLTextAreaElement {
|
||||
external set name(String value);
|
||||
external int? get selectionStart;
|
||||
external int? get selectionEnd;
|
||||
external set selectionStart(int? value);
|
||||
external set selectionEnd(int? value);
|
||||
external String? get value;
|
||||
void setSelectionRange(int start, int end, [String? direction]) =>
|
||||
js_util.callMethod(this, 'setSelectionRange',
|
||||
@@ -1098,18 +1116,27 @@ extension DomTouchExtension on DomTouch {
|
||||
DomPoint get client => DomPoint(clientX, clientY);
|
||||
}
|
||||
|
||||
DomTouch createDomTouch([Map<dynamic, dynamic>? init]) =>
|
||||
js_util.callConstructor(domGetConstructor('Touch')!,
|
||||
<Object>[if (init != null) js_util.jsify(init)]) as DomTouch;
|
||||
|
||||
DomTouchEvent createDomTouchEvent(String type, [Map<dynamic, dynamic>? init]) =>
|
||||
js_util.callConstructor(domGetConstructor('TouchEvent')!,
|
||||
<Object>[type, if (init != null) js_util.jsify(init)]);
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class DomCompositionEvent {}
|
||||
class DomCompositionEvent extends DomUIEvent {}
|
||||
|
||||
extension DomCompositionEventExtension on DomCompositionEvent {
|
||||
external String? get data;
|
||||
}
|
||||
|
||||
DomCompositionEvent createDomCompositionEvent(String type, [Map<dynamic,
|
||||
dynamic>? options]) =>
|
||||
js_util.callConstructor(domGetConstructor('CompositionEvent')!,
|
||||
<Object>[type, if (options != null) js_util.jsify(options)]);
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class DomHTMLInputElement extends DomHTMLElement {}
|
||||
@@ -1127,6 +1154,8 @@ extension DomHTMLInputElementExtension on DomHTMLInputElement {
|
||||
external set autocomplete(String value);
|
||||
external int? get selectionStart;
|
||||
external int? get selectionEnd;
|
||||
external set selectionStart(int? value);
|
||||
external set selectionEnd(int? value);
|
||||
void setSelectionRange(int start, int end, [String? direction]) =>
|
||||
js_util.callMethod(this, 'setSelectionRange',
|
||||
<Object>[start, end, if (direction != null) direction]);
|
||||
@@ -1225,6 +1254,7 @@ extension DomShadowRootExtension on DomShadowRoot {
|
||||
external DomElement? get host;
|
||||
external String? get mode;
|
||||
external bool? get delegatesFocus;
|
||||
external DomElement? elementFromPoint(int x, int y);
|
||||
}
|
||||
|
||||
@JS()
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:html' as html;
|
||||
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -27,8 +26,8 @@ class _MockWithCompositionAwareMixin with CompositionAwareMixin {
|
||||
static const String _kCompositionEnd = 'compositionend';
|
||||
}
|
||||
|
||||
html.InputElement get _inputElement {
|
||||
return defaultTextEditingRoot.querySelectorAll('input').first as html.InputElement;
|
||||
DomHTMLInputElement get _inputElement {
|
||||
return defaultTextEditingRoot.querySelectorAll('input').first as DomHTMLInputElement;
|
||||
}
|
||||
|
||||
GloballyPositionedTextEditingStrategy _enableEditingStrategy({
|
||||
@@ -69,10 +68,9 @@ Future<void> testMain() async {
|
||||
final _MockWithCompositionAwareMixin mockWithCompositionAwareMixin =
|
||||
_MockWithCompositionAwareMixin();
|
||||
mockWithCompositionAwareMixin.composingText = fakeComposingText;
|
||||
mockWithCompositionAwareMixin.addCompositionEventHandlers(_inputElement
|
||||
as DomHTMLElement);
|
||||
mockWithCompositionAwareMixin.addCompositionEventHandlers(_inputElement);
|
||||
|
||||
_inputElement.dispatchEvent(html.Event(_MockWithCompositionAwareMixin._kCompositionEnd));
|
||||
_inputElement.dispatchEvent(createDomEvent('Event', _MockWithCompositionAwareMixin._kCompositionEnd));
|
||||
|
||||
expect(mockWithCompositionAwareMixin.composingText, null);
|
||||
});
|
||||
@@ -83,10 +81,9 @@ Future<void> testMain() async {
|
||||
final _MockWithCompositionAwareMixin mockWithCompositionAwareMixin =
|
||||
_MockWithCompositionAwareMixin();
|
||||
mockWithCompositionAwareMixin.composingText = fakeComposingText;
|
||||
mockWithCompositionAwareMixin.addCompositionEventHandlers(_inputElement
|
||||
as DomHTMLElement);
|
||||
mockWithCompositionAwareMixin.addCompositionEventHandlers(_inputElement);
|
||||
|
||||
_inputElement.dispatchEvent(html.Event(_MockWithCompositionAwareMixin._kCompositionStart));
|
||||
_inputElement.dispatchEvent(createDomEvent('Event', _MockWithCompositionAwareMixin._kCompositionStart));
|
||||
|
||||
expect(mockWithCompositionAwareMixin.composingText, null);
|
||||
});
|
||||
@@ -98,12 +95,11 @@ Future<void> testMain() async {
|
||||
final _MockWithCompositionAwareMixin mockWithCompositionAwareMixin =
|
||||
_MockWithCompositionAwareMixin();
|
||||
mockWithCompositionAwareMixin.composingText = fakeComposingText;
|
||||
mockWithCompositionAwareMixin.addCompositionEventHandlers(_inputElement
|
||||
as DomHTMLElement);
|
||||
mockWithCompositionAwareMixin.addCompositionEventHandlers(_inputElement);
|
||||
|
||||
_inputElement.dispatchEvent(html.CompositionEvent(
|
||||
_inputElement.dispatchEvent(createDomCompositionEvent(
|
||||
_MockWithCompositionAwareMixin._kCompositionUpdate,
|
||||
data: fakeEventText
|
||||
<Object?, Object?>{ 'data': fakeEventText }
|
||||
));
|
||||
|
||||
expect(mockWithCompositionAwareMixin.composingText, fakeEventText);
|
||||
@@ -150,11 +146,13 @@ Future<void> testMain() async {
|
||||
test('should be [0, compostionStrLength] on new composition', () {
|
||||
const String composingText = 'hi';
|
||||
|
||||
_inputElement.dispatchEvent(html.CompositionEvent(_MockWithCompositionAwareMixin._kCompositionUpdate, data: composingText));
|
||||
_inputElement.dispatchEvent(createDomCompositionEvent(
|
||||
_MockWithCompositionAwareMixin._kCompositionUpdate,
|
||||
<Object?, Object?>{'data': composingText}));
|
||||
|
||||
// Set the selection text.
|
||||
_inputElement.value = composingText;
|
||||
_inputElement.dispatchEvent(html.Event.eventType('Event', 'input'));
|
||||
_inputElement.dispatchEvent(createDomEvent('Event', 'input'));
|
||||
|
||||
expect(
|
||||
editingStrategy.lastEditingState,
|
||||
@@ -176,13 +174,13 @@ Future<void> testMain() async {
|
||||
_inputElement.value = '$beforeComposingText$afterComposingText';
|
||||
_inputElement.setSelectionRange(beforeComposingText.length, beforeComposingText.length);
|
||||
|
||||
_inputElement.dispatchEvent(html.CompositionEvent(
|
||||
_inputElement.dispatchEvent(createDomCompositionEvent(
|
||||
_MockWithCompositionAwareMixin._kCompositionUpdate,
|
||||
data: composingText
|
||||
<Object?, Object?>{ 'data': composingText }
|
||||
));
|
||||
|
||||
// Flush editing state (since we did not compositionend).
|
||||
_inputElement.dispatchEvent(html.Event.eventType('Event', 'input'));
|
||||
_inputElement.dispatchEvent(createDomEvent('Event', 'input'));
|
||||
|
||||
expect(
|
||||
editingStrategy.lastEditingState,
|
||||
@@ -224,9 +222,9 @@ Future<void> testMain() async {
|
||||
));
|
||||
|
||||
|
||||
_inputElement.dispatchEvent(html.CompositionEvent(
|
||||
_inputElement.dispatchEvent(createDomCompositionEvent(
|
||||
_MockWithCompositionAwareMixin._kCompositionUpdate,
|
||||
data: newComposingText));
|
||||
<Object?, Object?>{ 'data': newComposingText }));
|
||||
|
||||
await containExpect;
|
||||
});
|
||||
@@ -248,9 +246,9 @@ Future<void> testMain() async {
|
||||
.having((TextEditingDeltaState deltaState) => deltaState.composingExtent, 'composingExtent', currCharIndex + 1)
|
||||
));
|
||||
|
||||
_inputElement.dispatchEvent(html.CompositionEvent(
|
||||
_inputElement.dispatchEvent(createDomCompositionEvent(
|
||||
_MockWithCompositionAwareMixin._kCompositionUpdate,
|
||||
data: currComposingSubstr));
|
||||
<Object?, Object?>{ 'data': currComposingSubstr }));
|
||||
|
||||
await containExpect;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:html' as html;
|
||||
import 'dart:js_util' as js_util;
|
||||
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
@@ -46,8 +45,7 @@ void main() {
|
||||
|
||||
void testMain() {
|
||||
ensureFlutterViewEmbedderInitialized();
|
||||
final html.Element glassPane = flutterViewEmbedder.glassPaneElement! as
|
||||
html.Element;
|
||||
final DomElement glassPane = flutterViewEmbedder.glassPaneElement!;
|
||||
double dpi = 1.0;
|
||||
|
||||
setUp(() {
|
||||
@@ -69,18 +67,18 @@ void testMain() {
|
||||
return;
|
||||
}
|
||||
|
||||
html.PointerEvent expectCorrectType(html.Event e) {
|
||||
expect(e.runtimeType, equals(html.PointerEvent));
|
||||
return e as html.PointerEvent;
|
||||
DomPointerEvent expectCorrectType(DomEvent e) {
|
||||
expect(domInstanceOfString(e, 'PointerEvent'), isTrue);
|
||||
return e as DomPointerEvent;
|
||||
}
|
||||
|
||||
List<html.PointerEvent> expectCorrectTypes(List<html.Event> events) {
|
||||
List<DomPointerEvent> expectCorrectTypes(List<DomEvent> events) {
|
||||
return events.map(expectCorrectType).toList();
|
||||
}
|
||||
|
||||
final _PointerEventContext context = _PointerEventContext();
|
||||
html.PointerEvent event;
|
||||
List<html.PointerEvent> events;
|
||||
DomPointerEvent event;
|
||||
List<DomPointerEvent> events;
|
||||
|
||||
event = expectCorrectType(context.primaryDown(clientX: 100, clientY: 101));
|
||||
expect(event.type, equals('pointerdown'));
|
||||
@@ -245,18 +243,18 @@ void testMain() {
|
||||
return;
|
||||
}
|
||||
|
||||
html.TouchEvent expectCorrectType(html.Event e) {
|
||||
expect(e.runtimeType, equals(html.TouchEvent));
|
||||
return e as html.TouchEvent;
|
||||
DomTouchEvent expectCorrectType(DomEvent e) {
|
||||
expect(domInstanceOfString(e, 'TouchEvent'), isTrue);
|
||||
return e as DomTouchEvent;
|
||||
}
|
||||
|
||||
List<html.TouchEvent> expectCorrectTypes(List<html.Event> events) {
|
||||
List<DomTouchEvent> expectCorrectTypes(List<DomEvent> events) {
|
||||
return events.map(expectCorrectType).toList();
|
||||
}
|
||||
|
||||
final _TouchEventContext context = _TouchEventContext();
|
||||
html.TouchEvent event;
|
||||
List<html.TouchEvent> events;
|
||||
DomTouchEvent event;
|
||||
List<DomTouchEvent> events;
|
||||
|
||||
event = expectCorrectType(context.primaryDown(clientX: 100, clientY: 101));
|
||||
expect(event.type, equals('touchstart'));
|
||||
@@ -341,13 +339,13 @@ void testMain() {
|
||||
return;
|
||||
}
|
||||
|
||||
html.MouseEvent expectCorrectType(html.Event e) {
|
||||
expect(e.runtimeType, equals(html.MouseEvent));
|
||||
return e as html.MouseEvent;
|
||||
DomMouseEvent expectCorrectType(DomEvent e) {
|
||||
expect(domInstanceOfString(e, 'MouseEvent'), isTrue);
|
||||
return e as DomMouseEvent;
|
||||
}
|
||||
|
||||
final _MouseEventContext context = _MouseEventContext();
|
||||
html.MouseEvent event;
|
||||
DomMouseEvent event;
|
||||
|
||||
event = expectCorrectType(context.primaryDown(clientX: 100, clientY: 101));
|
||||
expect(event.type, equals('mousedown'));
|
||||
@@ -485,8 +483,8 @@ void testMain() {
|
||||
packets.add(packet);
|
||||
};
|
||||
|
||||
final html.Element semanticsPlaceholder =
|
||||
html.Element.tag('flt-semantics-placeholder');
|
||||
final DomElement semanticsPlaceholder =
|
||||
createDomElement('flt-semantics-placeholder');
|
||||
glassPane.append(semanticsPlaceholder);
|
||||
|
||||
// Press on the semantics placeholder.
|
||||
@@ -526,7 +524,7 @@ void testMain() {
|
||||
packets.clear();
|
||||
|
||||
// Release the pointer on the semantics placeholder.
|
||||
html.window.dispatchEvent(context.primaryUp(
|
||||
domWindow.dispatchEvent(context.primaryUp(
|
||||
clientX: 100.0,
|
||||
clientY: 200.0,
|
||||
));
|
||||
@@ -1828,7 +1826,7 @@ void testMain() {
|
||||
packets.clear();
|
||||
|
||||
// Move outside the glasspane.
|
||||
html.window.dispatchEvent(context.primaryMove(
|
||||
domWindow.dispatchEvent(context.primaryMove(
|
||||
clientX: 900.0,
|
||||
clientY: 1900.0,
|
||||
));
|
||||
@@ -1840,7 +1838,7 @@ void testMain() {
|
||||
packets.clear();
|
||||
|
||||
// Release outside the glasspane.
|
||||
html.window.dispatchEvent(context.primaryUp(
|
||||
domWindow.dispatchEvent(context.primaryUp(
|
||||
clientX: 1000.0,
|
||||
clientY: 2000.0,
|
||||
));
|
||||
@@ -2306,44 +2304,43 @@ abstract class _BasicEventContext implements PointerSupportDetector {
|
||||
//
|
||||
// * For mouse, a left click
|
||||
// * For touch, a touch down
|
||||
html.Event primaryDown({double clientX, double clientY});
|
||||
DomEvent primaryDown({double clientX, double clientY});
|
||||
|
||||
// Generate an event that is:
|
||||
//
|
||||
// * For mouse, a drag with LMB down
|
||||
// * For touch, a touch drag
|
||||
html.Event primaryMove({double clientX, double clientY});
|
||||
DomEvent primaryMove({double clientX, double clientY});
|
||||
|
||||
// Generate an event that is:
|
||||
//
|
||||
// * For mouse, release LMB
|
||||
// * For touch, a touch up
|
||||
html.Event primaryUp({double clientX, double clientY});
|
||||
DomEvent primaryUp({double clientX, double clientY});
|
||||
}
|
||||
|
||||
mixin _ButtonedEventMixin on _BasicEventContext {
|
||||
// Generate an event that is a mouse down with the specific buttons.
|
||||
html.Event mouseDown(
|
||||
DomEvent mouseDown(
|
||||
{double? clientX, double? clientY, int? button, int? buttons});
|
||||
|
||||
// Generate an event that is a mouse drag with the specific buttons, or button
|
||||
// changes during the drag.
|
||||
//
|
||||
// If there is no button change, assign `button` with _kNoButtonChange.
|
||||
html.Event mouseMove(
|
||||
DomEvent mouseMove(
|
||||
{double? clientX,
|
||||
double? clientY,
|
||||
required int button,
|
||||
required int buttons});
|
||||
|
||||
// Generate an event that moves the mouse outside of the tracked area.
|
||||
html.Event mouseLeave({double? clientX, double? clientY, required int buttons});
|
||||
DomEvent mouseLeave({double? clientX, double? clientY, required int buttons});
|
||||
|
||||
// Generate an event that releases all mouse buttons.
|
||||
html.Event mouseUp(
|
||||
{double? clientX, double? clientY, int? button, int? buttons});
|
||||
DomEvent mouseUp({double? clientX, double? clientY, int? button, int? buttons});
|
||||
|
||||
html.Event hover({double? clientX, double? clientY}) {
|
||||
DomEvent hover({double? clientX, double? clientY}) {
|
||||
return mouseMove(
|
||||
buttons: 0,
|
||||
button: _kNoButtonChange,
|
||||
@@ -2353,7 +2350,7 @@ mixin _ButtonedEventMixin on _BasicEventContext {
|
||||
}
|
||||
|
||||
@override
|
||||
html.Event primaryDown({double? clientX, double? clientY}) {
|
||||
DomEvent primaryDown({double? clientX, double? clientY}) {
|
||||
return mouseDown(
|
||||
buttons: 1,
|
||||
button: 0,
|
||||
@@ -2363,7 +2360,7 @@ mixin _ButtonedEventMixin on _BasicEventContext {
|
||||
}
|
||||
|
||||
@override
|
||||
html.Event primaryMove({double? clientX, double? clientY}) {
|
||||
DomEvent primaryMove({double? clientX, double? clientY}) {
|
||||
return mouseMove(
|
||||
buttons: 1,
|
||||
button: _kNoButtonChange,
|
||||
@@ -2373,7 +2370,7 @@ mixin _ButtonedEventMixin on _BasicEventContext {
|
||||
}
|
||||
|
||||
@override
|
||||
html.Event primaryUp({double? clientX, double? clientY}) {
|
||||
DomEvent primaryUp({double? clientX, double? clientY}) {
|
||||
return mouseUp(
|
||||
button: 0,
|
||||
clientX: clientX,
|
||||
@@ -2381,15 +2378,14 @@ mixin _ButtonedEventMixin on _BasicEventContext {
|
||||
);
|
||||
}
|
||||
|
||||
html.Event wheel({
|
||||
DomEvent wheel({
|
||||
required int? buttons,
|
||||
required double? clientX,
|
||||
required double? clientY,
|
||||
required double? deltaX,
|
||||
required double? deltaY,
|
||||
}) {
|
||||
final Function jsWheelEvent =
|
||||
js_util.getProperty<Function>(html.window, 'WheelEvent');
|
||||
final Function jsWheelEvent = js_util.getProperty<Function>(domWindow, 'WheelEvent');
|
||||
final List<dynamic> eventArgs = <dynamic>[
|
||||
'wheel',
|
||||
<String, dynamic>{
|
||||
@@ -2400,7 +2396,7 @@ mixin _ButtonedEventMixin on _BasicEventContext {
|
||||
'deltaY': deltaY,
|
||||
}
|
||||
];
|
||||
return js_util.callConstructor<html.Event>(
|
||||
return js_util.callConstructor<DomEvent>(
|
||||
jsWheelEvent,
|
||||
js_util.jsify(eventArgs) as List<Object?>,
|
||||
);
|
||||
@@ -2416,13 +2412,13 @@ class _TouchDetails {
|
||||
}
|
||||
|
||||
mixin _MultiPointerEventMixin on _BasicEventContext {
|
||||
List<html.Event> multiTouchDown(List<_TouchDetails> touches);
|
||||
List<html.Event> multiTouchMove(List<_TouchDetails> touches);
|
||||
List<html.Event> multiTouchUp(List<_TouchDetails> touches);
|
||||
List<html.Event> multiTouchCancel(List<_TouchDetails> touches);
|
||||
List<DomEvent> multiTouchDown(List<_TouchDetails> touches);
|
||||
List<DomEvent> multiTouchMove(List<_TouchDetails> touches);
|
||||
List<DomEvent> multiTouchUp(List<_TouchDetails> touches);
|
||||
List<DomEvent> multiTouchCancel(List<_TouchDetails> touches);
|
||||
|
||||
@override
|
||||
html.Event primaryDown({double? clientX, double? clientY}) {
|
||||
DomEvent primaryDown({double? clientX, double? clientY}) {
|
||||
return multiTouchDown(<_TouchDetails>[
|
||||
_TouchDetails(
|
||||
pointer: 1,
|
||||
@@ -2433,7 +2429,7 @@ mixin _MultiPointerEventMixin on _BasicEventContext {
|
||||
}
|
||||
|
||||
@override
|
||||
html.Event primaryMove({double? clientX, double? clientY}) {
|
||||
DomEvent primaryMove({double? clientX, double? clientY}) {
|
||||
return multiTouchMove(<_TouchDetails>[
|
||||
_TouchDetails(
|
||||
pointer: 1,
|
||||
@@ -2444,7 +2440,7 @@ mixin _MultiPointerEventMixin on _BasicEventContext {
|
||||
}
|
||||
|
||||
@override
|
||||
html.Event primaryUp({double? clientX, double? clientY}) {
|
||||
DomEvent primaryUp({double? clientX, double? clientY}) {
|
||||
return multiTouchUp(<_TouchDetails>[
|
||||
_TouchDetails(
|
||||
pointer: 1,
|
||||
@@ -2460,7 +2456,7 @@ mixin _MultiPointerEventMixin on _BasicEventContext {
|
||||
class _TouchEventContext extends _BasicEventContext
|
||||
with _MultiPointerEventMixin
|
||||
implements PointerSupportDetector {
|
||||
_TouchEventContext() : _target = html.document.createElement('div');
|
||||
_TouchEventContext() : _target = domDocument.createElement('div');
|
||||
|
||||
@override
|
||||
String get name => 'TouchAdapter';
|
||||
@@ -2477,14 +2473,14 @@ class _TouchEventContext extends _BasicEventContext
|
||||
@override
|
||||
bool get hasMouseEvents => false;
|
||||
|
||||
html.EventTarget _target;
|
||||
DomEventTarget _target;
|
||||
|
||||
html.Touch _createTouch({
|
||||
DomTouch _createTouch({
|
||||
int? identifier,
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
}) {
|
||||
return html.Touch(<String, dynamic>{
|
||||
return createDomTouch(<String, dynamic>{
|
||||
'identifier': identifier,
|
||||
'clientX': clientX,
|
||||
'clientY': clientY,
|
||||
@@ -2492,9 +2488,9 @@ class _TouchEventContext extends _BasicEventContext
|
||||
});
|
||||
}
|
||||
|
||||
html.TouchEvent _createTouchEvent(
|
||||
DomTouchEvent _createTouchEvent(
|
||||
String eventType, List<_TouchDetails> touches) {
|
||||
return html.TouchEvent(
|
||||
return createDomTouchEvent(
|
||||
eventType,
|
||||
<String, dynamic>{
|
||||
'changedTouches': touches
|
||||
@@ -2511,23 +2507,23 @@ class _TouchEventContext extends _BasicEventContext
|
||||
}
|
||||
|
||||
@override
|
||||
List<html.Event> multiTouchDown(List<_TouchDetails> touches) {
|
||||
return <html.Event>[_createTouchEvent('touchstart', touches)];
|
||||
List<DomEvent> multiTouchDown(List<_TouchDetails> touches) {
|
||||
return <DomEvent>[_createTouchEvent('touchstart', touches)];
|
||||
}
|
||||
|
||||
@override
|
||||
List<html.Event> multiTouchMove(List<_TouchDetails> touches) {
|
||||
return <html.Event>[_createTouchEvent('touchmove', touches)];
|
||||
List<DomEvent> multiTouchMove(List<_TouchDetails> touches) {
|
||||
return <DomEvent>[_createTouchEvent('touchmove', touches)];
|
||||
}
|
||||
|
||||
@override
|
||||
List<html.Event> multiTouchUp(List<_TouchDetails> touches) {
|
||||
return <html.Event>[_createTouchEvent('touchend', touches)];
|
||||
List<DomEvent> multiTouchUp(List<_TouchDetails> touches) {
|
||||
return <DomEvent>[_createTouchEvent('touchend', touches)];
|
||||
}
|
||||
|
||||
@override
|
||||
List<html.Event> multiTouchCancel(List<_TouchDetails> touches) {
|
||||
return <html.Event>[_createTouchEvent('touchcancel', touches)];
|
||||
List<DomEvent> multiTouchCancel(List<_TouchDetails> touches) {
|
||||
return <DomEvent>[_createTouchEvent('touchcancel', touches)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2554,7 +2550,7 @@ class _MouseEventContext extends _BasicEventContext
|
||||
bool get hasMouseEvents => true;
|
||||
|
||||
@override
|
||||
html.Event mouseDown({
|
||||
DomEvent mouseDown({
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
int? button,
|
||||
@@ -2570,7 +2566,7 @@ class _MouseEventContext extends _BasicEventContext
|
||||
}
|
||||
|
||||
@override
|
||||
html.Event mouseMove({
|
||||
DomEvent mouseMove({
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
required int button,
|
||||
@@ -2595,7 +2591,7 @@ class _MouseEventContext extends _BasicEventContext
|
||||
}
|
||||
|
||||
@override
|
||||
html.Event mouseLeave({
|
||||
DomEvent mouseLeave({
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
required int buttons,
|
||||
@@ -2610,7 +2606,7 @@ class _MouseEventContext extends _BasicEventContext
|
||||
}
|
||||
|
||||
@override
|
||||
html.Event mouseUp({
|
||||
DomEvent mouseUp({
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
int? button,
|
||||
@@ -2625,7 +2621,7 @@ class _MouseEventContext extends _BasicEventContext
|
||||
);
|
||||
}
|
||||
|
||||
html.MouseEvent _createMouseEvent(
|
||||
DomMouseEvent _createMouseEvent(
|
||||
String type, {
|
||||
int? buttons,
|
||||
int? button,
|
||||
@@ -2633,7 +2629,7 @@ class _MouseEventContext extends _BasicEventContext
|
||||
double? clientY,
|
||||
}) {
|
||||
final Function jsMouseEvent =
|
||||
js_util.getProperty<Function>(html.window, 'MouseEvent');
|
||||
js_util.getProperty<Function>(domWindow, 'MouseEvent');
|
||||
final List<dynamic> eventArgs = <dynamic>[
|
||||
type,
|
||||
<String, dynamic>{
|
||||
@@ -2643,7 +2639,7 @@ class _MouseEventContext extends _BasicEventContext
|
||||
'clientY': clientY,
|
||||
}
|
||||
];
|
||||
return js_util.callConstructor<html.MouseEvent>(
|
||||
return js_util.callConstructor<DomMouseEvent>(
|
||||
jsMouseEvent,
|
||||
js_util.jsify(eventArgs) as List<Object?>,
|
||||
);
|
||||
@@ -2673,7 +2669,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
bool get hasMouseEvents => false;
|
||||
|
||||
@override
|
||||
List<html.Event> multiTouchDown(List<_TouchDetails> touches) {
|
||||
List<DomEvent> multiTouchDown(List<_TouchDetails> touches) {
|
||||
return touches
|
||||
.map((_TouchDetails details) => _downWithFullDetails(
|
||||
pointer: details.pointer,
|
||||
@@ -2687,7 +2683,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
}
|
||||
|
||||
@override
|
||||
html.Event mouseDown({
|
||||
DomEvent mouseDown({
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
int? button,
|
||||
@@ -2704,7 +2700,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
);
|
||||
}
|
||||
|
||||
html.Event _downWithFullDetails({
|
||||
DomEvent _downWithFullDetails({
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
int? button,
|
||||
@@ -2712,7 +2708,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
int? pointer,
|
||||
String? pointerType,
|
||||
}) {
|
||||
return html.PointerEvent('pointerdown', <String, dynamic>{
|
||||
return createDomPointerEvent('pointerdown', <String, dynamic>{
|
||||
'pointerId': pointer,
|
||||
'button': button,
|
||||
'buttons': buttons,
|
||||
@@ -2723,7 +2719,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
}
|
||||
|
||||
@override
|
||||
List<html.Event> multiTouchMove(List<_TouchDetails> touches) {
|
||||
List<DomEvent> multiTouchMove(List<_TouchDetails> touches) {
|
||||
return touches
|
||||
.map((_TouchDetails details) => _moveWithFullDetails(
|
||||
pointer: details.pointer,
|
||||
@@ -2737,7 +2733,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
}
|
||||
|
||||
@override
|
||||
html.Event mouseMove({
|
||||
DomEvent mouseMove({
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
required int button,
|
||||
@@ -2754,7 +2750,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
);
|
||||
}
|
||||
|
||||
html.Event _moveWithFullDetails({
|
||||
DomEvent _moveWithFullDetails({
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
int? button,
|
||||
@@ -2762,7 +2758,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
int? pointer,
|
||||
String? pointerType,
|
||||
}) {
|
||||
return html.PointerEvent('pointermove', <String, dynamic>{
|
||||
return createDomPointerEvent('pointermove', <String, dynamic>{
|
||||
'pointerId': pointer,
|
||||
'button': button,
|
||||
'buttons': buttons,
|
||||
@@ -2773,7 +2769,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
}
|
||||
|
||||
@override
|
||||
html.Event mouseLeave({
|
||||
DomEvent mouseLeave({
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
required int buttons,
|
||||
@@ -2789,7 +2785,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
);
|
||||
}
|
||||
|
||||
html.Event _leaveWithFullDetails({
|
||||
DomEvent _leaveWithFullDetails({
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
int? button,
|
||||
@@ -2797,7 +2793,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
int? pointer,
|
||||
String? pointerType,
|
||||
}) {
|
||||
return html.PointerEvent('pointerleave', <String, dynamic>{
|
||||
return createDomPointerEvent('pointerleave', <String, dynamic>{
|
||||
'pointerId': pointer,
|
||||
'button': button,
|
||||
'buttons': buttons,
|
||||
@@ -2808,7 +2804,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
}
|
||||
|
||||
@override
|
||||
List<html.Event> multiTouchUp(List<_TouchDetails> touches) {
|
||||
List<DomEvent> multiTouchUp(List<_TouchDetails> touches) {
|
||||
return touches
|
||||
.map((_TouchDetails details) => _upWithFullDetails(
|
||||
pointer: details.pointer,
|
||||
@@ -2821,7 +2817,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
}
|
||||
|
||||
@override
|
||||
html.Event mouseUp({
|
||||
DomEvent mouseUp({
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
int? button,
|
||||
@@ -2838,7 +2834,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
);
|
||||
}
|
||||
|
||||
html.Event _upWithFullDetails({
|
||||
DomEvent _upWithFullDetails({
|
||||
double? clientX,
|
||||
double? clientY,
|
||||
int? button,
|
||||
@@ -2846,7 +2842,7 @@ class _PointerEventContext extends _BasicEventContext
|
||||
int? pointer,
|
||||
String? pointerType,
|
||||
}) {
|
||||
return html.PointerEvent('pointerup', <String, dynamic>{
|
||||
return createDomPointerEvent('pointerup', <String, dynamic>{
|
||||
'pointerId': pointer,
|
||||
'button': button,
|
||||
'buttons': buttons,
|
||||
@@ -2857,10 +2853,10 @@ class _PointerEventContext extends _BasicEventContext
|
||||
}
|
||||
|
||||
@override
|
||||
List<html.Event> multiTouchCancel(List<_TouchDetails> touches) {
|
||||
List<DomEvent> multiTouchCancel(List<_TouchDetails> touches) {
|
||||
return touches
|
||||
.map((_TouchDetails details) =>
|
||||
html.PointerEvent('pointercancel', <String, dynamic>{
|
||||
createDomPointerEvent('pointercancel', <String, dynamic>{
|
||||
'pointerId': details.pointer,
|
||||
'button': 0,
|
||||
'buttons': 0,
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async' show Future;
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine/dom.dart';
|
||||
import 'package:ui/src/engine/semantics.dart';
|
||||
import 'package:ui/src/engine/services.dart';
|
||||
|
||||
@@ -36,16 +36,16 @@ void testMain() {
|
||||
const Duration(milliseconds: 500);
|
||||
|
||||
// Initially there is no accessibility-element
|
||||
expect(document.getElementById('accessibility-element'), isNull);
|
||||
expect(domDocument.getElementById('accessibility-element'), isNull);
|
||||
|
||||
accessibilityAnnouncements.handleMessage(codec,
|
||||
codec.encodeMessage(testInput));
|
||||
expect(
|
||||
document.getElementById('accessibility-element'),
|
||||
domDocument.getElementById('accessibility-element'),
|
||||
isNotNull,
|
||||
);
|
||||
final LabelElement input =
|
||||
document.getElementById('accessibility-element')! as LabelElement;
|
||||
final DomHTMLLabelElement input =
|
||||
domDocument.getElementById('accessibility-element')! as DomHTMLLabelElement;
|
||||
expect(input.getAttribute('aria-live'), equals('polite'));
|
||||
expect(input.text, testMessage);
|
||||
|
||||
@@ -53,7 +53,7 @@ void testMain() {
|
||||
Future<void>.delayed(
|
||||
accessibilityAnnouncements.durationA11yMessageIsOnDom,
|
||||
() =>
|
||||
expect(document.getElementById('accessibility-element'), isNull));
|
||||
expect(domDocument.getElementById('accessibility-element'), isNull));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
@TestOn('chrome || safari || firefox')
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:html' as html;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:quiver/testing/async.dart';
|
||||
@@ -96,16 +95,17 @@ void _testEngineSemanticsOwner() {
|
||||
expect(semantics().semanticsEnabled, isFalse);
|
||||
|
||||
// Synthesize a click on the placeholder.
|
||||
final html.Element placeholder =
|
||||
appHostNode.querySelector('flt-semantics-placeholder')! as html.Element;
|
||||
final DomElement placeholder =
|
||||
appHostNode.querySelector('flt-semantics-placeholder')!;
|
||||
|
||||
expect(placeholder.isConnected, isTrue);
|
||||
|
||||
final html.Rectangle<num> rect = placeholder.getBoundingClientRect();
|
||||
placeholder.dispatchEvent(html.MouseEvent(
|
||||
'click',
|
||||
clientX: (rect.left + (rect.right - rect.left) / 2).floor(),
|
||||
clientY: (rect.top + (rect.bottom - rect.top) / 2).floor(),
|
||||
final DomRect rect = placeholder.getBoundingClientRect();
|
||||
placeholder.dispatchEvent(createDomMouseEvent(
|
||||
'click', <Object?, Object?>{
|
||||
'clientX': (rect.left + (rect.right - rect.left) / 2).floor(),
|
||||
'clientY': (rect.top + (rect.bottom - rect.top) / 2).floor(),
|
||||
}
|
||||
));
|
||||
|
||||
// On mobile semantics is enabled asynchronously.
|
||||
@@ -192,8 +192,8 @@ void _testEngineSemanticsOwner() {
|
||||
.instance.configuration.accessibilityFeatures.accessibleNavigation,
|
||||
isFalse);
|
||||
|
||||
final html.Element placeholder =
|
||||
appHostNode.querySelector('flt-semantics-placeholder')! as html.Element;
|
||||
final DomElement placeholder =
|
||||
appHostNode.querySelector('flt-semantics-placeholder')!;
|
||||
|
||||
expect(placeholder.isConnected, isTrue);
|
||||
|
||||
@@ -521,10 +521,10 @@ void _testContainer() {
|
||||
</sem-c>
|
||||
</sem>''');
|
||||
|
||||
final html.Element parentElement =
|
||||
appHostNode.querySelector('flt-semantics')! as html.Element;
|
||||
final html.Element container =
|
||||
appHostNode.querySelector('flt-semantics-container')! as html.Element;
|
||||
final DomElement parentElement =
|
||||
appHostNode.querySelector('flt-semantics')!;
|
||||
final DomElement container =
|
||||
appHostNode.querySelector('flt-semantics-container')!;
|
||||
|
||||
if (isMacOrIOS) {
|
||||
expect(parentElement.style.top, '0px');
|
||||
@@ -575,10 +575,10 @@ void _testContainer() {
|
||||
</sem-c>
|
||||
</sem>''');
|
||||
|
||||
final html.Element parentElement =
|
||||
appHostNode.querySelector('flt-semantics')! as html.Element;
|
||||
final html.Element container =
|
||||
appHostNode.querySelector('flt-semantics-container')! as html.Element;
|
||||
final DomElement parentElement =
|
||||
appHostNode.querySelector('flt-semantics')!;
|
||||
final DomElement container =
|
||||
appHostNode.querySelector('flt-semantics-container')!;
|
||||
|
||||
expect(parentElement.style.transform, 'matrix(1, 0, 0, 1, 10, 10)');
|
||||
expect(parentElement.style.transformOrigin, '0px 0px 0px');
|
||||
@@ -618,10 +618,10 @@ void _testContainer() {
|
||||
</sem-c>
|
||||
</sem>''');
|
||||
|
||||
final html.Element parentElement =
|
||||
appHostNode.querySelector('flt-semantics')! as html.Element;
|
||||
final html.Element container =
|
||||
appHostNode.querySelector('flt-semantics-container')! as html.Element;
|
||||
final DomElement parentElement =
|
||||
appHostNode.querySelector('flt-semantics')!;
|
||||
final DomElement container =
|
||||
appHostNode.querySelector('flt-semantics-container')!;
|
||||
|
||||
if (isMacOrIOS) {
|
||||
expect(parentElement.style.top, '0px');
|
||||
@@ -826,7 +826,7 @@ void _testVerticalScrolling() {
|
||||
</sem-c>
|
||||
</sem>''');
|
||||
|
||||
final html.Element? scrollable = findScrollable();
|
||||
final DomElement? scrollable = findScrollable();
|
||||
expect(scrollable, isNotNull);
|
||||
|
||||
// When there's less content than the available size the neutral scrollTop
|
||||
@@ -896,7 +896,7 @@ void _testVerticalScrolling() {
|
||||
</sem-c>
|
||||
</sem>''');
|
||||
|
||||
final html.Element? scrollable = findScrollable();
|
||||
final DomElement? scrollable = findScrollable();
|
||||
expect(scrollable, isNotNull);
|
||||
|
||||
// When there's more content than the available size the neutral scrollTop
|
||||
@@ -984,7 +984,7 @@ void _testHorizontalScrolling() {
|
||||
</sem-c>
|
||||
</sem>''');
|
||||
|
||||
final html.Element? scrollable = findScrollable();
|
||||
final DomElement? scrollable = findScrollable();
|
||||
expect(scrollable, isNotNull);
|
||||
|
||||
// When there's less content than the available size the neutral
|
||||
@@ -1035,7 +1035,7 @@ void _testHorizontalScrolling() {
|
||||
</sem-c>
|
||||
</sem>''');
|
||||
|
||||
final html.Element? scrollable = findScrollable();
|
||||
final DomElement? scrollable = findScrollable();
|
||||
expect(scrollable, isNotNull);
|
||||
|
||||
// When there's more content than the available size the neutral scrollTop
|
||||
@@ -1117,9 +1117,10 @@ void _testIncrementables() {
|
||||
<input aria-valuenow="1" aria-valuetext="d" aria-valuemax="2" aria-valuemin="1">
|
||||
</sem>''');
|
||||
|
||||
final html.InputElement input = appHostNode.querySelector('input')! as html.InputElement;
|
||||
final DomHTMLInputElement input = appHostNode.querySelector('input')! as
|
||||
DomHTMLInputElement;
|
||||
input.value = '2';
|
||||
input.dispatchEvent(html.Event('change'));
|
||||
input.dispatchEvent(createDomEvent('Event', 'change'));
|
||||
|
||||
expect(await logger.idLog.first, 0);
|
||||
expect(await logger.actionLog.first, ui.SemanticsAction.increase);
|
||||
@@ -1151,9 +1152,10 @@ void _testIncrementables() {
|
||||
<input aria-valuenow="1" aria-valuetext="d" aria-valuemax="1" aria-valuemin="0">
|
||||
</sem>''');
|
||||
|
||||
final html.InputElement input = appHostNode.querySelector('input')! as html.InputElement;
|
||||
final DomHTMLInputElement input = appHostNode.querySelector('input')! as
|
||||
DomHTMLInputElement;
|
||||
input.value = '0';
|
||||
input.dispatchEvent(html.Event('change'));
|
||||
input.dispatchEvent(createDomEvent('Event', 'change'));
|
||||
|
||||
expect(await logger.idLog.first, 0);
|
||||
expect(await logger.actionLog.first, ui.SemanticsAction.decrease);
|
||||
@@ -1238,9 +1240,8 @@ void _testTextField() {
|
||||
|
||||
semantics().updateSemantics(builder.build());
|
||||
|
||||
final html.Element textField =
|
||||
appHostNode.querySelector('input[data-semantics-role="text-field"]')! as
|
||||
html.Element;
|
||||
final DomElement textField =
|
||||
appHostNode.querySelector('input[data-semantics-role="text-field"]')!;
|
||||
|
||||
expect(appHostNode.activeElement, isNot(textField));
|
||||
|
||||
@@ -1861,37 +1862,36 @@ void _testPlatformView() {
|
||||
final DomElement root = appHostNode.querySelector('#flt-semantic-node-0')!;
|
||||
expect(root.style.pointerEvents, 'none');
|
||||
|
||||
final html.Element child1 =
|
||||
appHostNode.querySelector('#flt-semantic-node-1')! as html.Element;
|
||||
final DomElement child1 =
|
||||
appHostNode.querySelector('#flt-semantic-node-1')!;
|
||||
expect(child1.style.pointerEvents, 'all');
|
||||
final html.Rectangle<num> child1Rect = child1.getBoundingClientRect();
|
||||
final DomRect child1Rect = child1.getBoundingClientRect();
|
||||
expect(child1Rect.left, 0);
|
||||
expect(child1Rect.top, 0);
|
||||
expect(child1Rect.right, 20);
|
||||
expect(child1Rect.bottom, 25);
|
||||
|
||||
final html.Element child2 =
|
||||
appHostNode.querySelector('#flt-semantic-node-2')! as html.Element;
|
||||
final DomElement child2 =
|
||||
appHostNode.querySelector('#flt-semantic-node-2')!;
|
||||
expect(child2.style.pointerEvents, 'none');
|
||||
final html.Rectangle<num> child2Rect = child2.getBoundingClientRect();
|
||||
final DomRect child2Rect = child2.getBoundingClientRect();
|
||||
expect(child2Rect.left, 0);
|
||||
expect(child2Rect.top, 15);
|
||||
expect(child2Rect.right, 20);
|
||||
expect(child2Rect.bottom, 45);
|
||||
|
||||
final html.Element child3 =
|
||||
appHostNode.querySelector('#flt-semantic-node-3')! as html.Element;
|
||||
final DomElement child3 =
|
||||
appHostNode.querySelector('#flt-semantic-node-3')!;
|
||||
expect(child3.style.pointerEvents, 'all');
|
||||
final html.Rectangle<num> child3Rect = child3.getBoundingClientRect();
|
||||
final DomRect child3Rect = child3.getBoundingClientRect();
|
||||
expect(child3Rect.left, 0);
|
||||
expect(child3Rect.top, 35);
|
||||
expect(child3Rect.right, 20);
|
||||
expect(child3Rect.bottom, 60);
|
||||
|
||||
final html.Element platformViewElement =
|
||||
flutterViewEmbedder.glassPaneElement!.querySelector('#view-0')! as
|
||||
html.Element;
|
||||
final html.Rectangle<num> platformViewRect = platformViewElement.getBoundingClientRect();
|
||||
final DomElement platformViewElement =
|
||||
flutterViewEmbedder.glassPaneElement!.querySelector('#view-0')!;
|
||||
final DomRect platformViewRect = platformViewElement.getBoundingClientRect();
|
||||
expect(platformViewRect.left, 0);
|
||||
expect(platformViewRect.top, 15);
|
||||
expect(platformViewRect.right, 20);
|
||||
@@ -1899,7 +1899,7 @@ void _testPlatformView() {
|
||||
|
||||
// This test is only relevant for shadow DOM because we only really support
|
||||
// proper platform view embedding in browsers that support shadow DOM.
|
||||
final html.ShadowRoot shadowRoot = appHostNode.node as html.ShadowRoot;
|
||||
final DomShadowRoot shadowRoot = appHostNode.node as DomShadowRoot;
|
||||
|
||||
// Hit test child 1
|
||||
expect(shadowRoot.elementFromPoint(10, 10)!, child1);
|
||||
@@ -1922,7 +1922,7 @@ void _testPlatformView() {
|
||||
// See:
|
||||
// * https://github.com/w3c/csswg-drafts/issues/556
|
||||
// * https://bugzilla.mozilla.org/show_bug.cgi?id=1502369
|
||||
expect(html.document.elementFromPoint(10, 30)!, platformViewElement);
|
||||
expect(domDocument.elementFromPoint(10, 30)!, platformViewElement);
|
||||
|
||||
// Hit test overlap between child 2 and 3
|
||||
expect(shadowRoot.elementFromPoint(10, 40)!, child3);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:html' as html;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
@@ -21,8 +20,8 @@ import '../../matchers.dart';
|
||||
/// Gets the DOM host where the Flutter app is being rendered.
|
||||
///
|
||||
/// This function returns the correct host for the flutter app under testing,
|
||||
/// so we don't have to hardcode html.document across the test. (The host of a
|
||||
/// normal flutter app used to be html.document, but now that the app is wrapped
|
||||
/// so we don't have to hardcode domDocument across the test. (The host of a
|
||||
/// normal flutter app used to be domDocument, but now that the app is wrapped
|
||||
/// in a Shadow DOM, that's not the case anymore.)
|
||||
HostNode get appHostNode => flutterViewEmbedder.glassPaneShadow!;
|
||||
|
||||
@@ -369,14 +368,14 @@ void expectSemanticsTree(String semanticsHtml) {
|
||||
}
|
||||
|
||||
/// Finds the first HTML element in the semantics tree used for scrolling.
|
||||
html.Element? findScrollable() {
|
||||
DomElement? findScrollable() {
|
||||
return appHostNode.querySelectorAll('flt-semantics').firstWhereOrNull(
|
||||
(DomElement? element) {
|
||||
return element!.style.overflow == 'hidden' ||
|
||||
element.style.overflowY == 'scroll' ||
|
||||
element.style.overflowX == 'scroll';
|
||||
},
|
||||
) as html.Element?;
|
||||
);
|
||||
}
|
||||
|
||||
/// Logs semantics actions dispatched to [ui.window].
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
@TestOn('chrome || safari || firefox')
|
||||
|
||||
import 'dart:html' as html;
|
||||
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -77,9 +75,8 @@ void testMain() {
|
||||
|
||||
createTextFieldSemantics(value: 'hello');
|
||||
|
||||
final html.Element textField = appHostNode
|
||||
.querySelector('input[data-semantics-role="text-field"]')! as
|
||||
html.Element;
|
||||
final DomElement textField = appHostNode
|
||||
.querySelector('input[data-semantics-role="text-field"]')!;
|
||||
|
||||
expect(appHostNode.activeElement, isNot(textField));
|
||||
|
||||
@@ -100,7 +97,7 @@ void testMain() {
|
||||
..debugOverrideTimestampFunction(() => _testTime)
|
||||
..semanticsEnabled = true;
|
||||
|
||||
expect(html.document.activeElement, html.document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
expect(appHostNode.activeElement, null);
|
||||
|
||||
int changeCount = 0;
|
||||
@@ -124,7 +121,7 @@ void testMain() {
|
||||
);
|
||||
|
||||
final TextField textField = textFieldSemantics.debugRoleManagerFor(Role.textField)! as TextField;
|
||||
expect(html.document.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(domDocument.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(appHostNode.activeElement, strategy.domElement);
|
||||
expect(textField.editableElement, strategy.domElement);
|
||||
expect((textField.editableElement as dynamic).value, 'hello');
|
||||
@@ -140,7 +137,7 @@ void testMain() {
|
||||
rect: const ui.Rect.fromLTWH(0, 0, 12, 17),
|
||||
);
|
||||
|
||||
expect(html.document.activeElement, html.document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
expect(appHostNode.activeElement, null);
|
||||
expect(strategy.domElement, null);
|
||||
expect((textField.editableElement as dynamic).value, 'bye');
|
||||
@@ -162,7 +159,7 @@ void testMain() {
|
||||
..debugOverrideTimestampFunction(() => _testTime)
|
||||
..semanticsEnabled = true;
|
||||
|
||||
expect(html.document.activeElement, html.document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
expect(appHostNode.activeElement, null);
|
||||
|
||||
strategy.enable(
|
||||
@@ -177,12 +174,12 @@ void testMain() {
|
||||
|
||||
final TextField textField = textFieldSemantics.debugRoleManagerFor(Role.textField)! as TextField;
|
||||
expect(textField.editableElement, strategy.domElement);
|
||||
expect(html.document.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(domDocument.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(appHostNode.activeElement, strategy.domElement);
|
||||
|
||||
// The input should not refocus after blur.
|
||||
textField.editableElement.blur();
|
||||
expect(html.document.activeElement, html.document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
expect(appHostNode.activeElement, null);
|
||||
strategy.disable();
|
||||
semantics().semanticsEnabled = false;
|
||||
@@ -208,7 +205,7 @@ void testMain() {
|
||||
isFocused: true,
|
||||
);
|
||||
expect(strategy.domElement, isNotNull);
|
||||
expect(html.document.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(domDocument.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(appHostNode.activeElement, strategy.domElement);
|
||||
|
||||
strategy.disable();
|
||||
@@ -219,7 +216,7 @@ void testMain() {
|
||||
expect(appHostNode.contains(textField.editableElement), isTrue);
|
||||
// Editing element is not enabled.
|
||||
expect(strategy.isEnabled, isFalse);
|
||||
expect(html.document.activeElement, html.document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
expect(appHostNode.activeElement, null);
|
||||
semantics().semanticsEnabled = false;
|
||||
});
|
||||
@@ -240,12 +237,12 @@ void testMain() {
|
||||
isFocused: true,
|
||||
);
|
||||
expect(strategy.domElement, isNotNull);
|
||||
expect(html.document.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(domDocument.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(appHostNode.activeElement, strategy.domElement);
|
||||
|
||||
// Blur the element without telling the framework.
|
||||
strategy.activeDomElement.blur();
|
||||
expect(html.document.activeElement, html.document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
expect(appHostNode.activeElement, null);
|
||||
|
||||
// The input will have focus after editing state is set and semantics updated.
|
||||
@@ -264,7 +261,7 @@ void testMain() {
|
||||
value: 'hello',
|
||||
isFocused: true,
|
||||
);
|
||||
expect(html.document.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(domDocument.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(appHostNode.activeElement, strategy.domElement);
|
||||
|
||||
strategy.disable();
|
||||
@@ -287,9 +284,9 @@ void testMain() {
|
||||
isMultiline: true,
|
||||
);
|
||||
|
||||
final html.TextAreaElement textArea = strategy.domElement! as html.TextAreaElement;
|
||||
final DomHTMLTextAreaElement textArea = strategy.domElement! as DomHTMLTextAreaElement;
|
||||
|
||||
expect(html.document.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(domDocument.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(appHostNode.activeElement, strategy.domElement);
|
||||
|
||||
strategy.enable(
|
||||
@@ -299,12 +296,12 @@ void testMain() {
|
||||
);
|
||||
|
||||
textArea.blur();
|
||||
expect(html.document.activeElement, html.document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
expect(appHostNode.activeElement, null);
|
||||
|
||||
strategy.disable();
|
||||
// It doesn't remove the textarea from the DOM.
|
||||
expect(appHostNode.contains(textArea as DomNode), isTrue);
|
||||
expect(appHostNode.contains(textArea), isTrue);
|
||||
// Editing element is not enabled.
|
||||
expect(strategy.isEnabled, isFalse);
|
||||
semantics().semanticsEnabled = false;
|
||||
@@ -395,7 +392,7 @@ void testMain() {
|
||||
createTwoFieldSemantics(tester, focusFieldId: 1);
|
||||
expect(tester.apply().length, 3);
|
||||
|
||||
expect(html.document.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(domDocument.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(appHostNode.activeElement, tester.getTextField(1).editableElement);
|
||||
expect(strategy.domElement, tester.getTextField(1).editableElement);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:html' as html;
|
||||
import 'dart:js_util' as js_util;
|
||||
import 'dart:typed_data';
|
||||
|
||||
@@ -10,6 +9,7 @@ import 'package:quiver/testing/async.dart';
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine/browser_detection.dart';
|
||||
import 'package:ui/src/engine/dom.dart';
|
||||
import 'package:ui/src/engine/keyboard.dart';
|
||||
import 'package:ui/src/engine/services.dart';
|
||||
import 'package:ui/src/engine/text_editing/text_editing.dart';
|
||||
@@ -51,7 +51,7 @@ void testMain() {
|
||||
dataReceived = const JSONMessageCodec().decodeMessage(data) as Map<String, dynamic>?;
|
||||
};
|
||||
|
||||
html.KeyboardEvent event;
|
||||
DomKeyboardEvent event;
|
||||
|
||||
event = dispatchKeyboardEvent('keyup', key: 'SomeKey', code: 'SomeCode', keyCode: 1);
|
||||
|
||||
@@ -83,7 +83,7 @@ void testMain() {
|
||||
dataReceived = const JSONMessageCodec().decodeMessage(data) as Map<String, dynamic>?;
|
||||
};
|
||||
|
||||
html.KeyboardEvent event;
|
||||
DomKeyboardEvent event;
|
||||
|
||||
event =
|
||||
dispatchKeyboardEvent('keydown', key: 'SomeKey', code: 'SomeCode', keyCode: 1);
|
||||
@@ -114,7 +114,7 @@ void testMain() {
|
||||
dataReceived = const JSONMessageCodec().decodeMessage(data) as Map<String, dynamic>?;
|
||||
};
|
||||
|
||||
html.KeyboardEvent event;
|
||||
DomKeyboardEvent event;
|
||||
|
||||
event = dispatchKeyboardEvent(
|
||||
'keydown',
|
||||
@@ -168,7 +168,7 @@ void testMain() {
|
||||
messages.add(const JSONMessageCodec().decodeMessage(data) as Map<String, dynamic>);
|
||||
};
|
||||
|
||||
html.KeyboardEvent event;
|
||||
DomKeyboardEvent event;
|
||||
|
||||
event = dispatchKeyboardEvent(
|
||||
'keydown',
|
||||
@@ -249,7 +249,7 @@ void testMain() {
|
||||
callback!(response);
|
||||
};
|
||||
|
||||
final html.KeyboardEvent event = dispatchKeyboardEvent(
|
||||
final DomKeyboardEvent event = dispatchKeyboardEvent(
|
||||
'keydown',
|
||||
key: 'Tab',
|
||||
code: 'Tab',
|
||||
@@ -272,7 +272,7 @@ void testMain() {
|
||||
callback!(response);
|
||||
};
|
||||
|
||||
final html.KeyboardEvent event = dispatchKeyboardEvent(
|
||||
final DomKeyboardEvent event = dispatchKeyboardEvent(
|
||||
'keydown',
|
||||
key: 'Tab',
|
||||
code: 'Tab',
|
||||
@@ -293,8 +293,8 @@ void testMain() {
|
||||
count += 1;
|
||||
};
|
||||
|
||||
useTextEditingElement((html.Element element) {
|
||||
final html.KeyboardEvent event = dispatchKeyboardEvent(
|
||||
useTextEditingElement((DomElement element) {
|
||||
final DomKeyboardEvent event = dispatchKeyboardEvent(
|
||||
'keydown',
|
||||
key: 'SomeKey',
|
||||
code: 'SomeCode',
|
||||
@@ -319,8 +319,8 @@ void testMain() {
|
||||
callback!(response);
|
||||
};
|
||||
|
||||
useTextEditingElement((html.Element element) {
|
||||
final html.KeyboardEvent event = dispatchKeyboardEvent(
|
||||
useTextEditingElement((DomElement element) {
|
||||
final DomKeyboardEvent event = dispatchKeyboardEvent(
|
||||
'keydown',
|
||||
key: 'Tab',
|
||||
code: 'Tab',
|
||||
@@ -703,23 +703,23 @@ void testMain() {
|
||||
});
|
||||
}
|
||||
|
||||
typedef ElementCallback = void Function(html.Element element);
|
||||
typedef ElementCallback = void Function(DomElement element);
|
||||
|
||||
void useTextEditingElement(ElementCallback callback) {
|
||||
final html.InputElement input = html.InputElement();
|
||||
input.classes.add(HybridTextEditing.textEditingClass);
|
||||
final DomHTMLInputElement input = createDomHTMLInputElement();
|
||||
input.classList.add(HybridTextEditing.textEditingClass);
|
||||
|
||||
try {
|
||||
html.document.body!.append(input);
|
||||
domDocument.body!.append(input);
|
||||
callback(input);
|
||||
} finally {
|
||||
input.remove();
|
||||
}
|
||||
}
|
||||
|
||||
html.KeyboardEvent dispatchKeyboardEvent(
|
||||
DomKeyboardEvent dispatchKeyboardEvent(
|
||||
String type, {
|
||||
html.EventTarget? target,
|
||||
DomEventTarget? target,
|
||||
String? key,
|
||||
String? code,
|
||||
int location = 0,
|
||||
@@ -730,10 +730,10 @@ html.KeyboardEvent dispatchKeyboardEvent(
|
||||
bool isMetaPressed = false,
|
||||
int keyCode = 0,
|
||||
}) {
|
||||
target ??= html.window;
|
||||
target ??= domWindow;
|
||||
|
||||
final Function jsKeyboardEvent =
|
||||
js_util.getProperty<Function>(html.window, 'KeyboardEvent');
|
||||
js_util.getProperty<Function>(domWindow, 'KeyboardEvent');
|
||||
final List<dynamic> eventArgs = <dynamic>[
|
||||
type,
|
||||
<String, dynamic>{
|
||||
@@ -750,7 +750,7 @@ html.KeyboardEvent dispatchKeyboardEvent(
|
||||
'cancelable': true,
|
||||
}
|
||||
];
|
||||
final html.KeyboardEvent event = js_util.callConstructor<html.KeyboardEvent>(
|
||||
final DomKeyboardEvent event = js_util.callConstructor<DomKeyboardEvent>(
|
||||
jsKeyboardEvent,
|
||||
js_util.jsify(eventArgs) as List<Object?>,
|
||||
);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:html';
|
||||
import 'dart:js_util' as js_util;
|
||||
import 'dart:typed_data';
|
||||
|
||||
@@ -14,6 +13,7 @@ import 'package:ui/src/engine.dart' show flutterViewEmbedder;
|
||||
import 'package:ui/src/engine/browser_detection.dart';
|
||||
import 'package:ui/src/engine/dom.dart';
|
||||
import 'package:ui/src/engine/initialization.dart';
|
||||
import 'package:ui/src/engine/safe_browser_api.dart';
|
||||
import 'package:ui/src/engine/services.dart';
|
||||
import 'package:ui/src/engine/text_editing/autofill_hint.dart';
|
||||
import 'package:ui/src/engine/text_editing/input_type.dart';
|
||||
@@ -88,11 +88,11 @@ Future<void> testMain() async {
|
||||
|
||||
test('Creates element when enabled and removes it when disabled', () {
|
||||
expect(
|
||||
document.getElementsByTagName('input'),
|
||||
domDocument.getElementsByTagName('input'),
|
||||
hasLength(0),
|
||||
);
|
||||
// The focus initially is on the body.
|
||||
expect(document.activeElement, document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
expect(defaultTextEditingRoot.activeElement, null);
|
||||
|
||||
editingStrategy!.enable(
|
||||
@@ -105,11 +105,10 @@ Future<void> testMain() async {
|
||||
defaultTextEditingRoot.querySelectorAll('input'),
|
||||
hasLength(1),
|
||||
);
|
||||
final Element input = defaultTextEditingRoot.querySelector('input')! as
|
||||
Element;
|
||||
final DomElement input = defaultTextEditingRoot.querySelector('input')!;
|
||||
// Now the editing element should have focus.
|
||||
|
||||
expect(document.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(domDocument.activeElement, flutterViewEmbedder.glassPaneElement);
|
||||
expect(defaultTextEditingRoot.activeElement, input);
|
||||
|
||||
expect(editingStrategy!.domElement, input);
|
||||
@@ -124,7 +123,7 @@ Future<void> testMain() async {
|
||||
hasLength(0),
|
||||
);
|
||||
// The focus is back to the body.
|
||||
expect(document.activeElement, document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
expect(defaultTextEditingRoot.activeElement, null);
|
||||
});
|
||||
|
||||
@@ -138,8 +137,7 @@ Future<void> testMain() async {
|
||||
onAction: trackInputAction,
|
||||
);
|
||||
expect(defaultTextEditingRoot.querySelectorAll('input'), hasLength(1));
|
||||
final Element input = defaultTextEditingRoot.querySelector('input')! as
|
||||
Element;
|
||||
final DomElement input = defaultTextEditingRoot.querySelector('input')!;
|
||||
expect(editingStrategy!.domElement, input);
|
||||
expect(input.getAttribute('readonly'), 'readonly');
|
||||
|
||||
@@ -156,8 +154,7 @@ Future<void> testMain() async {
|
||||
onAction: trackInputAction,
|
||||
);
|
||||
expect(defaultTextEditingRoot.querySelectorAll('input'), hasLength(1));
|
||||
final Element input = defaultTextEditingRoot.querySelector('input')! as
|
||||
Element;
|
||||
final DomElement input = defaultTextEditingRoot.querySelector('input')!;
|
||||
expect(editingStrategy!.domElement, input);
|
||||
expect(input.getAttribute('type'), 'password');
|
||||
|
||||
@@ -174,8 +171,7 @@ Future<void> testMain() async {
|
||||
onAction: trackInputAction,
|
||||
);
|
||||
expect(defaultTextEditingRoot.querySelectorAll('input'), hasLength(1));
|
||||
final Element input = defaultTextEditingRoot.querySelector('input')! as
|
||||
Element;
|
||||
final DomElement input = defaultTextEditingRoot.querySelector('input')!;
|
||||
expect(editingStrategy!.domElement, input);
|
||||
expect(input.getAttribute('autocorrect'), 'off');
|
||||
|
||||
@@ -192,8 +188,7 @@ Future<void> testMain() async {
|
||||
onAction: trackInputAction,
|
||||
);
|
||||
expect(defaultTextEditingRoot.querySelectorAll('input'), hasLength(1));
|
||||
final Element input = defaultTextEditingRoot.querySelector('input')! as
|
||||
Element;
|
||||
final DomElement input = defaultTextEditingRoot.querySelector('input')!;
|
||||
expect(editingStrategy!.domElement, input);
|
||||
expect(input.getAttribute('autocorrect'), 'on');
|
||||
|
||||
@@ -210,8 +205,7 @@ Future<void> testMain() async {
|
||||
onAction: trackInputAction,
|
||||
);
|
||||
expect(defaultTextEditingRoot.querySelectorAll('input'), hasLength(1));
|
||||
final Element input = defaultTextEditingRoot.querySelector('input')! as
|
||||
Element;
|
||||
final DomElement input = defaultTextEditingRoot.querySelector('input')!;
|
||||
expect(editingStrategy!.domElement, input);
|
||||
expect(input.getAttribute('autocomplete'), 'off');
|
||||
|
||||
@@ -225,16 +219,16 @@ Future<void> testMain() async {
|
||||
onAction: trackInputAction,
|
||||
);
|
||||
|
||||
final InputElement input = editingStrategy!.domElement! as InputElement;
|
||||
final DomHTMLInputElement input = editingStrategy!.domElement! as DomHTMLInputElement;
|
||||
input.value = 'foo bar';
|
||||
input.dispatchEvent(Event.eventType('Event', 'input'));
|
||||
input.dispatchEvent(createDomEvent('Event', 'input'));
|
||||
expect(
|
||||
lastEditingState,
|
||||
EditingState(text: 'foo bar', baseOffset: 7, extentOffset: 7),
|
||||
);
|
||||
|
||||
input.setSelectionRange(4, 6);
|
||||
document.dispatchEvent(Event.eventType('Event', 'selectionchange'));
|
||||
domDocument.dispatchEvent(createDomEvent('Event', 'selectionchange'));
|
||||
expect(
|
||||
lastEditingState,
|
||||
EditingState(text: 'foo bar', baseOffset: 4, extentOffset: 6),
|
||||
@@ -261,7 +255,7 @@ Future<void> testMain() async {
|
||||
|
||||
test('Multi-line mode also works', () {
|
||||
// The textarea element is created lazily.
|
||||
expect(document.getElementsByTagName('textarea'), hasLength(0));
|
||||
expect(domDocument.getElementsByTagName('textarea'), hasLength(0));
|
||||
editingStrategy!.enable(
|
||||
multilineConfig,
|
||||
onChange: trackEditingState,
|
||||
@@ -278,7 +272,7 @@ Future<void> testMain() async {
|
||||
textarea.value = 'foo\nbar';
|
||||
textarea.dispatchEvent(createDomEvent('Event', 'input'));
|
||||
textarea.setSelectionRange(4, 6);
|
||||
document.dispatchEvent(Event.eventType('Event', 'selectionchange'));
|
||||
domDocument.dispatchEvent(createDomEvent('Event', 'selectionchange'));
|
||||
// Can read textarea state correctly (and preserves new lines).
|
||||
expect(
|
||||
lastEditingState,
|
||||
@@ -302,8 +296,8 @@ Future<void> testMain() async {
|
||||
|
||||
test('Same instance can be re-enabled with different config', () {
|
||||
// Make sure there's nothing in the DOM yet.
|
||||
expect(document.getElementsByTagName('input'), hasLength(0));
|
||||
expect(document.getElementsByTagName('textarea'), hasLength(0));
|
||||
expect(domDocument.getElementsByTagName('input'), hasLength(0));
|
||||
expect(domDocument.getElementsByTagName('textarea'), hasLength(0));
|
||||
|
||||
// Use single-line config and expect an `<input>` to be created.
|
||||
editingStrategy!.enable(
|
||||
@@ -487,7 +481,7 @@ Future<void> testMain() async {
|
||||
sendFrameworkMessage(codec.encodeMethodCall(setClient));
|
||||
|
||||
// Editing shouldn't have started yet.
|
||||
expect(document.activeElement, document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
|
||||
const MethodCall show = MethodCall('TextInput.show');
|
||||
sendFrameworkMessage(codec.encodeMethodCall(show));
|
||||
@@ -518,7 +512,7 @@ Future<void> testMain() async {
|
||||
sendFrameworkMessage(codec.encodeMethodCall(hide));
|
||||
|
||||
// Text editing should've stopped.
|
||||
expect(document.activeElement, document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
|
||||
// Confirm that [HybridTextEditing] didn't send any messages.
|
||||
expect(spy.messages, isEmpty);
|
||||
@@ -538,7 +532,7 @@ Future<void> testMain() async {
|
||||
sendFrameworkMessage(codec.encodeMethodCall(setEditingState));
|
||||
|
||||
// Editing shouldn't have started yet.
|
||||
expect(document.activeElement, document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
|
||||
const MethodCall show = MethodCall('TextInput.show');
|
||||
sendFrameworkMessage(codec.encodeMethodCall(show));
|
||||
@@ -558,7 +552,7 @@ Future<void> testMain() async {
|
||||
const MethodCall clearClient = MethodCall('TextInput.clearClient');
|
||||
sendFrameworkMessage(codec.encodeMethodCall(clearClient));
|
||||
|
||||
expect(document.activeElement, document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
|
||||
// Confirm that [HybridTextEditing] didn't send any messages.
|
||||
expect(spy.messages, isEmpty);
|
||||
@@ -580,7 +574,7 @@ Future<void> testMain() async {
|
||||
sendFrameworkMessage(codec.encodeMethodCall(setEditingState));
|
||||
|
||||
// Editing shouldn't have started yet.
|
||||
expect(document.activeElement, document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
|
||||
// The "setSizeAndTransform" message has to be here before we call
|
||||
// checkInputEditingState, since on some platforms (e.g. Desktop Safari)
|
||||
@@ -879,10 +873,12 @@ Future<void> testMain() async {
|
||||
|
||||
// Form is added to DOM.
|
||||
expect(defaultTextEditingRoot.querySelectorAll('form'), isNotEmpty);
|
||||
final FormElement formElement = defaultTextEditingRoot.querySelector('form')! as FormElement;
|
||||
final DomHTMLFormElement formElement =
|
||||
defaultTextEditingRoot.querySelector('form')! as DomHTMLFormElement;
|
||||
final Completer<bool> submittedForm = Completer<bool>();
|
||||
formElement.addEventListener(
|
||||
'submit', (Event event) => submittedForm.complete(true));
|
||||
'submit', allowInterop((DomEvent event) =>
|
||||
submittedForm.complete(true)));
|
||||
|
||||
const MethodCall clearClient = MethodCall('TextInput.clearClient');
|
||||
sendFrameworkMessage(codec.encodeMethodCall(clearClient));
|
||||
@@ -932,10 +928,12 @@ Future<void> testMain() async {
|
||||
|
||||
// Form is added to DOM.
|
||||
expect(defaultTextEditingRoot.querySelectorAll('form'), isNotEmpty);
|
||||
final FormElement formElement = defaultTextEditingRoot.querySelector('form')! as FormElement;
|
||||
final DomHTMLFormElement formElement =
|
||||
defaultTextEditingRoot.querySelector('form')! as DomHTMLFormElement;
|
||||
final Completer<bool> submittedForm = Completer<bool>();
|
||||
formElement.addEventListener(
|
||||
'submit', (Event event) => submittedForm.complete(true));
|
||||
'submit', allowInterop((DomEvent event) =>
|
||||
submittedForm.complete(true)));
|
||||
|
||||
// Clear client is not called. The used requested context to be finalized.
|
||||
const MethodCall finishAutofillContext =
|
||||
@@ -970,7 +968,7 @@ Future<void> testMain() async {
|
||||
sendFrameworkMessage(codec.encodeMethodCall(setEditingState));
|
||||
|
||||
// Editing shouldn't have started yet.
|
||||
expect(document.activeElement, document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
|
||||
const MethodCall show = MethodCall('TextInput.show');
|
||||
sendFrameworkMessage(codec.encodeMethodCall(show));
|
||||
@@ -993,7 +991,7 @@ Future<void> testMain() async {
|
||||
|
||||
// Receiving another client via setClient should stop editing, hence
|
||||
// should remove the previous active element.
|
||||
expect(document.activeElement, document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
|
||||
// Confirm that [HybridTextEditing] didn't send any messages.
|
||||
expect(spy.messages, isEmpty);
|
||||
@@ -1079,7 +1077,8 @@ Future<void> testMain() async {
|
||||
checkInputEditingState(
|
||||
textEditing!.strategy.domElement, 'abcd', 2, 3);
|
||||
|
||||
final FormElement formElement = defaultTextEditingRoot.querySelector('form')! as FormElement;
|
||||
final DomHTMLFormElement formElement =
|
||||
defaultTextEditingRoot.querySelector('form')! as DomHTMLFormElement;
|
||||
// The form has one input element and one submit button.
|
||||
expect(formElement.childNodes, hasLength(2));
|
||||
|
||||
@@ -1123,8 +1122,8 @@ Future<void> testMain() async {
|
||||
Matrix4.translationValues(10.0, 10.0, 10.0).storage.toList());
|
||||
sendFrameworkMessage(codec.encodeMethodCall(setSizeAndTransform));
|
||||
|
||||
final InputElement inputElement =
|
||||
textEditing!.strategy.domElement! as InputElement;
|
||||
final DomHTMLInputElement inputElement =
|
||||
textEditing!.strategy.domElement! as DomHTMLInputElement;
|
||||
expect(inputElement.value, 'abcd');
|
||||
if (!(browserEngine == BrowserEngine.webkit &&
|
||||
operatingSystem == OperatingSystem.macOs)) {
|
||||
@@ -1202,7 +1201,8 @@ Future<void> testMain() async {
|
||||
checkInputEditingState(
|
||||
textEditing!.strategy.domElement, 'abcd', 2, 3);
|
||||
|
||||
final FormElement formElement = defaultTextEditingRoot.querySelector('form')! as FormElement;
|
||||
final DomHTMLFormElement formElement =
|
||||
defaultTextEditingRoot.querySelector('form')! as DomHTMLFormElement;
|
||||
// The form has 4 input elements and one submit button.
|
||||
expect(formElement.childNodes, hasLength(5));
|
||||
|
||||
@@ -1324,8 +1324,8 @@ Future<void> testMain() async {
|
||||
// Check if the location and styling is correct.
|
||||
expect(
|
||||
domElement.getBoundingClientRect(),
|
||||
Rectangle<double>.fromPoints(const Point<double>(10.0, 20.0),
|
||||
const Point<double>(160.0, 70.0)));
|
||||
createDomRectFromPoints(DomPoint(10.0, 20.0),
|
||||
DomPoint(160.0, 70.0)));
|
||||
expect(domElement.style.transform,
|
||||
'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 20, 30, 1)');
|
||||
expect(textEditing!.strategy.domElement!.style.font,
|
||||
@@ -1384,8 +1384,8 @@ Future<void> testMain() async {
|
||||
// Check if the position is correct.
|
||||
expect(
|
||||
domElement.getBoundingClientRect(),
|
||||
Rectangle<double>.fromPoints(
|
||||
const Point<double>(10.0, 20.0), const Point<double>(160.0, 70.0)),
|
||||
createDomRectFromPoints(
|
||||
DomPoint(10.0, 20.0), DomPoint(160.0, 70.0)),
|
||||
);
|
||||
expect(
|
||||
domElement.style.transform,
|
||||
@@ -1446,8 +1446,8 @@ Future<void> testMain() async {
|
||||
// Check if the location and styling is correct.
|
||||
expect(
|
||||
domElement.getBoundingClientRect(),
|
||||
Rectangle<double>.fromPoints(const Point<double>(10.0, 20.0),
|
||||
const Point<double>(160.0, 70.0)));
|
||||
createDomRectFromPoints(DomPoint(10.0, 20.0),
|
||||
DomPoint(160.0, 70.0)));
|
||||
expect(domElement.style.transform,
|
||||
'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 20, 30, 1)');
|
||||
expect(
|
||||
@@ -1542,10 +1542,11 @@ Future<void> testMain() async {
|
||||
const MethodCall show = MethodCall('TextInput.show');
|
||||
sendFrameworkMessage(codec.encodeMethodCall(show));
|
||||
|
||||
final InputElement input = textEditing!.strategy.domElement! as InputElement;
|
||||
final DomHTMLInputElement input = textEditing!.strategy.domElement! as
|
||||
DomHTMLInputElement;
|
||||
|
||||
input.value = 'something';
|
||||
input.dispatchEvent(Event.eventType('Event', 'input'));
|
||||
input.dispatchEvent(createDomEvent('Event', 'input'));
|
||||
|
||||
expect(spy.messages, hasLength(1));
|
||||
expect(spy.messages[0].channel, 'flutter/textinput');
|
||||
@@ -1567,10 +1568,10 @@ Future<void> testMain() async {
|
||||
|
||||
input.setSelectionRange(2, 5);
|
||||
if (browserEngine == BrowserEngine.firefox) {
|
||||
final Event keyup = KeyboardEvent('keyup');
|
||||
textEditing!.strategy.domElement!.dispatchEvent(keyup as DomEvent);
|
||||
final DomEvent keyup = createDomEvent('Event', 'keyup');
|
||||
textEditing!.strategy.domElement!.dispatchEvent(keyup);
|
||||
} else {
|
||||
document.dispatchEvent(Event.eventType('Event', 'selectionchange'));
|
||||
domDocument.dispatchEvent(createDomEvent('Event', 'selectionchange'));
|
||||
}
|
||||
|
||||
expect(spy.messages, hasLength(1));
|
||||
@@ -1610,19 +1611,20 @@ Future<void> testMain() async {
|
||||
const MethodCall show = MethodCall('TextInput.show');
|
||||
sendFrameworkMessage(codec.encodeMethodCall(show));
|
||||
|
||||
final InputElement input = textEditing!.strategy.domElement! as InputElement;
|
||||
final DomHTMLInputElement input = textEditing!.strategy.domElement! as
|
||||
DomHTMLInputElement;
|
||||
|
||||
input.value = 'something';
|
||||
input.dispatchEvent(Event.eventType('Event', 'input'));
|
||||
input.dispatchEvent(createDomEvent('Event', 'input'));
|
||||
|
||||
spy.messages.clear();
|
||||
|
||||
input.setSelectionRange(2, 5);
|
||||
if (browserEngine == BrowserEngine.firefox) {
|
||||
final Event keyup = KeyboardEvent('keyup');
|
||||
textEditing!.strategy.domElement!.dispatchEvent(keyup as DomEvent);
|
||||
final DomEvent keyup = createDomEvent('Event', 'keyup');
|
||||
textEditing!.strategy.domElement!.dispatchEvent(keyup);
|
||||
} else {
|
||||
document.dispatchEvent(Event.eventType('Event', 'selectionchange'));
|
||||
domDocument.dispatchEvent(createDomEvent('Event', 'selectionchange'));
|
||||
}
|
||||
|
||||
expect(spy.messages, hasLength(1));
|
||||
@@ -1693,12 +1695,14 @@ Future<void> testMain() async {
|
||||
checkInputEditingState(
|
||||
textEditing!.strategy.domElement, 'abcd', 2, 3);
|
||||
|
||||
final FormElement formElement = defaultTextEditingRoot.querySelector('form')! as FormElement;
|
||||
final DomHTMLFormElement formElement =
|
||||
defaultTextEditingRoot.querySelector('form')! as DomHTMLFormElement;
|
||||
// The form has 4 input elements and one submit button.
|
||||
expect(formElement.childNodes, hasLength(5));
|
||||
|
||||
// Autofill one of the form elements.
|
||||
final InputElement element = formElement.childNodes.first as InputElement;
|
||||
final DomHTMLInputElement element = formElement.childNodes.toList()[0] as
|
||||
DomHTMLInputElement;
|
||||
if (browserEngine == BrowserEngine.firefox) {
|
||||
expect(element.name,
|
||||
BrowserAutofillHints.instance.flutterToEngine(hintForFirstElement));
|
||||
@@ -1707,7 +1711,7 @@ Future<void> testMain() async {
|
||||
BrowserAutofillHints.instance.flutterToEngine(hintForFirstElement));
|
||||
}
|
||||
element.value = 'something';
|
||||
element.dispatchEvent(Event.eventType('Event', 'input'));
|
||||
element.dispatchEvent(createDomEvent('Event', 'input'));
|
||||
|
||||
expect(spy.messages, hasLength(1));
|
||||
expect(spy.messages[0].channel, 'flutter/textinput');
|
||||
@@ -1777,7 +1781,7 @@ Future<void> testMain() async {
|
||||
textEditing!.strategy.domElement!
|
||||
.dispatchEvent(createDomEvent('Event', 'keyup'));
|
||||
} else {
|
||||
document.dispatchEvent(Event.eventType('Event', 'selectionchange'));
|
||||
domDocument.dispatchEvent(createDomEvent('Event', 'selectionchange'));
|
||||
}
|
||||
|
||||
// Two messages should've been sent. One for the 'input' event and one for
|
||||
@@ -1821,7 +1825,7 @@ Future<void> testMain() async {
|
||||
sendFrameworkMessage(codec.encodeMethodCall(hide));
|
||||
|
||||
// Text editing should've stopped.
|
||||
expect(document.activeElement, document.body);
|
||||
expect(domDocument.activeElement, domDocument.body);
|
||||
|
||||
// Confirm that [HybridTextEditing] didn't send any more messages.
|
||||
expect(spy.messages, isEmpty);
|
||||
@@ -1997,7 +2001,7 @@ Future<void> testMain() async {
|
||||
expect(firstElement.selectionEnd, 0);
|
||||
|
||||
// Element is hidden.
|
||||
final CssStyleDeclaration css = firstElement.style as CssStyleDeclaration;
|
||||
final DomCSSStyleDeclaration css = firstElement.style;
|
||||
expect(css.color, 'transparent');
|
||||
expect(css.backgroundColor, 'transparent');
|
||||
|
||||
@@ -2041,7 +2045,8 @@ Future<void> testMain() async {
|
||||
final DomHTMLFormElement form = autofillForm.formElement;
|
||||
expect(form.childNodes, hasLength(4));
|
||||
|
||||
final FormElement formOnDom = defaultTextEditingRoot.querySelector('form')! as FormElement;
|
||||
final DomHTMLFormElement formOnDom =
|
||||
defaultTextEditingRoot.querySelector('form')! as DomHTMLFormElement;
|
||||
// Form is attached to the DOM.
|
||||
expect(form, equals(formOnDom));
|
||||
|
||||
@@ -2068,7 +2073,8 @@ Future<void> testMain() async {
|
||||
final DomHTMLFormElement form = autofillForm.formElement;
|
||||
// Submit button is added to the form.
|
||||
expect(form.childNodes, isNotEmpty);
|
||||
final InputElement inputElement = form.childNodes.toList()[0] as InputElement;
|
||||
final DomHTMLInputElement inputElement = form.childNodes.toList()[0] as
|
||||
DomHTMLInputElement;
|
||||
expect(inputElement.type, 'submit');
|
||||
|
||||
// The submit button should have class `submitBtn`.
|
||||
@@ -2231,11 +2237,12 @@ Future<void> testMain() async {
|
||||
});
|
||||
|
||||
test('Configure input element from the editing state', () {
|
||||
final InputElement input = defaultTextEditingRoot.querySelector('input')! as InputElement;
|
||||
final DomHTMLInputElement input =
|
||||
defaultTextEditingRoot.querySelector('input')! as DomHTMLInputElement;
|
||||
_editingState =
|
||||
EditingState(text: 'Test', baseOffset: 1, extentOffset: 2);
|
||||
|
||||
_editingState.applyToDomElement(input as DomHTMLInputElement);
|
||||
_editingState.applyToDomElement(input);
|
||||
|
||||
expect(input.value, 'Test');
|
||||
expect(input.selectionStart, 1);
|
||||
@@ -2250,12 +2257,12 @@ Future<void> testMain() async {
|
||||
onAction: trackInputAction,
|
||||
);
|
||||
|
||||
final TextAreaElement textArea =
|
||||
defaultTextEditingRoot.querySelector('textarea')! as TextAreaElement;
|
||||
final DomHTMLTextAreaElement textArea =
|
||||
defaultTextEditingRoot.querySelector('textarea')! as DomHTMLTextAreaElement;
|
||||
_editingState =
|
||||
EditingState(text: 'Test', baseOffset: 1, extentOffset: 2);
|
||||
|
||||
_editingState.applyToDomElement(textArea as DomHTMLTextAreaElement);
|
||||
_editingState.applyToDomElement(textArea);
|
||||
|
||||
expect(textArea.value, 'Test');
|
||||
expect(textArea.selectionStart, 1);
|
||||
@@ -2263,12 +2270,13 @@ Future<void> testMain() async {
|
||||
});
|
||||
|
||||
test('Get Editing State from input element', () {
|
||||
final InputElement input = defaultTextEditingRoot.querySelector('input')! as InputElement;
|
||||
final DomHTMLInputElement input =
|
||||
defaultTextEditingRoot.querySelector('input')! as DomHTMLInputElement;
|
||||
input.value = 'Test';
|
||||
input.selectionStart = 1;
|
||||
input.selectionEnd = 2;
|
||||
|
||||
_editingState = EditingState.fromDomElement(input as DomHTMLInputElement);
|
||||
_editingState = EditingState.fromDomElement(input);
|
||||
|
||||
expect(_editingState.text, 'Test');
|
||||
expect(_editingState.baseOffset, 1);
|
||||
@@ -2283,13 +2291,13 @@ Future<void> testMain() async {
|
||||
onAction: trackInputAction,
|
||||
);
|
||||
|
||||
final TextAreaElement input = defaultTextEditingRoot.querySelector('textarea')! as TextAreaElement;
|
||||
final DomHTMLTextAreaElement input =
|
||||
defaultTextEditingRoot.querySelector('textarea')! as DomHTMLTextAreaElement;
|
||||
input.value = 'Test';
|
||||
input.selectionStart = 1;
|
||||
input.selectionEnd = 2;
|
||||
|
||||
_editingState = EditingState.fromDomElement(input as
|
||||
DomHTMLTextAreaElement);
|
||||
_editingState = EditingState.fromDomElement(input);
|
||||
|
||||
expect(_editingState.text, 'Test');
|
||||
expect(_editingState.baseOffset, 1);
|
||||
@@ -2298,17 +2306,18 @@ Future<void> testMain() async {
|
||||
|
||||
group('comparing editing states', () {
|
||||
test('From dom element', () {
|
||||
final InputElement input = defaultTextEditingRoot.querySelector('input')! as InputElement;
|
||||
final DomHTMLInputElement input = defaultTextEditingRoot.querySelector('input')!
|
||||
as DomHTMLInputElement;
|
||||
input.value = 'Test';
|
||||
input.selectionStart = 1;
|
||||
input.selectionEnd = 2;
|
||||
|
||||
final EditingState editingState1 = EditingState.fromDomElement(input as DomHTMLInputElement);
|
||||
final EditingState editingState2 = EditingState.fromDomElement(input as DomHTMLInputElement);
|
||||
final EditingState editingState1 = EditingState.fromDomElement(input);
|
||||
final EditingState editingState2 = EditingState.fromDomElement(input);
|
||||
|
||||
input.setSelectionRange(1, 3);
|
||||
|
||||
final EditingState editingState3 = EditingState.fromDomElement(input as DomHTMLInputElement);
|
||||
final EditingState editingState3 = EditingState.fromDomElement(input);
|
||||
|
||||
expect(editingState1 == editingState2, isTrue);
|
||||
expect(editingState1 != editingState3, isTrue);
|
||||
@@ -2420,7 +2429,7 @@ DomKeyboardEvent dispatchKeyboardEvent(
|
||||
String type, {
|
||||
required int keyCode,
|
||||
}) {
|
||||
final Function jsKeyboardEvent = js_util.getProperty<Function>(window, 'KeyboardEvent');
|
||||
final Function jsKeyboardEvent = js_util.getProperty<Function>(domWindow, 'KeyboardEvent');
|
||||
final List<dynamic> eventArgs = <dynamic>[
|
||||
type,
|
||||
<String, dynamic>{
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -224,8 +222,8 @@ Future<void> testMain() async {
|
||||
final CanvasParagraph paragraph = builder.build() as CanvasParagraph;
|
||||
paragraph.layout(const ParagraphConstraints(width: 800.0));
|
||||
expect(paragraph.plainText, 'abcdef');
|
||||
final List<Element> spans =
|
||||
paragraph.toDomElement().querySelectorAll('flt-span').cast<Element>().toList();
|
||||
final List<DomElement> spans =
|
||||
paragraph.toDomElement().querySelectorAll('flt-span').toList();
|
||||
expect(spans[0].style.fontFamily, 'Ahem, $fallback, sans-serif');
|
||||
// The nested span here should not set it's family to default sans-serif.
|
||||
expect(spans[1].style.fontFamily, 'Ahem, $fallback, sans-serif');
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine.dart';
|
||||
@@ -22,8 +20,8 @@ void testMain() {
|
||||
ui.debugEmulateFlutterTesterEnvironment = false;
|
||||
|
||||
// TODO(yjbanov): https://github.com/flutter/flutter/issues/39159
|
||||
document.title = '';
|
||||
expect(document.title, '');
|
||||
domDocument.title = '';
|
||||
expect(domDocument.title, '');
|
||||
|
||||
ui.window.sendPlatformMessage(
|
||||
'flutter/platform',
|
||||
@@ -35,7 +33,7 @@ void testMain() {
|
||||
})),
|
||||
null);
|
||||
|
||||
expect(document.title, 'Title Test');
|
||||
expect(domDocument.title, 'Title Test');
|
||||
|
||||
ui.window.sendPlatformMessage(
|
||||
'flutter/platform',
|
||||
@@ -47,7 +45,7 @@ void testMain() {
|
||||
})),
|
||||
null);
|
||||
|
||||
expect(document.title, 'Different title');
|
||||
expect(domDocument.title, 'Different title');
|
||||
});
|
||||
|
||||
test('supports null title and primaryColor', () {
|
||||
@@ -55,8 +53,8 @@ void testMain() {
|
||||
ui.debugEmulateFlutterTesterEnvironment = false;
|
||||
|
||||
// TODO(yjbanov): https://github.com/flutter/flutter/issues/39159
|
||||
document.title = 'Something Else';
|
||||
expect(document.title, 'Something Else');
|
||||
domDocument.title = 'Something Else';
|
||||
expect(domDocument.title, 'Something Else');
|
||||
|
||||
ui.window.sendPlatformMessage(
|
||||
'flutter/platform',
|
||||
@@ -68,10 +66,10 @@ void testMain() {
|
||||
})),
|
||||
null);
|
||||
|
||||
expect(document.title, '');
|
||||
expect(domDocument.title, '');
|
||||
|
||||
document.title = 'Something Else';
|
||||
expect(document.title, 'Something Else');
|
||||
domDocument.title = 'Something Else';
|
||||
expect(domDocument.title, 'Something Else');
|
||||
|
||||
ui.window.sendPlatformMessage(
|
||||
'flutter/platform',
|
||||
@@ -81,7 +79,7 @@ void testMain() {
|
||||
})),
|
||||
null);
|
||||
|
||||
expect(document.title, '');
|
||||
expect(domDocument.title, '');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user