2023-06-10 23:55:42 +00:00
|
|
|
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
|
|
|
|
2023-06-10 23:55:42 +00:00
|
|
|
skippableTestWidgets('Content Blocker', (WidgetTester tester) async {
|
2023-11-23 15:01:14 +00:00
|
|
|
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
|
|
|
}
|