Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: ppapi/tests/test_post_message.cc

Issue 7312008: Porting ppapi_tests framework to postMessage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable Scrollbar test on Mac for now, merge Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/tests/test_case.html ('k') | ppapi/tests/test_url_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ppapi/tests/test_case.html ('k') | ppapi/tests/test_url_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698