Index: chrome/test/data/webui/async.js |
diff --git a/chrome/test/data/webui/async.js b/chrome/test/data/webui/async.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4ba2319a7f4937928c6f42302a31216e55394d9c |
--- /dev/null |
+++ b/chrome/test/data/webui/async.js |
@@ -0,0 +1,66 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+/** |
+ * Fails always. |
+ * @throw {Error} |
+ */ |
+function testFailsAssert() { |
+ assertNotReached(); |
+ chrome.send('testContinues'); |
+ assertNotReached(); |
+} |
+ |
+/** |
+ * Records failure. |
+ */ |
+function testFailsExpect() { |
+ expectNotReached(); |
+ chrome.send('testContinues'); |
+ expectNotReached(); |
+} |
+ |
+/** |
+ * Passes and sends asyncTestDone message for browser_test to call |
+ * asyncTestDone(). |
+ */ |
+function testPasses() { |
+ expectTrue(true); |
+ chrome.send('testContinues'); |
+ assertFalse(false); |
+} |
+ |
+function testAsyncDoneFailFirstSyncPass() { |
+ expectNotReached(); |
+ chrome.send('testContinues'); |
+} |
+ |
+/** |
+ * Wraps the function represented by |name| similar to the way net_internals |
+ * tests are wrapped. |
+ * @param {string} name The name of the function to run. |
+ */ |
+function runAsync(name) { |
+ // Strip |name| from arguments. |
+ var testArguments = Array.prototype.slice.call(arguments, 1); |
+ |
+ // call async function. |
+ var result = runTestFunction(name, this[name], testArguments); |
+ |
+ // Pass on success; bail on errors. |
+ if (result[0]) { |
+ chrome.send('testPasses'); |
+ } else { |
+ chrome.send('testFails'); |
+ asyncTestDone(result); |
+ } |
+} |
+ |
+/** |
+ * Sends a message to handler to start |testName| and returns. |
+ * @param {string} testName The name of the test to run. |
+ */ |
+function startAsyncTest(testName) { |
+ chrome.send('startAsyncTest', [testName]); |
+} |