Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void convertToInAppWebView() {
expect(headlessWebView.isRunning(), true);

final InAppWebViewController controller = await controllerCompleter.future;
await tester.pump();
await pageLoaded.future;

final String? url = (await controller.getUrl())?.toString();
Expand Down Expand Up @@ -55,6 +56,7 @@ void convertToInAppWebView() {
);
final InAppWebViewController widgetController =
await widgetControllerCompleter.future;
await tester.pump();

expect(headlessWebView.isRunning(), false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ void getContentHeight() {
);

final InAppWebViewController controller = await controllerCompleter.future;
await pageLoaded.future;

await tester.pump();
await pageLoaded.future;

final contentHeight = await controller.getContentHeight();
expect(contentHeight, isNonZero);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void getFavicons() {
);

final InAppWebViewController controller = await controllerCompleter.future;
await tester.pump();
await pageLoaded.future;

final List<Favicon>? favicons = await controller.getFavicons();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ void getHtml() {
);

final InAppWebViewController controller = await controllerCompleter.future;
// Platform view creation happens asynchronously.
await tester.pump();
await pageLoaded.future;

final String? html = await controller.getHtml();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void getMetaTags() {
);

final InAppWebViewController controller = await controllerCompleter.future;
await tester.pump();
await pageLoaded.future;

List<MetaTag> metaTags = await controller.getMetaTags();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void getMetaThemeColor() {
);

final InAppWebViewController controller = await controllerCompleter.future;
await tester.pump();
await pageLoaded.future;

expect(await controller.getMetaThemeColor(), isNotNull);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void getOriginalUrl() {
);

final InAppWebViewController controller = await controllerCompleter.future;
await tester.pump();
await pageLoaded.future;
var originUrl = (await controller.getOriginalUrl())?.toString();
expect(originUrl, url.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void getTitle() {
);

final InAppWebViewController controller = await controllerCompleter.future;
await tester.pump();
await pageStarted.future;
await pageLoaded.future;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ void initialUrlRequest() {
),
),
);
// Platform view creation happens asynchronously.
await tester.pump();

await pageLoaded.future;
final InAppWebViewController controller =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void injectCSS() {

final InAppWebViewController controller =
await controllerCompleter.future;
await tester.pump();
await pageLoaded.future;

await controller.injectCSSCode(source: """
Expand Down Expand Up @@ -74,6 +75,7 @@ void injectCSS() {

final InAppWebViewController controller =
await controllerCompleter.future;
await tester.pump();
await pageLoaded.future;

await controller.injectCSSFileFromUrl(
Expand Down Expand Up @@ -110,6 +112,7 @@ void injectCSS() {

final InAppWebViewController controller =
await controllerCompleter.future;
await tester.pump();
await pageLoaded.future;

await controller.injectCSSFileFromAsset(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void injectJavascriptFile() {

final InAppWebViewController controller =
await controllerCompleter.future;
await tester.pump();
await pageLoaded.future;

await controller.injectJavascriptFileFromUrl(
Expand Down Expand Up @@ -97,6 +98,7 @@ void injectJavascriptFile() {

final InAppWebViewController controller =
await controllerCompleter.future;
await tester.pump();
await pageLoaded.future;

await controller.injectJavascriptFileFromAsset(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void isSecureContext() {
);

final InAppWebViewController controller = await controllerCompleter.future;
await tester.pump();
await pageLoads.stream.first;
expect(await controller.isSecureContext(), true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void javascriptCodeEvaluation() {
);
final InAppWebViewController controller =
await controllerCompleter.future;
await tester.pump();
await pageLoaded.future;

var result = await controller.evaluateJavascript(source: """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ void loadData() {
);

final InAppWebViewController controller = await controllerCompleter.future;
// do not wait for pump to not miss the load event
tester.pump();
await pageLoads.stream.first;

final data = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ void loadFile() {
);

final InAppWebViewController controller = await controllerCompleter.future;
// do not wait for pump to not miss the load event
tester.pump();
await pageLoads.stream.first;

await controller.loadFile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void loadUrl() {
),
);
final InAppWebViewController controller = await controllerCompleter.future;
await tester.pump();
expect(await firstUrlLoad.future, initialUrl.toString());

await controller.loadUrl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void onConsoleMessage() {
),
),
);

