diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 8 | ||||
-rw-r--r-- | chrome/browser/browser_focus_uitest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/debugger/debugger_view.cc | 3 | ||||
-rw-r--r-- | chrome/browser/dom_ui/dom_ui_host.cc | 12 | ||||
-rw-r--r-- | chrome/browser/resource_dispatcher_host_uitest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ssl_uitest.cc | 36 |
6 files changed, 22 insertions, 46 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 7b9214c..820d446 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -1605,13 +1605,13 @@ void AutomationProvider::ExecuteJavascript(const IPC::Message& message, // This routing id needs to be remembered for the reverse // communication while sending back the response of // this javascript execution. - std::wstring url; - SStringPrintf(&url, - L"javascript:void(window.domAutomationController.setAutomationId(%d));", + std::wstring set_automation_id; + SStringPrintf(&set_automation_id, + L"window.domAutomationController.setAutomationId(%d);", message.routing_id()); web_contents->render_view_host()->ExecuteJavascriptInWebFrame( - frame_xpath, url); + frame_xpath, set_automation_id); web_contents->render_view_host()->ExecuteJavascriptInWebFrame( frame_xpath, script); succeeded = true; diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc index ec14e5e..c93c58b 100644 --- a/chrome/browser/browser_focus_uitest.cc +++ b/chrome/browser/browser_focus_uitest.cc @@ -304,8 +304,7 @@ TEST_F(BrowserFocusTest, FocusTraversal) { // Let's make sure the focus is on the expected element in the page. std::wstring actual; ASSERT_TRUE(tab->ExecuteAndExtractString(L"", - L"javascript:void(window.domAutomationController)" - L".send(getFocusedElement());", + L"window.domAutomationController.send(getFocusedElement());", &actual)); ASSERT_STREQ(kExpElementIDs[j], actual.c_str()); @@ -329,8 +328,7 @@ TEST_F(BrowserFocusTest, FocusTraversal) { // Let's make sure the focus is on the expected element in the page. std::wstring actual; ASSERT_TRUE(tab->ExecuteAndExtractString(L"", - L"javascript:void(window.domAutomationController)" - L".send(getFocusedElement());", + L"window.domAutomationController.send(getFocusedElement());", &actual)); ASSERT_STREQ(kExpElementIDs[6 - j], actual.c_str()); } diff --git a/chrome/browser/debugger/debugger_view.cc b/chrome/browser/debugger/debugger_view.cc index 89cb4e8..127c987 100644 --- a/chrome/browser/debugger/debugger_view.cc +++ b/chrome/browser/debugger/debugger_view.cc @@ -132,9 +132,8 @@ void DebuggerView::OpenURLFromTab(TabContents* source, } void DebuggerView::ExecuteJavascript(const std::string& js) { - const std::string url = StringPrintf("javascript:void(%s)", js.c_str()); web_contents_->render_view_host()->ExecuteJavascriptInWebFrame(L"", - UTF8ToWide(url)); + UTF8ToWide(js)); } void DebuggerView::LoadingStateChanged(TabContents* source) { diff --git a/chrome/browser/dom_ui/dom_ui_host.cc b/chrome/browser/dom_ui/dom_ui_host.cc index 2541e71..d9d0333 100644 --- a/chrome/browser/dom_ui/dom_ui_host.cc +++ b/chrome/browser/dom_ui/dom_ui_host.cc @@ -102,16 +102,6 @@ WebPreferences DOMUIHost::GetWebkitPrefs() { } void DOMUIHost::ExecuteJavascript(const std::wstring& javascript) { - // We're taking a string and making a javascript URL out of it. This means - // that escaping will follow the rules of a URL. Yet, the JSON text may have - // stuff in it that would be interpreted as escaped characters in a URL, but - // we want to preserve them literally. - // - // We just escape all the percents to avoid this, since when this javascript - // URL is interpreted, it will be unescaped. - std::wstring escaped_js(javascript); - ReplaceSubstringsAfterOffset(&escaped_js, 0, L"%", L"%25"); - render_view_host()->ExecuteJavascriptInWebFrame(std::wstring(), - L"javascript:" + escaped_js); + render_view_host()->ExecuteJavascriptInWebFrame(std::wstring(), javascript); } diff --git a/chrome/browser/resource_dispatcher_host_uitest.cc b/chrome/browser/resource_dispatcher_host_uitest.cc index 6db69fa..2f83e73 100644 --- a/chrome/browser/resource_dispatcher_host_uitest.cc +++ b/chrome/browser/resource_dispatcher_host_uitest.cc @@ -95,8 +95,7 @@ TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest) { // Let's check the XMLHttpRequest ran successfully. bool success = false; EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", - L"javascript:void(window.domAutomationController)" - L".send(DidSyncRequestSucceed());", + L"window.domAutomationController.send(DidSyncRequestSucceed());", &success)); EXPECT_TRUE(success); } diff --git a/chrome/browser/ssl_uitest.cc b/chrome/browser/ssl_uitest.cc index 4446a02..7915cfe 100644 --- a/chrome/browser/ssl_uitest.cc +++ b/chrome/browser/ssl_uitest.cc @@ -236,8 +236,7 @@ TEST_F(SSLUITest, TestMixedContents) { // The image should be filtered. int img_width; EXPECT_TRUE(tab->ExecuteAndExtractInt(L"", - L"javascript:void(window.domAutomationController)" - L".send(ImageWidth());", + L"window.domAutomationController.send(ImageWidth());", &img_width)); // In order to check that the image was not loaded, we check its width. // The actual image (Google logo) is 114 pixels wide, we assume the broken @@ -261,8 +260,7 @@ TEST_F(SSLUITest, TestMixedContents) { // The image should show now. EXPECT_TRUE(tab->ExecuteAndExtractInt(L"", - L"javascript:void(window.domAutomationController)" - L".send(ImageWidth());", + L"window.domAutomationController.send(ImageWidth());", &img_width)); EXPECT_LT(100, img_width); @@ -314,8 +312,7 @@ TEST_F(SSLUITest, TestUnsafeContents) { int img_width; EXPECT_TRUE(tab->ExecuteAndExtractInt(L"", - L"javascript:void(window.domAutomationController)" - L".send(ImageWidth());", + L"window.domAutomationController.send(ImageWidth());", &img_width)); // In order to check that the image was not loaded, we check its width. // The actual image (Google logo) is 114 pixels wide, we assume the broken @@ -324,8 +321,7 @@ TEST_F(SSLUITest, TestUnsafeContents) { bool js_result = false; EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", - L"javascript:void(window.domAutomationController)" - L".send(IsFooSet());", + L"window.domAutomationController.send(IsFooSet());", &js_result)); EXPECT_FALSE(js_result); } @@ -355,7 +351,7 @@ TEST_F(SSLUITest, TestMixedContentsLoadedFromJS) { // Load the insecure image. bool js_result = false; EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", - L"javascript:loadBadImage();", + L"loadBadImage();", &js_result)); EXPECT_TRUE(js_result); @@ -741,8 +737,7 @@ TEST_F(SSLUITest, TestGoodFrameNavigation) { int64 last_nav_time = 0; EXPECT_TRUE(tab->GetLastNavigationTime(&last_nav_time)); EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", - L"javascript:void(window.domAutomationController)" - L".send(clickLink('goodHTTPSLink'));", + L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", &success)); EXPECT_TRUE(success); EXPECT_TRUE(tab->WaitForNavigation(last_nav_time)); @@ -757,8 +752,7 @@ TEST_F(SSLUITest, TestGoodFrameNavigation) { // Now let's hit a bad page. EXPECT_TRUE(tab->GetLastNavigationTime(&last_nav_time)); EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", - L"javascript:void(window.domAutomationController)" - L".send(clickLink('badHTTPSLink'));", + L"window.domAutomationController.send(clickLink('badHTTPSLink'));", &success)); EXPECT_TRUE(success); EXPECT_TRUE(tab->WaitForNavigation(last_nav_time)); @@ -774,7 +768,7 @@ TEST_F(SSLUITest, TestGoodFrameNavigation) { bool is_content_evil = true; std::wstring content_frame_xpath(L"html/frameset/frame[2]"); std::wstring is_frame_evil_js( - L"javascript:void(window.domAutomationController)" + L"window.domAutomationController" L".send(document.getElementById('evilDiv') != null);"); EXPECT_TRUE(tab->ExecuteAndExtractBool(content_frame_xpath, is_frame_evil_js, @@ -792,8 +786,7 @@ TEST_F(SSLUITest, TestGoodFrameNavigation) { // Navigate to a page served over HTTP. EXPECT_TRUE(tab->GetLastNavigationTime(&last_nav_time)); EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", - L"javascript:void(window.domAutomationController)" - L".send(clickLink('HTTPLink'));", + L"window.domAutomationController.send(clickLink('HTTPLink'));", &success)); EXPECT_TRUE(success); EXPECT_TRUE(tab->WaitForNavigation(last_nav_time)); @@ -845,8 +838,7 @@ TEST_F(SSLUITest, TestBadFrameNavigation) { int64 last_nav_time = 0; EXPECT_TRUE(tab->GetLastNavigationTime(&last_nav_time)); EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", - L"javascript:void(window.domAutomationController)" - L".send(clickLink('goodHTTPSLink'));", + L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", &success)); EXPECT_TRUE(success); EXPECT_TRUE(tab->WaitForNavigation(last_nav_time)); @@ -887,8 +879,7 @@ TEST_F(SSLUITest, TestUnauthenticatedFrameNavigation) { int64 last_nav_time = 0; EXPECT_TRUE(tab->GetLastNavigationTime(&last_nav_time)); EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", - L"javascript:void(window.domAutomationController)" - L".send(clickLink('goodHTTPSLink'));", + L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", &success)); EXPECT_TRUE(success); EXPECT_TRUE(tab->WaitForNavigation(last_nav_time)); @@ -903,8 +894,7 @@ TEST_F(SSLUITest, TestUnauthenticatedFrameNavigation) { // Now navigate to a bad HTTPS frame. EXPECT_TRUE(tab->GetLastNavigationTime(&last_nav_time)); EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", - L"javascript:void(window.domAutomationController)" - L".send(clickLink('badHTTPSLink'));", + L"window.domAutomationController.send(clickLink('badHTTPSLink'));", &success)); EXPECT_TRUE(success); EXPECT_TRUE(tab->WaitForNavigation(last_nav_time)); @@ -920,7 +910,7 @@ TEST_F(SSLUITest, TestUnauthenticatedFrameNavigation) { bool is_content_evil = true; std::wstring content_frame_xpath(L"html/frameset/frame[2]"); std::wstring is_frame_evil_js( - L"javascript:void(window.domAutomationController)" + L"window.domAutomationController" L".send(document.getElementById('evilDiv') != null);"); EXPECT_TRUE(tab->ExecuteAndExtractBool(content_frame_xpath, is_frame_evil_js, |