| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_TESTS_TEST_POST_MESSAGE_H_ | 5 #ifndef PPAPI_TESTS_TEST_POST_MESSAGE_H_ |
| 6 #define PPAPI_TESTS_TEST_POST_MESSAGE_H_ | 6 #define PPAPI_TESTS_TEST_POST_MESSAGE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // Add a listener for message events which will echo back the given | 27 // Add a listener for message events which will echo back the given |
| 28 // JavaScript expression by passing it to postMessage. JavaScript Variables | 28 // JavaScript expression by passing it to postMessage. JavaScript Variables |
| 29 // available to the expression are: | 29 // available to the expression are: |
| 30 // 'plugin' - the DOM element for the test plugin. | 30 // 'plugin' - the DOM element for the test plugin. |
| 31 // 'message_event' - the message event parameter to the listener function. | 31 // 'message_event' - the message event parameter to the listener function. |
| 32 // This also adds the new listener to an array called 'eventListeners' on the | 32 // This also adds the new listener to an array called 'eventListeners' on the |
| 33 // plugin's DOM element. This is used by ClearListeners(). | 33 // plugin's DOM element. This is used by ClearListeners(). |
| 34 // Returns true on success, false on failure. | 34 // Returns true on success, false on failure. |
| 35 bool AddEchoingListener(const std::string& expression); | 35 bool AddEchoingListener(const std::string& expression); |
| 36 | 36 |
| 37 // Posts a message from JavaScript to the plugin. |func| should be a |
| 38 // JavaScript function which returns the variable to post. |
| 39 bool PostMessageFromJavaScript(const std::string& func); |
| 40 |
| 37 // Clear any listeners that have been added using AddEchoingListener by | 41 // Clear any listeners that have been added using AddEchoingListener by |
| 38 // calling removeEventListener for each. | 42 // calling removeEventListener for each. |
| 39 // Returns true on success, false on failure. | 43 // Returns true on success, false on failure. |
| 40 bool ClearListeners(); | 44 bool ClearListeners(); |
| 41 | 45 |
| 42 // Wait for pending messages; return the number of messages that were pending | 46 // Wait for pending messages; return the number of messages that were pending |
| 43 // at the time of invocation. | 47 // at the time of invocation. |
| 44 int WaitForMessages(); | 48 int WaitForMessages(); |
| 45 | 49 |
| 46 // Verifies that the given javascript assertions are true of the message | 50 // Verifies that the given javascript assertions are true of the message |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 90 |
| 87 typedef std::vector<pp::Var> VarVector; | 91 typedef std::vector<pp::Var> VarVector; |
| 88 | 92 |
| 89 // This is used to store pp::Var objects we receive via a call to | 93 // This is used to store pp::Var objects we receive via a call to |
| 90 // HandleMessage. | 94 // HandleMessage. |
| 91 VarVector message_data_; | 95 VarVector message_data_; |
| 92 }; | 96 }; |
| 93 | 97 |
| 94 #endif // PPAPI_TESTS_TEST_POST_MESSAGE_H_ | 98 #endif // PPAPI_TESTS_TEST_POST_MESSAGE_H_ |
| 95 | 99 |
| OLD | NEW |