diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 23:11:54 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 23:11:54 +0000 |
commit | 8585fd865df3044b8215e4486698422562712e6c (patch) | |
tree | f6f2b49818fac61ed3039dc9aa1402b9647c7fed /ppapi/tests/test_post_message.h | |
parent | 5e8d27087b478de2d7136fa9016c4e178e19305e (diff) | |
download | chromium_src-8585fd865df3044b8215e4486698422562712e6c.zip chromium_src-8585fd865df3044b8215e4486698422562712e6c.tar.gz chromium_src-8585fd865df3044b8215e4486698422562712e6c.tar.bz2 |
Fix event dispatching for PPB_Messaging::PostMessage. I asked Adam about the "plugin.onmessage = function(x){...}" style vs the 'plugin.addEventListener' style, and it seems that we should prefer supporting the addEventListener style.
This breaks the ability to do "plugin.onmessage =" :-(. I expected dispatchEvent to do it for me, but it does not. To add that support (if desired), I could work on making dispatchEvent do it, or I could fake it out via the script in MessageChannel (Basically have the old path of invoking onmessage directly, plus the new dispatchEvent code).
Brett, please focus on PPAPI-specific stuff. Adam, please focus on my event code (especially message_channel.cc and the JavaScript in test_post_message.cc).
BUG=None
TEST=test_post_message.cc
Review URL: http://codereview.chromium.org/6901060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85348 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests/test_post_message.h')
-rw-r--r-- | ppapi/tests/test_post_message.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/ppapi/tests/test_post_message.h b/ppapi/tests/test_post_message.h index cf347ec..3b58ba2 100644 --- a/ppapi/tests/test_post_message.h +++ b/ppapi/tests/test_post_message.h @@ -23,10 +23,20 @@ class TestPostMessage : public TestCase { // the given value to the back of message_data_ virtual void HandleMessage(const pp::Var& message_data); - // Set the JavaScript onmessage handler to echo back some expression based on - // the message_event by passing it to postMessage. Returns true on success, - // false on failure. - bool MakeOnMessageEcho(const std::string& expression); + // Add a listener for message events which will echo back the given + // JavaScript expression by passing it to postMessage. JavaScript Variables + // available to the expression are: + // 'plugin' - the DOM element for the test plugin. + // 'message_event' - the message event parameter to the listener function. + // This also adds the new listener to an array called 'eventListeners' on the + // plugin's DOM element. This is used by ClearListeners(). + // Returns true on success, false on failure. + bool AddEchoingListener(const std::string& expression); + + // Clear any listeners that have been added using AddEchoingListener by + // calling removeEventListener for each. + // Returns true on success, false on failure. + bool ClearListeners(); // Test some basic functionality; make sure we can send data successfully // in both directions. @@ -39,9 +49,11 @@ class TestPostMessage : public TestCase { // Test sending a message when no handler exists, make sure nothing happens. std::string TestNoHandler(); + typedef std::vector<pp::Var> VarVector; + // This is used to store pp::Var objects we receive via a call to // HandleMessage. - std::vector<pp::Var> message_data_; + VarVector message_data_; }; #endif // PPAPI_TESTS_TEST_POST_MESSAGE_H_ |