1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43

content / browser / resource_loading_browsertest.cc [blame]

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stdlib.h>

#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/shell/browser/shell.h"

namespace content {

class ResourceLoadingBrowserTest : public ContentBrowserTest  {
};

const char kResourceLoadingNonMobilePage[] =
    "/resource_loading/resource_loading_non_mobile.html";

// TODO(crbug.com/40850567): Flaky on Android.
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_ResourceLoadingAvoidDoubleDownloads \
  DISABLED_ResourceLoadingAvoidDoubleDownloads
#else
#define MAYBE_ResourceLoadingAvoidDoubleDownloads \
  ResourceLoadingAvoidDoubleDownloads
#endif
IN_PROC_BROWSER_TEST_F(ResourceLoadingBrowserTest,
                       MAYBE_ResourceLoadingAvoidDoubleDownloads) {
  ASSERT_TRUE(embedded_test_server()->Start());
  GURL url = embedded_test_server()->GetURL(kResourceLoadingNonMobilePage);
  EXPECT_TRUE(NavigateToURL(shell(), url));
  int resourceNumber = EvalJs(shell(), "getResourceNumber()").ExtractInt();
  // Hacky way to get the flaky extra resource timing entry content to logs.
  if (resourceNumber != 9) {
    EXPECT_EQ("", EvalJs(shell(), "getResources()"));
  }
  EXPECT_EQ(9, resourceNumber);
}

} // namespace content