await tester.pump();
final ConsoleMessage consoleMessage =
await onConsoleMessageCompleter.future;
expect(consoleMessage.message, 'message');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ void onScrollChanged() {
);

final InAppWebViewController controller = await controllerCompleter.future;
await pageLoaded.future;

await tester.pump();
await pageLoaded.future;

controller.scrollTo(x: 0, y: 500);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ void onTitleChanged() {
);

final InAppWebViewController controller = await controllerCompleter.future;
await pageLoaded.future;
await tester.pump();
await pageLoaded.future;
await controller.evaluateJavascript(
source: "document.title = 'title test';");
await expectLater(onTitleChangedCompleter.future, completes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void onUpdateVisitedHistory() {
);

final InAppWebViewController controller = await controllerCompleter.future;
await tester.pump();
await pageLoaded.future;

await controller.evaluateJavascript(source: """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void onWindowBlur() {
),
),
);
await tester.pump();
await expectLater(onWindowBlurCompleter.future, completes);
}, skip: shouldSkip);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void onWindowFocus() {
),
),
);
await tester.pump();
await expectLater(onWindowFocusCompleter.future, completes);
}, skip: shouldSkip);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ void printCurrentPage() {
);

final InAppWebViewController controller = await controllerCompleter.future;
await pageLoaded.future;
await tester.pump();
await pageLoaded.future;
await expectLater(controller.printCurrentPage(), completes);
}, skip: shouldSkip);
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ void programmaticScroll() {

final InAppWebViewController controller =
await controllerCompleter.future;
await pageLoaded.future;

await tester.pump();
await pageLoaded.future;

await controller.scrollTo(x: 0, y: 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ void reload() {
);
final InAppWebViewController controller =
await controllerCompleter.future;
// do not wait for pump to not miss the load event
tester.pump();
String? reloadUrl = await pageLoads.stream.first;
expect(reloadUrl, url.toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ void setGetSettings() {
),
),
);
// Platform view creation happens asynchronously.
await tester.pumpAndSettle();
final InAppWebViewController controller = await controllerCompleter.future;
await pageLoaded.future;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void webViewWindows() {
),
),
);

await tester.pump();
await expectLater(pageLoaded.future, completes);
}, skip: shouldSkipTest1);

Expand Down
10 changes: 7 additions & 3 deletions flutter_inappwebview_web/lib/assets/web/web_support.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
window.flutter_inappwebview = {
webViews: {},
createFlutterInAppWebView: function(viewId, iframeId) {
/**
* @param viewId {number | string}
* @param iframe {HTMLIFrameElement}
* @param iframeContainer {HTMLDivElement}
*/
createFlutterInAppWebView: function(viewId, iframe, iframeContainer) {
const iframeId = iframe.id;
var webView = {
viewId: viewId,
iframeId: iframeId,
Expand All @@ -19,8 +25,6 @@ window.flutter_inappwebview = {
},
prepare: function(settings) {
webView.settings = settings;
var iframe = document.getElementById(iframeId);
var iframeContainer = document.getElementById(iframeId + '-container');

document.addEventListener('fullscreenchange', function(event) {
// document.fullscreenElement will point to the element that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class InAppWebViewWebElement implements Disposable {
bridgeJsObject = js.JsObject.fromBrowserObject(
js.context[WebPlatformManager.BRIDGE_JS_OBJECT_NAME]);
bridgeJsObject['webViews'][_viewId] = bridgeJsObject
.callMethod("createFlutterInAppWebView", [_viewId, iframe.id]);
.callMethod("createFlutterInAppWebView", [_viewId, iframe, iframeContainer]);
}

/// Handles method calls over the MethodChannel of this plugin.
Expand Down Expand Up @@ -203,7 +203,7 @@ class InAppWebViewWebElement implements Disposable {
initialFile = webView.initialFile;

bridgeJsObject['webViews'][_viewId] = bridgeJsObject
.callMethod("createFlutterInAppWebView", [_viewId, iframe.id]);
.callMethod("createFlutterInAppWebView", [_viewId, iframe, iframeContainer]);
}
}
}
Expand Down