| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/files/file_util.h" | 5 #include "base/files/file_util.h" |
| 6 #include "base/message_loop/message_loop_proxy.h" | 6 #include "base/location.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/thread_task_runner_handle.h" |
| 8 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 9 #include "content/browser/browser_thread_impl.h" | 11 #include "content/browser/browser_thread_impl.h" |
| 10 #include "content/browser/gpu/shader_disk_cache.h" | 12 #include "content/browser/gpu/shader_disk_cache.h" |
| 11 #include "content/browser/quota/mock_quota_manager.h" | 13 #include "content/browser/quota/mock_quota_manager.h" |
| 12 #include "content/browser/storage_partition_impl.h" | 14 #include "content/browser/storage_partition_impl.h" |
| 13 #include "content/public/browser/local_storage_usage_info.h" | 15 #include "content/public/browser/local_storage_usage_info.h" |
| 14 #include "content/public/browser/storage_partition.h" | 16 #include "content/public/browser/storage_partition.h" |
| 15 #include "content/public/test/mock_special_storage_policy.h" | 17 #include "content/public/test/mock_special_storage_policy.h" |
| 16 #include "content/public/test/test_browser_context.h" | 18 #include "content/public/test/test_browser_context.h" |
| 17 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 scoped_refptr<ShaderDiskCache> cache_; | 398 scoped_refptr<ShaderDiskCache> cache_; |
| 397 }; | 399 }; |
| 398 | 400 |
| 399 // Tests --------------------------------------------------------------------- | 401 // Tests --------------------------------------------------------------------- |
| 400 | 402 |
| 401 TEST_F(StoragePartitionShaderClearTest, ClearShaderCache) { | 403 TEST_F(StoragePartitionShaderClearTest, ClearShaderCache) { |
| 402 InitCache(); | 404 InitCache(); |
| 403 EXPECT_EQ(1u, Size()); | 405 EXPECT_EQ(1u, Size()); |
| 404 | 406 |
| 405 base::RunLoop run_loop; | 407 base::RunLoop run_loop; |
| 406 base::MessageLoop::current()->PostTask( | 408 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 407 FROM_HERE, base::Bind( | 409 FROM_HERE, |
| 408 &ClearData, | 410 base::Bind(&ClearData, |
| 409 BrowserContext::GetDefaultStoragePartition(browser_context()), | 411 BrowserContext::GetDefaultStoragePartition(browser_context()), |
| 410 &run_loop)); | 412 &run_loop)); |
| 411 run_loop.Run(); | 413 run_loop.Run(); |
| 412 EXPECT_EQ(0u, Size()); | 414 EXPECT_EQ(0u, Size()); |
| 413 } | 415 } |
| 414 | 416 |
| 415 TEST_F(StoragePartitionImplTest, QuotaClientMaskGeneration) { | 417 TEST_F(StoragePartitionImplTest, QuotaClientMaskGeneration) { |
| 416 EXPECT_EQ(storage::QuotaClient::kFileSystem, | 418 EXPECT_EQ(storage::QuotaClient::kFileSystem, |
| 417 StoragePartitionImpl::GenerateQuotaClientMask( | 419 StoragePartitionImpl::GenerateQuotaClientMask( |
| 418 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS)); | 420 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS)); |
| 419 EXPECT_EQ(storage::QuotaClient::kDatabase, | 421 EXPECT_EQ(storage::QuotaClient::kDatabase, |
| 420 StoragePartitionImpl::GenerateQuotaClientMask( | 422 StoragePartitionImpl::GenerateQuotaClientMask( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 470 |
| 469 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverBoth) { | 471 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverBoth) { |
| 470 PopulateTestQuotaManagedData(GetMockManager()); | 472 PopulateTestQuotaManagedData(GetMockManager()); |
| 471 | 473 |
| 472 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 474 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 473 BrowserContext::GetDefaultStoragePartition(browser_context())); | 475 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 474 partition->OverrideQuotaManagerForTesting( | 476 partition->OverrideQuotaManagerForTesting( |
| 475 GetMockManager()); | 477 GetMockManager()); |
| 476 | 478 |
| 477 base::RunLoop run_loop; | 479 base::RunLoop run_loop; |
| 478 base::MessageLoop::current()->PostTask( | 480 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 479 FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); | 481 FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); |
| 480 run_loop.Run(); | 482 run_loop.Run(); |
| 481 | 483 |
| 482 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, | 484 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 483 kClientFile)); | 485 kClientFile)); |
| 484 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, | 486 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 485 kClientFile)); | 487 kClientFile)); |
| 486 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, | 488 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 487 kClientFile)); | 489 kClientFile)); |
| 488 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, | 490 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 489 kClientFile)); | 491 kClientFile)); |
| 490 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, | 492 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 491 kClientFile)); | 493 kClientFile)); |
| 492 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, | 494 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 493 kClientFile)); | 495 kClientFile)); |
| 494 } | 496 } |
| 495 | 497 |
| 496 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyTemporary) { | 498 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyTemporary) { |
| 497 PopulateTestQuotaManagedTemporaryData(GetMockManager()); | 499 PopulateTestQuotaManagedTemporaryData(GetMockManager()); |
| 498 | 500 |
| 499 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 501 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 500 BrowserContext::GetDefaultStoragePartition(browser_context())); | 502 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 501 partition->OverrideQuotaManagerForTesting( | 503 partition->OverrideQuotaManagerForTesting( |
| 502 GetMockManager()); | 504 GetMockManager()); |
| 503 | 505 |
| 504 base::RunLoop run_loop; | 506 base::RunLoop run_loop; |
| 505 base::MessageLoop::current()->PostTask( | 507 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 506 FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); | 508 FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); |
| 507 run_loop.Run(); | 509 run_loop.Run(); |
| 508 | 510 |
| 509 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, | 511 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 510 kClientFile)); | 512 kClientFile)); |
| 511 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, | 513 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 512 kClientFile)); | 514 kClientFile)); |
| 513 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, | 515 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 514 kClientFile)); | 516 kClientFile)); |
| 515 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, | 517 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 516 kClientFile)); | 518 kClientFile)); |
| 517 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, | 519 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 518 kClientFile)); | 520 kClientFile)); |
| 519 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, | 521 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 520 kClientFile)); | 522 kClientFile)); |
| 521 } | 523 } |
| 522 | 524 |
| 523 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyPersistent) { | 525 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyPersistent) { |
| 524 PopulateTestQuotaManagedPersistentData(GetMockManager()); | 526 PopulateTestQuotaManagedPersistentData(GetMockManager()); |
| 525 | 527 |
| 526 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 528 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 527 BrowserContext::GetDefaultStoragePartition(browser_context())); | 529 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 528 partition->OverrideQuotaManagerForTesting( | 530 partition->OverrideQuotaManagerForTesting( |
| 529 GetMockManager()); | 531 GetMockManager()); |
| 530 | 532 |
| 531 base::RunLoop run_loop; | 533 base::RunLoop run_loop; |
| 532 base::MessageLoop::current()->PostTask( | 534 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 533 FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); | 535 FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); |
| 534 run_loop.Run(); | 536 run_loop.Run(); |
| 535 | 537 |
| 536 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, | 538 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 537 kClientFile)); | 539 kClientFile)); |
| 538 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, | 540 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 539 kClientFile)); | 541 kClientFile)); |
| 540 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, | 542 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 541 kClientFile)); | 543 kClientFile)); |
| 542 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, | 544 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 543 kClientFile)); | 545 kClientFile)); |
| 544 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, | 546 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 545 kClientFile)); | 547 kClientFile)); |
| 546 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, | 548 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 547 kClientFile)); | 549 kClientFile)); |
| 548 } | 550 } |
| 549 | 551 |
| 550 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverNeither) { | 552 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverNeither) { |
| 551 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 553 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 552 BrowserContext::GetDefaultStoragePartition(browser_context())); | 554 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 553 partition->OverrideQuotaManagerForTesting( | 555 partition->OverrideQuotaManagerForTesting( |
| 554 GetMockManager()); | 556 GetMockManager()); |
| 555 | 557 |
| 556 base::RunLoop run_loop; | 558 base::RunLoop run_loop; |
| 557 base::MessageLoop::current()->PostTask( | 559 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 558 FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); | 560 FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); |
| 559 run_loop.Run(); | 561 run_loop.Run(); |
| 560 | 562 |
| 561 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, | 563 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 562 kClientFile)); | 564 kClientFile)); |
| 563 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, | 565 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 564 kClientFile)); | 566 kClientFile)); |
| 565 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, | 567 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 566 kClientFile)); | 568 kClientFile)); |
| 567 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, | 569 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 568 kClientFile)); | 570 kClientFile)); |
| 569 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, | 571 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 570 kClientFile)); | 572 kClientFile)); |
| 571 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, | 573 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 572 kClientFile)); | 574 kClientFile)); |
| 573 } | 575 } |
| 574 | 576 |
| 575 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverSpecificOrigin) { | 577 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverSpecificOrigin) { |
| 576 PopulateTestQuotaManagedData(GetMockManager()); | 578 PopulateTestQuotaManagedData(GetMockManager()); |
| 577 | 579 |
| 578 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 580 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 579 BrowserContext::GetDefaultStoragePartition(browser_context())); | 581 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 580 partition->OverrideQuotaManagerForTesting( | 582 partition->OverrideQuotaManagerForTesting( |
| 581 GetMockManager()); | 583 GetMockManager()); |
| 582 | 584 |
| 583 base::RunLoop run_loop; | 585 base::RunLoop run_loop; |
| 584 base::MessageLoop::current()->PostTask( | 586 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 585 FROM_HERE, base::Bind(&ClearQuotaDataForOrigin, | 587 FROM_HERE, base::Bind(&ClearQuotaDataForOrigin, partition, kOrigin1, |
| 586 partition, kOrigin1, base::Time(), | 588 base::Time(), &run_loop)); |
| 587 &run_loop)); | |
| 588 run_loop.Run(); | 589 run_loop.Run(); |
| 589 | 590 |
| 590 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, | 591 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 591 kClientFile)); | 592 kClientFile)); |
| 592 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, | 593 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 593 kClientFile)); | 594 kClientFile)); |
| 594 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, | 595 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 595 kClientFile)); | 596 kClientFile)); |
| 596 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, | 597 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 597 kClientFile)); | 598 kClientFile)); |
| 598 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, | 599 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 599 kClientFile)); | 600 kClientFile)); |
| 600 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, | 601 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 601 kClientFile)); | 602 kClientFile)); |
| 602 } | 603 } |
| 603 | 604 |
| 604 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastHour) { | 605 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastHour) { |
| 605 PopulateTestQuotaManagedData(GetMockManager()); | 606 PopulateTestQuotaManagedData(GetMockManager()); |
| 606 | 607 |
| 607 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 608 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 608 BrowserContext::GetDefaultStoragePartition(browser_context())); | 609 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 609 partition->OverrideQuotaManagerForTesting( | 610 partition->OverrideQuotaManagerForTesting( |
| 610 GetMockManager()); | 611 GetMockManager()); |
| 611 | 612 |
| 612 base::RunLoop run_loop; | 613 base::RunLoop run_loop; |
| 613 base::MessageLoop::current()->PostTask( | 614 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 614 FROM_HERE, base::Bind(&ClearQuotaDataForOrigin, | 615 FROM_HERE, |
| 615 partition, GURL(), | 616 base::Bind(&ClearQuotaDataForOrigin, partition, GURL(), |
| 616 base::Time::Now() - base::TimeDelta::FromHours(1), | 617 base::Time::Now() - base::TimeDelta::FromHours(1), &run_loop)); |
| 617 &run_loop)); | |
| 618 run_loop.Run(); | 618 run_loop.Run(); |
| 619 | 619 |
| 620 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, | 620 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 621 kClientFile)); | 621 kClientFile)); |
| 622 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, | 622 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 623 kClientFile)); | 623 kClientFile)); |
| 624 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, | 624 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 625 kClientFile)); | 625 kClientFile)); |
| 626 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, | 626 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 627 kClientFile)); | 627 kClientFile)); |
| 628 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, | 628 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 629 kClientFile)); | 629 kClientFile)); |
| 630 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, | 630 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 631 kClientFile)); | 631 kClientFile)); |
| 632 } | 632 } |
| 633 | 633 |
| 634 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastWeek) { | 634 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastWeek) { |
| 635 PopulateTestQuotaManagedData(GetMockManager()); | 635 PopulateTestQuotaManagedData(GetMockManager()); |
| 636 | 636 |
| 637 base::RunLoop run_loop; | 637 base::RunLoop run_loop; |
| 638 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 638 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 639 BrowserContext::GetDefaultStoragePartition(browser_context())); | 639 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 640 partition->OverrideQuotaManagerForTesting( | 640 partition->OverrideQuotaManagerForTesting( |
| 641 GetMockManager()); | 641 GetMockManager()); |
| 642 base::MessageLoop::current()->PostTask( | 642 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 643 FROM_HERE, base::Bind(&ClearQuotaDataForNonPersistent, | 643 FROM_HERE, |
| 644 partition, | 644 base::Bind(&ClearQuotaDataForNonPersistent, partition, |
| 645 base::Time::Now() - base::TimeDelta::FromDays(7), | 645 base::Time::Now() - base::TimeDelta::FromDays(7), &run_loop)); |
| 646 &run_loop)); | |
| 647 run_loop.Run(); | 646 run_loop.Run(); |
| 648 | 647 |
| 649 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, | 648 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 650 kClientFile)); | 649 kClientFile)); |
| 651 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, | 650 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 652 kClientFile)); | 651 kClientFile)); |
| 653 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, | 652 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 654 kClientFile)); | 653 kClientFile)); |
| 655 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, | 654 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 656 kClientFile)); | 655 kClientFile)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 668 | 667 |
| 669 PopulateTestQuotaManagedData(GetMockManager()); | 668 PopulateTestQuotaManagedData(GetMockManager()); |
| 670 | 669 |
| 671 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 670 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 672 BrowserContext::GetDefaultStoragePartition(browser_context())); | 671 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 673 partition->OverrideQuotaManagerForTesting( | 672 partition->OverrideQuotaManagerForTesting( |
| 674 GetMockManager()); | 673 GetMockManager()); |
| 675 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); | 674 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
| 676 | 675 |
| 677 base::RunLoop run_loop; | 676 base::RunLoop run_loop; |
| 678 base::MessageLoop::current()->PostTask( | 677 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 679 FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, | 678 FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, partition, GURL(), |
| 680 partition, GURL(), | |
| 681 base::Bind(&DoesOriginMatchForUnprotectedWeb), | 679 base::Bind(&DoesOriginMatchForUnprotectedWeb), |
| 682 base::Time(), &run_loop)); | 680 base::Time(), &run_loop)); |
| 683 run_loop.Run(); | 681 run_loop.Run(); |
| 684 | 682 |
| 685 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, | 683 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 686 kClientFile)); | 684 kClientFile)); |
| 687 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, | 685 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 688 kClientFile)); | 686 kClientFile)); |
| 689 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, | 687 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 690 kClientFile)); | 688 kClientFile)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 705 PopulateTestQuotaManagedData(GetMockManager()); | 703 PopulateTestQuotaManagedData(GetMockManager()); |
| 706 | 704 |
| 707 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 705 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 708 BrowserContext::GetDefaultStoragePartition(browser_context())); | 706 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 709 partition->OverrideQuotaManagerForTesting( | 707 partition->OverrideQuotaManagerForTesting( |
| 710 GetMockManager()); | 708 GetMockManager()); |
| 711 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); | 709 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
| 712 | 710 |
| 713 // Try to remove kOrigin1. Expect failure. | 711 // Try to remove kOrigin1. Expect failure. |
| 714 base::RunLoop run_loop; | 712 base::RunLoop run_loop; |
| 715 base::MessageLoop::current()->PostTask( | 713 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 716 FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, | 714 FROM_HERE, |
| 717 partition, kOrigin1, | 715 base::Bind(&ClearQuotaDataWithOriginMatcher, partition, kOrigin1, |
| 718 base::Bind(&DoesOriginMatchForUnprotectedWeb), | 716 base::Bind(&DoesOriginMatchForUnprotectedWeb), base::Time(), |
| 719 base::Time(), &run_loop)); | 717 &run_loop)); |
| 720 run_loop.Run(); | 718 run_loop.Run(); |
| 721 | 719 |
| 722 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, | 720 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 723 kClientFile)); | 721 kClientFile)); |
| 724 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, | 722 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 725 kClientFile)); | 723 kClientFile)); |
| 726 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, | 724 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 727 kClientFile)); | 725 kClientFile)); |
| 728 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, | 726 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 729 kClientFile)); | 727 kClientFile)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 741 | 739 |
| 742 PopulateTestQuotaManagedData(GetMockManager()); | 740 PopulateTestQuotaManagedData(GetMockManager()); |
| 743 | 741 |
| 744 // Try to remove kOrigin1. Expect success. | 742 // Try to remove kOrigin1. Expect success. |
| 745 base::RunLoop run_loop; | 743 base::RunLoop run_loop; |
| 746 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 744 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 747 BrowserContext::GetDefaultStoragePartition(browser_context())); | 745 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 748 partition->OverrideQuotaManagerForTesting( | 746 partition->OverrideQuotaManagerForTesting( |
| 749 GetMockManager()); | 747 GetMockManager()); |
| 750 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); | 748 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
| 751 base::MessageLoop::current()->PostTask( | 749 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 752 FROM_HERE, | 750 FROM_HERE, |
| 753 base::Bind(&ClearQuotaDataWithOriginMatcher, | 751 base::Bind(&ClearQuotaDataWithOriginMatcher, partition, GURL(), |
| 754 partition, GURL(), | |
| 755 base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), | 752 base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), |
| 756 base::Time(), &run_loop)); | 753 base::Time(), &run_loop)); |
| 757 run_loop.Run(); | 754 run_loop.Run(); |
| 758 | 755 |
| 759 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, | 756 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 760 kClientFile)); | 757 kClientFile)); |
| 761 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, | 758 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 762 kClientFile)); | 759 kClientFile)); |
| 763 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, | 760 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 764 kClientFile)); | 761 kClientFile)); |
| 765 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, | 762 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 766 kClientFile)); | 763 kClientFile)); |
| 767 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, | 764 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 768 kClientFile)); | 765 kClientFile)); |
| 769 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, | 766 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 770 kClientFile)); | 767 kClientFile)); |
| 771 } | 768 } |
| 772 | 769 |
| 773 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedIgnoreDevTools) { | 770 TEST_F(StoragePartitionImplTest, RemoveQuotaManagedIgnoreDevTools) { |
| 774 PopulateTestQuotaManagedNonBrowsingData(GetMockManager()); | 771 PopulateTestQuotaManagedNonBrowsingData(GetMockManager()); |
| 775 | 772 |
| 776 base::RunLoop run_loop; | 773 base::RunLoop run_loop; |
| 777 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 774 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 778 BrowserContext::GetDefaultStoragePartition(browser_context())); | 775 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 779 partition->OverrideQuotaManagerForTesting( | 776 partition->OverrideQuotaManagerForTesting( |
| 780 GetMockManager()); | 777 GetMockManager()); |
| 781 base::MessageLoop::current()->PostTask( | 778 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 782 FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, | 779 FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, partition, GURL(), |
| 783 partition, GURL(), | |
| 784 base::Bind(&DoesOriginMatchUnprotected), | 780 base::Bind(&DoesOriginMatchUnprotected), |
| 785 base::Time(), &run_loop)); | 781 base::Time(), &run_loop)); |
| 786 run_loop.Run(); | 782 run_loop.Run(); |
| 787 | 783 |
| 788 // Check that devtools data isn't removed. | 784 // Check that devtools data isn't removed. |
| 789 EXPECT_TRUE(GetMockManager()->OriginHasData(kOriginDevTools, kTemporary, | 785 EXPECT_TRUE(GetMockManager()->OriginHasData(kOriginDevTools, kTemporary, |
| 790 kClientFile)); | 786 kClientFile)); |
| 791 EXPECT_TRUE(GetMockManager()->OriginHasData(kOriginDevTools, kPersistent, | 787 EXPECT_TRUE(GetMockManager()->OriginHasData(kOriginDevTools, kPersistent, |
| 792 kClientFile)); | 788 kClientFile)); |
| 793 } | 789 } |
| 794 | 790 |
| 795 TEST_F(StoragePartitionImplTest, RemoveCookieForever) { | 791 TEST_F(StoragePartitionImplTest, RemoveCookieForever) { |
| 796 RemoveCookieTester tester(browser_context()); | 792 RemoveCookieTester tester(browser_context()); |
| 797 | 793 |
| 798 tester.AddCookie(); | 794 tester.AddCookie(); |
| 799 ASSERT_TRUE(tester.ContainsCookie()); | 795 ASSERT_TRUE(tester.ContainsCookie()); |
| 800 | 796 |
| 801 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 797 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 802 BrowserContext::GetDefaultStoragePartition(browser_context())); | 798 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 803 partition->SetURLRequestContext(browser_context()->GetRequestContext()); | 799 partition->SetURLRequestContext(browser_context()->GetRequestContext()); |
| 804 | 800 |
| 805 base::RunLoop run_loop; | 801 base::RunLoop run_loop; |
| 806 base::MessageLoop::current()->PostTask( | 802 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 807 FROM_HERE, base::Bind(&ClearCookies, | 803 FROM_HERE, base::Bind(&ClearCookies, partition, base::Time(), |
| 808 partition, base::Time(), base::Time::Max(), | 804 base::Time::Max(), &run_loop)); |
| 809 &run_loop)); | |
| 810 run_loop.Run(); | 805 run_loop.Run(); |
| 811 | 806 |
| 812 EXPECT_FALSE(tester.ContainsCookie()); | 807 EXPECT_FALSE(tester.ContainsCookie()); |
| 813 } | 808 } |
| 814 | 809 |
| 815 TEST_F(StoragePartitionImplTest, RemoveCookieLastHour) { | 810 TEST_F(StoragePartitionImplTest, RemoveCookieLastHour) { |
| 816 RemoveCookieTester tester(browser_context()); | 811 RemoveCookieTester tester(browser_context()); |
| 817 | 812 |
| 818 tester.AddCookie(); | 813 tester.AddCookie(); |
| 819 ASSERT_TRUE(tester.ContainsCookie()); | 814 ASSERT_TRUE(tester.ContainsCookie()); |
| 820 | 815 |
| 821 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 816 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 822 BrowserContext::GetDefaultStoragePartition(browser_context())); | 817 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 823 base::Time an_hour_ago = base::Time::Now() - base::TimeDelta::FromHours(1); | 818 base::Time an_hour_ago = base::Time::Now() - base::TimeDelta::FromHours(1); |
| 824 partition->SetURLRequestContext(browser_context()->GetRequestContext()); | 819 partition->SetURLRequestContext(browser_context()->GetRequestContext()); |
| 825 | 820 |
| 826 base::RunLoop run_loop; | 821 base::RunLoop run_loop; |
| 827 base::MessageLoop::current()->PostTask( | 822 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 828 FROM_HERE, base::Bind(&ClearCookies, | 823 FROM_HERE, base::Bind(&ClearCookies, partition, an_hour_ago, |
| 829 partition, an_hour_ago, base::Time::Max(), | 824 base::Time::Max(), &run_loop)); |
| 830 &run_loop)); | |
| 831 run_loop.Run(); | 825 run_loop.Run(); |
| 832 | 826 |
| 833 EXPECT_FALSE(tester.ContainsCookie()); | 827 EXPECT_FALSE(tester.ContainsCookie()); |
| 834 } | 828 } |
| 835 | 829 |
| 836 TEST_F(StoragePartitionImplTest, RemoveUnprotectedLocalStorageForever) { | 830 TEST_F(StoragePartitionImplTest, RemoveUnprotectedLocalStorageForever) { |
| 837 // Protect kOrigin1. | 831 // Protect kOrigin1. |
| 838 scoped_refptr<MockSpecialStoragePolicy> mock_policy = | 832 scoped_refptr<MockSpecialStoragePolicy> mock_policy = |
| 839 new MockSpecialStoragePolicy; | 833 new MockSpecialStoragePolicy; |
| 840 mock_policy->AddProtected(kOrigin1.GetOrigin()); | 834 mock_policy->AddProtected(kOrigin1.GetOrigin()); |
| 841 | 835 |
| 842 RemoveLocalStorageTester tester(browser_context()); | 836 RemoveLocalStorageTester tester(browser_context()); |
| 843 | 837 |
| 844 tester.AddDOMStorageTestData(); | 838 tester.AddDOMStorageTestData(); |
| 845 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); | 839 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 846 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); | 840 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 847 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); | 841 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 848 | 842 |
| 849 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 843 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 850 BrowserContext::GetDefaultStoragePartition(browser_context())); | 844 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 851 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); | 845 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
| 852 | 846 |
| 853 base::RunLoop run_loop; | 847 base::RunLoop run_loop; |
| 854 base::MessageLoop::current()->PostTask( | 848 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 855 FROM_HERE, | 849 FROM_HERE, |
| 856 base::Bind(&ClearStuff, | 850 base::Bind(&ClearStuff, |
| 857 StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, | 851 StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, |
| 858 partition, base::Time(), base::Time::Max(), | 852 partition, base::Time(), base::Time::Max(), |
| 859 base::Bind(&DoesOriginMatchForUnprotectedWeb), | 853 base::Bind(&DoesOriginMatchForUnprotectedWeb), &run_loop)); |
| 860 &run_loop)); | |
| 861 run_loop.Run(); | 854 run_loop.Run(); |
| 862 | 855 |
| 863 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); | 856 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 864 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); | 857 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 865 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin3)); | 858 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 866 } | 859 } |
| 867 | 860 |
| 868 TEST_F(StoragePartitionImplTest, RemoveProtectedLocalStorageForever) { | 861 TEST_F(StoragePartitionImplTest, RemoveProtectedLocalStorageForever) { |
| 869 // Protect kOrigin1. | 862 // Protect kOrigin1. |
| 870 scoped_refptr<MockSpecialStoragePolicy> mock_policy = | 863 scoped_refptr<MockSpecialStoragePolicy> mock_policy = |
| 871 new MockSpecialStoragePolicy; | 864 new MockSpecialStoragePolicy; |
| 872 mock_policy->AddProtected(kOrigin1.GetOrigin()); | 865 mock_policy->AddProtected(kOrigin1.GetOrigin()); |
| 873 | 866 |
| 874 RemoveLocalStorageTester tester(browser_context()); | 867 RemoveLocalStorageTester tester(browser_context()); |
| 875 | 868 |
| 876 tester.AddDOMStorageTestData(); | 869 tester.AddDOMStorageTestData(); |
| 877 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); | 870 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 878 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); | 871 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 879 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); | 872 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 880 | 873 |
| 881 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 874 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 882 BrowserContext::GetDefaultStoragePartition(browser_context())); | 875 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 883 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); | 876 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
| 884 | 877 |
| 885 base::RunLoop run_loop; | 878 base::RunLoop run_loop; |
| 886 base::MessageLoop::current()->PostTask( | 879 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 887 FROM_HERE, | 880 FROM_HERE, |
| 888 base::Bind(&ClearStuff, | 881 base::Bind(&ClearStuff, |
| 889 StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, | 882 StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, |
| 890 partition, base::Time(), base::Time::Max(), | 883 partition, base::Time(), base::Time::Max(), |
| 891 base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), | 884 base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), |
| 892 &run_loop)); | 885 &run_loop)); |
| 893 run_loop.Run(); | 886 run_loop.Run(); |
| 894 | 887 |
| 895 // Even if kOrigin1 is protected, it will be deleted since we specify | 888 // Even if kOrigin1 is protected, it will be deleted since we specify |
| 896 // ClearData to delete protected data. | 889 // ClearData to delete protected data. |
| 897 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1)); | 890 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 898 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); | 891 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 899 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin3)); | 892 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 900 } | 893 } |
| 901 | 894 |
| 902 TEST_F(StoragePartitionImplTest, RemoveLocalStorageForLastWeek) { | 895 TEST_F(StoragePartitionImplTest, RemoveLocalStorageForLastWeek) { |
| 903 RemoveLocalStorageTester tester(browser_context()); | 896 RemoveLocalStorageTester tester(browser_context()); |
| 904 | 897 |
| 905 tester.AddDOMStorageTestData(); | 898 tester.AddDOMStorageTestData(); |
| 906 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); | 899 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 907 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); | 900 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 908 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); | 901 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 909 | 902 |
| 910 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 903 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 911 BrowserContext::GetDefaultStoragePartition(browser_context())); | 904 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 912 base::Time a_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7); | 905 base::Time a_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7); |
| 913 | 906 |
| 914 base::RunLoop run_loop; | 907 base::RunLoop run_loop; |
| 915 base::MessageLoop::current()->PostTask( | 908 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 916 FROM_HERE, | 909 FROM_HERE, |
| 917 base::Bind(&ClearStuff, | 910 base::Bind(&ClearStuff, |
| 918 StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, | 911 StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, |
| 919 partition, a_week_ago, base::Time::Max(), | 912 partition, a_week_ago, base::Time::Max(), |
| 920 base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), | 913 base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), |
| 921 &run_loop)); | 914 &run_loop)); |
| 922 run_loop.Run(); | 915 run_loop.Run(); |
| 923 | 916 |
| 924 // kOrigin1 and kOrigin2 do not have age more than a week. | 917 // kOrigin1 and kOrigin2 do not have age more than a week. |
| 925 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1)); | 918 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 926 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); | 919 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 927 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); | 920 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 928 } | 921 } |
| 929 | 922 |
| 930 } // namespace content | 923 } // namespace content |
| OLD | NEW |