|
3 | 3 | // found in the LICENSE file. |
4 | 4 |
|
5 | 5 | import 'dart:async'; |
6 | | -import 'dart:convert'; |
7 | 6 | import 'dart:io'; |
8 | 7 |
|
9 | | -import 'environment.dart'; |
10 | | - |
11 | | -import 'package:path/path.dart' as path; |
12 | | -import 'package:pedantic/pedantic.dart'; |
13 | | - |
14 | | -import 'package:test_core/src/util/io.dart'; // ignore: implementation_imports |
15 | | - |
16 | 8 | import 'browser.dart'; |
17 | 9 | import 'safari_installation.dart'; |
18 | 10 | import 'common.dart'; |
@@ -43,21 +35,22 @@ class Safari extends Browser { |
43 | 35 | infoLog: DevNull(), |
44 | 36 | ); |
45 | 37 |
|
46 | | - // Safari will only open files (not general URLs) via the command-line |
47 | | - // API, so we create a dummy file to redirect it to the page we actually |
48 | | - // want it to load. |
49 | | - final Directory redirectDir = Directory( |
50 | | - path.join(environment.webUiDartToolDir.path), |
51 | | - ); |
52 | | - final redirect = path.join(redirectDir.path, 'redirect.html'); |
53 | | - File(redirect).writeAsStringSync( |
54 | | - '<script>location = ' + jsonEncode(url.toString()) + '</script>'); |
55 | | - |
56 | | - var process = |
57 | | - await Process.start(installation.executable, [redirect] /* args */); |
58 | | - |
59 | | - unawaited(process.exitCode |
60 | | - .then((_) => File(redirect).deleteSync(recursive: true))); |
| 38 | + // In the latest versions of MacOs opening Safari browser with a file brings |
| 39 | + // a popup which halts the test. |
| 40 | + // The following list of arguments needs to be provided to the `open` command |
| 41 | + // to open Safari for a given URL. In summary they provide a new instance |
| 42 | + // to open, that instance to wait for opening the url until Safari launches, |
| 43 | + // provide Safari bundles identifier. |
| 44 | + // The details copied from `man open` on MacOS. |
| 45 | + // TODO(nurhan): https://github.com/flutter/flutter/issues/50809 |
| 46 | + var process = await Process.start(installation.executable, [ |
| 47 | + '-F', // Open a fresh application with no persistant state. |
| 48 | + '-W', // Open to wait until the applications it opens. |
| 49 | + '-n', // Open a new instance of the application. |
| 50 | + '-b', // Specifies the bundle identifier for the application to use. |
| 51 | + 'com.apple.Safari', // Bundle identifier for Safari. |
| 52 | + '${url.toString()}' |
| 53 | + ]); |
61 | 54 |
|
62 | 55 | return process; |
63 | 56 | }); |
|
0 commit comments