| Index: content/browser/browser_plugin/browser_plugin_host_browsertest.cc
|
| ===================================================================
|
| --- content/browser/browser_plugin/browser_plugin_host_browsertest.cc (revision 174946)
|
| +++ content/browser/browser_plugin/browser_plugin_host_browsertest.cc (working copy)
|
| @@ -274,9 +274,9 @@
|
|
|
| // Executes the javascript synchronously and makes sure the returned value is
|
| // freed properly.
|
| - void ExecuteSyncJSFunction(RenderViewHost* rvh, const std::string& jscript) {
|
| + void ExecuteSyncJSFunction(RenderViewHost* rvh, const string16& jscript) {
|
| scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue(
|
| - string16(), UTF8ToUTF16(jscript)));
|
| + string16(), jscript));
|
| }
|
|
|
| // This helper method does the following:
|
| @@ -302,15 +302,15 @@
|
| // Allow the test to do some operations on the embedder before we perform
|
| // the first navigation of the guest.
|
| if (!embedder_code.empty())
|
| - ExecuteSyncJSFunction(rvh, embedder_code);
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(embedder_code));
|
|
|
| if (!is_guest_data_url) {
|
| test_url = test_server()->GetURL(guest_url);
|
| - ExecuteSyncJSFunction(
|
| - rvh, StringPrintf("SetSrc('%s');", test_url.spec().c_str()));
|
| + ExecuteSyncJSFunction(rvh,
|
| + ASCIIToUTF16(StringPrintf("SetSrc('%s');", test_url.spec().c_str())));
|
| } else {
|
| - ExecuteSyncJSFunction(
|
| - rvh, StringPrintf("SetSrc('%s');", guest_url.c_str()));
|
| + ExecuteSyncJSFunction(rvh,
|
| + ASCIIToUTF16(StringPrintf("SetSrc('%s');", guest_url.c_str())));
|
| }
|
|
|
| // Wait to make sure embedder is created/attached to WebContents.
|
| @@ -366,9 +366,8 @@
|
| expected_title);
|
| // Hang the guest for a length of time.
|
| int spin_time = 10 * TestTimeouts::tiny_timeout().InMilliseconds();
|
| - ExecuteSyncJSFunction(
|
| - test_guest()->web_contents()->GetRenderViewHost(),
|
| - StringPrintf("StartPauseMs(%d);", spin_time).c_str());
|
| + ExecuteSyncJSFunction(test_guest()->web_contents()->GetRenderViewHost(),
|
| + ASCIIToUTF16(StringPrintf("StartPauseMs(%d);", spin_time).c_str()));
|
|
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| @@ -511,8 +510,8 @@
|
| // Hide the Browser Plugin.
|
| RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| test_embedder()->web_contents()->GetRenderViewHost());
|
| - ExecuteSyncJSFunction(
|
| - rvh, "document.getElementById('plugin').style.visibility = 'hidden'");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').style.visibility = 'hidden'"));
|
|
|
| // Make sure that the guest is hidden.
|
| test_guest()->WaitUntilHidden();
|
| @@ -538,7 +537,8 @@
|
|
|
| RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| test_embedder()->web_contents()->GetRenderViewHost());
|
| - ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').reload()");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').reload()"));
|
| test_guest()->WaitForReload();
|
| }
|
|
|
| @@ -550,7 +550,8 @@
|
|
|
| RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| test_embedder()->web_contents()->GetRenderViewHost());
|
| - ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').stop()");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').stop()"));
|
| test_guest()->WaitForStop();
|
| }
|
|
|
| @@ -570,7 +571,7 @@
|
| RenderViewHostMessageObserver observer(rvh,
|
| ViewHostMsg_HasTouchEventHandlers::ID);
|
| ExecuteSyncJSFunction(test_guest()->web_contents()->GetRenderViewHost(),
|
| - "InstallTouchHandler();");
|
| + ASCIIToUTF16("InstallTouchHandler();"));
|
| observer.WaitUntilMessageReceived();
|
| EXPECT_TRUE(rvh->has_touch_handler());
|
|
|
| @@ -578,7 +579,7 @@
|
| // listening for touch events.
|
| observer.ResetState();
|
| ExecuteSyncJSFunction(test_guest()->web_contents()->GetRenderViewHost(),
|
| - "UninstallTouchHandler();");
|
| + ASCIIToUTF16("UninstallTouchHandler();"));
|
| observer.WaitUntilMessageReceived();
|
| EXPECT_FALSE(rvh->has_touch_handler());
|
| }
|
| @@ -596,9 +597,8 @@
|
| content::TitleWatcher title_watcher(test_guest()->web_contents(),
|
| expected_title);
|
|
|
| - ExecuteSyncJSFunction(
|
| - rvh,
|
| - StringPrintf("SetSrc('%s');", GetHTMLForGuestWithTitle("P2").c_str()));
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(StringPrintf("SetSrc('%s');",
|
| + GetHTMLForGuestWithTitle("P2").c_str())));
|
|
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| @@ -610,9 +610,8 @@
|
| content::TitleWatcher title_watcher(test_guest()->web_contents(),
|
| expected_title);
|
|
|
| - ExecuteSyncJSFunction(
|
| - rvh,
|
| - StringPrintf("SetSrc('%s');", GetHTMLForGuestWithTitle("P3").c_str()));
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(StringPrintf("SetSrc('%s');",
|
| + GetHTMLForGuestWithTitle("P3").c_str())));
|
|
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| @@ -624,7 +623,7 @@
|
| content::TitleWatcher title_watcher(test_guest()->web_contents(),
|
| expected_title);
|
|
|
| - ExecuteSyncJSFunction(rvh, "Back();");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16("Back();"));
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
|
|
| @@ -647,7 +646,7 @@
|
| content::TitleWatcher title_watcher(test_guest()->web_contents(),
|
| expected_title);
|
|
|
| - ExecuteSyncJSFunction(rvh, "Forward();");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16("Forward();"));
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
|
|
| @@ -664,7 +663,7 @@
|
| content::TitleWatcher title_watcher(test_guest()->web_contents(),
|
| expected_title);
|
|
|
| - ExecuteSyncJSFunction(rvh, "Go(-2);");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16("Go(-2);"));
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
|
|
| @@ -692,7 +691,8 @@
|
| content::TitleWatcher title_watcher(test_embedder()->web_contents(),
|
| expected_title);
|
|
|
| - ExecuteSyncJSFunction(rvh, StringPrintf("SetTitle('%s');", "modified"));
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(StringPrintf("SetTitle('%s');",
|
| + "modified")));
|
|
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| @@ -709,9 +709,8 @@
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
|
|
| - ExecuteSyncJSFunction(
|
| - test_embedder()->web_contents()->GetRenderViewHost(),
|
| - StringPrintf("SetSrc('%s');", kHTMLForGuest));
|
| + ExecuteSyncJSFunction(test_embedder()->web_contents()->GetRenderViewHost(),
|
| + ASCIIToUTF16(StringPrintf("SetSrc('%s');", kHTMLForGuest)));
|
|
|
| const BrowserPluginEmbedder::ContainerInstanceMap& instance_map =
|
| test_embedder()->guest_web_contents_for_testing();
|
| @@ -732,7 +731,8 @@
|
|
|
| RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| test_embedder()->web_contents()->GetRenderViewHost());
|
| - ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').terminate()");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').terminate()"));
|
|
|
| // Expect the guest to crash.
|
| test_guest()->WaitForExit();
|
| @@ -753,15 +753,15 @@
|
| content::TitleWatcher title_watcher(test_guest()->web_contents(),
|
| expected_title);
|
|
|
| - ExecuteSyncJSFunction(
|
| - rvh,
|
| - StringPrintf("SetSrc('%s');", GetHTMLForGuestWithTitle("P2").c_str()));
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(StringPrintf("SetSrc('%s');",
|
| + GetHTMLForGuestWithTitle("P2").c_str())));
|
|
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| }
|
| // Kill the guest.
|
| - ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').terminate()");
|
| + ExecuteSyncJSFunction(rvh,
|
| + ASCIIToUTF16("document.getElementById('plugin').terminate()"));
|
|
|
| // Expect the guest to report that it crashed.
|
| test_guest()->WaitForExit();
|
| @@ -771,7 +771,7 @@
|
| content::TitleWatcher title_watcher(test_guest()->web_contents(),
|
| expected_title);
|
|
|
| - ExecuteSyncJSFunction(rvh, "Back();");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16("Back();"));
|
|
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| @@ -792,7 +792,8 @@
|
| // Renavigate the guest to |kHTMLForGuest|.
|
| RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| test_embedder()->web_contents()->GetRenderViewHost());
|
| - ExecuteSyncJSFunction(rvh, StringPrintf("SetSrc('%s');", kHTMLForGuest));
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + StringPrintf("SetSrc('%s');", kHTMLForGuest)));
|
|
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| @@ -810,8 +811,8 @@
|
| RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| test_embedder()->web_contents()->GetRenderViewHost());
|
| GURL test_url = test_server()->GetURL("close-socket");
|
| - ExecuteSyncJSFunction(
|
| - rvh, StringPrintf("SetSrc('%s');", test_url.spec().c_str()));
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + StringPrintf("SetSrc('%s');", test_url.spec().c_str())));
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| }
|
| @@ -824,8 +825,8 @@
|
| RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| test_embedder()->web_contents()->GetRenderViewHost());
|
| GURL test_url("chrome://newtab");
|
| - ExecuteSyncJSFunction(
|
| - rvh, StringPrintf("SetSrc('%s');", test_url.spec().c_str()));
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + StringPrintf("SetSrc('%s');", test_url.spec().c_str())));
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| }
|
| @@ -838,8 +839,8 @@
|
| RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| test_embedder()->web_contents()->GetRenderViewHost());
|
| GURL test_url("file://foo");
|
| - ExecuteSyncJSFunction(
|
| - rvh, StringPrintf("SetSrc('%s');", test_url.spec().c_str()));
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + StringPrintf("SetSrc('%s');", test_url.spec().c_str())));
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| }
|
| @@ -858,8 +859,8 @@
|
| "server-redirect?files/title1.html"));
|
| RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| test_embedder()->web_contents()->GetRenderViewHost());
|
| - ExecuteSyncJSFunction(
|
| - rvh, StringPrintf("SetSrc('%s');", redirect_url.spec().c_str()));
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + StringPrintf("SetSrc('%s');", redirect_url.spec().c_str())));
|
|
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| @@ -948,8 +949,8 @@
|
|
|
| // By the time we get here 'contentWindow' should be ready because the
|
| // guest has completed loading.
|
| - ExecuteSyncJSFunction(
|
| - rvh, StringPrintf("PostMessage('%s, false');", kTesting));
|
| + ExecuteSyncJSFunction(rvh,
|
| + ASCIIToUTF16(StringPrintf("PostMessage('%s, false');", kTesting)));
|
|
|
| // The title will be updated to "main guest" at the last stage of the
|
| // process described above.
|
| @@ -974,8 +975,8 @@
|
| content::TitleWatcher title_watcher(test_embedder()->web_contents(),
|
| expected_title);
|
|
|
| - ExecuteSyncJSFunction(
|
| - rvh, StringPrintf("PostMessage('%s, false');", kTesting));
|
| + ExecuteSyncJSFunction(rvh,
|
| + ASCIIToUTF16(StringPrintf("PostMessage('%s, false');", kTesting)));
|
|
|
| // The title will be updated to "main guest" at the last stage of the
|
| // process described above.
|
| @@ -990,17 +991,17 @@
|
| test_guest()->web_contents()->GetRenderViewHost());
|
| GURL test_url = test_server()->GetURL(
|
| "files/browser_plugin_post_message_guest.html");
|
| - ExecuteSyncJSFunction(
|
| - guest_rvh,
|
| - StringPrintf("CreateChildFrame('%s');", test_url.spec().c_str()));
|
| + ExecuteSyncJSFunction(guest_rvh,
|
| + ASCIIToUTF16(StringPrintf("CreateChildFrame('%s');",
|
| + test_url.spec().c_str())));
|
|
|
| string16 actual_title = ready_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(ASCIIToUTF16("ready"), actual_title);
|
|
|
| content::TitleWatcher iframe_watcher(test_embedder()->web_contents(),
|
| ASCIIToUTF16("iframe"));
|
| - ExecuteSyncJSFunction(
|
| - rvh, StringPrintf("PostMessage('%s', true);", kTesting));
|
| + ExecuteSyncJSFunction(rvh,
|
| + ASCIIToUTF16(StringPrintf("PostMessage('%s', true);", kTesting)));
|
|
|
| // The title will be updated to "iframe" at the last stage of the
|
| // process described above.
|
| @@ -1019,7 +1020,8 @@
|
| // Renavigate the guest to |kHTMLForGuest|.
|
| RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| test_embedder()->web_contents()->GetRenderViewHost());
|
| - ExecuteSyncJSFunction(rvh, StringPrintf("SetSrc('%s');", kHTMLForGuest));
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + StringPrintf("SetSrc('%s');", kHTMLForGuest)));
|
|
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| @@ -1036,7 +1038,8 @@
|
| // Renavigate the guest to |kHTMLForGuest|.
|
| RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| test_embedder()->web_contents()->GetRenderViewHost());
|
| - ExecuteSyncJSFunction(rvh, StringPrintf("SetSrc('%s');", kHTMLForGuest));
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + StringPrintf("SetSrc('%s');", kHTMLForGuest)));
|
|
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| @@ -1069,14 +1072,16 @@
|
| RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
|
| test_embedder()->web_contents()->GetRenderViewHost());
|
| // Hide the BrowserPlugin.
|
| - ExecuteSyncJSFunction(
|
| - rvh, "document.getElementById('plugin').style.visibility = 'hidden';");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').style.visibility = 'hidden';"));
|
| test_guest()->WaitUntilHidden();
|
| // Kill the current guest.
|
| - ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').terminate();");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').terminate();"));
|
| test_guest()->WaitForExit();
|
| // Get a new guest.
|
| - ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').reload();");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').reload();"));
|
| test_guest()->WaitForLoadStop();
|
| // Verify that the guest is told to hide.
|
| test_guest()->WaitUntilHidden();
|
| @@ -1113,7 +1118,8 @@
|
| {
|
| // Focus the BrowserPlugin. This will have the effect of also focusing the
|
| // current guest.
|
| - ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').focus();");
|
| + ExecuteSyncJSFunction(
|
| + rvh, ASCIIToUTF16("document.getElementById('plugin').focus();"));
|
| // Verify that key presses go to the guest.
|
| SimulateSpaceKeyPress(test_embedder()->web_contents());
|
| test_guest()->WaitForInput();
|
| @@ -1127,12 +1133,14 @@
|
| }
|
|
|
| // Kill the current guest.
|
| - ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').terminate();");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').terminate();"));
|
| test_guest()->WaitForExit();
|
|
|
| {
|
| // Get a new guest.
|
| - ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').reload();");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').reload();"));
|
| test_guest()->WaitForLoadStop();
|
| // Verify that the guest is focused.
|
| scoped_ptr<base::Value> value(
|
| @@ -1154,7 +1162,8 @@
|
| {
|
| // Focus the BrowserPlugin. This will have the effect of also focusing the
|
| // current guest.
|
| - ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').focus();");
|
| + ExecuteSyncJSFunction(
|
| + rvh, ASCIIToUTF16("document.getElementById('plugin').focus();"));
|
| // Verify that key presses go to the guest.
|
| SimulateSpaceKeyPress(test_embedder()->web_contents());
|
| test_guest()->WaitForInput();
|
| @@ -1200,13 +1209,12 @@
|
| const string16 expected_title = ASCIIToUTF16("AutoSize(300, 400)");
|
| content::TitleWatcher title_watcher(test_embedder()->web_contents(),
|
| expected_title);
|
| - ExecuteSyncJSFunction(
|
| - rvh,
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| "document.getElementById('plugin').minWidth = 300;"
|
| "document.getElementById('plugin').minHeight = 200;"
|
| "document.getElementById('plugin').maxWidth = 600;"
|
| "document.getElementById('plugin').maxHeight = 400;"
|
| - "document.getElementById('plugin').autoSize = true;");
|
| + "document.getElementById('plugin').autoSize = true;"));
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| }
|
| @@ -1215,15 +1223,15 @@
|
| const string16 expected_title = ASCIIToUTF16("AutoSize(350, 400)");
|
| content::TitleWatcher title_watcher(test_embedder()->web_contents(),
|
| expected_title);
|
| - ExecuteSyncJSFunction(
|
| - rvh, "document.getElementById('plugin').minWidth = 350;");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').minWidth = 350;"));
|
| string16 actual_title = title_watcher.WaitAndGetTitle();
|
| EXPECT_EQ(expected_title, actual_title);
|
| }
|
| {
|
| // Turn off autoSize and verify that the guest resizes to fit the container.
|
| - ExecuteSyncJSFunction(
|
| - rvh, "document.getElementById('plugin').autoSize = false;");
|
| + ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
|
| + "document.getElementById('plugin').autoSize = false;"));
|
| test_guest()->WaitForViewSize(gfx::Size(640, 480));
|
| }
|
| }
|
|
|