@@ -128,6 +128,51 @@ void testMain() {
128128 expect (window.browserHistory.urlStrategy.getPath (), '/baz' );
129129 });
130130
131+ test ('initialize browser history with default url strategy (single)' , () async {
132+ // On purpose, we don't initialize history on the window. We want to let the
133+ // window to self-initialize when it receives a navigation message.
134+
135+ Completer <void > callback = Completer <void >();
136+ window.sendPlatformMessage (
137+ 'flutter/navigation' ,
138+ JSONMethodCodec ().encodeMethodCall (MethodCall (
139+ 'routeUpdated' ,
140+ < String , dynamic > {'routeName' : '/bar' },
141+ )),
142+ (_) { callback.complete (); },
143+ );
144+ await callback.future;
145+ expect (window.browserHistory is SingleEntryBrowserHistory , true );
146+ // The url strategy should've been set to the default, and the path
147+ // should've been correctly set to "/bar".
148+ expect (window.browserHistory.urlStrategy, isNot (isNull));
149+ expect (window.browserHistory.urlStrategy.getPath (), '/bar' );
150+ }, skip: browserEngine == BrowserEngine .webkit); // https://github.com/flutter/flutter/issues/50836
151+
152+ test ('initialize browser history with default url strategy (multiple)' , () async {
153+ // On purpose, we don't initialize history on the window. We want to let the
154+ // window to self-initialize when it receives a navigation message.
155+
156+ Completer <void > callback = Completer <void >();
157+ window.sendPlatformMessage (
158+ 'flutter/navigation' ,
159+ JSONMethodCodec ().encodeMethodCall (MethodCall (
160+ 'routeInformationUpdated' ,
161+ < String , dynamic > {
162+ 'location' : '/baz' ,
163+ 'state' : null ,
164+ },
165+ )),
166+ (_) { callback.complete (); },
167+ );
168+ await callback.future;
169+ expect (window.browserHistory is MultiEntriesBrowserHistory , true );
170+ // The url strategy should've been set to the default, and the path
171+ // should've been correctly set to "/baz".
172+ expect (window.browserHistory.urlStrategy, isNot (isNull));
173+ expect (window.browserHistory.urlStrategy.getPath (), '/baz' );
174+ }, skip: browserEngine == BrowserEngine .webkit); // https://github.com/flutter/flutter/issues/50836
175+
131176 test ('can disable location strategy' , () async {
132177 // Disable URL strategy.
133178 expect (() => jsSetUrlStrategy (null ), returnsNormally);
0 commit comments