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

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

Issue 107513004: Test infrastructure: add retry to browser controller sending "done" message. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 } 1254 }
1255 } 1255 }
1256 1256
1257 function contactBrowserController(method, 1257 function contactBrowserController(method,
1258 path, 1258 path,
1259 callback, 1259 callback,
1260 msg, 1260 msg,
1261 isUrlEncoded) { 1261 isUrlEncoded) {
1262 var client = new XMLHttpRequest(); 1262 var client = new XMLHttpRequest();
1263 client.onreadystatechange = callback; 1263 client.onreadystatechange = callback;
1264 client.open(method, path); 1264 client.open(method, path);
kustermann 2013/12/06 14:42:58 As discussed offline, if there is a client.onerror
1265 if (isUrlEncoded) { 1265 if (isUrlEncoded) {
1266 client.setRequestHeader('Content-type', 1266 client.setRequestHeader('Content-type',
1267 'application/x-www-form-urlencoded'); 1267 'application/x-www-form-urlencoded');
1268 } 1268 }
1269 client.send(msg); 1269 client.send(msg);
1270 } 1270 }
1271 1271
1272 function getNextTask() { 1272 function getNextTask() {
1273 // Until we have the next task we set the current_id to a specific 1273 // Until we have the next task we set the current_id to a specific
1274 // negative value. 1274 // negative value.
1275 contactBrowserController( 1275 contactBrowserController(
1276 'GET', '$nextTestPath/$browserId', newTaskHandler, "", false); 1276 'GET', '$nextTestPath/$browserId', newTaskHandler, "", false);
1277 } 1277 }
1278 1278
1279 function run(url) { 1279 function run(url) {
1280 number_of_tests++; 1280 number_of_tests++;
1281 number_div.innerHTML = number_of_tests; 1281 number_div.innerHTML = number_of_tests;
1282 executing_div.innerHTML = url; 1282 executing_div.innerHTML = url;
1283 if (use_iframe) { 1283 if (use_iframe) {
1284 embedded_iframe.src = url; 1284 embedded_iframe.src = url;
1285 } else { 1285 } else {
1286 if (testing_window == undefined) { 1286 if (testing_window == undefined) {
(...skipping 14 matching lines...) Expand all
1301 1301
1302 function reportError(msg) { 1302 function reportError(msg) {
1303 function handleReady() { 1303 function handleReady() {
1304 if (this.readyState == this.DONE && this.status != 200) { 1304 if (this.readyState == this.DONE && this.status != 200) {
1305 var error = 'Sending back error did not succeeed: ' + this.status; 1305 var error = 'Sending back error did not succeeed: ' + this.status;
1306 error = error + '. Failed to send msg: ' + msg; 1306 error = error + '. Failed to send msg: ' + msg;
1307 error_div.innerHTML = error; 1307 error_div.innerHTML = error;
1308 } 1308 }
1309 } 1309 }
1310 contactBrowserController( 1310 contactBrowserController(
1311 'POST', '$errorReportingUrl?test=1', handleReady, msg, true); 1311 'POST', '$errorReportingUrl?test=1', handleReady, msg, true);
1312 } 1312 }
1313 1313
1314 function reportMessage(msg, isFirstMessage, isStatusUpdate) { 1314 function reportMessage(msg, isFirstMessage, isStatusUpdate) {
1315 if (isFirstMessage) { 1315 if (isFirstMessage) {
1316 test_completed = false; 1316 test_completed = false;
1317 current_id = next_id; 1317 current_id = next_id;
1318 contactBrowserController( 1318 contactBrowserController(
1319 'POST', '$startedPath/${browserId}?id=' + current_id, 1319 'POST', '$startedPath/${browserId}?id=' + current_id,
1320 function () {}, msg, true); 1320 function () {}, msg, true);
1321 } else if (isStatusUpdate) { 1321 } else if (isStatusUpdate) {
1322 contactBrowserController( 1322 contactBrowserController(
1323 'POST', '$statusUpdatePath/${browserId}?id=' + current_id, 1323 'POST', '$statusUpdatePath/${browserId}?id=' + current_id,
1324 function() {}, msg, true); 1324 function() {}, msg, true);
1325 } else { 1325 } else {
1326 var is_double_report = test_completed; 1326 var is_double_report = test_completed;
1327 var retry = 0;
1327 test_completed = true; 1328 test_completed = true;
1328 1329
1330 function reportDoneMessage() {
1331 contactBrowserController(
1332 'POST', '$reportPath/${browserId}?id=' + current_id,
1333 handleReady, msg, true);
1334 }
1335
1329 function handleReady() { 1336 function handleReady() {
1330 if (this.readyState == this.DONE) { 1337 if (this.readyState == this.DONE) {
1331 if (this.status == 200) { 1338 if (this.status == 200) {
1332 if (!is_double_report) { 1339 if (!is_double_report) {
1333 getNextTask(); 1340 getNextTask();
1334 } 1341 }
1335 } else { 1342 } else {
1336 reportError('Error sending result to server'); 1343 reportError('Error sending result to server. Status: ' +
1344 this.status + ' Retry: ' + retry);
kustermann 2013/12/06 14:42:58 Could you test if this 'reportError()' functionali
1345 retry++;
1346 if (retry < 3) {
1347 setTimeout(reportDoneMessage, 1000);
1348 }
1337 } 1349 }
1338 } 1350 }
1339 } 1351 }
1340 contactBrowserController( 1352
1341 'POST', '$reportPath/${browserId}?id=' + current_id, handleReady, 1353 reportDoneMessage();
1342 msg, true);
1343 } 1354 }
1344 } 1355 }
1345 1356
1346 function parseResult(result) { 1357 function parseResult(result) {
1347 var parsedData = null; 1358 var parsedData = null;
1348 try { 1359 try {
1349 parsedData = JSON.parse(result); 1360 parsedData = JSON.parse(result);
1350 } catch(error) { } 1361 } catch(error) { }
1351 return parsedData; 1362 return parsedData;
1352 } 1363 }
1353 1364
1354 function messageHandler(e) { 1365 function messageHandler(e) {
1355 var msg = e.data; 1366 var msg = e.data;
1356 if (typeof msg != 'string') return; 1367 if (typeof msg != 'string') return;
1357 1368
1358 var parsedData = parseResult(msg); 1369 var parsedData = parseResult(msg);
1359 if (parsedData) { 1370 if (parsedData) {
1360 // Only if the JSON was valid, we'll post it back. 1371 // Only if the JSON was valid, we'll post it back.
1361 var message = parsedData['message']; 1372 var message = parsedData['message'];
1362 var isFirstMessage = parsedData['is_first_message']; 1373 var isFirstMessage = parsedData['is_first_message'];
1363 var isStatusUpdate = parsedData['is_status_update']; 1374 var isStatusUpdate = parsedData['is_status_update'];
1364 var isDone = parsedData['is_done']; 1375 var isDone = parsedData['is_done'];
1365 if (!isFirstMessage && !isStatusUpdate) { 1376 if (!isFirstMessage && !isStatusUpdate) {
1366 if (!isDone) { 1377 if (!isDone) {
1367 alert("Bug in test_controller.js: " + 1378 alert("Bug in test_controller.js: " +
(...skipping 20 matching lines...) Expand all
1388 Dart test driver, number of tests: <div id="number"></div><br> 1399 Dart test driver, number of tests: <div id="number"></div><br>
1389 Currently executing: <div id="currently_executing"></div><br> 1400 Currently executing: <div id="currently_executing"></div><br>
1390 Unhandled error: <div id="unhandled_error"></div> 1401 Unhandled error: <div id="unhandled_error"></div>
1391 <iframe id="embedded_iframe"></iframe> 1402 <iframe id="embedded_iframe"></iframe>
1392 </body> 1403 </body>
1393 </html> 1404 </html>
1394 """; 1405 """;
1395 return driverContent; 1406 return driverContent;
1396 } 1407 }
1397 } 1408 }
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