Make integration tests use the default_integration policy.

The default_integration policy should be used when no exp= is otherwise
specified to make sure that the GFE cache is not used.

Bug: 950734
Change-Id: I6129845bed78f84175fb440003575f626431ccbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1560454
Reviewed-by: Robert Ogden <robertogden@chromium.org>
Reviewed-by: Ryan Sturm <ryansturm@chromium.org>
Commit-Queue: Simon Pelchat <spelchat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652616}
diff --git a/tools/chrome_proxy/webdriver/bypass.py b/tools/chrome_proxy/webdriver/bypass.py
index fea8ae1..ea1bbbf 100644
--- a/tools/chrome_proxy/webdriver/bypass.py
+++ b/tools/chrome_proxy/webdriver/bypass.py
@@ -190,8 +190,7 @@
       self.skipTest('This test cannot be run with other experiments.')
     with TestDriver() as test_driver:
       test_driver.AddChromeArg('--enable-spdy-proxy-auth')
-      test_driver.AddChromeArg('--data-reduction-proxy-experiment='
-                               'client_test_bypass')
+      test_driver.SetExperiment('client_test_bypass')
 
       # Verify that loading a page other than the specific exp directive test
       # page loads through the proxy without being bypassed.
diff --git a/tools/chrome_proxy/webdriver/common.py b/tools/chrome_proxy/webdriver/common.py
index 7531935..62f2bc62 100644
--- a/tools/chrome_proxy/webdriver/common.py
+++ b/tools/chrome_proxy/webdriver/common.py
@@ -207,6 +207,10 @@
     self._flags = ParseFlags()
     self._driver = None
     self._chrome_args = set()
+    # By default use the default_integration policy. It is the same as the
+    # default policy except that it disables GFE caching to make sure we are
+    # running the tests against the current server version.
+    self._experiment = 'default_integration'
     self._url = ''
     self._logger = GetLogger(name='TestDriver')
     self._has_logs = False
@@ -251,6 +255,10 @@
     a flag given in the code. In that case, check by the flag whether to
     override the argument.
     """
+    # Set the Data Reduction Proxy experiment.
+    if self._experiment is not None:
+      self._chrome_args.add('--data-reduction-proxy-experiment=' +
+        self._experiment)
     def GetDictKey(argument):
       return argument.split('=', 1)[0]
     if self._flags.browser_args and len(self._flags.browser_args) > 0:
@@ -337,6 +345,14 @@
     self._driver.quit()
     self._driver = None
 
+  def SetExperiment(self, exp):
+    """Sets the Data Reduction Proxy experiment to use.
+
+    Args:
+      exp: a string with the experiment name.
+    """
+    self._experiment = exp
+
   def AddChromeArgs(self, args):
     """Adds multiple arguments that will be passed to Chromium at start.
 
diff --git a/tools/chrome_proxy/webdriver/compression_regression.py b/tools/chrome_proxy/webdriver/compression_regression.py
index 6b7b99e0..3fc3129 100644
--- a/tools/chrome_proxy/webdriver/compression_regression.py
+++ b/tools/chrome_proxy/webdriver/compression_regression.py
@@ -139,7 +139,6 @@
         compression[key] = [value]
     with TestDriver() as t:
       t.AddChromeArg('--enable-spdy-proxy-auth')
-      t.AddChromeArg('--data-reduction-proxy-server-experiments-disabled')
       t.LoadURL('http://check.googlezip.net/metrics/local.gif')
       t.LoadURL('http://check.googlezip.net/metrics/local.png')
       t.LoadURL('http://check.googlezip.net/metrics/local.jpg')
diff --git a/tools/chrome_proxy/webdriver/https_previews.py b/tools/chrome_proxy/webdriver/https_previews.py
index e4cbe83..d3b0170 100644
--- a/tools/chrome_proxy/webdriver/https_previews.py
+++ b/tools/chrome_proxy/webdriver/https_previews.py
@@ -55,8 +55,7 @@
     t.AddChromeArg('--ignore-previews-blocklist')
     t.AddChromeArg('--force-effective-connection-type=2G')
     t.AddChromeArg('--ignore-litepage-redirect-optimization-blacklist')
