Index: ppapi/tests/test_post_message.cc |
diff --git a/ppapi/tests/test_post_message.cc b/ppapi/tests/test_post_message.cc |
index a97ba420cf4cd92c36c1174646bd905e33fc68ed..ea298820efe442299c69b7e40bc71f76f0516b33 100644 |
--- a/ppapi/tests/test_post_message.cc |
+++ b/ppapi/tests/test_post_message.cc |
@@ -44,11 +44,18 @@ void TestPostMessage::HandleMessage(const pp::Var& message_data) { |
bool TestPostMessage::AddEchoingListener(const std::string& expression) { |
std::string js_code; |
+ // Note the following code is dependent on some features of test_case.html. |
+ // E.g., it is assumed that the DOM element where the plugin is embedded has |
+ // an id of 'plugin', and there is a function 'IsTestingMessage' that allows |
+ // us to ignore the messages that are intended for use by the testing |
+ // framework itself. |
js_code += "var plugin = document.getElementById('plugin');" |
"var message_handler = function(message_event) {" |
- " plugin.postMessage("; |
+ " if (!IsTestingMessage(message_event.data)) {" |
+ " plugin.postMessage("; |
js_code += expression; |
- js_code += " );" |
+ js_code += " );" |
+ " }" |
"};" |
"plugin.addEventListener('message', message_handler);" |
// Maintain an array of all event listeners, attached to the |