-
Notifications
You must be signed in to change notification settings - Fork 6k
/
edge.dart
83 lines (66 loc) · 2.23 KB
/
edge.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'package:test_api/src/backend/runtime.dart';
import 'browser.dart';
import 'browser_lock.dart';
import 'browser_process.dart';
import 'common.dart';
import 'edge_installation.dart';
/// Provides an environment for the desktop Microsoft Edge (Chromium-based).
class EdgeEnvironment implements BrowserEnvironment {
@override
final String name = 'Edge';
@override
Future<Browser> launchBrowserInstance(Uri url, {bool debug = false}) async {
return Edge(url);
}
@override
Runtime get packageTestRuntime => Runtime.internetExplorer;
@override
Future<void> prepare() async {
// Edge doesn't need any special prep.
}
@override
Future<void> cleanup() async {}
@override
String get packageTestConfigurationYamlFile => 'dart_test_edge.yaml';
}
/// Runs desktop Edge.
///
/// Most of the communication with the browser is expected to happen via HTTP,
/// so this exposes a bare-bones API. The browser starts as soon as the class is
/// constructed, and is killed when [close] is called.
///
/// Any errors starting or running the process are reported through [onExit].
class Edge extends Browser {
/// Starts a new instance of Safari open to the given [url], which may be a
/// [Uri] or a [String].
factory Edge(Uri url) {
return Edge._(BrowserProcess(() async {
final BrowserInstallation installation = await getEdgeInstallation(
browserLock.edgeLock.launcherVersion,
infoLog: DevNull(),
);
// Debug is not a valid option for Edge. Remove it.
String pathToOpen = url.toString();
if(pathToOpen.contains('debug')) {
final int index = pathToOpen.indexOf('debug');
pathToOpen = pathToOpen.substring(0, index-1);
}
final Process process = await Process.start(
installation.executable,
<String>[pathToOpen,'-k'],
);
return process;
}));
}
Edge._(this._process);
final BrowserProcess _process;
@override
Future<void> get onExit => _process.onExit;
@override
Future<void> close() => _process.close();
}