OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // End-to-end SDCH tests. Uses the embedded test server to return SDCH | 5 // End-to-end SDCH tests. Uses the embedded test server to return SDCH |
6 // results | 6 // results |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/base64.h" | 12 #include "base/base64.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/files/scoped_temp_dir.h" | 16 #include "base/files/scoped_temp_dir.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
20 #include "base/strings/string_tokenizer.h" | 20 #include "base/strings/string_tokenizer.h" |
21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 25 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
26 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 26 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
27 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 27 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
28 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 28 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| 29 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
29 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/browser/profiles/profile_manager.h" | 31 #include "chrome/browser/profiles/profile_manager.h" |
31 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
32 #include "chrome/browser/ui/browser_tabstrip.h" | 33 #include "chrome/browser/ui/browser_tabstrip.h" |
33 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
34 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
35 #include "chrome/common/chrome_paths.h" | 36 #include "chrome/common/chrome_paths.h" |
36 #include "chrome/test/base/in_process_browser_test.h" | 37 #include "chrome/test/base/in_process_browser_test.h" |
37 #include "components/browsing_data/core/browsing_data_utils.h" | 38 #include "components/browsing_data/core/browsing_data_utils.h" |
38 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 run_loop.QuitClosure()); | 403 run_loop.QuitClosure()); |
403 run_loop.Run(); | 404 run_loop.Run(); |
404 DCHECK_NE(-1, fetches); | 405 DCHECK_NE(-1, fetches); |
405 return fetches; | 406 return fetches; |
406 } | 407 } |
407 | 408 |
408 void BrowsingDataRemoveAndWait(int remove_mask) { | 409 void BrowsingDataRemoveAndWait(int remove_mask) { |
409 BrowsingDataRemover* remover = | 410 BrowsingDataRemover* remover = |
410 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); | 411 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); |
411 BrowsingDataRemoverCompletionObserver completion_observer(remover); | 412 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
412 remover->RemoveAndReply(browsing_data::CalculateBeginDeleteTime( | 413 remover->RemoveAndReply( |
413 browsing_data::TimePeriod::LAST_HOUR), | 414 browsing_data::CalculateBeginDeleteTime( |
414 browsing_data::CalculateEndDeleteTime( | 415 browsing_data::TimePeriod::LAST_HOUR), |
415 browsing_data::TimePeriod::LAST_HOUR), | 416 browsing_data::CalculateEndDeleteTime( |
416 remove_mask, BrowsingDataHelper::UNPROTECTED_WEB, | 417 browsing_data::TimePeriod::LAST_HOUR), |
417 &completion_observer); | 418 remove_mask, |
| 419 ChromeBrowsingDataRemoverDelegate::ORIGIN_TYPE_UNPROTECTED_WEB, |
| 420 &completion_observer); |
418 completion_observer.BlockUntilCompletion(); | 421 completion_observer.BlockUntilCompletion(); |
419 } | 422 } |
420 | 423 |
421 // Something of a cheat; nuke the dictionaries off the SdchManager without | 424 // Something of a cheat; nuke the dictionaries off the SdchManager without |
422 // touching the cache (which browsing data remover would do). | 425 // touching the cache (which browsing data remover would do). |
423 void NukeSdchDictionaries() { | 426 void NukeSdchDictionaries() { |
424 base::RunLoop run_loop; | 427 base::RunLoop run_loop; |
425 content::BrowserThread::PostTaskAndReply( | 428 content::BrowserThread::PostTaskAndReply( |
426 content::BrowserThread::IO, FROM_HERE, | 429 content::BrowserThread::IO, FROM_HERE, |
427 base::Bind(&SdchBrowserTest::NukeSdchDictionariesOnIOThread, | 430 base::Bind(&SdchBrowserTest::NukeSdchDictionariesOnIOThread, |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 const char SdchBrowserTest::kTestHost[] = "our.test.host.com"; | 672 const char SdchBrowserTest::kTestHost[] = "our.test.host.com"; |
670 | 673 |
671 // Confirm that after getting a dictionary, calling the browsing | 674 // Confirm that after getting a dictionary, calling the browsing |
672 // data remover renders it unusable. Also (in calling | 675 // data remover renders it unusable. Also (in calling |
673 // ForceSdchDictionaryLoad()) servers as a smoke test for SDCH. | 676 // ForceSdchDictionaryLoad()) servers as a smoke test for SDCH. |
674 IN_PROC_BROWSER_TEST_F(SdchBrowserTest, BrowsingDataRemover) { | 677 IN_PROC_BROWSER_TEST_F(SdchBrowserTest, BrowsingDataRemover) { |
675 ASSERT_TRUE(ForceSdchDictionaryLoad(browser())); | 678 ASSERT_TRUE(ForceSdchDictionaryLoad(browser())); |
676 | 679 |
677 // Confirm browsing data remover without removing the cache leaves | 680 // Confirm browsing data remover without removing the cache leaves |
678 // SDCH alone. | 681 // SDCH alone. |
679 BrowsingDataRemoveAndWait(BrowsingDataRemover::REMOVE_ALL & | 682 BrowsingDataRemoveAndWait( |
680 ~BrowsingDataRemover::REMOVE_CACHE); | 683 ChromeBrowsingDataRemoverDelegate::ALL_DATA_TYPES & |
| 684 ~ChromeBrowsingDataRemoverDelegate::DATA_TYPE_CACHE); |
681 bool sdch_encoding_used = false; | 685 bool sdch_encoding_used = false; |
682 ASSERT_TRUE(GetData(&sdch_encoding_used)); | 686 ASSERT_TRUE(GetData(&sdch_encoding_used)); |
683 EXPECT_TRUE(sdch_encoding_used); | 687 EXPECT_TRUE(sdch_encoding_used); |
684 | 688 |
685 // Confirm browsing data remover removing the cache clears SDCH state. | 689 // Confirm browsing data remover removing the cache clears SDCH state. |
686 BrowsingDataRemoveAndWait(BrowsingDataRemover::REMOVE_CACHE); | 690 BrowsingDataRemoveAndWait(ChromeBrowsingDataRemoverDelegate::DATA_TYPE_CACHE); |
687 sdch_encoding_used = false; | 691 sdch_encoding_used = false; |
688 ASSERT_TRUE(GetData(&sdch_encoding_used)); | 692 ASSERT_TRUE(GetData(&sdch_encoding_used)); |
689 EXPECT_FALSE(sdch_encoding_used); | 693 EXPECT_FALSE(sdch_encoding_used); |
690 } | 694 } |
691 | 695 |
692 // Confirm dictionaries not visible in other profiles. | 696 // Confirm dictionaries not visible in other profiles. |
693 IN_PROC_BROWSER_TEST_F(SdchBrowserTest, Isolation) { | 697 IN_PROC_BROWSER_TEST_F(SdchBrowserTest, Isolation) { |
694 ASSERT_TRUE(ForceSdchDictionaryLoad(browser())); | 698 ASSERT_TRUE(ForceSdchDictionaryLoad(browser())); |
695 ASSERT_TRUE(SetupSecondBrowser()); | 699 ASSERT_TRUE(SetupSecondBrowser()); |
696 ASSERT_TRUE(SetupIncognitoBrowser()); | 700 ASSERT_TRUE(SetupIncognitoBrowser()); |
(...skipping 17 matching lines...) Expand all Loading... |
714 ASSERT_TRUE(SetupIncognitoBrowser()); | 718 ASSERT_TRUE(SetupIncognitoBrowser()); |
715 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); | 719 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); |
716 | 720 |
717 // Data fetches on main browser should not be SDCH encoded. | 721 // Data fetches on main browser should not be SDCH encoded. |
718 bool sdch_encoding_used = true; | 722 bool sdch_encoding_used = true; |
719 ASSERT_TRUE(GetData(&sdch_encoding_used)); | 723 ASSERT_TRUE(GetData(&sdch_encoding_used)); |
720 EXPECT_FALSE(sdch_encoding_used); | 724 EXPECT_FALSE(sdch_encoding_used); |
721 } | 725 } |
722 | 726 |
723 } // namespace | 727 } // namespace |
OLD | NEW |