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

Side by Side Diff: tools/testing/dart/browser_controller.dart

Issue 15782006: Allow safari to do pop ups on startup (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 library browser; 4 library browser;
5 5
6 import "dart:async"; 6 import "dart:async";
7 import "dart:core"; 7 import "dart:core";
8 import "dart:io"; 8 import "dart:io";
9 9
10 import 'android.dart'; 10 import 'android.dart';
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 * The binary used to run safari - changing this can be nececcary for 191 * The binary used to run safari - changing this can be nececcary for
192 * testing or using non standard safari installation. 192 * testing or using non standard safari installation.
193 */ 193 */
194 const String binary = "/Applications/Safari.app/Contents/MacOS/Safari"; 194 const String binary = "/Applications/Safari.app/Contents/MacOS/Safari";
195 195
196 /** 196 /**
197 * We get the safari version by parsing a version file 197 * We get the safari version by parsing a version file
198 */ 198 */
199 const String versionFile = "/Applications/Safari.app/Contents/version.plist"; 199 const String versionFile = "/Applications/Safari.app/Contents/version.plist";
200 200
201
202 Future<bool> allowPopUps() {
203 var command = "defaults";
204 var args = ["write", "com.apple.safari",
205 "com.apple.Safari.ContentPageGroupIdentifier." // No ,
kustermann 2013/05/28 15:07:52 What is this "// no," ?
206 "WebKit2JavaScriptCanOpenWindowsAutomatically",
207 "1"];
208 return Process.run(command, args).then((result) {
209 if (result.exitCode != 0) {
210 _logEvent("Could not disable pop-up blocking for safari");
211 return false;
212 }
213 return true;
214 });
215 }
216
201 Future<String> getVersion() { 217 Future<String> getVersion() {
202 /** 218 /**
203 * Example of the file: 219 * Example of the file:
204 * <?xml version="1.0" encoding="UTF-8"?> 220 * <?xml version="1.0" encoding="UTF-8"?>
205 * <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.co m/DTDs/PropertyList-1.0.dtd"> 221 * <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.co m/DTDs/PropertyList-1.0.dtd">
206 * <plist version="1.0"> 222 * <plist version="1.0">
207 * <dict> 223 * <dict>
208 * <key>BuildVersion</key> 224 * <key>BuildVersion</key>
209 * <string>2</string> 225 * <string>2</string>
210 * <key>CFBundleShortVersionString</key> 226 * <key>CFBundleShortVersionString</key>
(...skipping 24 matching lines...) Expand all
235 var file = new File("${path}/launch.html"); 251 var file = new File("${path}/launch.html");
236 var randomFile = file.openSync(FileMode.WRITE); 252 var randomFile = file.openSync(FileMode.WRITE);
237 var content = '<script language="JavaScript">location = "$url"</script>'; 253 var content = '<script language="JavaScript">location = "$url"</script>';
238 randomFile.writeStringSync(content); 254 randomFile.writeStringSync(content);
239 randomFile.close(); 255 randomFile.close();
240 } 256 }
241 257
242 Future<bool> start(String url) { 258 Future<bool> start(String url) {
243 _logEvent("Starting Safari browser on: $url"); 259 _logEvent("Starting Safari browser on: $url");
244 // Get the version and log that. 260 // Get the version and log that.
245 return getVersion().then((version) { 261 return allowPopUps().then((success) {
246 _logEvent("Got version: $version"); 262 if (!success) {
247 var args = ["'$url'"]; 263 return new Future.immediate(false);
248 return new Directory('').createTemp().then((userDir) { 264 }
249 _cleanup = () { userDir.delete(recursive: true); }; 265 return .getVersion().then((version) {
250 » _createLaunchHTML(userDir.path, url); 266 _logEvent("Got version: $version");
251 var args = ["${userDir.path}/launch.html"]; 267 var args = ["'$url'"];
252 return startBrowser(binary, args); 268 return new Directory('').createTemp().then((userDir) {
269 _cleanup = () { userDir.delete(recursive: true); };
270 _createLaunchHTML(userDir.path, url);
271 var args = ["${userDir.path}/launch.html"];
272 return startBrowser(binary, args);
273 });
274 }).catchError((e) {
275 _logEvent("Running $binary --version failed with $e");
276 return false;
253 }); 277 });
254 }).catchError((e) {
255 _logEvent("Running $binary --version failed with $e");
256 return false;
257 }); 278 });
258 } 279 }
259 280
260 String toString() => "Safari"; 281 String toString() => "Safari";
261 } 282 }
262 283
263 284
264 class Chrome extends Browser { 285 class Chrome extends Browser {
265 /** 286 /**
266 * The binary used to run chrome - changing this can be nececcary for 287 * The binary used to run chrome - changing this can be nececcary for
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 </script> 930 </script>
910 </head> 931 </head>
911 <body> 932 <body>
912 Dart test driver, number of tests: <div id="number"></div> 933 Dart test driver, number of tests: <div id="number"></div>
913 </body> 934 </body>
914 </html> 935 </html>
915 """; 936 """;
916 return driverContent; 937 return driverContent;
917 } 938 }
918 } 939 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698