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

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

Issue 23679006: Add support for firefox on windows to the browser controller (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | 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:convert" show LineSplitter, UTF8; 7 import "dart:convert" show LineSplitter, UTF8;
8 import "dart:core"; 8 import "dart:core";
9 import "dart:io"; 9 import "dart:io";
10 10
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 return _adbDevice.killAll().then((_) => true); 448 return _adbDevice.killAll().then((_) => true);
449 }); 449 });
450 } 450 }
451 return new Future.value(true); 451 return new Future.value(true);
452 } 452 }
453 453
454 String toString() => "chromeOnAndroid"; 454 String toString() => "chromeOnAndroid";
455 } 455 }
456 456
457 class Firefox extends Browser { 457 class Firefox extends Browser {
458 /**
459 * The binary used to run firefox - changing this can be nececcary for
460 * testing or using non standard firefox installation.
461 */
462 static const String binary = "firefox";
463
464 static const String enablePopUp = 458 static const String enablePopUp =
465 'user_pref("dom.disable_open_during_load", false);'; 459 'user_pref("dom.disable_open_during_load", false);';
466 static const String disableDefaultCheck = 460 static const String disableDefaultCheck =
467 'user_pref("browser.shell.checkDefaultBrowser", false);'; 461 'user_pref("browser.shell.checkDefaultBrowser", false);';
468 static const String disableScriptTimeLimit = 462 static const String disableScriptTimeLimit =
469 'user_pref("dom.max_script_run_time", 0);'; 463 'user_pref("dom.max_script_run_time", 0);';
470 464
465 static string _binary = _getBinary();
466
471 Future _createPreferenceFile(var path) { 467 Future _createPreferenceFile(var path) {
472 var file = new File("${path.toString()}/user.js"); 468 var file = new File("${path.toString()}/user.js");
473 var randomFile = file.openSync(mode: FileMode.WRITE); 469 var randomFile = file.openSync(mode: FileMode.WRITE);
474 randomFile.writeStringSync(enablePopUp); 470 randomFile.writeStringSync(enablePopUp);
475 randomFile.writeStringSync(disableDefaultCheck); 471 randomFile.writeStringSync(disableDefaultCheck);
476 randomFile.writeStringSync(disableScriptTimeLimit); 472 randomFile.writeStringSync(disableScriptTimeLimit);
477 randomFile.close(); 473 randomFile.close();
478 } 474 }
479 475
476 // This is extracted to a function since we may need to support several
477 // locations.
478 static String _getWindowsBinary() {
479 return "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe";
480 }
481
482 static String _getBinary() {
483 if (Platform.isWindows) return _getWindowsBinary();
484 if (Platform.isLinux) return 'firefox';
485 }
486
480 487
481 Future<bool> start(String url) { 488 Future<bool> start(String url) {
482 _logEvent("Starting firefox browser on: $url"); 489 _logEvent("Starting firefox browser on: $url");
483 // Get the version and log that. 490 // Get the version and log that.
484 return Process.run(binary, ["--version"]).then((var versionResult) { 491 return Process.run(_binary, ["--version"]).then((var versionResult) {
485 if (versionResult.exitCode != 0) { 492 if (versionResult.exitCode != 0) {
486 _logEvent("Failed to firefox get version"); 493 _logEvent("Failed to firefox get version");
487 _logEvent("Make sure $binary is a valid program for running firefox"); 494 _logEvent("Make sure $binary is a valid program for running firefox");
488 return new Future.value(false); 495 return new Future.value(false);
489 } 496 }
490 version = versionResult.stdout; 497 version = versionResult.stdout;
491 _logEvent("Got version: $version"); 498 _logEvent("Got version: $version");
492 499
493 return new Directory('').createTemp().then((userDir) { 500 return new Directory('').createTemp().then((userDir) {
494 _createPreferenceFile(userDir.path); 501 _createPreferenceFile(userDir.path);
495 _cleanup = () { userDir.deleteSync(recursive: true); }; 502 _cleanup = () { userDir.deleteSync(recursive: true); };
496 var args = ["-profile", "${userDir.path}", 503 var args = ["-profile", "${userDir.path}",
497 "-no-remote", "-new-instance", url]; 504 "-no-remote", "-new-instance", url];
498 return startBrowser(binary, args); 505 return startBrowser(_binary, args);
499 506
500 }); 507 });
501 }).catchError((e) { 508 }).catchError((e) {
502 _logEvent("Running $binary --version failed with $e"); 509 _logEvent("Running $binary --version failed with $e");
503 return false; 510 return false;
504 }); 511 });
505 } 512 }
506 513
507 String toString() => "Firefox"; 514 String toString() => "Firefox";
508 } 515 }
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 Dart test driver, number of tests: <div id="number"></div><br> 1144 Dart test driver, number of tests: <div id="number"></div><br>
1138 Currently executing: <div id="currently_executing"></div><br> 1145 Currently executing: <div id="currently_executing"></div><br>
1139 Unhandled error: <div id="unhandled_error"></div> 1146 Unhandled error: <div id="unhandled_error"></div>
1140 <iframe id="embedded_iframe"></iframe> 1147 <iframe id="embedded_iframe"></iframe>
1141 </body> 1148 </body>
1142 </html> 1149 </html>
1143 """; 1150 """;
1144 return driverContent; 1151 return driverContent;
1145 } 1152 }
1146 } 1153 }
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