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

Side by Side Diff: lib/unittest/test_controller.js

Issue 10836241: Move unittest from lib to pkg. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/unittest/test_case.dart ('k') | lib/unittest/unittest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * Test controller logic - used by unit test harness to embed tests in
7 * DumpRenderTree.
8 */
9
10 if (navigator.webkitStartDart) {
11 navigator.webkitStartDart();
12 }
13
14 function processMessage(msg) {
15 if (window.layoutTestController) {
16 if (msg == 'unittest-suite-done') {
17 window.layoutTestController.notifyDone();
18 } else if (msg == 'unittest-suite-wait-for-done') {
19 window.layoutTestController.startedDartTest = true;
20 }
21 }
22 }
23
24 function onReceive(e) {
25 processMessage(e.data);
26 }
27
28 if (window.layoutTestController) {
29 window.layoutTestController.dumpAsText();
30 window.layoutTestController.waitUntilDone();
31 }
32 window.addEventListener("message", onReceive, false);
33
34 function showErrorAndExit(message) {
35 if (message) {
36 var element = document.createElement('pre');
37 element.innerHTML = message;
38 document.body.appendChild(element);
39 }
40 if (window.layoutTestController) {
41 window.layoutTestController.notifyDone();
42 }
43 }
44
45 function onLoad(e) {
46 // needed for dartium compilation errors.
47 if (window.compilationError) {
48 showErrorAndExit(window.compilationError);
49 }
50 }
51
52 window.addEventListener("DOMContentLoaded", onLoad, false);
53
54 // If nobody intercepts the error, finish the test.
55 window.addEventListener("error", function(e) {
56 // needed for dartium compilation errors.
57 showErrorAndExit(e && e.message);
58 }, false);
59
60 document.onreadystatechange = function() {
61 if (document.readyState != "loaded") return;
62 // If 'startedDartTest' is not set, that means that the test did not have
63 // a chance to load. This will happen when a load error occurs in the VM.
64 // Give the machine time to start up.
65 setTimeout(function() {
66 // A window.postMessage might have been enqueued after this timeout.
67 // Just sleep another time to give the browser the time to process the
68 // posted message.
69 setTimeout(function() {
70 if (layoutTestController && !layoutTestController.startedDartTest) {
71 layoutTestController.notifyDone();
72 }
73 }, 0);
74 }, 50);
75 };
OLDNEW
« no previous file with comments | « lib/unittest/test_case.dart ('k') | lib/unittest/unittest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698