Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web] Respond with null for unimplemented method channels #21423

Merged
merged 1 commit into from
Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions lib/web_ui/lib/src/engine/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -679,14 +679,10 @@ class EngineWindow extends ui.Window {
return;
}

// TODO(flutter_web): Some Flutter widgets send platform messages that we
// don't handle on web. So for now, let's just ignore them. In the future,
// we should consider uncommenting the following "callback(null)" line.

// Passing [null] to [callback] indicates that the platform message isn't
// implemented. Look at [MethodChannel.invokeMethod] to see how [null] is
// handled.
// callback(null);
_replyToPlatformMessage(callback, null);
}

int _getHapticFeedbackDuration(String? type) {
Expand Down
18 changes: 18 additions & 0 deletions lib/web_ui/test/engine/window_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,24 @@ void testMain() {
await completer.future;
});

test('sendPlatformMessage responds even when channel is unknown', () async {
bool responded = false;

final ByteData inputData = ByteData(4);
inputData.setUint32(0, 42);
window.sendPlatformMessage(
'flutter/__unknown__channel__',
null,
(outputData) {
responded = true;
expect(outputData, isNull);
},
);

await Future<void>.delayed(const Duration(milliseconds: 1));
expect(responded, isTrue);
});

test('Window implements locale, locales, and locale change notifications', () async {
// This will count how many times we notified about locale changes.
int localeChangedCount = 0;
Expand Down