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

Side by Side Diff: chrome/browser/geolocation/geolocation_browsertest.cc

Issue 1123783002: Add ExecuteJavaScriptForTest and make all tests use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 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) 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 browser->tab_strip_model()->GetActiveWebContents(); 83 browser->tab_strip_model()->GetActiveWebContents();
84 NavigationController* controller = &web_contents->GetController(); 84 NavigationController* controller = &web_contents->GetController();
85 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, 85 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP,
86 content::Source<NavigationController>(controller)); 86 content::Source<NavigationController>(controller));
87 registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE, 87 registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE,
88 content::NotificationService::AllSources()); 88 content::NotificationService::AllSources());
89 std::string script(base::StringPrintf( 89 std::string script(base::StringPrintf(
90 "window.domAutomationController.setAutomationId(0);" 90 "window.domAutomationController.setAutomationId(0);"
91 "window.domAutomationController.send(addIFrame(%d, \"%s\"));", 91 "window.domAutomationController.send(addIFrame(%d, \"%s\"));",
92 iframe_id, url.spec().c_str())); 92 iframe_id, url.spec().c_str()));
93 web_contents->GetMainFrame()->ExecuteJavaScript(base::UTF8ToUTF16(script)); 93 web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
94 base::UTF8ToUTF16(script));
94 content::RunMessageLoop(); 95 content::RunMessageLoop();
95 96
96 EXPECT_EQ(base::StringPrintf("\"%d\"", iframe_id), javascript_response_); 97 EXPECT_EQ(base::StringPrintf("\"%d\"", iframe_id), javascript_response_);
97 registrar_.RemoveAll(); 98 registrar_.RemoveAll();
98 // Now that we loaded the iframe, let's fetch its src. 99 // Now that we loaded the iframe, let's fetch its src.
99 script = base::StringPrintf( 100 script = base::StringPrintf(
100 "window.domAutomationController.send(getIFrameSrc(%d))", iframe_id); 101 "window.domAutomationController.send(getIFrameSrc(%d))", iframe_id);
101 std::string iframe_src; 102 std::string iframe_src;
102 EXPECT_TRUE(content::ExecuteScriptAndExtractString(web_contents, script, 103 EXPECT_TRUE(content::ExecuteScriptAndExtractString(web_contents, script,
103 &iframe_src)); 104 &iframe_src));
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // Last usage has been updated. 713 // Last usage has been updated.
713 EXPECT_EQ(current_browser() 714 EXPECT_EQ(current_browser()
714 ->profile() 715 ->profile()
715 ->GetHostContentSettingsMap() 716 ->GetHostContentSettingsMap()
716 ->GetLastUsage(current_url().GetOrigin(), 717 ->GetLastUsage(current_url().GetOrigin(),
717 current_url().GetOrigin(), 718 current_url().GetOrigin(),
718 CONTENT_SETTINGS_TYPE_GEOLOCATION) 719 CONTENT_SETTINGS_TYPE_GEOLOCATION)
719 .ToDoubleT(), 720 .ToDoubleT(),
720 13); 721 13);
721 } 722 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc ('k') | chrome/browser/mouseleave_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698