make parameter properly respects key-value pairs
diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart
index 8d9301c..ca5cba9 100644
--- a/engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart
+++ b/engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart
@@ -56,14 +56,21 @@
}
/// Checks if the given URI contains the flutter-semantics query parameter.
- /// If present, enables semantics. This allows automation testing tools to
- /// enable semantics without modifying the app.
+ /// If present and not explicitly set to false, enables semantics. This allows
+ /// automation testing tools to enable semantics without modifying the app.
+ ///
+ /// Accepted values:
+ /// - `?flutter-semantics` or `?flutter-semantics=true` → enables
+ /// - `?flutter-semantics=false` → does not enable
///
/// This method is separated for testing purposes.
@visibleForTesting
void checkUriForSemanticsParameter(Uri uri) {
- if (uri.queryParameters.containsKey('flutter-semantics')) {
- EngineSemantics.instance.semanticsEnabled = true;
+ final String? value = uri.queryParameters['flutter-semantics'];
+ if (value != null) {
+ if (value.toLowerCase() != 'false') {
+ EngineSemantics.instance.semanticsEnabled = true;
+ }
}
}
diff --git a/engine/src/flutter/lib/web_ui/test/engine/platform_dispatcher/platform_dispatcher_test.dart b/engine/src/flutter/lib/web_ui/test/engine/platform_dispatcher/platform_dispatcher_test.dart
index 702e962..10a07fb 100644
--- a/engine/src/flutter/lib/web_ui/test/engine/platform_dispatcher/platform_dispatcher_test.dart
+++ b/engine/src/flutter/lib/web_ui/test/engine/platform_dispatcher/platform_dispatcher_test.dart
@@ -420,6 +420,24 @@
expect(semantics().semanticsEnabled, isTrue);
});
+ test('query parameter enables semantics when set to true', () {
+ semantics().semanticsEnabled = false;
+ final Uri uriWithTrue = Uri.parse('https://example.com/?flutter-semantics=true');
+
+ dispatcher.checkUriForSemanticsParameter(uriWithTrue);
+
+ expect(semantics().semanticsEnabled, isTrue);
+ });
+
+ test('query parameter does not enable semantics when set to false', () {
+ semantics().semanticsEnabled = false;
+ final Uri uriWithFalse = Uri.parse('https://example.com/?flutter-semantics=false');
+
+ dispatcher.checkUriForSemanticsParameter(uriWithFalse);
+
+ expect(semantics().semanticsEnabled, isFalse);
+ });
+
test('query parameter does not enable semantics when absent', () {
semantics().semanticsEnabled = false;
final Uri uriWithoutParameter = Uri.parse('https://example.com/');