Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / webrtc / test_functions.js
1 /**
2  * Copyright (c) 2012 The Chromium Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 // Helper / error handling functions.
8
9 /**
10  * Prints a debug message.
11  */
12 function debug(txt) {
13   console.log(txt);
14 }
15
16 /**
17  * Sends a value back to the test.
18  *
19  * @param {string} message The message to return.
20  */
21 function returnToTest(message) {
22   debug('Returning ' + message + ' to test.');
23   window.domAutomationController.send(message);
24 }
25
26 /**
27  * Fails the test by generating an exception. If the test automation is calling
28  * into us, make sure to fail the test as fast as possible. You must use this
29  * function like this:
30  *
31  * throw failTest('my reason');
32  *
33  * @return {!Error}
34  */
35 function failTest(reason) {
36   returnToTest('Test failed: ' + reason);
37   return new Error(reason);
38 }