This source file includes following definitions.
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "chrome/browser/extensions/browser_action_test_util.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
using content::WebContents;
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoNoScript) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("incognito")
.AppendASCII("content_scripts")));
Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord(
browser()->profile(),
embedded_test_server()->GetURL("/extensions/test_file.html"));
WebContents* tab = otr_browser->tab_strip_model()->GetActiveWebContents();
bool result = false;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
tab,
"window.domAutomationController.send(document.title == 'Unmodified')",
&result));
EXPECT_TRUE(result);
}
#if defined(OS_WIN)
#define MAYBE_IncognitoYesScript DISABLED_IncognitoYesScript
#else
#define MAYBE_IncognitoYesScript IncognitoYesScript
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_IncognitoYesScript) {
host_resolver()->AddRule("*", "127.0.0.1");
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("content_scripts")
.AppendASCII("all_frames")));
ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_
.AppendASCII("incognito").AppendASCII("content_scripts")));
ASSERT_TRUE(LoadExtension(test_data_dir_
.AppendASCII("content_scripts").AppendASCII("isolated_world1")));
Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord(
browser()->profile(),
embedded_test_server()->GetURL("/extensions/test_file.html"));
WebContents* tab = otr_browser->tab_strip_model()->GetActiveWebContents();
bool result = false;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
tab,
"window.domAutomationController.send(document.title == 'modified')",
&result));
EXPECT_TRUE(result);
}
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_DontCreateIncognitoProfile) {
ASSERT_FALSE(browser()->profile()->HasOffTheRecordProfile());
ASSERT_TRUE(RunExtensionTestIncognito(
"incognito/dont_create_profile")) << message_;
ASSERT_FALSE(browser()->profile()->HasOffTheRecordProfile());
}
#if defined(OS_WIN) || defined(OS_MACOSX)
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_Incognito) {
#else
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Incognito) {
#endif
host_resolver()->AddRule("*", "127.0.0.1");
ASSERT_TRUE(StartEmbeddedTestServer());
ResultCatcher catcher;
ui_test_utils::OpenURLOffTheRecord(
browser()->profile(),
embedded_test_server()->GetURL("/extensions/test_file.html"));
ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_
.AppendASCII("incognito").AppendASCII("apis")));
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
#if defined(OS_WIN)
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_IncognitoSplitMode) {
#else
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoSplitMode) {
#endif
host_resolver()->AddRule("*", "127.0.0.1");
ASSERT_TRUE(StartEmbeddedTestServer());
ResultCatcher catcher;
catcher.RestrictToProfile(browser()->profile());
ResultCatcher catcher_incognito;
catcher_incognito.RestrictToProfile(
browser()->profile()->GetOffTheRecordProfile());
ExtensionTestMessageListener listener("waiting", true);
ExtensionTestMessageListener listener_incognito("waiting_incognito", true);
ui_test_utils::OpenURLOffTheRecord(
browser()->profile(),
embedded_test_server()->GetURL("/extensions/test_file.html"));
ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_
.AppendASCII("incognito").AppendASCII("split")));
EXPECT_TRUE(listener.WaitUntilSatisfied());
EXPECT_TRUE(listener_incognito.WaitUntilSatisfied());
listener.Reply("go");
listener_incognito.Reply("go");
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message();
}
#if defined(OS_WIN)
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_IncognitoDisabled) {
#else
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoDisabled) {
#endif
host_resolver()->AddRule("*", "127.0.0.1");
ASSERT_TRUE(StartEmbeddedTestServer());
ResultCatcher catcher;
ExtensionTestMessageListener listener("createIncognitoTab", true);
ui_test_utils::OpenURLOffTheRecord(
browser()->profile(),
embedded_test_server()->GetURL("/extensions/test_file.html"));
ASSERT_TRUE(LoadExtension(test_data_dir_
.AppendASCII("incognito").AppendASCII("apis_disabled")));
EXPECT_TRUE(listener.WaitUntilSatisfied());
ui_test_utils::OpenURLOffTheRecord(browser()->profile(),
GURL("about:blank"));
listener.Reply("created");
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
#if defined(OS_WIN) || defined(OS_MACOSX)
#define MAYBE_IncognitoPopup DISABLED_IncognitoPopup
#else
#define MAYBE_IncognitoPopup IncognitoPopup
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_IncognitoPopup) {
host_resolver()->AddRule("*", "127.0.0.1");
ASSERT_TRUE(StartEmbeddedTestServer());
ResultCatcher catcher;
ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_
.AppendASCII("incognito").AppendASCII("popup")));
Browser* incognito_browser = ui_test_utils::OpenURLOffTheRecord(
browser()->profile(),
embedded_test_server()->GetURL("/extensions/test_file.html"));
BrowserActionTestUtil(incognito_browser).Press(0);
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}