OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "content/browser/message_port_service.h" | |
10 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/message_port_delegate.h" | 10 #include "content/public/browser/message_port_delegate.h" |
12 #include "content/public/browser/message_port_provider.h" | 11 #include "content/public/browser/message_port_provider.h" |
13 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/common/message_port.h" |
14 #include "content/public/test/browser_test_utils.h" | 14 #include "content/public/test/browser_test_utils.h" |
15 #include "content/public/test/content_browser_test.h" | 15 #include "content/public/test/content_browser_test.h" |
16 #include "content/public/test/content_browser_test_utils.h" | 16 #include "content/public/test/content_browser_test_utils.h" |
17 #include "content/shell/browser/shell.h" | 17 #include "content/shell/browser/shell.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 // This test verifies the functionality of the Message Port Provider API. | 21 // This test verifies the functionality of the Message Port Provider API. |
22 | 22 |
23 // A mock class for testing message port provider. | 23 // A mock class for testing message port provider. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 " onmessage = function (e) { document.title = e.data; }" | 70 " onmessage = function (e) { document.title = e.data; }" |
71 " </script>" | 71 " </script>" |
72 "</body></html>"; | 72 "</body></html>"; |
73 const base::string16 target_origin(base::UTF8ToUTF16("http://baseurl")); | 73 const base::string16 target_origin(base::UTF8ToUTF16("http://baseurl")); |
74 const GURL base_url(target_origin); | 74 const GURL base_url(target_origin); |
75 const GURL history_url; | 75 const GURL history_url; |
76 // Load data. Blocks until it is done. | 76 // Load data. Blocks until it is done. |
77 content::LoadDataWithBaseURL(shell(), history_url, data, base_url); | 77 content::LoadDataWithBaseURL(shell(), history_url, data, base_url); |
78 const base::string16 source_origin(base::UTF8ToUTF16("source")); | 78 const base::string16 source_origin(base::UTF8ToUTF16("source")); |
79 const base::string16 message(base::UTF8ToUTF16("success")); | 79 const base::string16 message(base::UTF8ToUTF16("success")); |
80 const std::vector<int> ports; | 80 const std::vector<MessagePort> ports; |
81 content::TitleWatcher title_watcher(shell()->web_contents(), message); | 81 content::TitleWatcher title_watcher(shell()->web_contents(), message); |
82 MessagePortProvider::PostMessageToFrame(shell()->web_contents(), | 82 MessagePortProvider::PostMessageToFrame(shell()->web_contents(), |
83 source_origin, | 83 source_origin, |
84 target_origin, | 84 target_origin, |
85 message, | 85 message, |
86 ports); | 86 ports); |
87 EXPECT_EQ(message, title_watcher.WaitAndGetTitle()); | 87 EXPECT_EQ(message, title_watcher.WaitAndGetTitle()); |
88 } | 88 } |
89 | 89 |
90 } // namespace content | 90 } // namespace content |
OLD | NEW |