diff --git a/packages/flutter_tools/lib/src/web/bootstrap.dart b/packages/flutter_tools/lib/src/web/bootstrap.dart index a232b672be..c3bc6425ed 100644 --- a/packages/flutter_tools/lib/src/web/bootstrap.dart +++ b/packages/flutter_tools/lib/src/web/bootstrap.dart @@ -28,6 +28,7 @@ var styles = ` position: absolute; top: 0px; left: 0px; + overflow: hidden; } .indeterminate { @@ -131,6 +132,10 @@ String generateMainModule({ }) { return ''' /* ENTRYPOINT_EXTENTION_MARKER */ +// Disable require module timeout +require.config({ + waitSeconds: 0 +}); // Create the main module loaded below. define("$bootstrapModule", ["$entrypoint", "dart_sdk"], function(app, dart_sdk) { dart_sdk.dart.setStartAsyncSynchronously(true); diff --git a/packages/flutter_tools/test/general.shard/web/bootstrap_test.dart b/packages/flutter_tools/test/general.shard/web/bootstrap_test.dart index a8881a48bc..757f12c81b 100644 --- a/packages/flutter_tools/test/general.shard/web/bootstrap_test.dart +++ b/packages/flutter_tools/test/general.shard/web/bootstrap_test.dart @@ -21,7 +21,7 @@ void main() { expect(result, contains('requireEl.setAttribute("data-main", "main_module.bootstrap");')); }); -test('generateBootstrapScript includes loading indicator', () { + test('generateBootstrapScript includes loading indicator', () { final String result = generateBootstrapScript( requireUrl: 'require.js', mapperUrl: 'mapper.js', @@ -30,6 +30,36 @@ test('generateBootstrapScript includes loading indicator', () { expect(result, contains('"indeterminate"')); }); + // https://github.com/flutter/flutter/issues/107742 + test('generateBootstrapScript loading indicator does not trigger scrollbars', () { + final String result = generateBootstrapScript( + requireUrl: 'require.js', + mapperUrl: 'mapper.js', + ); + + // See: https://regexr.com/6q0ft + final RegExp regex = RegExp(r'(?:\.flutter-loader\s*\{)[^}]+(?:overflow\:\s*hidden;)[^}]+}'); + + expect(result, matches(regex), reason: '.flutter-loader must have overflow: hidden'); + }); + + // https://github.com/flutter/flutter/issues/82524 + test('generateMainModule removes timeout from requireJS', () { + final String result = generateMainModule( + entrypoint: 'foo/bar/main.js', + nullAssertions: false, + nativeNullAssertions: false, + ); + + // See: https://regexr.com/6q0kp + final RegExp regex = RegExp( + r'(?:require\.config\(\{)(?:.|\s(?!\}\);))*' + r'(?:waitSeconds\:\s*0[,]?)' + r'(?:(?!\}\);).|\s)*\}\);'); + + expect(result, matches(regex), reason: 'require.config must have a waitSeconds: 0 config entry'); + }); + test('generateMainModule embeds urls correctly', () { final String result = generateMainModule( entrypoint: 'foo/bar/main.js',