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

Unified Diff: tools/testing/dart/browser_controller.dart

Issue 702543006: Improve browser testing scripts to better handle tests that reload themselves. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove debugging code. Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/co19/co19-dartium.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/browser_controller.dart
diff --git a/tools/testing/dart/browser_controller.dart b/tools/testing/dart/browser_controller.dart
index d17612dbbcaa319b3216420f7173e347c8f8cd28..8a57d695c0c761830ea74a3faff33a8e3d869905 100644
--- a/tools/testing/dart/browser_controller.dart
+++ b/tools/testing/dart/browser_controller.dart
@@ -1466,11 +1466,14 @@ class BrowserTestingServer {
var number_of_tests = 0;
var current_id;
var next_id;
- // Describes a state where we are currently fetching the next test
- // from the server. We use this to never double request tasks.
+
+ // Has the test in the current iframe reported that it is done?
var test_completed = true;
+ // Has the test in the current iframe reported that it is started?
+ var test_started = false;
var testing_window;
+ var embedded_iframe_div = document.getElementById('embedded_iframe_div');
var embedded_iframe = document.getElementById('embedded_iframe');
var number_div = document.getElementById('number');
var executing_div = document.getElementById('currently_executing');
@@ -1582,6 +1585,11 @@ class BrowserTestingServer {
} else {
embedded_iframe.onload = null;
}
+ embedded_iframe_div.removeChild(embedded_iframe);
+ embedded_iframe = document.createElement('iframe');
+ embedded_iframe.id = "embedded_iframe";
+ embedded_iframe.style="width:100%;height:100%";
+ embedded_iframe_div.appendChild(embedded_iframe);
embedded_iframe.src = url;
} else {
if (typeof testing_window != 'undefined') {
@@ -1589,6 +1597,8 @@ class BrowserTestingServer {
}
testing_window = window.open(url);
}
+ test_started = false;
+ test_completed = false;
}
window.onerror = function (message, url, lineNumber) {
@@ -1613,8 +1623,14 @@ class BrowserTestingServer {
function reportMessage(msg, isFirstMessage, isStatusUpdate) {
if (isFirstMessage) {
- test_completed = false;
+ if (test_started) {
+ reportMessage(
+ "FAIL: test started more than once (test reloads itself) " +
+ msg, false, false);
+ return;
+ }
current_id = next_id;
+ test_started = true;
contactBrowserController(
'POST', '$startedPath/${browserId}?id=' + current_id,
function () {}, msg, true);
@@ -1666,7 +1682,12 @@ class BrowserTestingServer {
function messageHandler(e) {
var msg = e.data;
if (typeof msg != 'string') return;
-
+ var expectedSource =
+ use_iframe ? embedded_iframe.contentWindow : testing_window;
+ if (e.source != expectedSource) {
+ reportError("Message received from old test window: " + msg);
+ return;
+ }
var parsedData = parseResult(msg);
if (parsedData) {
// Only if the JSON message contains all required parameters,
@@ -1744,7 +1765,7 @@ class BrowserTestingServer {
Currently executing: <span id="currently_executing"></span><br>
Unhandled error: <span id="unhandled_error"></span>
</div>
- <div class="test box">
+ <div id="embedded_iframe_div" class="test box">
<iframe style="width:100%;height:100%;" id="embedded_iframe"></iframe>
</div>
</body>
« no previous file with comments | « tests/co19/co19-dartium.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698