Commit 4e84bea5 authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

Test that first non-empty paint doesn't depend on BACKGROUND tasks.

TaskPriority::BACKGROUND tasks can take "an arbitrarily long time to
complete".
https://cs.chromium.org/chromium/src/base/task_scheduler/task_traits.h?l=26&rcl=19a69a1389844f51c474efa446e3f22dd1fb36a8

We have plan to restrict more aggressively when they can run. To make
sure that this doesn't introduce unwanted performance regressions,
we need to make sure that there is no need to run
TaskPriority::BACKGROUND tasks to respond to user actions.

This CL adds a browser test to verify that the first
non-empty paint can happen when no TaskPriority::BACKGROUND tasks
are allowed to run.

Bug: 831835
Change-Id: I4c5d4f1056d823a6c36aa1504e2508d1bc1c58b6
Reviewed-on: https://chromium-review.googlesource.com/1008640Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550973}
parent ef19a2a3
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "base/run_loop.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
class RunLoopUntilNonEmptyPaint : public content::WebContentsObserver {
public:
explicit RunLoopUntilNonEmptyPaint(content::WebContents* web_contents)
: content::WebContentsObserver(web_contents) {}
~RunLoopUntilNonEmptyPaint() override = default;
// Runs a RunLoop on the main thread until the first non-empty frame is
// painted for the WebContents provided to the constructor.
void RunUntilIdle() { run_loop_.Run(); }
private:
// content::WebContentsObserver:
void DidFirstVisuallyNonEmptyPaint() override { run_loop_.Quit(); }
base::RunLoop run_loop_;
DISALLOW_COPY_AND_ASSIGN(RunLoopUntilNonEmptyPaint);
};
class NoBackgroundTasksTest : public InProcessBrowserTest {
protected:
NoBackgroundTasksTest() = default;
~NoBackgroundTasksTest() override = default;
private:
void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitch(switches::kDisableBackgroundTasks);
}
DISALLOW_COPY_AND_ASSIGN(NoBackgroundTasksTest);
};
} // namespace
// Verify that it is possible to get the first non-empty paint without running
// background tasks.
//
// TODO(fdoray): Enable on ChromeOS once all dependencies on background tasks to
// produce the first non-empty paint have been removed. https://crbug.com/831835
#if defined(OS_CHROMEOS)
#define MAYBE_FirstNonEmptyPaintWithoutBackgroundTasks \
DISABLED_FirstNonEmptyPaintWithoutBackgroundTasks
#else
#define MAYBE_FirstNonEmptyPaintWithoutBackgroundTasks \
FirstNonEmptyPaintWithoutBackgroundTasks
#endif
IN_PROC_BROWSER_TEST_F(NoBackgroundTasksTest,
MAYBE_FirstNonEmptyPaintWithoutBackgroundTasks) {
RunLoopUntilNonEmptyPaint run_loop_until_non_empty_paint(
browser()->tab_strip_model()->GetActiveWebContents());
run_loop_until_non_empty_paint.RunUntilIdle();
}
...@@ -628,6 +628,7 @@ test("browser_tests") { ...@@ -628,6 +628,7 @@ test("browser_tests") {
"../browser/net/proxy_browsertest.cc", "../browser/net/proxy_browsertest.cc",
"../browser/net/variations_http_headers_browsertest.cc", "../browser/net/variations_http_headers_browsertest.cc",
"../browser/net/websocket_browsertest.cc", "../browser/net/websocket_browsertest.cc",
"../browser/no_background_tasks_browsertest.cc",
"../browser/ntp_snippets/content_suggestions_service_factory_browsertest.cc", "../browser/ntp_snippets/content_suggestions_service_factory_browsertest.cc",
"../browser/ntp_tiles/ntp_tiles_browsertest.cc", "../browser/ntp_tiles/ntp_tiles_browsertest.cc",
"../browser/page_load_metrics/observers/ads_page_load_metrics_observer_browsertest.cc", "../browser/page_load_metrics/observers/ads_page_load_metrics_observer_browsertest.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment