[web] Add JS type test for JsStrategy. (flutter/engine#39765)
This commit is contained in:
@@ -273,8 +273,18 @@ Future<void> _downloadAssetFonts() async {
|
||||
|
||||
void _addUrlStrategyListener() {
|
||||
jsSetUrlStrategy = allowInterop((JsUrlStrategy? jsStrategy) {
|
||||
customUrlStrategy =
|
||||
jsStrategy == null ? null : CustomUrlStrategy.fromJs(jsStrategy);
|
||||
if (jsStrategy == null) {
|
||||
customUrlStrategy = null;
|
||||
} else {
|
||||
// Because `JSStrategy` could be anything, we check for the
|
||||
// `addPopStateListener` property and throw if it is missing.
|
||||
if (!hasJsProperty(jsStrategy, 'addPopStateListener')) {
|
||||
throw StateError(
|
||||
'Unexpected JsUrlStrategy: $jsStrategy is missing '
|
||||
'`addPopStateListener` property');
|
||||
}
|
||||
customUrlStrategy = CustomUrlStrategy.fromJs(jsStrategy);
|
||||
}
|
||||
});
|
||||
registerHotRestartListener(() {
|
||||
jsSetUrlStrategy = null;
|
||||
|
||||
@@ -435,6 +435,7 @@ void testMain() {
|
||||
expect(() => jsSetUrlStrategy(123), throwsA(anything));
|
||||
expect(() => jsSetUrlStrategy('foo'), throwsA(anything));
|
||||
expect(() => jsSetUrlStrategy(false), throwsA(anything));
|
||||
expect(() => jsSetUrlStrategy(<Object?>[]), throwsA(anything));
|
||||
});
|
||||
|
||||
test('cannot set url strategy after it is initialized', () async {
|
||||
|
||||
Reference in New Issue
Block a user