Skip to content

Commit 2567fd6

Browse files
authored
Switch to headless Chrome on bots (#225)
* Use headless Chrome This fixes an issue on Linux where Chrome silently fails to start. * Use Headless Chrome by default
1 parent 032c04e commit 2567fd6

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎packages/devtools/test/integration_tests/integration.dart‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@ class BrowserTabInstance {
206206
}
207207

208208
Future<void> close() async {
209-
await tab.wipConnection.target.closeTarget(tab.wipTab.id);
209+
// In Headless Chrome, we get Inspector.detached when we close the last
210+
// target rather than a response.
211+
await Future.any(<Future<Object>>[
212+
tab.wipConnection.onNotification
213+
.firstWhere((n) => n.method == 'Inspector.detached'),
214+
tab.wipConnection.target.closeTarget(tab.wipTab.id),
215+
]);
210216
}
211217

212218
void _handleBrowserMessage(Map<dynamic, dynamic> message) {

‎packages/devtools/test/support/chrome.dart‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'
1313
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'
1414
as wip show ChromeTab;
1515

16+
// Change this if you want to be able to see Chrome opening while tests run
17+
// to aid debugging.
18+
const _useChromeHeadless = true;
19+
1620
class Chrome {
1721
factory Chrome.from(String executable) {
1822
return FileSystemEntity.isFileSync(executable)
@@ -66,6 +70,13 @@ class Chrome {
6670
'--user-data-dir=${getCreateChromeDataDir()}',
6771
'--remote-debugging-port=$debugPort'
6872
];
73+
if (_useChromeHeadless) {
74+
args.addAll(<String>[
75+
'--headless',
76+
'--disable-gpu',
77+
'--no-sandbox',
78+
]);
79+
}
6980
if (url != null) {
7081
args.add(url);
7182
}
@@ -207,7 +218,7 @@ class ChromeTab {
207218
}
208219

209220
Future<String> createNewTarget() {
210-
return _wip.target.createTarget('');
221+
return _wip.target.createTarget('about:blank');
211222
}
212223

213224
bool get isConnected => _wip != null;

0 commit comments

Comments
 (0)