OLD | NEW |
---|---|
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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 #include "chrome/test/base/in_process_browser_test.h" | 34 #include "chrome/test/base/in_process_browser_test.h" |
35 #include "chrome/test/base/test_switches.h" | 35 #include "chrome/test/base/test_switches.h" |
36 #include "components/crx_file/id_util.h" | 36 #include "components/crx_file/id_util.h" |
37 #include "components/signin/core/browser/signin_manager.h" | 37 #include "components/signin/core/browser/signin_manager.h" |
38 #include "components/signin/core/common/profile_management_switches.h" | 38 #include "components/signin/core/common/profile_management_switches.h" |
39 #include "components/signin/core/common/signin_pref_names.h" | 39 #include "components/signin/core/common/signin_pref_names.h" |
40 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
41 #include "content/public/browser/notification_source.h" | 41 #include "content/public/browser/notification_source.h" |
42 #include "content/public/test/test_utils.h" | 42 #include "content/public/test/test_utils.h" |
43 #include "extensions/browser/guest_view/guest_view_base.h" | 43 #include "extensions/browser/guest_view/guest_view_base.h" |
44 #include "extensions/common/test_util.h" | |
44 #include "google_apis/gaia/google_service_auth_error.h" | 45 #include "google_apis/gaia/google_service_auth_error.h" |
45 #include "google_apis/gaia/oauth2_mint_token_flow.h" | 46 #include "google_apis/gaia/oauth2_mint_token_flow.h" |
46 #include "net/test/spawned_test_server/spawned_test_server.h" | 47 #include "net/test/spawned_test_server/spawned_test_server.h" |
47 #include "testing/gmock/include/gmock/gmock.h" | 48 #include "testing/gmock/include/gmock/gmock.h" |
48 #include "testing/gtest/include/gtest/gtest.h" | 49 #include "testing/gtest/include/gtest/gtest.h" |
49 #include "url/gurl.h" | 50 #include "url/gurl.h" |
50 | 51 |
51 using testing::_; | 52 using testing::_; |
52 using testing::Return; | 53 using testing::Return; |
53 using testing::ReturnRef; | 54 using testing::ReturnRef; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 const std::string& args) { | 111 const std::string& args) { |
111 response_delegate_.reset(new SendResponseDelegate); | 112 response_delegate_.reset(new SendResponseDelegate); |
112 function->set_test_delegate(response_delegate_.get()); | 113 function->set_test_delegate(response_delegate_.get()); |
113 scoped_ptr<base::ListValue> parsed_args(utils::ParseList(args)); | 114 scoped_ptr<base::ListValue> parsed_args(utils::ParseList(args)); |
114 EXPECT_TRUE(parsed_args.get()) << | 115 EXPECT_TRUE(parsed_args.get()) << |
115 "Could not parse extension function arguments: " << args; | 116 "Could not parse extension function arguments: " << args; |
116 function->SetArgs(parsed_args.get()); | 117 function->SetArgs(parsed_args.get()); |
117 | 118 |
118 if (!function->extension()) { | 119 if (!function->extension()) { |
119 scoped_refptr<Extension> empty_extension( | 120 scoped_refptr<Extension> empty_extension( |
120 utils::CreateEmptyExtension()); | 121 test_util::CreateEmptyExtension()); |
121 function->set_extension(empty_extension.get()); | 122 function->set_extension(empty_extension.get()); |
122 } | 123 } |
123 | 124 |
124 function->set_browser_context(browser()->profile()); | 125 function->set_browser_context(browser()->profile()); |
125 function->set_has_callback(true); | 126 function->set_has_callback(true); |
126 function->Run()->Execute(); | 127 function->Run()->Execute(); |
127 } | 128 } |
128 | 129 |
129 std::string WaitForError(UIThreadExtensionFunction* function) { | 130 std::string WaitForError(UIThreadExtensionFunction* function) { |
130 RunMessageLoopUntilResponse(); | 131 RunMessageLoopUntilResponse(); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 protected: | 405 protected: |
405 void SetAccountState(gaia::AccountIds ids, bool is_signed_in) { | 406 void SetAccountState(gaia::AccountIds ids, bool is_signed_in) { |
406 IdentityAPI::GetFactoryInstance()->Get(profile())->SetAccountStateForTest( | 407 IdentityAPI::GetFactoryInstance()->Get(profile())->SetAccountStateForTest( |
407 ids, is_signed_in); | 408 ids, is_signed_in); |
408 } | 409 } |
409 | 410 |
410 testing::AssertionResult ExpectGetAccounts( | 411 testing::AssertionResult ExpectGetAccounts( |
411 const std::vector<std::string>& accounts) { | 412 const std::vector<std::string>& accounts) { |
412 scoped_refptr<IdentityGetAccountsFunction> func( | 413 scoped_refptr<IdentityGetAccountsFunction> func( |
413 new IdentityGetAccountsFunction); | 414 new IdentityGetAccountsFunction); |
414 func->set_extension(utils::CreateEmptyExtension(kExtensionId).get()); | 415 func->set_extension(test_util::CreateEmptyExtension(kExtensionId).get()); |
415 if (!utils::RunFunction( | 416 if (!utils::RunFunction( |
416 func.get(), std::string("[]"), browser(), utils::NONE)) { | 417 func.get(), std::string("[]"), browser(), utils::NONE)) { |
417 return GenerateFailureResult(accounts, NULL) | 418 return GenerateFailureResult(accounts, NULL) |
418 << "getAccounts did not return a result."; | 419 << "getAccounts did not return a result."; |
419 } | 420 } |
420 const base::ListValue* callback_arguments = func->GetResultList(); | 421 const base::ListValue* callback_arguments = func->GetResultList(); |
421 if (!callback_arguments) | 422 if (!callback_arguments) |
422 return GenerateFailureResult(accounts, NULL) << "NULL result"; | 423 return GenerateFailureResult(accounts, NULL) << "NULL result"; |
423 | 424 |
424 if (callback_arguments->GetSize() != 1) { | 425 if (callback_arguments->GetSize() != 1) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 std::vector<std::string> only_primary; | 526 std::vector<std::string> only_primary; |
526 only_primary.push_back("1"); | 527 only_primary.push_back("1"); |
527 EXPECT_TRUE(ExpectGetAccounts(only_primary)); | 528 EXPECT_TRUE(ExpectGetAccounts(only_primary)); |
528 } | 529 } |
529 | 530 |
530 class IdentityGetProfileUserInfoFunctionTest : public ExtensionBrowserTest { | 531 class IdentityGetProfileUserInfoFunctionTest : public ExtensionBrowserTest { |
531 protected: | 532 protected: |
532 scoped_ptr<api::identity::ProfileUserInfo> RunGetProfileUserInfo() { | 533 scoped_ptr<api::identity::ProfileUserInfo> RunGetProfileUserInfo() { |
533 scoped_refptr<IdentityGetProfileUserInfoFunction> func( | 534 scoped_refptr<IdentityGetProfileUserInfoFunction> func( |
534 new IdentityGetProfileUserInfoFunction); | 535 new IdentityGetProfileUserInfoFunction); |
535 func->set_extension(utils::CreateEmptyExtension(kExtensionId).get()); | 536 func->set_extension(test_util::CreateEmptyExtension(kExtensionId).get()); |
536 scoped_ptr<base::Value> value( | 537 scoped_ptr<base::Value> value( |
537 utils::RunFunctionAndReturnSingleResult(func.get(), "[]", browser())); | 538 utils::RunFunctionAndReturnSingleResult(func.get(), "[]", browser())); |
538 return api::identity::ProfileUserInfo::FromValue(*value.get()); | 539 return api::identity::ProfileUserInfo::FromValue(*value.get()); |
539 } | 540 } |
540 | 541 |
541 scoped_ptr<api::identity::ProfileUserInfo> RunGetProfileUserInfoWithEmail() { | 542 scoped_ptr<api::identity::ProfileUserInfo> RunGetProfileUserInfoWithEmail() { |
542 scoped_refptr<IdentityGetProfileUserInfoFunction> func( | 543 scoped_refptr<IdentityGetProfileUserInfoFunction> func( |
543 new IdentityGetProfileUserInfoFunction); | 544 new IdentityGetProfileUserInfoFunction); |
544 func->set_extension(CreateExtensionWithEmailPermission()); | 545 func->set_extension(CreateExtensionWithEmailPermission()); |
545 scoped_ptr<base::Value> value( | 546 scoped_ptr<base::Value> value( |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1587 EXPECT_TRUE(ContainsKey(token_key->scopes, "email")); | 1588 EXPECT_TRUE(ContainsKey(token_key->scopes, "email")); |
1588 EXPECT_TRUE(ContainsKey(token_key->scopes, "foo")); | 1589 EXPECT_TRUE(ContainsKey(token_key->scopes, "foo")); |
1589 EXPECT_TRUE(ContainsKey(token_key->scopes, "bar")); | 1590 EXPECT_TRUE(ContainsKey(token_key->scopes, "bar")); |
1590 } | 1591 } |
1591 | 1592 |
1592 class RemoveCachedAuthTokenFunctionTest : public ExtensionBrowserTest { | 1593 class RemoveCachedAuthTokenFunctionTest : public ExtensionBrowserTest { |
1593 protected: | 1594 protected: |
1594 bool InvalidateDefaultToken() { | 1595 bool InvalidateDefaultToken() { |
1595 scoped_refptr<IdentityRemoveCachedAuthTokenFunction> func( | 1596 scoped_refptr<IdentityRemoveCachedAuthTokenFunction> func( |
1596 new IdentityRemoveCachedAuthTokenFunction); | 1597 new IdentityRemoveCachedAuthTokenFunction); |
1597 func->set_extension(utils::CreateEmptyExtension(kExtensionId).get()); | 1598 func->set_extension(test_util::CreateEmptyExtension( |
1599 crx_file::id_util::GenerateId(kExtensionId)).get()); | |
Yoyo Zhou
2014/09/15 18:52:43
Why is this changed?
limasdf
2014/09/16 15:36:47
Because ExtensionTOkenKey is made with crx_file::i
Yoyo Zhou
2014/09/18 17:55:29
Yeah, it looks unnecessary there too.
| |
1598 return utils::RunFunction( | 1600 return utils::RunFunction( |
1599 func.get(), | 1601 func.get(), |
1600 std::string("[{\"token\": \"") + kAccessToken + "\"}]", | 1602 std::string("[{\"token\": \"") + kAccessToken + "\"}]", |
1601 browser(), | 1603 browser(), |
1602 extension_function_test_utils::NONE); | 1604 extension_function_test_utils::NONE); |
1603 } | 1605 } |
1604 | 1606 |
1605 IdentityAPI* id_api() { | 1607 IdentityAPI* id_api() { |
1606 return IdentityAPI::GetFactoryInstance()->Get(browser()->profile()); | 1608 return IdentityAPI::GetFactoryInstance()->Get(browser()->profile()); |
1607 } | 1609 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1670 net::SpawnedTestServer https_server( | 1672 net::SpawnedTestServer https_server( |
1671 net::SpawnedTestServer::TYPE_HTTPS, | 1673 net::SpawnedTestServer::TYPE_HTTPS, |
1672 net::SpawnedTestServer::kLocalhost, | 1674 net::SpawnedTestServer::kLocalhost, |
1673 base::FilePath(FILE_PATH_LITERAL( | 1675 base::FilePath(FILE_PATH_LITERAL( |
1674 "chrome/test/data/extensions/api_test/identity"))); | 1676 "chrome/test/data/extensions/api_test/identity"))); |
1675 ASSERT_TRUE(https_server.Start()); | 1677 ASSERT_TRUE(https_server.Start()); |
1676 GURL auth_url(https_server.GetURL("files/interaction_required.html")); | 1678 GURL auth_url(https_server.GetURL("files/interaction_required.html")); |
1677 | 1679 |
1678 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1680 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
1679 new IdentityLaunchWebAuthFlowFunction()); | 1681 new IdentityLaunchWebAuthFlowFunction()); |
1680 scoped_refptr<Extension> empty_extension( | 1682 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
1681 utils::CreateEmptyExtension()); | |
1682 function->set_extension(empty_extension.get()); | 1683 function->set_extension(empty_extension.get()); |
1683 | 1684 |
1684 WaitForGURLAndCloseWindow popup_observer(auth_url); | 1685 WaitForGURLAndCloseWindow popup_observer(auth_url); |
1685 | 1686 |
1686 std::string args = "[{\"interactive\": true, \"url\": \"" + | 1687 std::string args = "[{\"interactive\": true, \"url\": \"" + |
1687 auth_url.spec() + "\"}]"; | 1688 auth_url.spec() + "\"}]"; |
1688 RunFunctionAsync(function.get(), args); | 1689 RunFunctionAsync(function.get(), args); |
1689 | 1690 |
1690 popup_observer.Wait(); | 1691 popup_observer.Wait(); |
1691 popup_observer.CloseEmbedderWebContents(); | 1692 popup_observer.CloseEmbedderWebContents(); |
1692 | 1693 |
1693 EXPECT_EQ(std::string(errors::kUserRejected), WaitForError(function.get())); | 1694 EXPECT_EQ(std::string(errors::kUserRejected), WaitForError(function.get())); |
1694 } | 1695 } |
1695 | 1696 |
1696 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, InteractionRequired) { | 1697 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, InteractionRequired) { |
1697 net::SpawnedTestServer https_server( | 1698 net::SpawnedTestServer https_server( |
1698 net::SpawnedTestServer::TYPE_HTTPS, | 1699 net::SpawnedTestServer::TYPE_HTTPS, |
1699 net::SpawnedTestServer::kLocalhost, | 1700 net::SpawnedTestServer::kLocalhost, |
1700 base::FilePath(FILE_PATH_LITERAL( | 1701 base::FilePath(FILE_PATH_LITERAL( |
1701 "chrome/test/data/extensions/api_test/identity"))); | 1702 "chrome/test/data/extensions/api_test/identity"))); |
1702 ASSERT_TRUE(https_server.Start()); | 1703 ASSERT_TRUE(https_server.Start()); |
1703 GURL auth_url(https_server.GetURL("files/interaction_required.html")); | 1704 GURL auth_url(https_server.GetURL("files/interaction_required.html")); |
1704 | 1705 |
1705 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1706 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
1706 new IdentityLaunchWebAuthFlowFunction()); | 1707 new IdentityLaunchWebAuthFlowFunction()); |
1707 scoped_refptr<Extension> empty_extension( | 1708 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
1708 utils::CreateEmptyExtension()); | |
1709 function->set_extension(empty_extension.get()); | 1709 function->set_extension(empty_extension.get()); |
1710 | 1710 |
1711 std::string args = "[{\"interactive\": false, \"url\": \"" + | 1711 std::string args = "[{\"interactive\": false, \"url\": \"" + |
1712 auth_url.spec() + "\"}]"; | 1712 auth_url.spec() + "\"}]"; |
1713 std::string error = | 1713 std::string error = |
1714 utils::RunFunctionAndReturnError(function.get(), args, browser()); | 1714 utils::RunFunctionAndReturnError(function.get(), args, browser()); |
1715 | 1715 |
1716 EXPECT_EQ(std::string(errors::kInteractionRequired), error); | 1716 EXPECT_EQ(std::string(errors::kInteractionRequired), error); |
1717 } | 1717 } |
1718 | 1718 |
1719 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, LoadFailed) { | 1719 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, LoadFailed) { |
1720 net::SpawnedTestServer https_server( | 1720 net::SpawnedTestServer https_server( |
1721 net::SpawnedTestServer::TYPE_HTTPS, | 1721 net::SpawnedTestServer::TYPE_HTTPS, |
1722 net::SpawnedTestServer::kLocalhost, | 1722 net::SpawnedTestServer::kLocalhost, |
1723 base::FilePath(FILE_PATH_LITERAL( | 1723 base::FilePath(FILE_PATH_LITERAL( |
1724 "chrome/test/data/extensions/api_test/identity"))); | 1724 "chrome/test/data/extensions/api_test/identity"))); |
1725 ASSERT_TRUE(https_server.Start()); | 1725 ASSERT_TRUE(https_server.Start()); |
1726 GURL auth_url(https_server.GetURL("files/five_hundred.html")); | 1726 GURL auth_url(https_server.GetURL("files/five_hundred.html")); |
1727 | 1727 |
1728 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1728 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
1729 new IdentityLaunchWebAuthFlowFunction()); | 1729 new IdentityLaunchWebAuthFlowFunction()); |
1730 scoped_refptr<Extension> empty_extension( | 1730 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
1731 utils::CreateEmptyExtension()); | |
1732 function->set_extension(empty_extension.get()); | 1731 function->set_extension(empty_extension.get()); |
1733 | 1732 |
1734 std::string args = "[{\"interactive\": true, \"url\": \"" + | 1733 std::string args = "[{\"interactive\": true, \"url\": \"" + |
1735 auth_url.spec() + "\"}]"; | 1734 auth_url.spec() + "\"}]"; |
1736 std::string error = | 1735 std::string error = |
1737 utils::RunFunctionAndReturnError(function.get(), args, browser()); | 1736 utils::RunFunctionAndReturnError(function.get(), args, browser()); |
1738 | 1737 |
1739 EXPECT_EQ(std::string(errors::kPageLoadFailure), error); | 1738 EXPECT_EQ(std::string(errors::kPageLoadFailure), error); |
1740 } | 1739 } |
1741 | 1740 |
1742 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, NonInteractiveSuccess) { | 1741 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, NonInteractiveSuccess) { |
1743 #if defined(OS_WIN) && defined(USE_ASH) | 1742 #if defined(OS_WIN) && defined(USE_ASH) |
1744 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 1743 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
1745 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 1744 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
1746 return; | 1745 return; |
1747 #endif | 1746 #endif |
1748 | 1747 |
1749 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1748 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
1750 new IdentityLaunchWebAuthFlowFunction()); | 1749 new IdentityLaunchWebAuthFlowFunction()); |
1751 scoped_refptr<Extension> empty_extension( | 1750 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
1752 utils::CreateEmptyExtension()); | |
1753 function->set_extension(empty_extension.get()); | 1751 function->set_extension(empty_extension.get()); |
1754 | 1752 |
1755 function->InitFinalRedirectURLPrefixForTest("abcdefghij"); | 1753 function->InitFinalRedirectURLPrefixForTest("abcdefghij"); |
1756 scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( | 1754 scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( |
1757 function.get(), | 1755 function.get(), |
1758 "[{\"interactive\": false," | 1756 "[{\"interactive\": false," |
1759 "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]", | 1757 "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]", |
1760 browser())); | 1758 browser())); |
1761 | 1759 |
1762 std::string url; | 1760 std::string url; |
1763 EXPECT_TRUE(value->GetAsString(&url)); | 1761 EXPECT_TRUE(value->GetAsString(&url)); |
1764 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1762 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1765 url); | 1763 url); |
1766 } | 1764 } |
1767 | 1765 |
1768 IN_PROC_BROWSER_TEST_F( | 1766 IN_PROC_BROWSER_TEST_F( |
1769 LaunchWebAuthFlowFunctionTest, InteractiveFirstNavigationSuccess) { | 1767 LaunchWebAuthFlowFunctionTest, InteractiveFirstNavigationSuccess) { |
1770 #if defined(OS_WIN) && defined(USE_ASH) | 1768 #if defined(OS_WIN) && defined(USE_ASH) |
1771 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 1769 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
1772 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 1770 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
1773 return; | 1771 return; |
1774 #endif | 1772 #endif |
1775 | 1773 |
1776 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1774 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
1777 new IdentityLaunchWebAuthFlowFunction()); | 1775 new IdentityLaunchWebAuthFlowFunction()); |
1778 scoped_refptr<Extension> empty_extension( | 1776 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
1779 utils::CreateEmptyExtension()); | |
1780 function->set_extension(empty_extension.get()); | 1777 function->set_extension(empty_extension.get()); |
1781 | 1778 |
1782 function->InitFinalRedirectURLPrefixForTest("abcdefghij"); | 1779 function->InitFinalRedirectURLPrefixForTest("abcdefghij"); |
1783 scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( | 1780 scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( |
1784 function.get(), | 1781 function.get(), |
1785 "[{\"interactive\": true," | 1782 "[{\"interactive\": true," |
1786 "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]", | 1783 "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]", |
1787 browser())); | 1784 browser())); |
1788 | 1785 |
1789 std::string url; | 1786 std::string url; |
1790 EXPECT_TRUE(value->GetAsString(&url)); | 1787 EXPECT_TRUE(value->GetAsString(&url)); |
1791 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1788 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1792 url); | 1789 url); |
1793 } | 1790 } |
1794 | 1791 |
1795 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, | 1792 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, |
1796 DISABLED_InteractiveSecondNavigationSuccess) { | 1793 DISABLED_InteractiveSecondNavigationSuccess) { |
1797 net::SpawnedTestServer https_server( | 1794 net::SpawnedTestServer https_server( |
1798 net::SpawnedTestServer::TYPE_HTTPS, | 1795 net::SpawnedTestServer::TYPE_HTTPS, |
1799 net::SpawnedTestServer::kLocalhost, | 1796 net::SpawnedTestServer::kLocalhost, |
1800 base::FilePath(FILE_PATH_LITERAL( | 1797 base::FilePath(FILE_PATH_LITERAL( |
1801 "chrome/test/data/extensions/api_test/identity"))); | 1798 "chrome/test/data/extensions/api_test/identity"))); |
1802 ASSERT_TRUE(https_server.Start()); | 1799 ASSERT_TRUE(https_server.Start()); |
1803 GURL auth_url(https_server.GetURL("files/redirect_to_chromiumapp.html")); | 1800 GURL auth_url(https_server.GetURL("files/redirect_to_chromiumapp.html")); |
1804 | 1801 |
1805 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1802 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
1806 new IdentityLaunchWebAuthFlowFunction()); | 1803 new IdentityLaunchWebAuthFlowFunction()); |
1807 scoped_refptr<Extension> empty_extension( | 1804 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
1808 utils::CreateEmptyExtension()); | |
1809 function->set_extension(empty_extension.get()); | 1805 function->set_extension(empty_extension.get()); |
1810 | 1806 |
1811 function->InitFinalRedirectURLPrefixForTest("abcdefghij"); | 1807 function->InitFinalRedirectURLPrefixForTest("abcdefghij"); |
1812 std::string args = "[{\"interactive\": true, \"url\": \"" + | 1808 std::string args = "[{\"interactive\": true, \"url\": \"" + |
1813 auth_url.spec() + "\"}]"; | 1809 auth_url.spec() + "\"}]"; |
1814 scoped_ptr<base::Value> value( | 1810 scoped_ptr<base::Value> value( |
1815 utils::RunFunctionAndReturnSingleResult(function.get(), args, browser())); | 1811 utils::RunFunctionAndReturnSingleResult(function.get(), args, browser())); |
1816 | 1812 |
1817 std::string url; | 1813 std::string url; |
1818 EXPECT_TRUE(value->GetAsString(&url)); | 1814 EXPECT_TRUE(value->GetAsString(&url)); |
1819 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1815 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1820 url); | 1816 url); |
1821 } | 1817 } |
1822 | 1818 |
1823 } // namespace extensions | 1819 } // namespace extensions |
1824 | 1820 |
1825 // Tests the chrome.identity API implemented by custom JS bindings . | 1821 // Tests the chrome.identity API implemented by custom JS bindings . |
1826 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1822 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
1827 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1823 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
1828 } | 1824 } |
OLD | NEW |