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

Unified Diff: pkg/unittest/lib/test_controller.js

Issue 16050006: Support for running tests in an iframe (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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
Index: pkg/unittest/lib/test_controller.js
diff --git a/pkg/unittest/lib/test_controller.js b/pkg/unittest/lib/test_controller.js
index d8ef908c53c4c2189e938b109af9ed4df03417b6..f3932d3adfbf525823ad54385bb65e9a1a0b7428 100644
--- a/pkg/unittest/lib/test_controller.js
+++ b/pkg/unittest/lib/test_controller.js
@@ -33,9 +33,22 @@ var testRunner = window.testRunner || window.layoutTestController;
var waitForDone = false;
+// Returns the driving window object if available
+function getDriverWindow() {
+ if (window != window.parent) {
+ // We're running in an iframe.
+ return window.parent;
+ } else if (window.opener) {
+ // We were opened by another window.
+ return window.opener;
+ }
+ return null;
+}
+
function notifyStart() {
- if (window.opener) {
- window.opener.postMessage("STARTING", "*");
+ var driver = getDriverWindow();
+ if (driver) {
+ driver.postMessage("STARTING", "*");
}
}
@@ -43,8 +56,9 @@ function notifyDone() {
if (testRunner) testRunner.notifyDone();
// To support in browser launching of tests we post back start and result
// messages to the window.opener.
- if (window.opener) {
- window.opener.postMessage(window.document.body.innerHTML, "*");
+ var driver = getDriverWindow();
+ if (driver) {
+ driver.postMessage(window.document.body.innerHTML, "*");
}
}
« no previous file with comments | « no previous file | tools/testing/dart/browser_controller.dart » ('j') | tools/testing/dart/browser_controller.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698