| Index: ppapi/tests/test_post_message.cc
|
| ===================================================================
|
| --- ppapi/tests/test_post_message.cc (revision 114869)
|
| +++ ppapi/tests/test_post_message.cc (working copy)
|
| @@ -60,13 +60,12 @@
|
| TestPostMessage::~TestPostMessage() {
|
| // Remove the special listener that only responds to a FINISHED_WAITING
|
| // string. See Init for where it gets added.
|
| - std::string js_code;
|
| + std::string js_code("TESTING_MESSAGE:ExecuteScript:");
|
| js_code += "var plugin = document.getElementById('plugin');"
|
| "plugin.removeEventListener('message',"
|
| " plugin.wait_for_messages_handler);"
|
| "delete plugin.wait_for_messages_handler;";
|
| - pp::Var exception;
|
| - instance_->ExecuteScript(js_code, &exception);
|
| + instance_->PostMessage(pp::Var(js_code));
|
| }
|
|
|
| bool TestPostMessage::Init() {
|
| @@ -74,7 +73,7 @@
|
|
|
| // Set up a special listener that only responds to a FINISHED_WAITING string.
|
| // This is for use by WaitForMessages.
|
| - std::string js_code;
|
| + std::string js_code("TESTING_MESSAGE:ExecuteScript:");
|
| // 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
|
| @@ -90,9 +89,7 @@
|
| "plugin.addEventListener('message', wait_for_messages_handler);"
|
| // Stash it on the plugin so we can remove it in the destructor.
|
| "plugin.wait_for_messages_handler = wait_for_messages_handler;";
|
| - pp::Var exception;
|
| - instance_->ExecuteScript(js_code, &exception);
|
| - success = success && exception.is_undefined();
|
| + instance_->PostMessage(pp::Var(js_code));
|
|
|
| // Set up the JavaScript message event listener to echo the data part of the
|
| // message event back to us.
|
| @@ -128,7 +125,7 @@
|
| }
|
|
|
| bool TestPostMessage::AddEchoingListener(const std::string& expression) {
|
| - std::string js_code;
|
| + std::string js_code("TESTING_MESSAGE:ExecuteScript:");
|
| // 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
|
| @@ -149,20 +146,19 @@
|
| // ClearListeners()).
|
| "if (!plugin.eventListeners) plugin.eventListeners = [];"
|
| "plugin.eventListeners.push(message_handler);";
|
| - pp::Var exception;
|
| - instance_->ExecuteScript(js_code, &exception);
|
| - return exception.is_undefined();
|
| + instance_->PostMessage(pp::Var(js_code));
|
| + return true;
|
| }
|
|
|
| bool TestPostMessage::ClearListeners() {
|
| - std::string js_code(
|
| - "var plugin = document.getElementById('plugin');"
|
| - "while (plugin.eventListeners.length) {"
|
| - " plugin.removeEventListener('message', plugin.eventListeners.pop());"
|
| - "}");
|
| - pp::Var exception;
|
| - instance_->ExecuteScript(js_code, &exception);
|
| - return(exception.is_undefined());
|
| + std::string js_code("TESTING_MESSAGE:ExecuteScript:");
|
| + js_code += "var plugin = document.getElementById('plugin');"
|
| + "while (plugin.eventListeners.length) {"
|
| + " plugin.removeEventListener('message',"
|
| + " plugin.eventListeners.pop());"
|
| + "}";
|
| + instance_->PostMessage(pp::Var(js_code));
|
| + return true;
|
| }
|
|
|
| int TestPostMessage::WaitForMessages() {
|
|
|