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

Unified Diff: tools/testing/dart/test_controller.js

Issue 472883002: Test scripts: Detect and report error in accessing window.parent in browser_controller. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/test_controller.js
diff --git a/tools/testing/dart/test_controller.js b/tools/testing/dart/test_controller.js
index dace747fe7fbb57812b55fdb1b55d969c15ab6e9..e952aaffa08f70b636f317474627ab34fe45a4ee 100644
--- a/tools/testing/dart/test_controller.js
+++ b/tools/testing/dart/test_controller.js
@@ -109,16 +109,39 @@ var isContentShell = testRunner;
var waitForDone = false;
+var driverWindowCached = false;
+var driverWindow;
+var reportingDriverWindowError = false;
+
// Returns the driving window object if available
+// This function occasionally returns null instead of the
+// parent on Android content shell, so we cache the value
+// to get a consistent answer.
function getDriverWindow() {
if (window != window.parent) {
// We're running in an iframe.
- return window.parent;
+ result = window.parent;
} else if (window.opener) {
// We were opened by another window.
- return window.opener;
+ result = window.opener;
+ } else {
+ result = null;
+ }
+ if (driverWindowCached) {
+ if (result != driverWindow) {
+ recordEvent('debug', 'Driver windows changed: was null == ' +
+ (driverWindow == null) + ', is null == ' + (result == null));
+ // notifyDone calls back into this function multiple times. Avoid loop.
+ if (!reportingDriverWindowError) {
ricow1 2014/08/14 15:24:10 I assume this is to get us to fail explicitly to d
+ reportingDriverWindowError = true;
+ notifyDone('FAIL');
+ }
+ }
+ } else {
+ driverWindowCached = true;
+ driverWindow = result;
}
- return null;
+ return driverWindow;
}
function usingBrowserController() {
« 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