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

Side by Side Diff: chrome/test/data/webui/async.js

Issue 7576024: Provide ability for WebUIBrowserTests to run asynchronous tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved |errors| around and do errors.splice only when completing results. Created 9 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * Fails always.
7 * @throw {Error}
8 */
9 function testFailsAssert() {
10 assertNotReached();
11 chrome.send('testContinues');
12 assertNotReached();
13 }
14
15 /**
16 * Records failure.
17 */
18 function testFailsExpect() {
19 expectNotReached();
20 chrome.send('testContinues');
21 expectNotReached();
22 }
23
24 /**
25 * Passes and sends asyncTestDone message for browser_test to call
26 * asyncTestDone().
27 */
28 function testPasses() {
29 expectTrue(true);
30 chrome.send('testContinues');
31 assertFalse(false);
32 }
33
34 /**
35 * Wraps the function represented by |name| similar to the way net_internals
36 * tests are wrapped.
37 * @param {string} name The name of the function to run.
38 */
39 function runAsync(name) {
40 // Strip |name| from arguments.
41 var testArguments = Array.prototype.slice.call(arguments, 1);
42
43 // call async function.
44 var result = runTestFunction(name, this[name], testArguments);
45
46 // Pass on success; bail on errors.
47 if (result[0])
48 chrome.send('testPasses');
49 else
50 asyncTestDone(result);
51 }
52
53 /**
54 * Sends a message to handler to start |testName| and returns.
55 * @param {string} testName The name of the test to run.
56 */
57 function startAsyncTest(testName) {
58 chrome.send('startAsyncTest', [testName]);
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698