diff options
Diffstat (limited to 'chromium/chrome/browser/devtools/devtools_sanity_browsertest.cc')
-rw-r--r-- | chromium/chrome/browser/devtools/devtools_sanity_browsertest.cc | 92 |
1 files changed, 73 insertions, 19 deletions
diff --git a/chromium/chrome/browser/devtools/devtools_sanity_browsertest.cc b/chromium/chrome/browser/devtools/devtools_sanity_browsertest.cc index 250a9ade9f3..ad76170f21e 100644 --- a/chromium/chrome/browser/devtools/devtools_sanity_browsertest.cc +++ b/chromium/chrome/browser/devtools/devtools_sanity_browsertest.cc @@ -39,10 +39,12 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/unpacked_installer.h" #include "chrome/browser/lifetime/application_lifetime.h" +#include "chrome/browser/policy/chrome_browser_policy_connector.h" #include "chrome/browser/policy/developer_tools_policy_handler.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" +#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" @@ -59,6 +61,9 @@ #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/autofill_manager_test_delegate.h" #include "components/autofill/core/common/autofill_features.h" +#include "components/policy/core/common/mock_configuration_policy_provider.h" +#include "components/policy/core/common/policy_map.h" +#include "components/policy/policy_constants.h" #include "components/prefs/pref_service.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" @@ -621,7 +626,7 @@ class WorkerDevToolsSanityTest : public InProcessBrowserTest { if (host->GetType() == DevToolsAgentHost::kTypeSharedWorker && host->GetURL().path().rfind(path_) != std::string::npos) { *out_host_ = host; - base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, quit_); + base::PostTask(FROM_HERE, {BrowserThread::UI}, quit_); delete this; } } @@ -757,8 +762,13 @@ IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, // Tests that BeforeUnload event gets called on devtools that are opened // on another devtools. -IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, - TestDevToolsOnDevTools) { +#if defined(OS_CHROMEOS) || defined(OS_LINUX) +// TODO(https://crbug.com/1000654): Re-enable this test. +#define MAYBE_TestDevToolsOnDevTools DISABLED_TestDevToolsOnDevTools +#else +#define MAYBE_TestDevToolsOnDevTools TestDevToolsOnDevTools +#endif +IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, MAYBE_TestDevToolsOnDevTools) { ASSERT_TRUE(spawned_test_server()->Start()); LoadTestPage(kDebuggerTestPage); @@ -786,22 +796,21 @@ IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, DevToolsWindowTesting::Get(windows[2])->main_web_contents()); // Try to close second devtools. { - content::WindowedNotificationObserver cancel_browser( - chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED, - content::NotificationService::AllSources()); chrome::CloseWindow(DevToolsWindowTesting::Get(windows[1])->browser()); CancelModalDialog(); - cancel_browser.Wait(); + base::RunLoop().RunUntilIdle(); + // The second devtools hasn't closed. + EXPECT_EQ(windows[1], + DevToolsWindow::GetInstanceForInspectedWebContents( + DevToolsWindowTesting::Get(windows[0])->main_web_contents())); } // Try to close browser window. { - content::WindowedNotificationObserver cancel_browser( - chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED, - content::NotificationService::AllSources()); chrome::CloseWindow(browser()); AcceptModalDialog(); CancelModalDialog(); - cancel_browser.Wait(); + base::RunLoop().RunUntilIdle(); + EXPECT_EQ(browser(), BrowserList::GetInstance()->get(0)); } // Try to exit application. { @@ -1354,8 +1363,10 @@ IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, DevtoolsInDevTools) { // Some web features, when used from an extension, are subject to browser-side // security policy enforcement. Make sure they work properly from inside a // devtools extension. +// ToDo(993982): The test is flaky (timeout, crash, and fail) on several builds: +// Debug, Windows, Mac, MSan, and ASan. IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, - DevToolsExtensionSecurityPolicyGrants) { + DISABLED_DevToolsExtensionSecurityPolicyGrants) { ASSERT_TRUE(embedded_test_server()->Start()); auto dir = std::make_unique<extensions::TestExtensionDir>(); @@ -1593,7 +1604,13 @@ IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, MAYBE_TestConsoleOnNavigateBack) { RunTest("testConsoleOnNavigateBack", kNavigateBackTestPage); } -IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDeviceEmulation) { +#if defined(OS_LINUX) +// Flaking on linux runs, see crbug.com/990692. +#define MAYBE_TestDeviceEmulation DISABLED_TestDeviceEmulation +#else +#define MAYBE_TestDeviceEmulation TestDeviceEmulation +#endif +IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, MAYBE_TestDeviceEmulation) { RunTest("testDeviceMetricsOverrides", "about:blank"); } @@ -1917,7 +1934,8 @@ class RemoteDebuggingTest : public extensions::ExtensionApiTest { #if defined(OS_CHROMEOS) #define MAYBE_RemoteDebugger DISABLED_RemoteDebugger #else -#define MAYBE_RemoteDebugger RemoteDebugger +// TODO(crbug.com/997911): Flaky on all platforms. +#define MAYBE_RemoteDebugger DISABLED_RemoteDebugger #endif IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, MAYBE_RemoteDebugger) { ASSERT_TRUE(RunExtensionTest("target_list")) << message_; @@ -2118,10 +2136,9 @@ class StaticURLDataSource : public content::URLDataSource { // content::URLDataSource: std::string GetSource() override { return source_; } - void StartDataRequest( - const std::string& path, - const content::ResourceRequestInfo::WebContentsGetter& wc_getter, - const GotDataCallback& callback) override { + void StartDataRequest(const std::string& path, + const content::WebContents::Getter& wc_getter, + const GotDataCallback& callback) override { std::string data(content_); callback.Run(base::RefCountedString::TakeString(&data)); } @@ -2347,6 +2364,43 @@ IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, BrowserCloseWithBeforeUnload) { ui_test_utils::WaitForBrowserToClose(browser()); } +class DevToolsPolicyTest : public InProcessBrowserTest { + protected: + DevToolsPolicyTest() { + EXPECT_CALL(provider_, IsInitializationComplete(testing::_)) + .WillRepeatedly(testing::Return(true)); + } + + void SetUpInProcessBrowserTestFixture() override { + policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); + } + policy::MockConfigurationPolicyProvider provider_; +}; + +IN_PROC_BROWSER_TEST_F(DevToolsPolicyTest, OpenBlackListedDevTools) { + base::ListValue blacklist; + blacklist.AppendString("chrome-devtools://*"); + policy::PolicyMap policies; + policies.Set(policy::key::kURLBlacklist, policy::POLICY_LEVEL_MANDATORY, + policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, + blacklist.CreateDeepCopy(), nullptr); + provider_.UpdateChromePolicy(policies); + + WebContents* wc = browser()->tab_strip_model()->GetActiveWebContents(); + scoped_refptr<content::DevToolsAgentHost> agent( + content::DevToolsAgentHost::GetOrCreateFor(wc)); + DevToolsWindow::OpenDevToolsWindow(wc); + DevToolsWindow* window = DevToolsWindow::FindDevToolsWindow(agent.get()); + if (window) { + base::RunLoop run_loop; + DevToolsWindowTesting::Get(window)->SetCloseCallback( + run_loop.QuitClosure()); + run_loop.Run(); + } + window = DevToolsWindow::FindDevToolsWindow(agent.get()); + ASSERT_EQ(nullptr, window); +} + // Flaky on Mus. See https://crbug.com/819285. IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsSanityTest, DISABLED_InputDispatchEventsToOOPIF) { @@ -2368,7 +2422,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsSanityTest, content::WaitForLoadStop(tab); for (auto* frame : GetInspectedTab()->GetAllFrames()) { - content::WaitForHitTestDataOrChildSurfaceReady(frame); + content::WaitForHitTestData(frame); } DevToolsWindow* window = DevToolsWindowTesting::OpenDevToolsWindowSync(GetInspectedTab(), false); |