Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 30 matching lines...) Expand all Loading... | |
| 41 | 41 |
| 42 /** Print everything (stdout, stderr, usageLog) whenever we add to it */ | 42 /** Print everything (stdout, stderr, usageLog) whenever we add to it */ |
| 43 bool debugPrint = false; | 43 bool debugPrint = false; |
| 44 | 44 |
| 45 // This future returns when the process exits. It is also the return value | 45 // This future returns when the process exits. It is also the return value |
| 46 // of close() | 46 // of close() |
| 47 Future done; | 47 Future done; |
| 48 | 48 |
| 49 Browser(); | 49 Browser(); |
| 50 | 50 |
| 51 factory Browser.byName(String name) { | 51 factory Browser.byName(String name, [String binaryLocation]) { |
|
kustermann
2013/09/03 07:35:15
Unused variable!
| |
| 52 if (name == 'ff' || name == 'firefox') { | 52 if (name == 'ff' || name == 'firefox') { |
| 53 return new Firefox(); | 53 return new Firefox(); |
| 54 } else if (name == 'chrome') { | 54 } else if (name == 'chrome') { |
| 55 return new Chrome(); | 55 return new Chrome(); |
| 56 } else if (name == 'safari') { | 56 } else if (name == 'safari') { |
| 57 return new Safari(); | 57 return new Safari(); |
| 58 } else if (name.startsWith('ie')) { | 58 } else if (name.startsWith('ie')) { |
| 59 return new IE(); | 59 return new IE(); |
| 60 } else { | 60 } else { |
| 61 throw "Non supported browser"; | 61 throw "Non supported browser"; |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 /** | 458 /** |
| 459 * The binary used to run firefox - changing this can be nececcary for | 459 * The binary used to run firefox - changing this can be nececcary for |
| 460 * testing or using non standard firefox installation. | 460 * testing or using non standard firefox installation. |
| 461 */ | 461 */ |
| 462 static const String binary = "firefox"; | 462 static const String _binary = "firefox"; |
|
kustermann
2013/09/03 07:35:15
You still use 'binary'!
| |
| 463 | 463 |
| 464 static const String enablePopUp = | 464 static const String enablePopUp = |
| 465 'user_pref("dom.disable_open_during_load", false);'; | 465 'user_pref("dom.disable_open_during_load", false);'; |
| 466 static const String disableDefaultCheck = | 466 static const String disableDefaultCheck = |
| 467 'user_pref("browser.shell.checkDefaultBrowser", false);'; | 467 'user_pref("browser.shell.checkDefaultBrowser", false);'; |
| 468 static const String disableScriptTimeLimit = | 468 static const String disableScriptTimeLimit = |
| 469 'user_pref("dom.max_script_run_time", 0);'; | 469 'user_pref("dom.max_script_run_time", 0);'; |
| 470 | 470 |
| 471 Future _createPreferenceFile(var path) { | 471 Future _createPreferenceFile(var path) { |
| 472 var file = new File("${path.toString()}/user.js"); | 472 var file = new File("${path.toString()}/user.js"); |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 998 function startTesting() { | 998 function startTesting() { |
| 999 var number_of_tests = 0; | 999 var number_of_tests = 0; |
| 1000 var current_id; | 1000 var current_id; |
| 1001 var next_id; | 1001 var next_id; |
| 1002 // Describes a state where we are currently fetching the next test | 1002 // Describes a state where we are currently fetching the next test |
| 1003 // from the server. We use this to never double request tasks. | 1003 // from the server. We use this to never double request tasks. |
| 1004 var test_completed = true; | 1004 var test_completed = true; |
| 1005 var testing_window; | 1005 var testing_window; |
| 1006 | 1006 |
| 1007 var embedded_iframe = document.getElementById('embedded_iframe'); | 1007 var embedded_iframe = document.getElementById('embedded_iframe'); |
| 1008 var number_div = document.getElementById('number'); | |
| 1009 var executing_div = document.getElementById('currently_executing'); | |
| 1010 var error_div = document.getElementById('unhandled_error'); | |
| 1008 var use_iframe = ${useIframe}; | 1011 var use_iframe = ${useIframe}; |
| 1009 var start = new Date(); | 1012 var start = new Date(); |
| 1010 | 1013 |
| 1011 function newTaskHandler() { | 1014 function newTaskHandler() { |
| 1012 if (this.readyState == this.DONE) { | 1015 if (this.readyState == this.DONE) { |
| 1013 if (this.status == 200) { | 1016 if (this.status == 200) { |
| 1014 if (this.responseText == '$waitSignal') { | 1017 if (this.responseText == '$waitSignal') { |
| 1015 setTimeout(getNextTask, 500); | 1018 setTimeout(getNextTask, 500); |
| 1016 } else if (this.responseText == '$terminateSignal') { | 1019 } else if (this.responseText == '$terminateSignal') { |
| 1017 // Don't do anything, we will be killed shortly. | 1020 // Don't do anything, we will be killed shortly. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1047 | 1050 |
| 1048 function getNextTask() { | 1051 function getNextTask() { |
| 1049 // Until we have the next task we set the current_id to a specific | 1052 // Until we have the next task we set the current_id to a specific |
| 1050 // negative value. | 1053 // negative value. |
| 1051 contactBrowserController( | 1054 contactBrowserController( |
| 1052 'GET', '$nextTestPath/$browserId', newTaskHandler, "", false); | 1055 'GET', '$nextTestPath/$browserId', newTaskHandler, "", false); |
| 1053 } | 1056 } |
| 1054 | 1057 |
| 1055 function run(url) { | 1058 function run(url) { |
| 1056 number_of_tests++; | 1059 number_of_tests++; |
| 1057 document.getElementById('number').innerHTML = number_of_tests; | 1060 number_div.innerHTML = number_of_tests; |
| 1061 executing_div.innerHTML = url; | |
| 1058 if (use_iframe) { | 1062 if (use_iframe) { |
| 1059 embedded_iframe.src = url; | 1063 embedded_iframe.src = url; |
| 1060 } else { | 1064 } else { |
| 1061 if (testing_window == undefined) { | 1065 if (testing_window == undefined) { |
| 1062 testing_window = window.open(url); | 1066 testing_window = window.open(url); |
| 1063 } else { | 1067 } else { |
| 1064 testing_window.location = url; | 1068 testing_window.location = url; |
| 1065 } | 1069 } |
| 1066 } | 1070 } |
| 1067 } | 1071 } |
| 1068 | 1072 |
| 1069 window.onerror = function (message, url, lineNumber) { | 1073 window.onerror = function (message, url, lineNumber) { |
| 1070 if (url) { | 1074 if (url) { |
| 1071 reportError(url + ':' + lineNumber + ':' + message); | 1075 reportError(url + ':' + lineNumber + ':' + message); |
| 1072 } else { | 1076 } else { |
| 1073 reportError(message); | 1077 reportError(message); |
| 1074 } | 1078 } |
| 1075 } | 1079 } |
| 1076 | 1080 |
| 1077 function reportError(msg) { | 1081 function reportError(msg) { |
| 1078 function handleReady() { | 1082 function handleReady() { |
| 1079 if (this.readyState == this.DONE && this.status != 200) { | 1083 if (this.readyState == this.DONE && this.status != 200) { |
| 1080 // We could not report, pop up to notify if running interactively. | 1084 var error = 'Sending back error did not succeeed: ' + this.status; |
| 1081 alert(this.status); | 1085 error = error + '. Failed to send msg: ' + msg; |
| 1086 error_div.innerHTML = error; | |
| 1082 } | 1087 } |
| 1083 } | 1088 } |
| 1084 contactBrowserController( | 1089 contactBrowserController( |
| 1085 'POST', '$errorReportingUrl?test=1', handleReady, msg, true); | 1090 'POST', '$errorReportingUrl?test=1', handleReady, msg, true); |
| 1086 } | 1091 } |
| 1087 | 1092 |
| 1088 function reportMessage(msg) { | 1093 function reportMessage(msg) { |
| 1089 if (msg == 'STARTING') { | 1094 if (msg == 'STARTING') { |
| 1090 test_completed = false; | 1095 test_completed = false; |
| 1091 current_id = next_id; | 1096 current_id = next_id; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1122 | 1127 |
| 1123 window.addEventListener('message', messageHandler, false); | 1128 window.addEventListener('message', messageHandler, false); |
| 1124 waitForDone = false; | 1129 waitForDone = false; |
| 1125 | 1130 |
| 1126 getNextTask(); | 1131 getNextTask(); |
| 1127 } | 1132 } |
| 1128 | 1133 |
| 1129 </script> | 1134 </script> |
| 1130 </head> | 1135 </head> |
| 1131 <body onload="startTesting()"> | 1136 <body onload="startTesting()"> |
| 1132 Dart test driver, number of tests: <div id="number"></div> | 1137 Dart test driver, number of tests: <div id="number"></div><br> |
| 1138 Currently executing: <div id="currently_executing"></div><br> | |
| 1139 Unhandled error: <div id="unhandled_error"></div> | |
| 1133 <iframe id="embedded_iframe"></iframe> | 1140 <iframe id="embedded_iframe"></iframe> |
| 1134 </body> | 1141 </body> |
| 1135 </html> | 1142 </html> |
| 1136 """; | 1143 """; |
| 1137 return driverContent; | 1144 return driverContent; |
| 1138 } | 1145 } |
| 1139 } | 1146 } |
| OLD | NEW |