blob: bf3acc7159400f3b964e8772caf59e60c75dbeef [file] [log] [blame]
// 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 'common.dart';
import 'edge_installation.dart';
/// Provides an environment for the desktop Microsoft Edge (Chromium-based).
class EdgeEnvironment implements BrowserEnvironment {
Browser launchBrowserInstance(Uri url, {bool debug = false}) {
return Edge(url);
Runtime get packageTestRuntime => Runtime.internetExplorer;
Future<void> prepare() async {
// Edge doesn't need any special prep.
ScreenshotManager? getScreenshotManager() => null;
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 {
final String name = 'Edge';
/// 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._(() async {
final BrowserInstallation installation = await getEdgeInstallation(
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(
return process;
Edge._(Future<Process> Function() startBrowser) : super(startBrowser);