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

Side by Side 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, 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 | tools/testing/dart/browser_controller.dart » ('j') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 4
5 /** 5 /**
6 * Test controller logic - used by unit test harness to embed tests in 6 * Test controller logic - used by unit test harness to embed tests in
7 * conent shell. 7 * conent shell.
8 */ 8 */
9 9
10 // Clear the console before every test run - this is Firebug specific code. 10 // Clear the console before every test run - this is Firebug specific code.
(...skipping 15 matching lines...) Expand all
26 if (navigator.webkitStartDart) { 26 if (navigator.webkitStartDart) {
27 navigator.webkitStartDart(); 27 navigator.webkitStartDart();
28 } 28 }
29 29
30 // testRunner is provided by content shell. 30 // testRunner is provided by content shell.
31 // It is not available in selenium tests. 31 // It is not available in selenium tests.
32 var testRunner = window.testRunner || window.layoutTestController; 32 var testRunner = window.testRunner || window.layoutTestController;
33 33
34 var waitForDone = false; 34 var waitForDone = false;
35 35
36 // Returns the driving window object if available
37 function getDriverWindow() {
38 if (window != window.parent) {
39 // We're running in an iframe.
40 return window.parent;
41 } else if (window.opener) {
42 // We were opened by another window.
43 return window.opener;
44 }
45 return null;
46 }
47
36 function notifyStart() { 48 function notifyStart() {
37 if (window.opener) { 49 var driver = getDriverWindow();
38 window.opener.postMessage("STARTING", "*"); 50 if (driver) {
51 driver.postMessage("STARTING", "*");
39 } 52 }
40 } 53 }
41 54
42 function notifyDone() { 55 function notifyDone() {
43 if (testRunner) testRunner.notifyDone(); 56 if (testRunner) testRunner.notifyDone();
44 // To support in browser launching of tests we post back start and result 57 // To support in browser launching of tests we post back start and result
45 // messages to the window.opener. 58 // messages to the window.opener.
46 if (window.opener) { 59 var driver = getDriverWindow();
47 window.opener.postMessage(window.document.body.innerHTML, "*"); 60 if (driver) {
61 driver.postMessage(window.document.body.innerHTML, "*");
48 } 62 }
49 } 63 }
50 64
51 function processMessage(msg) { 65 function processMessage(msg) {
52 if (typeof msg != 'string') return; 66 if (typeof msg != 'string') return;
53 if (msg == 'unittest-suite-done') { 67 if (msg == 'unittest-suite-done') {
54 notifyDone(); 68 notifyDone();
55 } else if (msg == 'unittest-suite-wait-for-done') { 69 } else if (msg == 'unittest-suite-wait-for-done') {
56 waitForDone = true; 70 waitForDone = true;
57 if (testRunner) testRunner.startedDartTest = true; 71 if (testRunner) testRunner.startedDartTest = true;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 try { 166 try {
153 main(); 167 main();
154 } catch (e) { 168 } catch (e) {
155 dartPrint(e); 169 dartPrint(e);
156 if (e.stack) dartPrint(e.stack); 170 if (e.stack) dartPrint(e.stack);
157 window.postMessage('unittest-suite-fail', '*'); 171 window.postMessage('unittest-suite-fail', '*');
158 return; 172 return;
159 } 173 }
160 window.postMessage('dart-main-done', '*'); 174 window.postMessage('dart-main-done', '*');
161 } 175 }
OLDNEW
« no previous file with comments | « no previous file | tools/testing/dart/browser_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698