From ad6f346f5f774a1bd7e437e1c34fe09701cea3c6 Mon Sep 17 00:00:00 2001 From: Mouad Debbar Date: Fri, 26 May 2023 16:16:59 -0400 Subject: [PATCH] [web] Correct JS property name for baseUri (flutter/engine#42357) Up to this point, whenever users use the `PathUrlStrategy`, they would be using `flutter_web_plugins`'s copy of `BrowserPlatformLocation` which has a [different implementation for `getBaseHref()`](https://github.com/flutter/flutter/blob/9376a2ac6003740c357688a376870dbe84a88883/packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart#L235). So we never hit the [implementation in the engine](https://github.com/flutter/engine/blob/d73aac24349344007f1ae95053ad75d7ffdb18cf/lib/web_ui/lib/ui_web/src/ui_web/navigation/platform_location.dart#L138), meaning the bug was invisible. Now that we are [removing](https://github.com/flutter/flutter/pull/126851) `BrowserPlatformLocation` from `flutter_web_plugins`, we are hitting the engine's implementation which contains the bug being solved in this PR. --- engine/src/flutter/lib/web_ui/lib/src/engine/dom.dart | 2 +- engine/src/flutter/lib/web_ui/test/engine/history_test.dart | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/dom.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/dom.dart index 44f943ed05..4a5ad17889 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/dom.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/dom.dart @@ -440,7 +440,7 @@ extension DomProgressEventExtension on DomProgressEvent { class DomNode extends DomEventTarget {} extension DomNodeExtension on DomNode { - @JS('baseUri') + @JS('baseURI') external JSString? get _baseUri; String? get baseUri => _baseUri?.toDart; diff --git a/engine/src/flutter/lib/web_ui/test/engine/history_test.dart b/engine/src/flutter/lib/web_ui/test/engine/history_test.dart index f92ed5dc8c..9cba044620 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/history_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/history_test.dart @@ -717,6 +717,11 @@ void testMain() { // A listener that was never added. expect(() => location.removePopStateListener(myNonAddedListener), throwsAssertionError); }); + + test('returns a non-empty baseUri', () { + const BrowserPlatformLocation location = BrowserPlatformLocation(); + expect(location.getBaseHref(), isNotNull); + }); }); }