-    t.AddChromeArg('--data-reduction-proxy-experiment='
-      'external_chrome_integration_test')
+    t.SetExperiment('external_chrome_integration_test')
 
     # Start Chrome and wait for initialization.
     t.LoadURL('data:,')
diff --git a/tools/chrome_proxy/webdriver/lite_page.py b/tools/chrome_proxy/webdriver/lite_page.py
index 5c1bf49..80f193c 100644
--- a/tools/chrome_proxy/webdriver/lite_page.py
+++ b/tools/chrome_proxy/webdriver/lite_page.py
@@ -38,6 +38,8 @@
           'force_effective_connection_type/2G,'
           'DataReductionProxyServerExperiments.IgnoreCountryBlacklist:'
           'exp/ignore_preview_blacklist')
+      # The previous argument implicitly sets the experiment.
+      test_driver.SetExperiment(None)
       test_driver.AddChromeArg(
           '--force-fieldtrials=NetworkQualityEstimator/Enabled/'
           'DataReductionProxyServerExperiments/IgnoreCountryBlacklist')
@@ -167,8 +169,7 @@
       # Need to force 2G speed to get lite-page response.
       test_driver.AddChromeArg('--force-effective-connection-type=2G')
       # Set exp=client_test_nano to force Nano response.
-      test_driver.AddChromeArg(
-          '--data-reduction-proxy-experiment=client_test_nano')
+      test_driver.SetExperiment('client_test_nano')
 
       # This page is long and has many media resources.
       test_driver.LoadURL('http://check.googlezip.net/metrics/index.html')
@@ -217,8 +218,7 @@
       test_driver.AddChromeArg('--disable-features=AndroidOmniboxPreviewsBadge')
       test_driver.AddChromeArg('--force-effective-connection-type=2G')
       # Set exp=client_test_nano to force Lite page response.
-      test_driver.AddChromeArg(
-        '--data-reduction-proxy-experiment=client_test_nano')
+      test_driver.SetExperiment('client_test_nano')
       # LoadURL waits for onLoadFinish so the Previews UI will be showing by
       # then since it's triggered on commit.
       test_driver.LoadURL(
@@ -463,8 +463,7 @@
       # Need to force 2G speed to get a preview.
       test_driver.AddChromeArg('--force-effective-connection-type=2G')
       # Set exp=client_test_icaspr to force iCASPR response.
-      test_driver.AddChromeArg(
-          '--data-reduction-proxy-experiment=ihdp_integration')
+      test_driver.SetExperiment('ihdp_integration')
 
       test_driver.LoadURL('http://check.googlezip.net/previews/ihdp.html')
 
diff --git a/tools/chrome_proxy/webdriver/safebrowsing.py b/tools/chrome_proxy/webdriver/safebrowsing.py
index b0f3f5e..4bb099b 100644
--- a/tools/chrome_proxy/webdriver/safebrowsing.py
+++ b/tools/chrome_proxy/webdriver/safebrowsing.py
@@ -7,6 +7,7 @@
 from common import IntegrationTest
 from decorators import AndroidOnly
 from decorators import NotAndroid
+from decorators import ChromeVersionBeforeM
 from decorators import ChromeVersionEqualOrAfterM
 
 from selenium.common.exceptions import TimeoutException
@@ -14,6 +15,7 @@
 class SafeBrowsing(IntegrationTest):
 
   @AndroidOnly
+  @ChromeVersionBeforeM(73)
   def testSafeBrowsingOn(self):
     with TestDriver() as t:
       t.AddChromeArg('--enable-spdy-proxy-auth')
diff --git a/tools/chrome_proxy/webdriver/variations_combinations.py b/tools/chrome_proxy/webdriver/variations_combinations.py
index fc6d36d..83a693c 100644
--- a/tools/chrome_proxy/webdriver/variations_combinations.py
+++ b/tools/chrome_proxy/webdriver/variations_combinations.py
@@ -17,9 +17,6 @@
 
 test_blacklist = [
   # These tests set their own field trials and should be ignored.
-  'lite_page.LitePage.testLitePageFallback',
-  'lofi.LoFi.testLoFiSlowConnection',
-  'lofi.LoFi.testLoFiIfHeavyFastConnection',
   'quic.Quic.testCheckPageWithQuicProxy',
   'quic.Quic.testCheckPageWithQuicProxyTransaction',
   'smoke.Smoke.testCheckPageWithHoldback',