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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 js_code += "result = plugin.postMessageAndAwaitResponse("; | 245 js_code += "result = plugin.postMessageAndAwaitResponse("; |
246 js_code += values_to_test[i]; | 246 js_code += values_to_test[i]; |
247 js_code += ");\n"; | 247 js_code += ");\n"; |
248 js_code += "if (!deepCompare(result, "; | 248 js_code += "if (!deepCompare(result, "; |
249 js_code += values_to_test[i]; | 249 js_code += values_to_test[i]; |
250 js_code += "))\n"; | 250 js_code += "))\n"; |
251 js_code += " InternalError(\" Failed postMessageAndAwaitResponse for: "; | 251 js_code += " InternalError(\" Failed postMessageAndAwaitResponse for: "; |
252 js_code += values_to_test[i]; | 252 js_code += values_to_test[i]; |
253 js_code += " result: \" + result);\n"; | 253 js_code += " result: \" + result);\n"; |
254 } | 254 } |
| 255 // TODO(dmichael): Setting a property uses GetInstanceObject, which sends sync |
| 256 // message, which can get interrupted with message to eval script, etc. |
| 257 // FINISHED_WAITING message can therefore jump ahead. This test is |
| 258 // currently carefully crafted to avoid races by doing all the JS in one call. |
| 259 // That should be fixed before this API goes to stable. See crbug.com/384528 |
| 260 js_code += "plugin.postMessage('FINISHED_TEST');\n"; |
255 instance_->EvalScript(js_code); | 261 instance_->EvalScript(js_code); |
256 instance_->EvalScript("plugin.postMessage('FINISHED_TEST');\n"); | |
257 handler.WaitForTestFinishedMessage(); | 262 handler.WaitForTestFinishedMessage(); |
258 handler.Unregister(); | 263 handler.Unregister(); |
259 ASSERT_SUBTEST_SUCCESS(handler.WaitForDestroy()); | 264 ASSERT_SUBTEST_SUCCESS(handler.WaitForDestroy()); |
260 | 265 |
261 PASS(); | 266 PASS(); |
262 } | 267 } |
263 | 268 |
OLD | NEW |