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

[webview_flutter_web] Improve support for JavaScript channels #2

Open
wants to merge 3 commits into
base: feat/javascript-channels
Choose a base branch
from

Conversation

Frank3K
Copy link
Collaborator

@Frank3K Frank3K commented Jun 21, 2023

An improvement on #1.

Note: base branch is feat/javascript-channels.

Improvements

Security

Incoming messages from other origins are now ignored, as advised on MDN.

Messages processing in case of multiple webview

Previously, if one created N webviews, each message was being processed N times. This can now be prevented by choosing a unique channel name per webview. From web, messages should be send in a slightly different way.

Before:

	window.parent.postMessage(message, targetOrigin);

New format:

	window.parent.postMessage(
		{
			channel: this.channelName,
			message: message,
		},
		targetOrigin
	);

Frank3K added 2 commits June 21, 2023 12:44
In case multiple webviews were used, messages previously were processed multiple times. This can now be fixed by choosing a unique channel name per webview.
Copy link

@timovandeput timovandeput left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (see one suggestion)

}

// ignore: avoid_dynamic_calls
final String? message = event.data?['message'] as String?;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the explicit variable type, as the compiler can infer it from "as String?".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repo has stricter analysis options; I received a number of warnings otherwise.

Frank3K pushed a commit that referenced this pull request Apr 5, 2024
flutter/flutter@fe0275f...ad20089

2023-10-06 [email protected] Roll Flutter Engine from cc9bc9e2c0d3 to 59b6b94e1a51 (1 revision) (flutter/flutter#136066)
2023-10-06 [email protected] Fix memory leaks in DateRangePickerDialog. (flutter/flutter#136034)
2023-10-06 [email protected] Roll Flutter Engine from 6492e1f8c315 to cc9bc9e2c0d3 (1 revision) (flutter/flutter#136062)
2023-10-06 [email protected] Tiny improve code style by using records instead of lists (flutter/flutter#135886)
2023-10-05 [email protected] Roll Flutter Engine from 27a674466094 to 6492e1f8c315 (1 revision) (flutter/flutter#136052)
2023-10-05 [email protected] Upload frame_request_pending_latency [attempt #2] (flutter/flutter#135890)
2023-10-05 [email protected] Roll Flutter Engine from 0ff05464f42f to 27a674466094 (1 revision) (flutter/flutter#136050)
2023-10-05 [email protected] Roll Flutter Engine from ad83202a59a6 to 0ff05464f42f (1 revision) (flutter/flutter#136047)
2023-10-05 [email protected] Roll Flutter Engine from f8d53c5fe9f2 to ad83202a59a6 (2 revisions) (flutter/flutter#136040)
2023-10-05 [email protected] Roll Packages from d654f75 to 6714d50 (3 revisions) (flutter/flutter#136039)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Frank3K pushed a commit that referenced this pull request Apr 5, 2024
flutter/flutter@5207a30...f52fe4f

2023-10-09 [email protected] [leak-tracking] Add leak tracking in test/painting #2 (flutter/flutter#136169)
2023-10-09 [email protected] Roll Flutter Engine from 2886353ee612 to 664f5e833871 (1 revision) (flutter/flutter#136195)
2023-10-09 [email protected] Fix `flutter drive` instructions in `Macrobenchmark` README (flutter/flutter#135990)
2023-10-09 [email protected] Update `CircleAvatar` & `DataTable` tests for Material 3 (flutter/flutter#135901)
2023-10-09 [email protected] Roll Flutter Engine from 69ffbd18ab5e to 2886353ee612 (1 revision) (flutter/flutter#136187)
2023-10-09 [email protected] Roll Flutter Engine from 53da096c0c38 to 69ffbd18ab5e (2 revisions) (flutter/flutter#136186)
2023-10-09 [email protected] Roll Flutter Engine from e58a9b3c54b6 to 53da096c0c38 (2 revisions) (flutter/flutter#136182)
2023-10-09 [email protected] Update BottomSheet test for M3 + fix an issue in elevation resolution (flutter/flutter#136071)
2023-10-09 [email protected] Roll Flutter Engine from 7b8f5d4297c6 to e58a9b3c54b6 (1 revision) (flutter/flutter#136175)
2023-10-09 [email protected] Roll Flutter Engine from d5485d67b9f9 to 7b8f5d4297c6 (1 revision) (flutter/flutter#136168)
2023-10-08 [email protected] Roll Flutter Engine from 34ffdf06ca93 to d5485d67b9f9 (1 revision) (flutter/flutter#136158)
2023-10-08 [email protected] Roll Flutter Engine from 0785e3c69f7c to 34ffdf06ca93 (1 revision) (flutter/flutter#136156)
2023-10-08 [email protected] Roll Flutter Engine from 03c8c7724873 to 0785e3c69f7c (2 revisions) (flutter/flutter#136150)
2023-10-08 [email protected] Roll Flutter Engine from eb88bb5b5c4b to 03c8c7724873 (1 revision) (flutter/flutter#136147)
2023-10-08 [email protected] Roll Flutter Engine from 46b05f69187d to eb88bb5b5c4b (1 revision) (flutter/flutter#136145)
2023-10-07 [email protected] Roll Flutter Engine from a18c52768bbc to 46b05f69187d (1 revision) (flutter/flutter#136142)
2023-10-07 [email protected] Roll Flutter Engine from 8711c1fd2191 to a18c52768bbc (6 revisions) (flutter/flutter#136141)
2023-10-07 [email protected] Allow leaks around tap down/up, while flackiness is not fixed. (flutter/flutter#136133)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants