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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_host_browsertest.cc

Issue 10829225: Browser Plugin: Add HTML5-like postMessage support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/singleton.h" 6 #include "base/memory/singleton.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/browser/browser_plugin/browser_plugin_guest.h" 10 #include "content/browser/browser_plugin/browser_plugin_guest.h"
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 rvh->DragTargetDragEnter(drop_data, gfx::Point(start_x, start_y), 826 rvh->DragTargetDragEnter(drop_data, gfx::Point(start_x, start_y),
827 gfx::Point(start_x, start_y), WebKit::WebDragOperationEvery, 0); 827 gfx::Point(start_x, start_y), WebKit::WebDragOperationEvery, 0);
828 rvh->DragTargetDragOver(gfx::Point(end_x, end_y), gfx::Point(end_x, end_y), 828 rvh->DragTargetDragOver(gfx::Point(end_x, end_y), gfx::Point(end_x, end_y),
829 WebKit::WebDragOperationEvery, 0); 829 WebKit::WebDragOperationEvery, 0);
830 rvh->DragTargetDrop(gfx::Point(end_x, end_y), gfx::Point(end_x, end_y), 0); 830 rvh->DragTargetDrop(gfx::Point(end_x, end_y), gfx::Point(end_x, end_y), 0);
831 831
832 string16 actual_title = title_watcher.WaitAndGetTitle(); 832 string16 actual_title = title_watcher.WaitAndGetTitle();
833 EXPECT_EQ(expected_title, actual_title); 833 EXPECT_EQ(expected_title, actual_title);
834 } 834 }
835 835
836 // This test verifies that round trip postMessage works as expected.
837 // 1. The embedder posts a message 'testing123' to the guest.
838 // 2. The guest receives and replies to the message using the event object's
839 // source object: event.source.postMessage('foobar', '*')
840 // 3. The embedder receives the message and uses the event's source
841 // object to do one final reply: 'stop'
842 // 4. The guest receives the final 'stop' message.
843 // 5. The guest acks the 'stop' message with a 'stop_ack' message.
844 // 6. The embedder changes its title to 'main guest' when it sees the 'stop_ack'
845 // message.
846 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, PostMessage) {
847 const char* kTesting = "testing123";
848 const char* kEmbedderURL = "files/browser_plugin_embedder.html";
849 const char* kGuestURL = "files/browser_plugin_post_message_guest.html";
850 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, "");
851 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
852 test_embedder()->web_contents()->GetRenderViewHost());
853 {
854 const string16 expected_title = ASCIIToUTF16("main guest");
855 content::TitleWatcher title_watcher(test_embedder()->web_contents(),
856 expected_title);
857
858 // By the time we get here 'contentWindow' should be ready because the
859 // guest has begun sending pixels to the embedder. This happens after
860 // the browser process sends the guest_routing_id to the embedder via
861 // BrowserPluginMsg_GuestContentWindowReady and after the browser process
862 // issues a ViewMsg_New to create the swapped out guest in the embedder's
863 // render process.
864 ExecuteSyncJSFunction(rvh,
865 ASCIIToUTF16(StringPrintf("PostMessage('%s, false');", kTesting)));
866
867 // The title will be updated to "main guest" at the last stage of the
868 // process described above.
869 string16 actual_title = title_watcher.WaitAndGetTitle();
870 EXPECT_EQ(expected_title, actual_title);
871 }
872 }
873
874 // This is the same as BrowserPluginHostTest.PostMessage but also
875 // posts a message to an iframe.
876 // TODO(fsamuel): This test should replace the previous test once postMessage
877 // iframe targeting is fixed (see http://crbug.com/153701).
878 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, DISABLED_PostMessageToIFrame) {
879 const char* kTesting = "testing123";
880 const char* kEmbedderURL = "files/browser_plugin_embedder.html";
881 const char* kGuestURL = "files/browser_plugin_post_message_guest.html";
882 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, "");
883 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
884 test_embedder()->web_contents()->GetRenderViewHost());
885 {
886 const string16 expected_title = ASCIIToUTF16("main guest");
887 content::TitleWatcher title_watcher(test_embedder()->web_contents(),
888 expected_title);
889
890 ExecuteSyncJSFunction(rvh,
891 ASCIIToUTF16(StringPrintf("PostMessage('%s, false');", kTesting)));
892
893 // The title will be updated to "main guest" at the last stage of the
894 // process described above.
895 string16 actual_title = title_watcher.WaitAndGetTitle();
896 EXPECT_EQ(expected_title, actual_title);
897 }
898 {
899 content::TitleWatcher ready_watcher(test_embedder()->web_contents(),
900 ASCIIToUTF16("ready"));
901
902 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>(
903 test_guest()->web_contents()->GetRenderViewHost());
904 GURL test_url = test_server()->GetURL(
905 "files/browser_plugin_post_message_guest.html");
906 ExecuteSyncJSFunction(guest_rvh,
907 ASCIIToUTF16(StringPrintf("CreateChildFrame('%s');",
908 test_url.spec().c_str())));
909
910 string16 actual_title = ready_watcher.WaitAndGetTitle();
911 EXPECT_EQ(ASCIIToUTF16("ready"), actual_title);
912
913 content::TitleWatcher iframe_watcher(test_embedder()->web_contents(),
914 ASCIIToUTF16("iframe"));
915 ExecuteSyncJSFunction(rvh,
916 ASCIIToUTF16(StringPrintf("PostMessage('%s', true);", kTesting)));
917
918 // The title will be updated to "iframe" at the last stage of the
919 // process described above.
920 actual_title = iframe_watcher.WaitAndGetTitle();
921 EXPECT_EQ(ASCIIToUTF16("iframe"), actual_title);
922 }
923 }
924
836 } // namespace content 925 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_embedder.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698