OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/tests/test_message_handler.h" | 5 #include "ppapi/tests/test_message_handler.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 js_code += "result = plugin.postMessageAndAwaitResponse("; | 272 js_code += "result = plugin.postMessageAndAwaitResponse("; |
273 js_code += values_to_test[i]; | 273 js_code += values_to_test[i]; |
274 js_code += ");\n"; | 274 js_code += ");\n"; |
275 js_code += "if (!deepCompare(result, "; | 275 js_code += "if (!deepCompare(result, "; |
276 js_code += values_to_test[i]; | 276 js_code += values_to_test[i]; |
277 js_code += "))\n"; | 277 js_code += "))\n"; |
278 js_code += " InternalError(\" Failed postMessageAndAwaitResponse for: "; | 278 js_code += " InternalError(\" Failed postMessageAndAwaitResponse for: "; |
279 js_code += values_to_test[i]; | 279 js_code += values_to_test[i]; |
280 js_code += " result: \" + result);\n"; | 280 js_code += " result: \" + result);\n"; |
281 } | 281 } |
282 // TODO(dmichael): Setting a property uses GetInstanceObject, which sends sync | |
283 // message, which can get interrupted with message to eval script, etc. | |
284 // FINISHED_WAITING message can therefore jump ahead. This test is | |
285 // currently carefully crafted to avoid races by doing all the JS in one call. | |
286 // That should be fixed before this API goes to stable. See crbug.com/384528 | |
287 js_code += "plugin.postMessage('FINISHED_TEST');\n"; | |
288 instance_->EvalScript(js_code); | 282 instance_->EvalScript(js_code); |
| 283 instance_->EvalScript("plugin.postMessage('FINISHED_TEST');\n"); |
289 handler.WaitForTestFinishedMessage(); | 284 handler.WaitForTestFinishedMessage(); |
290 handler.Unregister(); | 285 handler.Unregister(); |
291 ASSERT_SUBTEST_SUCCESS(handler.WaitForDestroy()); | 286 ASSERT_SUBTEST_SUCCESS(handler.WaitForDestroy()); |
292 | 287 |
293 PASS(); | 288 PASS(); |
294 } | 289 } |
295 | 290 |
296 std::string TestMessageHandler::TestExceptions() { | 291 std::string TestMessageHandler::TestExceptions() { |
297 EchoingMessageHandler handler(instance(), | 292 EchoingMessageHandler handler(instance(), |
298 handler_thread_.message_loop()); | 293 handler_thread_.message_loop()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 instance_->EvalScript(js_code); | 334 instance_->EvalScript(js_code); |
340 message_received_.Wait(); | 335 message_received_.Wait(); |
341 ASSERT_EQ("SUCCESS", last_message_); | 336 ASSERT_EQ("SUCCESS", last_message_); |
342 } | 337 } |
343 handler.Unregister(); | 338 handler.Unregister(); |
344 ASSERT_SUBTEST_SUCCESS(handler.WaitForDestroy()); | 339 ASSERT_SUBTEST_SUCCESS(handler.WaitForDestroy()); |
345 | 340 |
346 PASS(); | 341 PASS(); |
347 } | 342 } |
348 | 343 |
OLD | NEW |