Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: mojo/public/dart/third_party/test/lib/src/runner/browser/safari.dart

Issue 1346773002: Stop running pub get at gclient sync time and fix build bugs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.runner.browser.safari;
6
7 import 'dart:async';
8 import 'dart:convert';
9 import 'dart:io';
10
11 import 'package:path/path.dart' as p;
12
13 import '../../util/io.dart';
14 import 'browser.dart';
15
16 /// A class for running an instance of Safari.
17 ///
18 /// Any errors starting or running the process are reported through [onExit].
19 class Safari extends Browser {
20 final name = "Safari";
21
22 Safari(url, {String executable})
23 : super(() => _startBrowser(url, executable));
24
25 /// Starts a new instance of Safari open to the given [url], which may be a
26 /// [Uri] or a [String].
27 ///
28 /// If [executable] is passed, it's used as the content shell executable.
29 /// Otherwise the default executable name for the current OS will be used.
30 static Future<Process> _startBrowser(url, [String executable]) async {
31 if (executable == null) {
32 executable = '/Applications/Safari.app/Contents/MacOS/Safari';
33 }
34
35 var dir = createTempDir();
36
37 // Safari will only open files (not general URLs) via the command-line
38 // API, so we create a dummy file to redirect it to the page we actually
39 // want it to load.
40 var redirect = p.join(dir, 'redirect.html');
41 new File(redirect).writeAsStringSync(
42 "<script>location = " + JSON.encode(url.toString()) + "</script>");
43
44 var process = await Process.start(executable, [redirect]);
45
46 process.exitCode
47 .then((_) => new Directory(dir).deleteSync(recursive: true));
48
49 return process;
50 }
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698