| Index: chrome/browser/extensions/api/page_capture/page_capture_apitest.cc
|
| diff --git a/chrome/browser/extensions/api/page_capture/page_capture_apitest.cc b/chrome/browser/extensions/api/page_capture/page_capture_apitest.cc
|
| index 556e4be15b6086ad54e4023b671ff71906b8381a..3cdf16b7efa0f2f87e112f420aa44ff1bd0f2804 100644
|
| --- a/chrome/browser/extensions/api/page_capture/page_capture_apitest.cc
|
| +++ b/chrome/browser/extensions/api/page_capture/page_capture_apitest.cc
|
| @@ -7,11 +7,14 @@
|
| #include "chrome/browser/extensions/api/page_capture/page_capture_api.h"
|
| #include "chrome/browser/extensions/extension_apitest.h"
|
| #include "chrome/common/chrome_switches.h"
|
| +#include "chromeos/login/login_state.h"
|
| #include "content/public/common/content_switches.h"
|
| #include "content/public/test/test_utils.h"
|
| +#include "extensions/browser/extension_dialog_auto_confirm.h"
|
| #include "net/dns/mock_host_resolver.h"
|
|
|
| using extensions::PageCaptureSaveAsMHTMLFunction;
|
| +using extensions::ScopedTestDialogAutoConfirm;
|
|
|
| class ExtensionPageCaptureApiTest : public ExtensionApiTest {
|
| public:
|
| @@ -44,9 +47,46 @@ IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest, SaveAsMHTML) {
|
| ASSERT_TRUE(StartEmbeddedTestServer());
|
| PageCaptureSaveAsMHTMLDelegate delegate;
|
| ASSERT_TRUE(RunExtensionTest("page_capture")) << message_;
|
| + // Make sure the MHTML data gets written to the temporary file.
|
| ASSERT_FALSE(delegate.temp_file_.empty());
|
| // Flush the message loops to make sure the delete happens.
|
| content::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
|
| content::RunAllPendingInMessageLoop(content::BrowserThread::IO);
|
| + // Make sure the temporary file is destroyed once the javascript side reads
|
| + // the contents.
|
| ASSERT_FALSE(base::PathExists(delegate.temp_file_));
|
| }
|
| +
|
| +#if defined(OS_CHROMEOS)
|
| +IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest,
|
| + PublicSessionRequestAllowed) {
|
| + host_resolver()->AddRule("www.a.com", "127.0.0.1");
|
| + ASSERT_TRUE(StartEmbeddedTestServer());
|
| + PageCaptureSaveAsMHTMLDelegate delegate;
|
| + // Set Public Session state.
|
| + chromeos::LoginState::Get()->SetLoggedInState(
|
| + chromeos::LoginState::LOGGED_IN_ACTIVE,
|
| + chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
|
| + // Resolve Permission dialog with Allow.
|
| + ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::ACCEPT);
|
| + ASSERT_TRUE(RunExtensionTest("page_capture")) << message_;
|
| + ASSERT_FALSE(delegate.temp_file_.empty());
|
| + content::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
|
| + content::RunAllPendingInMessageLoop(content::BrowserThread::IO);
|
| + ASSERT_FALSE(base::PathExists(delegate.temp_file_));
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest,
|
| + PublicSessionRequestDenied) {
|
| + host_resolver()->AddRule("www.a.com", "127.0.0.1");
|
| + ASSERT_TRUE(StartEmbeddedTestServer());
|
| + // Set Public Session state.
|
| + chromeos::LoginState::Get()->SetLoggedInState(
|
| + chromeos::LoginState::LOGGED_IN_ACTIVE,
|
| + chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
|
| + // Resolve Permission dialog with Deny.
|
| + ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::CANCEL);
|
| + ASSERT_TRUE(RunExtensionTestWithArg("page_capture", "REQUEST_DENIED"))
|
| + << message_;
|
| +}
|
| +#endif // defined(OS_CHROMEOS)
|
|
|