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

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

Issue 22420002: Add support for ie in the browser controller (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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
« tools/test.dart ('K') | « tools/test.dart ('k') | 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 Browser(); 48 Browser();
49 49
50 factory Browser.byName(String name) { 50 factory Browser.byName(String name) {
51 if (name == 'ff' || name == 'firefox') { 51 if (name == 'ff' || name == 'firefox') {
52 return new Firefox(); 52 return new Firefox();
53 } else if (name == 'chrome') { 53 } else if (name == 'chrome') {
54 return new Chrome(); 54 return new Chrome();
55 } else if (name == 'safari') { 55 } else if (name == 'safari') {
56 return new Safari(); 56 return new Safari();
57 } else if (name.startsWith('ie')) {
58 return new IE();
57 } else { 59 } else {
58 throw "Non supported browser"; 60 throw "Non supported browser";
59 } 61 }
60 } 62 }
61 63
62 static const List<String> SUPPORTED_BROWSERS = 64 static const List<String> SUPPORTED_BROWSERS =
63 const ['safari', 'ff', 'firefox', 'chrome']; 65 const ['safari', 'ff', 'firefox', 'chrome'];
64 66
65 static const List<String> BROWSERS_WITH_WINDOW_SUPPORT = 67 static const List<String> BROWSERS_WITH_WINDOW_SUPPORT =
66 const ['safari', 'ff', 'firefox', 'chrome']; 68 const ['safari', 'ff', 'firefox', 'chrome'];
67 69
kustermann 2013/08/06 13:58:45 Please add 'ie9' and/or 'ie10' to the list dependi
ricow1 2013/08/13 06:42:43 Done.
68 // TODO(kustermann): add standard support for chrome on android 70 // TODO(kustermann): add standard support for chrome on android
69 static bool supportedBrowser(String name) { 71 static bool supportedBrowser(String name) {
70 return SUPPORTED_BROWSERS.contains(name); 72 return SUPPORTED_BROWSERS.contains(name);
71 } 73 }
72 74
73 void _logEvent(String event) { 75 void _logEvent(String event) {
74 String toLog = "$this ($id) - $event \n"; 76 String toLog = "$this ($id) - $event \n";
75 if (debugPrint) print("usageLog: $toLog"); 77 if (debugPrint) print("usageLog: $toLog");
76 if (logger != null) logger(toLog); 78 if (logger != null) logger(toLog);
77 _usageLog.write(toLog); 79 _usageLog.write(toLog);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 }); 342 });
341 }).catchError((e) { 343 }).catchError((e) {
342 _logEvent("Running $binary --version failed with $e"); 344 _logEvent("Running $binary --version failed with $e");
343 return false; 345 return false;
344 }); 346 });
345 } 347 }
346 348
347 String toString() => "Chrome"; 349 String toString() => "Chrome";
348 } 350 }
349 351
352 class IE extends Browser {
353
354 static const String binary =
355 "c:\\Program Files\\Internet Explorer\\iexplore.exe";
kustermann 2013/08/06 13:58:45 Is that path the same on our bots?
ricow1 2013/08/13 06:42:43 Yes, and filed: dartbug.com/12409
356
357 Future<String> getVersion() {
358 var args = ["query",
359 "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer",
360 "/v",
361 "version"];
362 return Process.run("reg", args).then((result) {
363 if (result.exitCode == 0) {
364 // The string we get back looks like this:
365 // HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer
366 // version REG_SZ 9.0.8112.16421
367 var findString = "REG_SZ";
368 var index = result.stdout.indexOf("REG_SZ");
kustermann 2013/08/06 13:58:45 use 'findString' instead of "REG_SZ"
ricow1 2013/08/13 06:42:43 Done.
369 if (index > 0) {
370 return result.stdout.substring(index + findString.length).trim();
371 }
372 }
373 return "Could not get the version of internet explorer";
374 });
375 }
376
377
378 Future<bool> start(String url) {
379 _logEvent("Starting ie browser on: $url");
380 // Get the version and log that.
381 return getVersion().then((version) {
382 _logEvent("Got version: $version");
383 return startBrowser(binary, [url]);
384 });
385 }
386 String toString() => "IE";
387 }
388
389
350 class AndroidChrome extends Browser { 390 class AndroidChrome extends Browser {
351 static const String viewAction = 'android.intent.action.VIEW'; 391 static const String viewAction = 'android.intent.action.VIEW';
352 static const String mainAction = 'android.intent.action.MAIN'; 392 static const String mainAction = 'android.intent.action.MAIN';
353 static const String chromePackage = 'com.android.chrome'; 393 static const String chromePackage = 'com.android.chrome';
354 static const String browserPackage = 'com.android.browser'; 394 static const String browserPackage = 'com.android.browser';
355 static const String firefoxPackage = 'org.mozilla.firefox'; 395 static const String firefoxPackage = 'org.mozilla.firefox';
356 static const String turnScreenOnPackage = 'com.google.dart.turnscreenon'; 396 static const String turnScreenOnPackage = 'com.google.dart.turnscreenon';
357 397
358 AndroidEmulator _emulator; 398 AndroidEmulator _emulator;
359 AdbDevice _adbDevice; 399 AdbDevice _adbDevice;
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 837
798 BrowserTestingServer(this.local_ip, this.useIframe); 838 BrowserTestingServer(this.local_ip, this.useIframe);
799 839
800 Future start() { 840 Future start() {
801 return HttpServer.bind(local_ip, 0).then((createdServer) { 841 return HttpServer.bind(local_ip, 0).then((createdServer) {
802 httpServer = createdServer; 842 httpServer = createdServer;
803 void handler(HttpRequest request) { 843 void handler(HttpRequest request) {
804 DebugLogger.info("Handling request to: ${request.uri.path}"); 844 DebugLogger.info("Handling request to: ${request.uri.path}");
805 if (request.uri.path.startsWith(reportPath)) { 845 if (request.uri.path.startsWith(reportPath)) {
806 var browserId = request.uri.path.substring(reportPath.length + 1); 846 var browserId = request.uri.path.substring(reportPath.length + 1);
807 var testId = 847 var testId =
808 int.parse(request.uri.queryParameters["id"].split("=")[1]); 848 int.parse(request.uri.queryParameters["id"].split("=")[1]);
809 handleReport(request, browserId, testId); 849 handleReport(request, browserId, testId);
810 // handleReport will asynchroniously fetch the data and will handle 850 // handleReport will asynchroniously fetch the data and will handle
811 // the closing of the streams. 851 // the closing of the streams.
812 return; 852 return;
813 } 853 }
814 var textResponse = ""; 854 var textResponse = "";
815 if (request.uri.path.startsWith(driverPath)) { 855 if (request.uri.path.startsWith(driverPath)) {
816 var browserId = request.uri.path.substring(driverPath.length + 1); 856 var browserId = request.uri.path.substring(driverPath.length + 1);
817 textResponse = getDriverPage(browserId); 857 textResponse = getDriverPage(browserId);
818 } else if (request.uri.path.startsWith(nextTestPath)) { 858 } else if (request.uri.path.startsWith(nextTestPath)) {
819 var browserId = request.uri.path.substring(nextTestPath.length + 1); 859 var browserId = request.uri.path.substring(nextTestPath.length + 1);
820 textResponse = getNextTest(browserId); 860 textResponse = getNextTest(browserId);
821 } else { 861 } else {
822 DebugLogger.info("Handling non standard request to: " 862 DebugLogger.info("Handling non standard request to: "
823 "${request.uri.path}"); 863 "${request.uri.path}");
824 } 864 }
865 request.response.headers.set("Cache-Control",
866 "no-cache, no-store, must-revalidate");
867 request.response.headers.set("Pragma", "no-cache");
kustermann 2013/08/06 13:58:45 Why do we need Pragma,Expires in addition to Cache
ricow1 2013/08/13 06:42:43 That is only if we want to support 1.0 clients. I
868 request.response.headers.set("Expires", "0");
825 request.response.write(textResponse); 869 request.response.write(textResponse);
826 request.listen((_) {}, onDone: request.response.close); 870 request.listen((_) {}, onDone: request.response.close);
827 request.response.done.then((_) { 871 request.response.done.then((_) {
828 DebugLogger.info("Done handling request to: ${request.uri.path}"); 872 DebugLogger.info("Done handling request to: ${request.uri.path}");
829 }).catchError((error) { 873 }).catchError((error) {
830 if (!underTermination) { 874 if (!underTermination) {
831 print("URI ${request.uri}"); 875 print("URI ${request.uri}");
832 print("Textresponse $textResponse"); 876 print("Textresponse $textResponse");
833 throw "Error returning content to browser: $error"; 877 throw "Error returning content to browser: $error";
834 } 878 }
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 </head> 1093 </head>
1050 <body onload="startTesting()"> 1094 <body onload="startTesting()">
1051 Dart test driver, number of tests: <div id="number"></div> 1095 Dart test driver, number of tests: <div id="number"></div>
1052 <iframe id="embedded_iframe"></iframe> 1096 <iframe id="embedded_iframe"></iframe>
1053 </body> 1097 </body>
1054 </html> 1098 </html>
1055 """; 1099 """;
1056 return driverContent; 1100 return driverContent;
1057 } 1101 }
1058 } 1102 }
OLDNEW
« tools/test.dart ('K') | « tools/test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698