Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: chrome/browser/extensions/extension_messages_unittest.cc

Issue 180016: Extension API Renaming/Consistency changes (Closed)
Patch Set: render docs Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/extensions/extension_message_service.h" 5 #include "chrome/browser/extensions/extension_message_service.h"
6 #include "chrome/common/render_messages.h" 6 #include "chrome/common/render_messages.h"
7 #include "chrome/renderer/extensions/event_bindings.h" 7 #include "chrome/renderer/extensions/event_bindings.h"
8 #include "chrome/renderer/extensions/renderer_extension_bindings.h" 8 #include "chrome/renderer/extensions/renderer_extension_bindings.h"
9 #include "chrome/test/render_view_test.h" 9 #include "chrome/test/render_view_test.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 24 matching lines...) Expand all
35 ExtensionMessageService::kDispatchOnMessage, args, NULL); 35 ExtensionMessageService::kDispatchOnMessage, args, NULL);
36 } 36 }
37 37
38 // Tests that the bindings for opening a channel to an extension and sending 38 // Tests that the bindings for opening a channel to an extension and sending
39 // and receiving messages through that channel all works. 39 // and receiving messages through that channel all works.
40 TEST_F(RenderViewTest, ExtensionMessagesOpenChannel) { 40 TEST_F(RenderViewTest, ExtensionMessagesOpenChannel) {
41 render_thread_.sink().ClearMessages(); 41 render_thread_.sink().ClearMessages();
42 LoadHTML("<body></body>"); 42 LoadHTML("<body></body>");
43 ExecuteJavaScript( 43 ExecuteJavaScript(
44 "var e = new chrome.Extension('foobar');" 44 "var e = new chrome.Extension('foobar');"
45 "var port = e.connect('testName');" 45 "var port = e.connect({name:'testName'});"
46 "port.onMessage.addListener(doOnMessage);" 46 "port.onMessage.addListener(doOnMessage);"
47 "port.postMessage({message: 'content ready'});" 47 "port.postMessage({message: 'content ready'});"
48 "function doOnMessage(msg, port) {" 48 "function doOnMessage(msg, port) {"
49 " alert('content got: ' + msg.val);" 49 " alert('content got: ' + msg.val);"
50 "}"); 50 "}");
51 51
52 // Verify that we opened a channel and sent a message through it. 52 // Verify that we opened a channel and sent a message through it.
53 const IPC::Message* open_channel_msg = 53 const IPC::Message* open_channel_msg =
54 render_thread_.sink().GetUniqueMessageMatching( 54 render_thread_.sink().GetUniqueMessageMatching(
55 ViewHostMsg_OpenChannelToExtension::ID); 55 ViewHostMsg_OpenChannelToExtension::ID);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // Disconnect the port in the top frame. 209 // Disconnect the port in the top frame.
210 render_thread_.sink().ClearMessages(); 210 render_thread_.sink().ClearMessages();
211 DispatchOnMessage("{\"disconnect\": true}", kPortId); 211 DispatchOnMessage("{\"disconnect\": true}", kPortId);
212 212
213 // Now we should have a disconnect message. 213 // Now we should have a disconnect message.
214 disconnect_msg = 214 disconnect_msg =
215 render_thread_.sink().GetUniqueMessageMatching( 215 render_thread_.sink().GetUniqueMessageMatching(
216 ViewHostMsg_ExtensionCloseChannel::ID); 216 ViewHostMsg_ExtensionCloseChannel::ID);
217 ASSERT_TRUE(disconnect_msg); 217 ASSERT_TRUE(disconnect_msg);
218 } 218 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertests_misc.cc ('k') | chrome/browser/extensions/extension_tabs_module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698