iosWebViewFix/example/integration_test/in_app_webview/content_blocker.dart

46 lines
1.5 KiB
Dart
Raw Normal View History

part of 'main.dart';
2022-04-28 17:29:01 +00:00
void contentBlocker() {
2022-04-29 11:39:28 +00:00
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
2022-04-28 17:29:01 +00:00
skippableTestWidgets('Content Blocker', (WidgetTester tester) async {
final Completer<InAppWebViewController> controllerCompleter =
Completer<InAppWebViewController>();
2022-04-28 17:29:01 +00:00
final Completer<void> pageLoaded = Completer<void>();
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: InAppWebView(
key: GlobalKey(),
2022-04-29 11:39:28 +00:00
initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1),
2022-04-28 17:29:01 +00:00
onWebViewCreated: (controller) {
controllerCompleter.complete(controller);
},
2022-04-29 11:39:28 +00:00
initialSettings:
InAppWebViewSettings(clearCache: true, contentBlockers: [
ContentBlocker(
trigger: ContentBlockerTrigger(urlFilter: ".*", resourceType: [
ContentBlockerTriggerResourceType.IMAGE,
ContentBlockerTriggerResourceType.STYLE_SHEET
], ifTopUrl: [
TEST_CROSS_PLATFORM_URL_1.toString()
]),
action:
ContentBlockerAction(type: ContentBlockerActionType.BLOCK))
]),
2022-04-28 17:29:01 +00:00
onLoadStop: (controller, url) {
pageLoaded.complete();
},
),
),
);
await expectLater(pageLoaded.future, completes);
}, skip: shouldSkip);
2022-04-29 11:39:28 +00:00
}