| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/password_manager/password_manager_test_base.h" | 5 #include "chrome/browser/password_manager/password_manager_test_base.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 void PasswordManagerBrowserTestBase::CheckElementValue( | 393 void PasswordManagerBrowserTestBase::CheckElementValue( |
| 394 const std::string& element_id, | 394 const std::string& element_id, |
| 395 const std::string& expected_value) { | 395 const std::string& expected_value) { |
| 396 CheckElementValue("null", element_id, expected_value); | 396 CheckElementValue("null", element_id, expected_value); |
| 397 } | 397 } |
| 398 | 398 |
| 399 void PasswordManagerBrowserTestBase::CheckElementValue( | 399 void PasswordManagerBrowserTestBase::CheckElementValue( |
| 400 const std::string& iframe_id, | 400 const std::string& iframe_id, |
| 401 const std::string& element_id, | 401 const std::string& element_id, |
| 402 const std::string& expected_value) { | 402 const std::string& expected_value) { |
| 403 const std::string value_check_script = base::StringPrintf( | 403 const std::string value_get_script = base::StringPrintf( |
| 404 "if (%s)" | 404 "if (%s)" |
| 405 " var element = document.getElementById(" | 405 " var element = document.getElementById(" |
| 406 " '%s').contentDocument.getElementById('%s');" | 406 " '%s').contentDocument.getElementById('%s');" |
| 407 "else " | 407 "else " |
| 408 " var element = document.getElementById('%s');" | 408 " var element = document.getElementById('%s');" |
| 409 "window.domAutomationController.send(element && element.value == '%s');", | 409 "var value = element ? element.value : 'element not found';" |
| 410 "window.domAutomationController.send(value);", |
| 410 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(), | 411 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(), |
| 411 element_id.c_str(), expected_value.c_str()); | 412 element_id.c_str()); |
| 412 bool return_value = false; | 413 std::string return_value; |
| 413 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 414 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 414 RenderViewHost(), value_check_script, &return_value)); | 415 RenderViewHost(), value_get_script, &return_value)); |
| 415 EXPECT_TRUE(return_value) << "element_id = " << element_id | 416 EXPECT_EQ(expected_value, return_value) << "element_id = " << element_id; |
| 416 << ", expected_value = " << expected_value; | |
| 417 } | 417 } |
| 418 | 418 |
| 419 void PasswordManagerBrowserTestBase::AddHSTSHost(const std::string& host) { | 419 void PasswordManagerBrowserTestBase::AddHSTSHost(const std::string& host) { |
| 420 base::RunLoop run_loop; | 420 base::RunLoop run_loop; |
| 421 | 421 |
| 422 content::BrowserThread::PostTaskAndReply( | 422 content::BrowserThread::PostTaskAndReply( |
| 423 content::BrowserThread::IO, FROM_HERE, | 423 content::BrowserThread::IO, FROM_HERE, |
| 424 base::Bind(&AddHSTSHostImpl, | 424 base::Bind(&AddHSTSHostImpl, |
| 425 make_scoped_refptr(browser()->profile()->GetRequestContext()), | 425 make_scoped_refptr(browser()->profile()->GetRequestContext()), |
| 426 host), | 426 host), |
| 427 run_loop.QuitClosure()); | 427 run_loop.QuitClosure()); |
| 428 | 428 |
| 429 run_loop.Run(); | 429 run_loop.Run(); |
| 430 } | 430 } |
| OLD | NEW |