Fix DomProgressEvent constructor (flutter/engine#37849)

DomProgressEvent should have a non-synthetic constructor that accepts
a String to match the MDN definition:
https://developer.mozilla.org/en-US/docs/Web/API/ProgressEvent/ProgressEvent.
It should also have a JS name that points to ProgressEvent. Lastly,
image_golden_test is modified to use the parameter values from before the
static interop migration:
9276dc1ff1/lib/web_ui/test/canvaskit/image_golden_test.dart
This commit is contained in:
Srujan Gaddam 2022-11-23 08:03:32 -08:00 committed by GitHub
parent 3d326b0f61
commit 4cfd8884fe
2 changed files with 7 additions and 5 deletions

View File

@ -193,9 +193,11 @@ DomEvent createDomEvent(String type, String name) {
return event;
}
@JS()
@JS('ProgressEvent')
@staticInterop
class DomProgressEvent extends DomEvent {}
class DomProgressEvent extends DomEvent {
external factory DomProgressEvent(String type);
}
extension DomProgressEventExtension on DomProgressEvent {
external double? get loaded;

View File

@ -229,7 +229,7 @@ void _testForImageCodecs({required bool useBrowserImageDecoder}) {
final Future<ui.Codec> futureCodec =
skiaInstantiateWebImageCodec('http://image-server.com/picture.jpg',
null);
mock.sendEvent('load', DomProgressEvent());
mock.sendEvent('load', DomProgressEvent('test progress event'));
final ui.Codec codec = await futureCodec;
expect(codec.frameCount, 1);
final ui.Image image = (await codec.getNextFrame()).image;
@ -277,7 +277,7 @@ void _testForImageCodecs({required bool useBrowserImageDecoder}) {
try {
final Future<ui.Codec> futureCodec = skiaInstantiateWebImageCodec(
'url-does-not-matter', null);
mock.sendEvent('error', DomProgressEvent());
mock.sendEvent('error', DomProgressEvent('test error'));
await futureCodec;
fail('Expected to throw');
} on ImageCodecException catch (exception) {
@ -317,7 +317,7 @@ void _testForImageCodecs({required bool useBrowserImageDecoder}) {
try {
final Future<ui.Codec> futureCodec = skiaInstantiateWebImageCodec(
'http://image-server.com/picture.jpg', null);
mock.sendEvent('load', DomProgressEvent());
mock.sendEvent('load', DomProgressEvent('test progress event'));
await futureCodec;
fail('Expected to throw');
} on ImageCodecException catch (exception) {