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

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

Issue 16848011: Write browser timings on the debug log (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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 var number_of_tests = 0; 867 var number_of_tests = 0;
868 var current_id; 868 var current_id;
869 var last_reported_id; 869 var last_reported_id;
870 var testing_window; 870 var testing_window;
871 // We use this to determine if we did actually get back a start event 871 // We use this to determine if we did actually get back a start event
872 // from the test we just loaded. 872 // from the test we just loaded.
873 var did_start = false; 873 var did_start = false;
874 874
875 var embedded_iframe = document.getElementById('embedded_iframe'); 875 var embedded_iframe = document.getElementById('embedded_iframe');
876 var use_iframe = ${useIframe}; 876 var use_iframe = ${useIframe};
877 var start = new Date();
877 878
878 function newTaskHandler() { 879 function newTaskHandler() {
879 if (this.readyState == this.DONE) { 880 if (this.readyState == this.DONE) {
880 if (this.status == 200) { 881 if (this.status == 200) {
881 if (this.responseText == '$waitSignal') { 882 if (this.responseText == '$waitSignal') {
882 setTimeout(getNextTask, 500); 883 setTimeout(getNextTask, 500);
883 } else if (this.responseText == '$terminateSignal') { 884 } else if (this.responseText == '$terminateSignal') {
884 // Don't do anything, we will be killed shortly. 885 // Don't do anything, we will be killed shortly.
885 } else { 886 } else {
887 var elapsed = new Date() - start;
888 reportError('Done getting task at: ' + elapsed);
886 // TODO(ricow): Do something more clever here. 889 // TODO(ricow): Do something more clever here.
887 if (nextTask != undefined) alert('This is really bad'); 890 if (nextTask != undefined) alert('This is really bad');
888 // The task is send to us as: 891 // The task is send to us as:
889 // URL#ID 892 // URL#ID
890 var split = this.responseText.split('#'); 893 var split = this.responseText.split('#');
891 var nextTask = split[0]; 894 var nextTask = split[0];
892 current_id = split[1]; 895 current_id = split[1];
893 did_start = false; 896 did_start = false;
894 run(nextTask); 897 run(nextTask);
895 } 898 }
896 } else { 899 } else {
897 reportError('Could not contact the server and get a new task'); 900 reportError('Could not contact the server and get a new task');
898 } 901 }
899 } 902 }
900 } 903 }
901 904
902 function getNextTask() { 905 function getNextTask() {
906 var elapsed = new Date() - start;
907 reportError('Getting task at: ' + elapsed);
903 var client = new XMLHttpRequest(); 908 var client = new XMLHttpRequest();
904 client.onreadystatechange = newTaskHandler; 909 client.onreadystatechange = newTaskHandler;
905 client.open('GET', '$nextTestPath/$browserId'); 910 client.open('GET', '$nextTestPath/$browserId');
906 client.send(); 911 client.send();
907 } 912 }
908 913
909 function run(url) { 914 function run(url) {
910 number_of_tests++; 915 number_of_tests++;
911 document.getElementById('number').innerHTML = number_of_tests; 916 document.getElementById('number').innerHTML = number_of_tests;
912 if (use_iframe) { 917 if (use_iframe) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 function reportMessage(msg) { 951 function reportMessage(msg) {
947 if (msg == 'STARTING') { 952 if (msg == 'STARTING') {
948 did_start = true; 953 did_start = true;
949 return; 954 return;
950 } 955 }
951 var client = new XMLHttpRequest(); 956 var client = new XMLHttpRequest();
952 function handleReady() { 957 function handleReady() {
953 if (this.readyState == this.DONE) { 958 if (this.readyState == this.DONE) {
954 if (this.status == 200) { 959 if (this.status == 200) {
955 if (last_reported_id != current_id && did_start) { 960 if (last_reported_id != current_id && did_start) {
961 var elapsed = new Date() - start;
962 reportError('Done sending results at: ' + elapsed);
956 getNextTask(); 963 getNextTask();
957 last_reported_id = current_id; 964 last_reported_id = current_id;
958 } 965 }
959 } else { 966 } else {
960 reportError('Error sending result to server'); 967 reportError('Error sending result to server');
961 } 968 }
962 } 969 }
963 } 970 }
964 client.onreadystatechange = handleReady; 971 client.onreadystatechange = handleReady;
965 // If did_start is false it means that we did actually set the url on 972 // If did_start is false it means that we did actually set the url on
966 // the testing_window, but this is a report left in the event loop or 973 // the testing_window, but this is a report left in the event loop or
967 // a callback because the page did not load yet. 974 // a callback because the page did not load yet.
968 // In both cases this is a double report from the last test. 975 // In both cases this is a double report from the last test.
969 var posting_id = did_start ? current_id : last_reported_id; 976 var posting_id = did_start ? current_id : last_reported_id;
970 client.open('POST', '$reportPath/${browserId}?id=' + posting_id); 977 client.open('POST', '$reportPath/${browserId}?id=' + posting_id);
971 client.setRequestHeader('Content-type', 978 client.setRequestHeader('Content-type',
972 'application/x-www-form-urlencoded'); 979 'application/x-www-form-urlencoded');
973 client.send(msg); 980 client.send(msg);
981 var elapsed = new Date() - start;
982 reportError('Sending results at: ' + elapsed);
974 } 983 }
975 984
976 function messageHandler(e) { 985 function messageHandler(e) {
977 var msg = e.data; 986 var msg = e.data;
978 if (typeof msg != 'string') return; 987 if (typeof msg != 'string') return;
979 reportMessage(msg); 988 reportMessage(msg);
980 } 989 }
981 990
982 window.addEventListener('message', messageHandler, false); 991 window.addEventListener('message', messageHandler, false);
983 waitForDone = false; 992 waitForDone = false;
984 993
985 getNextTask(); 994 getNextTask();
986 } 995 }
987 996
988 </script> 997 </script>
989 </head> 998 </head>
990 <body onload="startTesting()"> 999 <body onload="startTesting()">
991 Dart test driver, number of tests: <div id="number"></div> 1000 Dart test driver, number of tests: <div id="number"></div>
992 <iframe id="embedded_iframe"></iframe> 1001 <iframe id="embedded_iframe"></iframe>
993 </body> 1002 </body>
994 </html> 1003 </html>
995 """; 1004 """;
996 return driverContent; 1005 return driverContent;
997 } 1006 }
998 } 1007 }
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