OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 // Helper function to send a postMessage and wait for a reply message. The | 45 // Helper function to send a postMessage and wait for a reply message. The |
46 // |post_message_script| is executed on the |sender_ftn| frame, and the sender | 46 // |post_message_script| is executed on the |sender_ftn| frame, and the sender |
47 // frame is expected to post |reply_status| from the DOMAutomationController | 47 // frame is expected to post |reply_status| from the DOMAutomationController |
48 // when it receives a reply. | 48 // when it receives a reply. |
49 void PostMessageAndWaitForReply(FrameTreeNode* sender_ftn, | 49 void PostMessageAndWaitForReply(FrameTreeNode* sender_ftn, |
50 const std::string& post_message_script, | 50 const std::string& post_message_script, |
51 const std::string& reply_status) { | 51 const std::string& reply_status) { |
52 // Subtle: msg_queue needs to be declared before the ExecuteScript below. | |
Charlie Reis
2015/08/14 22:54:13
..., or else it might miss the message of interest
alexmos
2015/08/14 23:51:32
Done.
| |
53 // See https://crbug.com/518729. | |
Charlie Reis
2015/08/14 22:54:13
Looks like WebUIMojoTest.ConnectToApplication migh
alexmos
2015/08/14 23:51:32
That one actually seems fine to me - it's using DO
Charlie Reis
2015/08/15 00:09:50
I'm not 100% sure, but that test doesn't do anythi
alexmos
2015/08/15 00:57:24
Ah, yes, it may be possible that the message could
| |
54 content::DOMMessageQueue msg_queue; | |
nasko
2015/08/14 23:21:13
nit: no need for content:: prefix, as it is alread
alexmos
2015/08/14 23:51:32
Done. Thanks for noticing!
| |
55 | |
52 bool success = false; | 56 bool success = false; |
53 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 57 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
54 sender_ftn->current_frame_host(), | 58 sender_ftn->current_frame_host(), |
55 "window.domAutomationController.send(" + post_message_script + ");", | 59 "window.domAutomationController.send(" + post_message_script + ");", |
56 &success)); | 60 &success)); |
57 EXPECT_TRUE(success); | 61 EXPECT_TRUE(success); |
58 | 62 |
59 content::DOMMessageQueue msg_queue; | |
60 std::string status; | 63 std::string status; |
61 while (msg_queue.WaitForMessage(&status)) { | 64 while (msg_queue.WaitForMessage(&status)) { |
62 if (status == reply_status) | 65 if (status == reply_status) |
63 break; | 66 break; |
64 } | 67 } |
65 } | 68 } |
66 | 69 |
67 // Helper function to extract and return "window.receivedMessages" from the | 70 // Helper function to extract and return "window.receivedMessages" from the |
68 // |sender_ftn| frame. This variable is used in post_message.html to count the | 71 // |sender_ftn| frame. This variable is used in post_message.html to count the |
69 // number of messages received via postMessage by the current window. | 72 // number of messages received via postMessage by the current window. |
(...skipping 2832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2902 foo_root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); | 2905 foo_root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); |
2903 | 2906 |
2904 // Verify that the a.com popup can now find the "foo" popup by name. | 2907 // Verify that the a.com popup can now find the "foo" popup by name. |
2905 GURL named_frame_url(embedded_test_server()->GetURL("c.com", "/title2.html")); | 2908 GURL named_frame_url(embedded_test_server()->GetURL("c.com", "/title2.html")); |
2906 NavigateNamedFrame(a_com_shell->web_contents(), named_frame_url, "foo"); | 2909 NavigateNamedFrame(a_com_shell->web_contents(), named_frame_url, "foo"); |
2907 EXPECT_TRUE(WaitForLoadStop(foo_shell->web_contents())); | 2910 EXPECT_TRUE(WaitForLoadStop(foo_shell->web_contents())); |
2908 EXPECT_EQ(named_frame_url, foo_root->current_url()); | 2911 EXPECT_EQ(named_frame_url, foo_root->current_url()); |
2909 } | 2912 } |
2910 | 2913 |
2911 } // namespace content | 2914 } // namespace content |
OLD | NEW |