This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,9 @@ Future<void> initializeEngineUi() async {
229
229
RawKeyboard .initialize (onMacOs: ui_web.browser.operatingSystem == ui_web.OperatingSystem .macOs);
230
230
KeyboardBinding .initInstance ();
231
231
232
+ // Ensures Flutter renders a global "generator" meta-tag.
233
+ ensureMetaTag ('generator' , 'Flutter' );
234
+
232
235
if (! configuration.multiViewEnabled) {
233
236
final EngineFlutterWindow implicitView =
234
237
ensureImplicitViewInitialized (hostElement: configuration.hostElement);
Original file line number Diff line number Diff line change @@ -722,6 +722,19 @@ void setThemeColor(ui.Color? color) {
722
722
}
723
723
}
724
724
725
+ /// Ensure a "meta" tag with [name] and [content] is set on the page.
726
+ void ensureMetaTag (String name, String content) {
727
+ final DomElement ? existingTag =
728
+ domDocument.querySelector ('meta[name=$name ][content=$content ]' );
729
+
730
+ if (existingTag == null ) {
731
+ final DomHTMLMetaElement meta = createDomHTMLMetaElement ()
732
+ ..name = name
733
+ ..content = content;
734
+ domDocument.head! .append (meta);
735
+ }
736
+ }
737
+
725
738
bool ? _ellipseFeatureDetected;
726
739
727
740
/// Draws CanvasElement ellipse with fallback.
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import 'package:js/js_util.dart' as js_util;
8
8
import 'package:test/bootstrap/browser.dart' ;
9
9
import 'package:test/test.dart' ;
10
10
import 'package:ui/src/engine.dart' as engine;
11
+ import 'package:ui/src/engine/dom.dart' ;
11
12
import 'package:ui/ui_web/src/ui_web.dart' as ui_web;
12
13
13
14
@JS ('_flutter' )
@@ -76,6 +77,10 @@ void testMain() {
76
77
// Check that the object we captured is actually a loader
77
78
expect (pluginsRegistered, isTrue, reason: 'Plugins should be immediately registered in autoStart mode.' );
78
79
expect (appRan, isTrue, reason: 'App should run immediately in autoStart mode' );
80
+
81
+ // After starting the engine, the meta-generator tag should be on the page
82
+ final DomElement ? meta = domDocument.querySelector ('meta[name=generator][content=Flutter]' );
83
+ expect (meta, isNotNull, reason: 'The generator meta-tag should be added when Flutter initializes its UI.' );
79
84
});
80
85
81
86
// We cannot test anymore, because by now the engine has registered some stuff that can't be rewound back.
You can’t perform that action at this time.
0 commit comments