diff options
Diffstat (limited to 'ppapi/tests')
-rw-r--r-- | ppapi/tests/test_post_message.cc | 23 | ||||
-rw-r--r-- | ppapi/tests/test_post_message.h | 4 |
2 files changed, 27 insertions, 0 deletions
diff --git a/ppapi/tests/test_post_message.cc b/ppapi/tests/test_post_message.cc index d8cbb8d..a97ba42 100644 --- a/ppapi/tests/test_post_message.cc +++ b/ppapi/tests/test_post_message.cc @@ -34,6 +34,7 @@ void TestPostMessage::RunTest() { RUN_TEST(SendingData); RUN_TEST(MessageEvent); RUN_TEST(NoHandler); + RUN_TEST(ExtraParam); } void TestPostMessage::HandleMessage(const pp::Var& message_data) { @@ -219,3 +220,25 @@ std::string TestPostMessage::TestNoHandler() { PASS(); } +std::string TestPostMessage::TestExtraParam() { + // Delete any lingering event listeners. + ASSERT_TRUE(ClearListeners()); + // Add a listener that will respond with 1 and an empty array (where the + // message port array would appear if it was Worker postMessage). + ASSERT_TRUE(AddEchoingListener("1, []")); + + // Now send a message. We shouldn't get a response. + message_data_.clear(); + instance_->PostMessage(pp::Var()); + // Note that at this point, if we call RunMessageLoop, we should hang, because + // there should be no call to our HandleMessage function to quit the loop. + // Therefore, we will do CallOnMainThread to yield control. That event should + // fire, but we should see no messages when we return. + TestCompletionCallback callback(instance_->pp_instance()); + pp::Module::Get()->core()->CallOnMainThread(0, callback); + callback.WaitForResult(); + ASSERT_TRUE(message_data_.empty()); + + PASS(); +} + diff --git a/ppapi/tests/test_post_message.h b/ppapi/tests/test_post_message.h index 3b58ba2..df7256b 100644 --- a/ppapi/tests/test_post_message.h +++ b/ppapi/tests/test_post_message.h @@ -49,6 +49,10 @@ class TestPostMessage : public TestCase { // Test sending a message when no handler exists, make sure nothing happens. std::string TestNoHandler(); + // Test sending from JavaScript to the plugin with extra parameters, make sure + // nothing happens. + std::string TestExtraParam(); + typedef std::vector<pp::Var> VarVector; // This is used to store pp::Var objects we receive via a call to |