-
Notifications
You must be signed in to change notification settings - Fork 3k
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] Migrate to package:web. #6792
Conversation
84dc580
to
143d50f
Compare
packages/webview_flutter/webview_flutter_web/lib/src/http_request_factory.dart
Outdated
Show resolved
Hide resolved
The tests that seem to be failing now are just the ones in the legacy/ folder, that we require to create a mock And these two calls that i do not understand what it is trying to do. packages/packages/webview_flutter/webview_flutter_web/test/legacy/webview_flutter_web_test.dart Line 84 in a598bef
packages/packages/webview_flutter/webview_flutter_web/test/legacy/webview_flutter_web_test.dart Line 178 in a598bef
Legacy tests N-2 are failing due to the
nvm, |
79c0198
to
fa99260
Compare
Thanks for the PR @ThomasAunvik! I'll take a look! (Please take into account that next monday is a holiday in the US, so I won't be able to get to this until next tuesday at the earliest) |
fa99260
to
1fc9f8c
Compare
I have been experimenting with this PR for a few days, and run into the issue that the created <iframe> doesn't have the I think it would make sense to make it possible to specify whether this attribute should be set from Flutter code? |
Looking at the compatability, firefox and safari is not yet supported, but an option to enable it would be beneficial once it is fully supported.
|
In most cases people don't own the sites that they iframe, and it can be very hard to convince a third party to add support for these headers.
I don't see why we would wait. The WASM builds are already only supported in Chromium based browsers. But I also understand if you don't want to add it in this PR :) |
Nevermind i got confused on how the cors weirdness works, as i did pain with it too. It would work on setting credentialless on the iframe. It can be easily done by adding this right after _webWebViewParams.iFrame.setAttribute('credentialless', 'true'); As the current
|
Here is a proposal on how setting the /// Sets the IFrame Credentialless
/// https://developer.mozilla.org/en-US/docs/Web/Security/IFrame_credentialless
void setIFrameCredentialless(bool flag) {
_webWebViewParams.iFrame
.setAttribute('credentialless', flag ? 'true' : 'false');
} And to set it would be as such: if(WebViewPlatform.instance is WebWebViewPlatform) {
WebWebViewController(
const PlatformWebViewControllerCreationParams(),
)
..setIFrameCredentialless(true)
..loadRequest(
LoadRequestParams(
uri: Uri.parse('https://flutter.dev'),
),
))
}
I have set up a branch for it: https://github.com/ThomasAunvik/flutter-packages/tree/wasmcredentialless Would like feedback. Another issue would be that |
It seems that on other platforms these kind of platform specific parameters are set on the An example from the Webkit impl. Here some boolean parameters like I am by no means well versed in the Flutter codebase, but this was just my best effort on some feedback. I will be going on vacation for a week, but will test the new branch when I am back :) |
What's the status here, friends? |
@ditman would you take a look? |
I have been testing the PR quite a bit, and created this issue because Godot games being loaded in the iframe resulted in an error: flutter/flutter#150119 However since then I have also started getting the error on other sites (for example https://flutter.dev/). It does however work great on a payment site that I use. (reepay.com). I am not sure what properties of the iframe'ed site makes it throw the error. Maybe the error is unrelated to this PR, and probably a bug in the skwasm renderer? |
This is next on my radar, after this lands: |
@ThomasAunvik I've finally had some time to review this! Instead of adding a bunch of comments and back and forth with the code, I just force pushed (please, remember to (TL;DR: I removed the Do you mind to make a quick re-review yourself, ensure that the changes I added make sense, and verify that the plugin still does what you need? Tests seem to be passing, and the example app seems to work as expected, but the more use cases, the merrier! |
packages/webview_flutter/webview_flutter_web/lib/src/http_request_factory.dart
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_web/lib/src/http_request_factory.dart
Outdated
Show resolved
Hide resolved
method: method, | ||
body: sendData?.toJS, | ||
credentials: withCredentials ? 'include' : 'same-origin', | ||
headers: headers.jsify()! as web.HeadersInit, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have support for the JS Map type yet (in JS interop that is), so perhaps we should add a TODO for that? Unless we have a constructor for web.HeadersInit
that takes a Map<String, String>
?
In my opinion we can eventually get rid of the jsify()
in the long run?
Not sure how @ditman feels about doing that, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(@navaronbracke I wrote the .jsify()
bits :P)
Currently HeadersInit
is just an alias of JSObject
.
The init
in JS itself is a vague object-like thing that doesn't have a very specific way of being constructed: Headers
init
parameter:
init
An object containing any HTTP headers that you want to pre-populate your Headers object with. This can be a simple object literal with String values, an array of name-value pairs, where each pair is a 2-element string array; or an existing Headers object. In the last case, the new Headers object copies its data from the existing Headers object.
I'm using the simplest/most legible way I've found so far of creating an object literal of a JS-interop type (a Map<String, Object?>.jsify()! as JsInteropType
). I agree that a more semantic constructor in package:web
could be better, but this way I can use all the power of Dart Maps until the very last moment. /cc @srujzs for The Ultimate Expert Opinion™!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Maybe something with _createObjectLiteral
? source)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add a better constructor here if that's easier to read, but it's not going to do anything more complicated than just jsify
:) e.g.
JSObject.fromMap(Map m) => m.jsify() as JSObject;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srujzs yeah, I'd like to have a jsify
in non-nullable-object so I don't have to Map.jsify()!
and maybe a T jsifyAs<T>()
that does the casting for me, so I could replace:
headers.jsify()! as web.HeadersInit
by
headers.jsifyAs<web.HeadersInit>();
(Not that it saves too much typing, though)
Co-authored-by: Navaron Bracke <[email protected]>
Just verified in CI that this package enables the
If this works for @ThomasAunvik, I think it's ready to land! |
Works as expected. Experiencing an issue when re-opening the iframe (and be using the same pdf blob data / url), iframe doesn't render properly, showing nothing just the background of the parent widget, until resizing the window. (on wasm only). |
Created a reproducible example: ThomasAunvik/flutter_webview_wasm_error@f75fddb Seems like this time I managed to make the iframe not appear at all when using Left is wasm on chrome, right is non-wasm using firefox. error.mp4Unless it is an issue with this package alone, i don't see it to be needing to not merge it with this issue, if that is also just a lower level flutter issue. |
@ThomasAunvik I think you've encountered something like this: Platform Views in Wasm have some positioning issues yet (it can also be seen with the default example app, I think) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been here, seen this!
Let's try to autoland the PR! |
auto label is removed for flutter/packages/6792, due to This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.
|
Rerunning failures and adding back auto-submit! |
auto label is removed for flutter/packages/6792, due to This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.
|
flutter/packages@14341d1...ea35fc6 2024-07-10 [email protected] [camera_avfoundation] Adds Swift Package Manager compatibility (flutter/packages#7080) 2024-07-10 [email protected] [webview_flutter_wkwebview] Adds Swift Package Manager compatibility (flutter/packages#7091) 2024-07-10 [email protected] [webview_flutter_web] Migrate to package:web. (flutter/packages#6792) 2024-07-10 [email protected] [camera] Clean up `maxDuration` code (flutter/packages#7039) 2024-07-10 [email protected] Update espresso dependencies (flutter/packages#7048) 2024-07-09 [email protected] [camera] Fix iOS torch mode regression (flutter/packages#7085) 2024-07-09 [email protected] [google_maps_flutter] Convert Obj-C->Dart calls to Pigeon (flutter/packages#7086) 2024-07-09 [email protected] Roll Flutter from fafd67d to 5103d75 (27 revisions) (flutter/packages#7084) 2024-07-09 [email protected] [camera_avfoundation] fix sample times not being numeric after pause/resume. (flutter/packages#6897) 2024-07-09 [email protected] [camera] Convert Windows to Pigeon (flutter/packages#6925) 2024-07-09 [email protected] [camera] Deprecate `maxDuration` in platform interface (flutter/packages#7078) 2024-07-09 [email protected] [google_maps_flutter] Semi-convert remaining iOS host API calls to Pigeon (flutter/packages#7079) 2024-07-09 [email protected] [path_provider] Remove `win32` (flutter/packages#7073) 2024-07-08 [email protected] [google_maps_flutter] Move iOS inspector to Pigeon (flutter/packages#6937) 2024-07-08 49699333+dependabot[bot]@users.noreply.github.com [camera]: Bump com.android.tools.build:gradle from 7.3.0 to 8.5.0 in /packages/camera/camera_android_camerax/android (flutter/packages#7072) 2024-07-08 49699333+dependabot[bot]@users.noreply.github.com [local_auth]: Bump com.android.tools.build:gradle from 7.3.1 to 8.5.0 in /packages/local_auth/local_auth_android/android (flutter/packages#7069) 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-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
package:web
[webview_flutter] migrate to pkg:web flutter#139749HttpRequestFactory.request
to usepackage:http
BrowserClient
ìndex.html
in the example to useflutter_bootstrap.js
^3.3.0
Would appreciate help with completing the mock tests if in case it does not work.
(I am somehow stuck with 'loading...' when attempting to test with mockito with --platform chrome)
Integration tests from what i was able to test passes.
Migrated to using BrowserClient for web due to issues creating mock tests with
XMLHttpRequest
which is returned frompackage:web
'sHttpRequest.request
following error:Bad state: Interface type 'XMLHttpRequest' which is nether an enum, nor a class, nor a mixin. This case is unknown, please report a bug.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Co-authored-by: David Iglesias [email protected]
Co-authored-by: Navaron Bracke [email protected]