Repository: GoogleChrome/lighthouse
Pull request #7388 (2019-03-05 19:50:17)

misc: clean node_modules/.cache before travis builds its cache
I noticed this in the travis logs:

![image](https://user-images.githubusercontent.com/39191/53833244-eb503280-3f3c-11e9-81e6-015d76469ac1.png)

Fixing this might speed up travis by ~55s..


Patch:
diff --git a/.travis.yml b/.travis.yml
index b42b9cebf..ad9440bef 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -48,6 +48,8 @@ before_cache:
   # the `yarn compile-devtools` task adds these to node_modules, which slows down caching
   - rm -rf ./node_modules/temp-devtoolsfrontend/
   - rm -rf ./node_modules/temp-devtoolsprotocol/
+  # nyc, jest and other projects store files in here. They mess up the travis build cache.
+  - rm -rf ./node_modules/.cache/
 after_success:
   - yarn coveralls
   - yarn codecov
diff --git a/clients/lightrider-entry.js b/clients/lightrider-entry.js
index d46dd36d6..98d1dbc30 100644
--- a/clients/lightrider-entry.js
+++ b/clients/lightrider-entry.js
@@ -24,16 +24,19 @@ const LR_PRESETS = {
  * @param {Connection} connection
  * @param {string} url
  * @param {LH.Flags} flags Lighthouse flags, including `output`
- * @param {{lrDevice?: 'desktop'|'mobile', categoryIDs?: Array<string>, logAssets: boolean}} lrOpts Options coming from Lightrider
+ * @param {{lrDevice?: 'desktop'|'mobile', categoryIDs?: Array<string>, logAssets: boolean, keepRawValues: boolean}} lrOpts Options coming from Lightrider
  * @return {Promise<string|Array<string>|void>}
  */
-async function runLighthouseInLR(connection, url, flags, {lrDevice, categoryIDs, logAssets}) {
+async function runLighthouseInLR(connection, url, flags, lrOpts) {
+  const {lrDevice, categoryIDs, logAssets, keepRawValues} = lrOpts;
+
   // Certain fixes need to kick in under LR, see https://github.com/GoogleChrome/lighthouse/issues/5839
   global.isLightRider = true;
 
   // disableStorageReset because it causes render server hang
   flags.disableStorageReset = true;
   flags.logLevel = flags.logLevel || 'info';
+
   const config = lrDevice === 'desktop' ? LR_PRESETS.desktop : LR_PRESETS.mobile;
   if (categoryIDs) {
     config.settings = config.settings || {};
@@ -50,7 +53,7 @@ async function runLighthouseInLR(connection, url, flags, {lrDevice, categoryIDs,
 
     // pre process the LHR for proto
     if (flags.output === 'json' && typeof results.report === 'string') {
-      return preprocessor.processForProto(results.report);
+      return preprocessor.processForProto(results.report, {keepRawValues});
     }
 
     return results.report;
diff --git a/lighthouse-core/audits/content-width.js b/lighthouse-core/audits/content-width.js
index 3f4f06a6b..f8625ba0f 100644
--- a/lighthouse-core/audits/content-width.js
+++ b/lighthouse-core/audits/content-width.js
@@ -19,26 +19,21 @@ class ContentWidth extends Audit {
       description: 'If the width of your app\'s content doesn\'t match the width ' +
           'of the viewport, your app might not be optimized for mobile screens. ' +
           '[Learn more](https://developers.google.com/web/tools/lighthouse/audits/content-sized-correctly-for-viewport).',
-      requiredArtifacts: ['ViewportDimensions', 'HostUserAgent'],
+      requiredArtifacts: ['ViewportDimensions', 'TestedAsMobileDevice'],
     };
   }
 
   /**
    * @param {LH.Artifacts} artifacts
-   * @param {LH.Audit.Context} context
    * @return {LH.Audit.Product}
    */
-  static audit(artifacts, context) {
-    const userAgent = artifacts.HostUserAgent;
+  static audit(artifacts) {
+    const IsMobile = artifacts.TestedAsMobileDevice;
     const viewportWidth = artifacts.ViewportDimensions.innerWidth;
     const windowWidth = artifacts.ViewportDimensions.outerWidth;
     const widthsMatch = viewportWidth === windowWidth;
 
-    const isMobileHost = userAgent.includes('Android') || userAgent.includes('Mobile');
-    const isMobile = context.settings.emulatedFormFactor === 'mobile' ||
-      (context.settings.emulatedFormFactor !== 'desktop' && isMobileHost);
-
-    if (isMobile) {
+    if (IsMobile) {
       return {
         rawValue: widthsMatch,
         explanation: this.createExplanation(widthsMatch, artifacts.ViewportDimensions),
diff --git a/lighthouse-core/audits/seo/font-size.js b/lighthouse-core/audits/seo/font-size.js
index d33826f2b..2dad98bc9 100644
--- a/lighthouse-core/audits/seo/font-size.js
+++ b/lighthouse-core/audits/seo/font-size.js
@@ -207,7 +207,7 @@ class FontSize extends Audit {
       title: str_(UIStrings.title),
       failureTitle: str_(UIStrings.failureTitle),
       description: str_(UIStrings.description),
-      requiredArtifacts: ['FontSize', 'URL', 'MetaElements'],
+      requiredArtifacts: ['FontSize', 'URL', 'MetaElements', 'TestedAsMobileDevice'],
     };
   }
 
@@ -217,6 +217,14 @@ class FontSize extends Audit {
    * @return {Promise<LH.Audit.Product>}
    */
   static async audit(artifacts, context) {
+    if (!artifacts.TestedAsMobileDevice) {
+      // Font size isn't important to desktop SEO
+      return {
+        rawValue: true,
+        notApplicable: true,
+      };
+    }
+
     const viewportMeta = await ComputedViewportMeta.request(artifacts, context);
     if (!viewportMeta.isMobileOptimized) {
       return {
diff --git a/lighthouse-core/audits/seo/tap-targets.js b/lighthouse-core/audits/seo/tap-targets.js
index 4b3505c0b..7d95dea73 100644
--- a/lighthouse-core/audits/seo/tap-targets.js
+++ b/lighthouse-core/audits/seo/tap-targets.js
@@ -264,7 +264,7 @@ class TapTargets extends Audit {
       title: str_(UIStrings.title),
       failureTitle: str_(UIStrings.failureTitle),
       description: str_(UIStrings.description),
-      requiredArtifacts: ['MetaElements', 'TapTargets'],
+      requiredArtifacts: ['MetaElements', 'TapTargets', 'TestedAsMobileDevice'],
     };
   }
 
@@ -274,6 +274,15 @@ class TapTargets extends Audit {
    * @return {Promise<LH.Audit.Product>}
    */
   static async audit(artifacts, context) {
+    if (!artifacts.TestedAsMobileDevice) {
+      // Tap target sizes aren't important for desktop SEO, so disable the audit there.
+      // On desktop people also tend to have more precise pointing devices than fingers.
+      return {
+        rawValue: true,
+        notApplicable: true,
+      };
+    }
+
     const viewportMeta = await ComputedViewportMeta.request(artifacts, context);
     if (!viewportMeta.isMobileOptimized) {
       return {
diff --git a/lighthouse-core/gather/gather-runner.js b/lighthouse-core/gather/gather-runner.js
index 86ae7a8f4..6237ff706 100644
--- a/lighthouse-core/gather/gather-runner.js
+++ b/lighthouse-core/gather/gather-runner.js
@@ -395,10 +395,19 @@ class GatherRunner {
    * @return {Promise<LH.BaseArtifacts>}
    */
   static async getBaseArtifacts(options) {
+    const hostUserAgent = (await options.driver.getBrowserVersion()).userAgent;
+
+    const {emulatedFormFactor} = options.settings;
+    // Whether Lighthouse was run on a mobile device (i.e. not on a desktop machine).
+    const IsMobileHost = hostUserAgent.includes('Android') || hostUserAgent.includes('Mobile');
+    const TestedAsMobileDevice = emulatedFormFactor === 'mobile' ||
+      (emulatedFormFactor !== 'desktop' && IsMobileHost);
+
     return {
       fetchTime: (new Date()).toJSON(),
       LighthouseRunWarnings: [],
-      HostUserAgent: (await options.driver.getBrowserVersion()).userAgent,
+      TestedAsMobileDevice,
+      HostUserAgent: hostUserAgent,
       NetworkUserAgent: '', // updated later
       BenchmarkIndex: 0, // updated later
       WebAppManifest: null, // updated later
diff --git a/lighthouse-core/lib/network-recorder.js b/lighthouse-core/lib/network-recorder.js
index ed38a3498..005f06edf 100644
--- a/lighthouse-core/lib/network-recorder.js
+++ b/lighthouse-core/lib/network-recorder.js
@@ -380,7 +380,9 @@ class NetworkRecorder extends EventEmitter {
     for (const record of records) {
       const stackFrames = (record.initiator.stack && record.initiator.stack.callFrames) || [];
       const initiatorURL = record.initiator.url || (stackFrames[0] && stackFrames[0].url);
-      const initiator = recordsByURL.get(initiatorURL) || record.redirectSource;
+      // If we were redirected to this request, our initiator is that redirect, otherwise, it's the
+      // initiator provided by the protocol. See https://github.com/GoogleChrome/lighthouse/pull/7352/
+      const initiator = record.redirectSource || recordsByURL.get(initiatorURL);
       if (initiator) {
         record.setInitiatorRequest(initiator);
       }
diff --git a/lighthouse-core/lib/proto-preprocessor.js b/lighthouse-core/lib/proto-preprocessor.js
index fa73cec2f..77b40feda 100644
--- a/lighthouse-core/lib/proto-preprocessor.js
+++ b/lighthouse-core/lib/proto-preprocessor.js
@@ -17,8 +17,11 @@ const fs = require('fs');
 
 /**
   * @param {string} result
+  * @param {{keepRawValues?: boolean}} opts
   */
-function processForProto(result) {
+function processForProto(result, opts = {}) {
+  const {keepRawValues = false} = opts;
+
   /** @type {LH.Result} */
   const reportJson = JSON.parse(result);
 
@@ -53,8 +56,8 @@ function processForProto(result) {
           audit.scoreDisplayMode = 'notApplicable';
         }
       }
-      // Drop raw values. #6199
-      if ('rawValue' in audit) {
+      // Drop raw values. https://github.com/GoogleChrome/lighthouse/issues/6199
+      if (!keepRawValues && 'rawValue' in audit) {
         delete audit.rawValue;
       }
       // Normalize displayValue to always be a string, not an array. #6200
diff --git a/readme.md b/readme.md
index 5a0e99c2c..ccc283eae 100644
--- a/readme.md
+++ b/readme.md
@@ -282,6 +282,8 @@ This section details services that have integrated Lighthouse data. If you're wo
 
 * **[HTTPArchive](http://httparchive.org/)** - HTTPArchive tracks how the web is built by crawling 500k pages with Web Page Test, including Lighthouse results, and stores the information in BigQuery where it is [publicly available](https://discuss.httparchive.org/t/quickstart-guide-to-exploring-the-http-archive/682).
 
+* **[Lighthouse Keeper](https://lighthouse-keeper.com/)** - Lighthouse Keeper monitors your pages' Lighthouse scores and notifies you if they drop below your thresholds. Lighthouse Keeper is a free service that monitors up to 3 URLs once per day.
+
 * **[SpeedCurve](https://speedcurve.com)** — SpeedCurve is a tool for continuously monitoring web performance across different browsers, devices, and regions. It can aggregate any metric including Lighthouse scores across multiple pages and sites, and allows you to set performance budgets with Slack or email alerts. SpeedCurve is a paid product with a free 30-day trial.
 
 * **[Speedrank](https://speedrank.app)** - Speedrank monitors the performance of your website in the background. It displays Lighthouse reports over time and delivers recommendations for improvement. Speedrank is a paid product with 14-day-trial.
diff --git a/types/artifacts.d.ts b/types/artifacts.d.ts
index 9afc84562..825833b94 100644
--- a/types/artifacts.d.ts
+++ b/types/artifacts.d.ts
@@ -23,6 +23,8 @@ declare global {
       fetchTime: string;
       /** A set of warnings about unexpected things encountered while loading and testing the page. */
       LighthouseRunWarnings: string[];
+      /** Whether the page was loaded on either a real or emulated mobile device. */
+      TestedAsMobileDevice: boolean;
       /** The user agent string of the version of Chrome used. */
       HostUserAgent: string;
       /** The user agent string that Lighthouse used to load the page. */
diff --git a/types/smokehouse.d.ts b/types/smokehouse.d.ts
new file mode 100644
index 000000000..a3393f4f4
--- /dev/null
+++ b/types/smokehouse.d.ts
@@ -0,0 +1,36 @@
+/**
+ * @license Copyright 2019 Google Inc. All Rights Reserved.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+ */
+
+ declare module Smokehouse {
+  export interface Difference {
+    path: string;
+    actual: any;
+    expected: any;
+  }
+
+  export interface Comparison {
+    category: string;
+    actual: any;
+    expected: any;
+    equal: boolean;
+    diff?: Difference | null;
+  }
+
+  export type ExpectedLHR = Pick<LH.Result, 'audits' | 'finalUrl' | 'requestedUrl'> & { errorCode?: string }
+
+  export interface LHRComparison {
+    audits: Comparison[];
+    errorCode: Comparison;
+    finalUrl: Comparison;
+  }
+
+  export interface TestDfn {
+    id: string;
+    expectations: string;
+    config: string;
+    batch: string;
+  }
+}


Test patch:
diff --git a/lighthouse-cli/test/smokehouse/run-smoke.js b/lighthouse-cli/test/smokehouse/run-smoke.js
index 5399eb77b..7653821eb 100644
--- a/lighthouse-cli/test/smokehouse/run-smoke.js
+++ b/lighthouse-cli/test/smokehouse/run-smoke.js
@@ -14,88 +14,7 @@ const log = require('lighthouse-logger');
 
 /** @param {string} str */
 const purpleify = str => `${log.purple}${str}${log.reset}`;
-const smokehouseDir = 'lighthouse-cli/test/smokehouse/';
-
-/**
- * @typedef {object} SmoketestDfn
- * @property {string} id
- * @property {string} expectations
- * @property {string} config
- * @property {string | undefined} batch
- */
-
-/** @type {Array<SmoketestDfn>} */
-const SMOKETESTS = [{
-  id: 'a11y',
-  config: smokehouseDir + 'a11y/a11y-config.js',
-  expectations: 'a11y/expectations.js',
-  batch: 'parallel-first',
-}, {
-  id: 'errors',
-  expectations: smokehouseDir + 'error-expectations.js',
-  config: smokehouseDir + 'error-config.js',
-  batch: 'errors',
-}, {
-  id: 'oopif',
-  expectations: smokehouseDir + 'oopif-expectations.js',
-  config: smokehouseDir + 'oopif-config.js',
-  batch: 'parallel-first',
-}, {
-  id: 'pwa',
-  expectations: smokehouseDir + 'pwa-expectations.js',
-  config: smokehouseDir + 'pwa-config.js',
-  batch: 'parallel-second',
-}, {
-  id: 'pwa2',
-  expectations: smokehouseDir + 'pwa2-expectations.js',
-  config: smokehouseDir + 'pwa-config.js',
-  batch: 'parallel-second',
-}, {
-  id: 'pwa3',
-  expectations: smokehouseDir + 'pwa3-expectations.js',
-  config: smokehouseDir + 'pwa-config.js',
-  batch: 'parallel-first',
-}, {
-  id: 'dbw',
-  expectations: 'dobetterweb/dbw-expectations.js',
-  config: smokehouseDir + 'dbw-config.js',
-  batch: 'parallel-second',
-}, {
-  id: 'redirects',
-  expectations: 'redirects/expectations.js',
-  config: smokehouseDir + 'redirects-config.js',
-  batch: 'parallel-first',
-}, {
-  id: 'seo',
-  expectations: 'seo/expectations.js',
-  config: smokehouseDir + 'seo-config.js',
-  batch: 'parallel-first',
-}, {
-  id: 'offline',
-  expectations: 'offline-local/offline-expectations.js',
-  config: smokehouseDir + 'offline-config.js',
-  batch: 'offline',
-}, {
-  id: 'byte',
-  expectations: 'byte-efficiency/expectations.js',
-  config: smokehouseDir + 'byte-config.js',
-  batch: 'perf-opportunity',
-}, {
-  id: 'perf',
-  expectations: 'perf/expectations.js',
-  config: 'lighthouse-core/config/perf-config.js',
-  batch: 'perf-metric',
-}, {
-  id: 'lantern',
-  expectations: 'perf/lantern-expectations.js',
-  config: smokehouseDir + 'lantern-config.js',
-  batch: 'parallel-first',
-}, {
-  id: 'metrics',
-  expectations: 'tricky-metrics/expectations.js',
-  config: 'lighthouse-core/config/perf-config.js',
-  batch: 'parallel-second',
-}];
+const SMOKETESTS = require('./smoke-test-dfns').SMOKE_TEST_DFNS;
 
 /**
  * Display smokehouse output from child process
@@ -116,7 +35,7 @@ function displaySmokehouseOutput(result) {
 /**
  * Run smokehouse in child processes for selected smoketests
  * Display output from each as soon as they finish, but resolve function when ALL are complete
- * @param {Array<SmoketestDfn>} smokes
+ * @param {Array<Smokehouse.TestDfn>} smokes
  * @return {Promise<Array<{id: string, error?: Error}>>}
  */
 async function runSmokehouse(smokes) {
@@ -149,7 +68,7 @@ async function runSmokehouse(smokes) {
 /**
  * Determine batches of smoketests to run, based on argv
  * @param {string[]} argv
- * @return {Map<string|undefined, Array<SmoketestDfn>>}
+ * @return {Map<string|undefined, Array<Smokehouse.TestDfn>>}
  */
 function getSmoketestBatches(argv) {
   let smokes = [];
diff --git a/lighthouse-cli/test/smokehouse/smoke-test-dfns.js b/lighthouse-cli/test/smokehouse/smoke-test-dfns.js
new file mode 100644
index 000000000..6ca5d920d
--- /dev/null
+++ b/lighthouse-cli/test/smokehouse/smoke-test-dfns.js
@@ -0,0 +1,133 @@
+/**
+ * @license Copyright 2019 Google Inc. All Rights Reserved.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+ */
+'use strict';
+
+const path = require('path');
+const smokehouseDir = 'lighthouse-cli/test/smokehouse/';
+
+/** @type {Array<Smokehouse.TestDfn>} */
+const SMOKE_TEST_DFNS = [{
+  id: 'a11y',
+  config: smokehouseDir + 'a11y/a11y-config.js',
+  expectations: 'a11y/expectations.js',
+  batch: 'parallel-first',
+}, {
+  id: 'errors',
+  expectations: smokehouseDir + 'error-expectations.js',
+  config: smokehouseDir + 'error-config.js',
+  batch: 'errors',
+}, {
+  id: 'oopif',
+  expectations: smokehouseDir + 'oopif-expectations.js',
+  config: smokehouseDir + 'oopif-config.js',
+  batch: 'parallel-first',
+}, {
+  id: 'pwa',
+  expectations: smokehouseDir + 'pwa-expectations.js',
+  config: smokehouseDir + 'pwa-config.js',
+  batch: 'parallel-second',
+}, {
+  id: 'pwa2',
+  expectations: smokehouseDir + 'pwa2-expectations.js',
+  config: smokehouseDir + 'pwa-config.js',
+  batch: 'parallel-second',
+}, {
+  id: 'pwa3',
+  expectations: smokehouseDir + 'pwa3-expectations.js',
+  config: smokehouseDir + 'pwa-config.js',
+  batch: 'parallel-first',
+}, {
+  id: 'dbw',
+  expectations: 'dobetterweb/dbw-expectations.js',
+  config: smokehouseDir + 'dbw-config.js',
+  batch: 'parallel-second',
+}, {
+  id: 'redirects',
+  expectations: 'redirects/expectations.js',
+  config: smokehouseDir + 'redirects-config.js',
+  batch: 'parallel-first',
+}, {
+  id: 'seo',
+  expectations: 'seo/expectations.js',
+  config: smokehouseDir + 'seo-config.js',
+  batch: 'parallel-first',
+}, {
+  id: 'offline',
+  expectations: 'offline-local/offline-expectations.js',
+  config: smokehouseDir + 'offline-config.js',
+  batch: 'offline',
+}, {
+  id: 'byte',
+  expectations: 'byte-efficiency/expectations.js',
+  config: smokehouseDir + 'byte-config.js',
+  batch: 'perf-opportunity',
+}, {
+  id: 'perf',
+  expectations: 'perf/expectations.js',
+  config: 'lighthouse-core/config/perf-config.js',
+  batch: 'perf-metric',
+}, {
+  id: 'lantern',
+  expectations: 'perf/lantern-expectations.js',
+  config: smokehouseDir + 'lantern-config.js',
+  batch: 'parallel-first',
+}, {
+  id: 'metrics',
+  expectations: 'tricky-metrics/expectations.js',
+  config: 'lighthouse-core/config/perf-config.js',
+  batch: 'parallel-second',
+}];
+
+/**
+ * Attempt to resolve a path relative to the smokehouse folder.
+ * If this fails, attempts to locate the path
+ * relative to the project root.
+ * @param {string} payloadPath
+ * @return {string}
+ */
+function resolveLocalOrProjectRoot(payloadPath) {
+  let resolved;
+  try {
+    resolved = require.resolve(__dirname + '/' + payloadPath);
+  } catch (e) {
+    const cwdPath = path.resolve(__dirname + '/../../../', payloadPath);
+    resolved = require.resolve(cwdPath);
+  }
+
+  return resolved;
+}
+
+/**
+ * @param {string} configPath
+ * @return {LH.Config.Json}
+ */
+function loadConfig(configPath) {
+  return require(configPath);
+}
+
+/**
+ * @param {string} expectationsPath
+ * @return {Smokehouse.ExpectedLHR[]}
+ */
+function loadExpectations(expectationsPath) {
+  return require(expectationsPath);
+}
+
+function getSmokeTests() {
+  return SMOKE_TEST_DFNS.map(smokeTestDfn => {
+    return {
+      id: smokeTestDfn.id,
+      config: loadConfig(resolveLocalOrProjectRoot(smokeTestDfn.config)),
+      expectations: loadExpectations(resolveLocalOrProjectRoot(smokeTestDfn.expectations)),
+      batch: smokeTestDfn.batch,
+    };
+  });
+}
+
+module.exports = {
+  SMOKE_TEST_DFNS,
+  getSmokeTests,
+};
diff --git a/lighthouse-cli/test/smokehouse/smokehouse-report.js b/lighthouse-cli/test/smokehouse/smokehouse-report.js
new file mode 100644
index 000000000..a08349928
--- /dev/null
+++ b/lighthouse-cli/test/smokehouse/smokehouse-report.js
@@ -0,0 +1,233 @@
+/**
+ * @license Copyright 2019 Google Inc. All Rights Reserved.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+ */
+/* eslint-disable no-console */
+'use strict';
+
+const log = require('lighthouse-logger');
+
+const VERBOSE = Boolean(process.env.LH_SMOKE_VERBOSE);
+const NUMBER_REGEXP = /(?:\d|\.)+/.source;
+const OPS_REGEXP = /<=?|>=?|\+\/-/.source;
+// An optional number, optional whitespace, an operator, optional whitespace, a number.
+const NUMERICAL_EXPECTATION_REGEXP =
+  new RegExp(`^(${NUMBER_REGEXP})?\\s*(${OPS_REGEXP})\\s*(${NUMBER_REGEXP})$`);
+
+/**
+ * Checks if the actual value matches the expectation. Does not recursively search. This supports
+ *    - Greater than/less than operators, e.g. "<100", ">90"
+ *    - Regular expressions
+ *    - Strict equality
+ *
+ * @param {*} actual
+ * @param {*} expected
+ * @return {boolean}
+ */
+function matchesExpectation(actual, expected) {
+  if (typeof actual === 'number' && NUMERICAL_EXPECTATION_REGEXP.test(expected)) {
+    const parts = expected.match(NUMERICAL_EXPECTATION_REGEXP);
+    const [, prefixNumber, operator, postfixNumber] = parts;
+    switch (operator) {
+      case '>':
+        return actual > postfixNumber;
+      case '>=':
+        return actual >= postfixNumber;
+      case '<':
+        return actual < postfixNumber;
+      case '<=':
+        return actual <= postfixNumber;
+      case '+/-':
+        return Math.abs(actual - prefixNumber) <= postfixNumber;
+      default:
+        throw new Error(`unexpected operator ${operator}`);
+    }
+  } else if (typeof actual === 'string' && expected instanceof RegExp && expected.test(actual)) {
+    return true;
+  } else {
+    // Strict equality check, plus NaN equivalence.
+    return Object.is(actual, expected);
+  }
+}
+
+/**
+ * Walk down expected result, comparing to actual result. If a difference is found,
+ * the path to the difference is returned, along with the expected primitive value
+ * and the value actually found at that location. If no difference is found, returns
+ * null.
+ *
+ * Only checks own enumerable properties, not object prototypes, and will loop
+ * until the stack is exhausted, so works best with simple objects (e.g. parsed JSON).
+ * @param {string} path
+ * @param {*} actual
+ * @param {*} expected
+ * @return {(Smokehouse.Difference|null)}
+ */
+function findDifference(path, actual, expected) {
+  if (matchesExpectation(actual, expected)) {
+    return null;
+  }
+
+  // If they aren't both an object we can't recurse further, so this is the difference.
+  if (actual === null || expected === null || typeof actual !== 'object' ||
+      typeof expected !== 'object' || expected instanceof RegExp) {
+    return {
+      path,
+      actual,
+      expected,
+    };
+  }
+
+  // We only care that all expected's own properties are on actual (and not the other way around).
+  for (const key of Object.keys(expected)) {
+    // Bracket numbers, but property names requiring quotes will still be unquoted.
+    const keyAccessor = /^\d+$/.test(key) ? `[${key}]` : `.${key}`;
+    const keyPath = path + keyAccessor;
+    const expectedValue = expected[key];
+
+    if (!(key in actual)) {
+      return {path: keyPath, actual: undefined, expected: expectedValue};
+    }
+
+    const actualValue = actual[key];
+    const subDifference = findDifference(keyPath, actualValue, expectedValue);
+
+    // Break on first difference found.
+    if (subDifference) {
+      return subDifference;
+    }
+  }
+
+  return null;
+}
+
+/**
+ * Collate results into comparisons of actual and expected scores on each audit.
+ * @param {Smokehouse.ExpectedLHR} actual
+ * @param {Smokehouse.ExpectedLHR} expected
+ * @return {Smokehouse.LHRComparison}
+ */
+function collateResults(actual, expected) {
+  const auditNames = Object.keys(expected.audits);
+  const collatedAudits = auditNames.map(auditName => {
+    const actualResult = actual.audits[auditName];
+    if (!actualResult) {
+      throw new Error(`Config did not trigger run of expected audit ${auditName}`);
+    }
+
+    const expectedResult = expected.audits[auditName];
+    const diff = findDifference(auditName, actualResult, expectedResult);
+
+    return {
+      category: auditName,
+      actual: actualResult,
+      expected: expectedResult,
+      equal: !diff,
+      diff,
+    };
+  });
+
+  return {
+    audits: collatedAudits,
+    errorCode: {
+      category: 'error code',
+      actual: actual.errorCode,
+      expected: expected.errorCode,
+      equal: actual.errorCode === expected.errorCode,
+    },
+    finalUrl: {
+      category: 'final url',
+      actual: actual.finalUrl,
+      expected: expected.finalUrl,
+      equal: actual.finalUrl === expected.finalUrl,
+    },
+  };
+}
+
+/**
+ * @param {unknown} obj
+ */
+function isPlainObject(obj) {
+  return Object.prototype.toString.call(obj) === '[object Object]';
+}
+
+/**
+ * Log the result of an assertion of actual and expected results.
+ * @param {Smokehouse.Comparison} assertion
+ */
+function reportAssertion(assertion) {
+  // @ts-ignore - this doesn't exist now but could one day, so try not to break the future
+  const _toJSON = RegExp.prototype.toJSON;
+  // @ts-ignore
+  // eslint-disable-next-line no-extend-native
+  RegExp.prototype.toJSON = RegExp.prototype.toString;
+
+  if (assertion.equal) {
+    if (isPlainObject(assertion.actual)) {
+      console.log(`  ${log.greenify(log.tick)} ${assertion.category}`);
+    } else {
+      console.log(`  ${log.greenify(log.tick)} ${assertion.category}: ` +
+          log.greenify(assertion.actual));
+    }
+  } else {
+    if (assertion.diff) {
+      const diff = assertion.diff;
+      const fullActual = JSON.stringify(assertion.actual, null, 2).replace(/\n/g, '\n      ');
+      const msg = `
+  ${log.redify(log.cross)} difference at ${log.bold}${diff.path}${log.reset}
+              expected: ${JSON.stringify(diff.expected)}
+                 found: ${JSON.stringify(diff.actual)}
+
+          found result:
+      ${log.redify(fullActual)}
+`;
+      console.log(msg);
+    } else {
+      console.log(`  ${log.redify(log.cross)} ${assertion.category}:
+              expected: ${JSON.stringify(assertion.expected)}
+                 found: ${JSON.stringify(assertion.actual)}
+`);
+    }
+  }
+
+  // @ts-ignore
+  // eslint-disable-next-line no-extend-native
+  RegExp.prototype.toJSON = _toJSON;
+}
+
+/**
+ * Log all the comparisons between actual and expected test results, then print
+ * summary. Returns count of passed and failed tests.
+ * @param {Smokehouse.LHRComparison} results
+ * @return {{passed: number, failed: number}}
+ */
+function report(results) {
+  let correctCount = 0;
+  let failedCount = 0;
+
+  [results.finalUrl, results.errorCode, ...results.audits].forEach(auditAssertion => {
+    if (auditAssertion.equal) {
+      correctCount++;
+    } else {
+      failedCount++;
+    }
+
+    if (!auditAssertion.equal || VERBOSE) {
+      reportAssertion(auditAssertion);
+    }
+  });
+
+  const plural = correctCount === 1 ? '' : 's';
+  const correctStr = `${correctCount} assertion${plural}`;
+  const colorFn = correctCount === 0 ? log.redify : log.greenify;
+  console.log(`  Correctly passed ${colorFn(correctStr)}\n`);
+
+  return {
+    passed: correctCount,
+    failed: failedCount,
+  };
+}
+
+module.exports.collateResults = collateResults;
+module.exports.report = report;
diff --git a/lighthouse-cli/test/smokehouse/smokehouse.js b/lighthouse-cli/test/smokehouse/smokehouse.js
index be6534d35..eb5d74a61 100755
--- a/lighthouse-cli/test/smokehouse/smokehouse.js
+++ b/lighthouse-cli/test/smokehouse/smokehouse.js
@@ -6,22 +6,6 @@
  */
 'use strict';
 
-/**
- * @typedef {{path: string, actual: *, expected: *}} Difference
- */
-
-/**
- * @typedef {{category: string, actual: *, expected: *, equal: boolean, diff?: Difference | null}} Comparison
- */
-
-/**
- * @typedef {Pick<LH.Result, 'audits' | 'finalUrl' | 'requestedUrl'> & {errorCode?: string}} ExpectedLHR
- */
-
-/**
- * @typedef {{audits: Comparison[], errorCode: Comparison, finalUrl: Comparison}} LHRComparison
- */
-
 /* eslint-disable no-console */
 
 const fs = require('fs');
@@ -29,17 +13,12 @@ const path = require('path');
 const spawnSync = require('child_process').spawnSync;
 const yargs = require('yargs');
 const log = require('lighthouse-logger');
+const {collateResults, report} = require('./smokehouse-report');
 
 const PROTOCOL_TIMEOUT_EXIT_CODE = 67;
 const PAGE_HUNG_EXIT_CODE = 68;
 const INSECURE_DOCUMENT_REQUEST_EXIT_CODE = 69;
 const RETRIES = 3;
-const VERBOSE = Boolean(process.env.LH_SMOKE_VERBOSE);
-const NUMBER_REGEXP = /(?:\d|\.)+/.source;
-const OPS_REGEXP = /<=?|>=?|\+\/-/.source;
-// An optional number, optional whitespace, an operator, optional whitespace, a number.
-const NUMERICAL_EXPECTATION_REGEXP =
-  new RegExp(`^(${NUMBER_REGEXP})?\\s*(${OPS_REGEXP})\\s*(${NUMBER_REGEXP})$`);
 
 /**
  * Attempt to resolve a path locally. If this fails, attempts to locate the path
@@ -64,7 +43,7 @@ function resolveLocalOrCwd(payloadPath) {
  * @param {string} url
  * @param {string} configPath
  * @param {boolean=} isDebug
- * @return {ExpectedLHR}
+ * @return {Smokehouse.ExpectedLHR}
  */
 function runLighthouse(url, configPath, isDebug) {
   isDebug = isDebug || Boolean(process.env.LH_SMOKE_DEBUG);
@@ -140,220 +119,6 @@ function runLighthouse(url, configPath, isDebug) {
   return JSON.parse(lhr);
 }
 
-/**
- * Checks if the actual value matches the expectation. Does not recursively search. This supports
- *    - Greater than/less than operators, e.g. "<100", ">90"
- *    - Regular expressions
- *    - Strict equality
- *
- * @param {*} actual
- * @param {*} expected
- * @return {boolean}
- */
-function matchesExpectation(actual, expected) {
-  if (typeof actual === 'number' && NUMERICAL_EXPECTATION_REGEXP.test(expected)) {
-    const parts = expected.match(NUMERICAL_EXPECTATION_REGEXP);
-    const [, prefixNumber, operator, postfixNumber] = parts;
-    switch (operator) {
-      case '>':
-        return actual > postfixNumber;
-      case '>=':
-        return actual >= postfixNumber;
-      case '<':
-        return actual < postfixNumber;
-      case '<=':
-        return actual <= postfixNumber;
-      case '+/-':
-        return Math.abs(actual - prefixNumber) <= postfixNumber;
-      default:
-        throw new Error(`unexpected operator ${operator}`);
-    }
-  } else if (typeof actual === 'string' && expected instanceof RegExp && expected.test(actual)) {
-    return true;
-  } else {
-    // Strict equality check, plus NaN equivalence.
-    return Object.is(actual, expected);
-  }
-}
-
-/**
- * Walk down expected result, comparing to actual result. If a difference is found,
- * the path to the difference is returned, along with the expected primitive value
- * and the value actually found at that location. If no difference is found, returns
- * null.
- *
- * Only checks own enumerable properties, not object prototypes, and will loop
- * until the stack is exhausted, so works best with simple objects (e.g. parsed JSON).
- * @param {string} path
- * @param {*} actual
- * @param {*} expected
- * @return {(Difference|null)}
- */
-function findDifference(path, actual, expected) {
-  if (matchesExpectation(actual, expected)) {
-    return null;
-  }
-
-  // If they aren't both an object we can't recurse further, so this is the difference.
-  if (actual === null || expected === null || typeof actual !== 'object' ||
-      typeof expected !== 'object' || expected instanceof RegExp) {
-    return {
-      path,
-      actual,
-      expected,
-    };
-  }
-
-  // We only care that all expected's own properties are on actual (and not the other way around).
-  for (const key of Object.keys(expected)) {
-    // Bracket numbers, but property names requiring quotes will still be unquoted.
-    const keyAccessor = /^\d+$/.test(key) ? `[${key}]` : `.${key}`;
-    const keyPath = path + keyAccessor;
-    const expectedValue = expected[key];
-
-    if (!(key in actual)) {
-      return {path: keyPath, actual: undefined, expected: expectedValue};
-    }
-
-    const actualValue = actual[key];
-    const subDifference = findDifference(keyPath, actualValue, expectedValue);
-
-    // Break on first difference found.
-    if (subDifference) {
-      return subDifference;
-    }
-  }
-
-  return null;
-}
-
-/**
- * Collate results into comparisons of actual and expected scores on each audit.
- * @param {ExpectedLHR} actual
- * @param {ExpectedLHR} expected
- * @return {LHRComparison}
- */
-function collateResults(actual, expected) {
-  const auditNames = Object.keys(expected.audits);
-  const collatedAudits = auditNames.map(auditName => {
-    const actualResult = actual.audits[auditName];
-    if (!actualResult) {
-      throw new Error(`Config did not trigger run of expected audit ${auditName}`);
-    }
-
-    const expectedResult = expected.audits[auditName];
-    const diff = findDifference(auditName, actualResult, expectedResult);
-
-    return {
-      category: auditName,
-      actual: actualResult,
-      expected: expectedResult,
-      equal: !diff,
-      diff,
-    };
-  });
-
-  return {
-    audits: collatedAudits,
-    errorCode: {
-      category: 'error code',
-      actual: actual.errorCode,
-      expected: expected.errorCode,
-      equal: actual.errorCode === expected.errorCode,
-    },
-    finalUrl: {
-      category: 'final url',
-      actual: actual.finalUrl,
-      expected: expected.finalUrl,
-      equal: actual.finalUrl === expected.finalUrl,
-    },
-  };
-}
-
-/**
- * @param {unknown} obj
- */
-function isPlainObject(obj) {
-  return Object.prototype.toString.call(obj) === '[object Object]';
-}
-
-/**
- * Log the result of an assertion of actual and expected results.
- * @param {Comparison} assertion
- */
-function reportAssertion(assertion) {
-  // @ts-ignore - this doesn't exist now but could one day, so try not to break the future
-  const _toJSON = RegExp.prototype.toJSON;
-  // @ts-ignore
-  // eslint-disable-next-line no-extend-native
-  RegExp.prototype.toJSON = RegExp.prototype.toString;
-
-  if (assertion.equal) {
-    if (isPlainObject(assertion.actual)) {
-      console.log(`  ${log.greenify(log.tick)} ${assertion.category}`);
-    } else {
-      console.log(`  ${log.greenify(log.tick)} ${assertion.category}: ` +
-          log.greenify(assertion.actual));
-    }
-  } else {
-    if (assertion.diff) {
-      const diff = assertion.diff;
-      const fullActual = JSON.stringify(assertion.actual, null, 2).replace(/\n/g, '\n      ');
-      const msg = `
-  ${log.redify(log.cross)} difference at ${log.bold}${diff.path}${log.reset}
-              expected: ${JSON.stringify(diff.expected)}
-                 found: ${JSON.stringify(diff.actual)}
-
-          found result:
-      ${log.redify(fullActual)}
-`;
-      console.log(msg);
-    } else {
-      console.log(`  ${log.redify(log.cross)} ${assertion.category}:
-              expected: ${JSON.stringify(assertion.expected)}
-                 found: ${JSON.stringify(assertion.actual)}
-`);
-    }
-  }
-
-  // @ts-ignore
-  // eslint-disable-next-line no-extend-native
-  RegExp.prototype.toJSON = _toJSON;
-}
-
-/**
- * Log all the comparisons between actual and expected test results, then print
- * summary. Returns count of passed and failed tests.
- * @param {LHRComparison} results
- * @return {{passed: number, failed: number}}
- */
-function report(results) {
-  let correctCount = 0;
-  let failedCount = 0;
-
-  [results.finalUrl, results.errorCode, ...results.audits].forEach(auditAssertion => {
-    if (auditAssertion.equal) {
-      correctCount++;
-    } else {
-      failedCount++;
-    }
-
-    if (!auditAssertion.equal || VERBOSE) {
-      reportAssertion(auditAssertion);
-    }
-  });
-
-  const plural = correctCount === 1 ? '' : 's';
-  const correctStr = `${correctCount} assertion${plural}`;
-  const colorFn = correctCount === 0 ? log.redify : log.greenify;
-  console.log(`  Correctly passed ${colorFn(correctStr)}\n`);
-
-  return {
-    passed: correctCount,
-    failed: failedCount,
-  };
-}
-
 const cli = yargs
   .help('help')
   .describe({
@@ -366,7 +131,7 @@ const cli = yargs
   .argv;
 
 const configPath = resolveLocalOrCwd(cli['config-path']);
-/** @type {ExpectedLHR[]} */
+/** @type {Smokehouse.ExpectedLHR[]} */
 const expectations = require(resolveLocalOrCwd(cli['expectations-path']));
 
 // Loop sequentially over expectations, comparing against Lighthouse run, and
diff --git a/lighthouse-core/test/audits/content-width-test.js b/lighthouse-core/test/audits/content-width-test.js
index e4ce6e8b4..d2ec66fa7 100644
--- a/lighthouse-core/test/audits/content-width-test.js
+++ b/lighthouse-core/test/audits/content-width-test.js
@@ -13,25 +13,12 @@ const assert = require('assert');
 describe('Mobile-friendly: content-width audit', () => {
   it('fails when scroll width differs from viewport width', () => {
     const result = Audit.audit({
-      HostUserAgent: 'Desktop',
+      TestedAsMobileDevice: true,
       ViewportDimensions: {
         innerWidth: 100,
         outerWidth: 300,
       },
-    }, {settings: {emulatedFormFactor: 'mobile'}});
-
-    assert.equal(result.rawValue, false);
-    assert.ok(result.explanation);
-  });
-
-  it('fails when host user agent is a phone', () => {
-    const result = Audit.audit({
-      HostUserAgent: 'Mobile Android',
-      ViewportDimensions: {
-        innerWidth: 100,
-        outerWidth: 300,
-      },
-    }, {settings: {emulatedFormFactor: 'none'}});
+    });
 
     assert.equal(result.rawValue, false);
     assert.ok(result.explanation);
@@ -47,13 +34,13 @@ describe('Mobile-friendly: content-width audit', () => {
     }, {settings: {emulatedFormFactor: 'mobile'}}).rawValue, true);
   });
 
-  it('not applicable when device emulation is turned off', () => {
+  it('not applicable when run on desktop', () => {
     return assert.equal(Audit.audit({
-      HostUserAgent: 'Mobile Android Chrome',
+      TestedAsMobileDevice: false,
       ViewportDimensions: {
         innerWidth: 300,
         outerWidth: 450,
       },
-    }, {settings: {emulatedFormFactor: 'desktop'}}).notApplicable, true);
+    }).notApplicable, true);
   });
 });
diff --git a/lighthouse-core/test/audits/seo/font-size-test.js b/lighthouse-core/test/audits/seo/font-size-test.js
index c075fe132..8c093e1d2 100644
--- a/lighthouse-core/test/audits/seo/font-size-test.js
+++ b/lighthouse-core/test/audits/seo/font-size-test.js
@@ -22,6 +22,7 @@ describe('SEO: Font size audit', () => {
       URL,
       MetaElements: [],
       FontSize: [],
+      TestedAsMobileDevice: true,
     };
 
     const auditResult = await FontSizeAudit.audit(artifacts, getFakeContext());
@@ -45,6 +46,7 @@ describe('SEO: Font size audit', () => {
           {textLength: 31, fontSize: 11, node: {nodeId: 2, localName: 'p', attributes: []}},
         ],
       },
+      TestedAsMobileDevice: true,
     };
 
     const auditResult = await FontSizeAudit.audit(artifacts, getFakeContext());
@@ -66,6 +68,7 @@ describe('SEO: Font size audit', () => {
           {textLength: 0, fontSize: 11, node: {nodeId: 1, localName: 'p', attributes: []}},
         ],
       },
+      TestedAsMobileDevice: true,
     };
 
     const auditResult = await FontSizeAudit.audit(artifacts, getFakeContext());
@@ -86,6 +89,7 @@ describe('SEO: Font size audit', () => {
           {textLength: 22, fontSize: 11, node: {nodeId: 2, localName: 'p', attributes: []}},
         ],
       },
+      TestedAsMobileDevice: true,
     };
     const auditResult = await FontSizeAudit.audit(artifacts, getFakeContext());
     assert.equal(auditResult.rawValue, true);
@@ -123,6 +127,7 @@ describe('SEO: Font size audit', () => {
           {textLength: 2, fontSize: 10, node: {nodeId: 3}, cssRule: style2},
         ],
       },
+      TestedAsMobileDevice: true,
     };
     const auditResult = await FontSizeAudit.audit(artifacts, getFakeContext());
 
@@ -145,6 +150,7 @@ describe('SEO: Font size audit', () => {
           {textLength: 10, fontSize: 10, node: {nodeId: 1, localName: 'p', attributes: []}},
         ],
       },
+      TestedAsMobileDevice: true,
     };
     const auditResult = await FontSizeAudit.audit(artifacts, getFakeContext());
     assert.equal(auditResult.rawValue, false);
@@ -167,11 +173,13 @@ describe('SEO: Font size audit', () => {
           {textLength: 50, fontSize: 10, node: {nodeId: 1, localName: 'p', attributes: []}},
         ],
       },
+      TestedAsMobileDevice: true,
     };
     const auditResult = await FontSizeAudit.audit(artifacts, getFakeContext());
     assert.equal(auditResult.rawValue, false);
-    expect(auditResult.explanation)
-      .toBeDisplayString('100% of text is too small (based on 50% sample).');
+    expect(auditResult.explanation).toBeDisplayString(
+      '100% of text is too small (based on 50% sample).'
+    );
     expect(auditResult.displayValue).toBeDisplayString('0% legible text');
   });
 
@@ -189,6 +197,7 @@ describe('SEO: Font size audit', () => {
           {textLength: 22, fontSize: 11, node: {nodeId: 2, localName: 'p', attributes: []}},
         ],
       },
+      TestedAsMobileDevice: true,
     };
     const auditResult = await FontSizeAudit.audit(artifacts, getFakeContext());
     expect(auditResult.displayValue).toBeDisplayString('89.78% legible text');
@@ -208,8 +217,21 @@ describe('SEO: Font size audit', () => {
           {textLength: 4, fontSize: 11, node: {nodeId: 2, localName: 'p', attributes: []}},
         ],
       },
+      TestedAsMobileDevice: true,
     };
     const auditResult = await FontSizeAudit.audit(artifacts, getFakeContext());
     expect(auditResult.displayValue).toBeDisplayString('2.48% legible text');
   });
+
+  it('is not applicable on desktop', async () => {
+    const artifacts = {
+      URL,
+      MetaElements: [],
+      FontSize: {},
+      TestedAsMobileDevice: false,
+    };
+    const auditResult = await FontSizeAudit.audit(artifacts, getFakeContext());
+    expect(auditResult.rawValue).toBe(true);
+    expect(auditResult.notApplicable).toBe(true);
+  });
 });
diff --git a/lighthouse-core/test/audits/seo/tap-targets-test.js b/lighthouse-core/test/audits/seo/tap-targets-test.js
index 977143a50..3683d9b0a 100644
--- a/lighthouse-core/test/audits/seo/tap-targets-test.js
+++ b/lighthouse-core/test/audits/seo/tap-targets-test.js
@@ -12,13 +12,14 @@ const assert = require('assert');
 
 const getFakeContext = () => ({computedCache: new Map()});
 
-function auditTapTargets(tapTargets, metaElements = [{
+function auditTapTargets(tapTargets, {MetaElements = [{
   name: 'viewport',
   content: 'width=device-width',
-}]) {
+}], TestedAsMobileDevice = true} = {}) {
   const artifacts = {
     TapTargets: tapTargets,
-    MetaElements: metaElements,
+    MetaElements,
+    TestedAsMobileDevice,
   };
 
   return TapTargetsAudit.audit(artifacts, getFakeContext());
@@ -203,11 +204,19 @@ describe('SEO: Tap targets audit', () => {
   });
 
   it('fails if no meta viewport tag is provided', async () => {
-    const auditResult = await auditTapTargets([], []);
+    const auditResult = await auditTapTargets([], {MetaElements: []});
     assert.equal(auditResult.rawValue, false);
 
     expect(auditResult.explanation).toBeDisplayString(
       /* eslint-disable max-len */
       'Tap targets are too small because there\'s no viewport meta tag optimized for mobile screens');
   });
+
+  it('is not applicable on desktop', async () => {
+    const auditResult = await auditTapTargets(getBorderlineTapTargets({
+      overlapSecondClientRect: true,
+    }), {TestedAsMobileDevice: false});
+    assert.equal(auditResult.rawValue, true);
+    assert.equal(auditResult.notApplicable, true);
+  });
 });
diff --git a/lighthouse-core/test/fixtures/redirects-from-script.devtoolslog.json b/lighthouse-core/test/fixtures/redirects-from-script.devtoolslog.json
new file mode 100644
index 000000000..01dfb0bbf
--- /dev/null
+++ b/lighthouse-core/test/fixtures/redirects-from-script.devtoolslog.json
@@ -0,0 +1,33 @@
+[
+  {"method":"Page.lifecycleEvent","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"FB0836DEB3DBEF7ABC0655BE538C9E50","name":"commit","timestamp":7161.561296}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"FB0836DEB3DBEF7ABC0655BE538C9E50","name":"DOMContentLoaded","timestamp":7161.562802}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"FB0836DEB3DBEF7ABC0655BE538C9E50","name":"load","timestamp":7161.563057}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"FB0836DEB3DBEF7ABC0655BE538C9E50","name":"networkAlmostIdle","timestamp":7161.563436}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"FB0836DEB3DBEF7ABC0655BE538C9E50","name":"networkIdle","timestamp":7161.563436}},
+  {"method":"Network.requestWillBeSent","params":{"requestId":"82A9687A3E396289BF288BE28FAC977B","loaderId":"82A9687A3E396289BF288BE28FAC977B","documentURL":"http://localhost:10200/redirects-script.html","request":{"url":"http://localhost:10200/redirects-script.html","method":"GET","headers":{"Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse"},"mixedContentType":"none","initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":7162.22791,"wallTime":1551376568.301146,"initiator":{"type":"other"},"type":"Document","frameId":"E6C992E73862A3AB8AEADAC3772D5421","hasUserGesture":false}},
+  {"method":"Network.responseReceived","params":{"requestId":"82A9687A3E396289BF288BE28FAC977B","loaderId":"82A9687A3E396289BF288BE28FAC977B","timestamp":7162.231603,"type":"Document","response":{"url":"http://localhost:10200/redirects-script.html","status":200,"statusText":"OK","headers":{"Access-Control-Allow-Origin":"*","Date":"Thu, 28 Feb 2019 17:56:08 GMT","Connection":"keep-alive","Transfer-Encoding":"chunked"},"headersText":"HTTP/1.1 200 OK\r\nAccess-Control-Allow-Origin: *\r\nDate: Thu, 28 Feb 2019 17:56:08 GMT\r\nConnection: keep-alive\r\nTransfer-Encoding: chunked\r\n\r\n","mimeType":"text/html","requestHeaders":{"Host":"localhost:10200","Connection":"keep-alive","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3","Accept-Encoding":"gzip, deflate, br","Accept-Language":"en-US,en;q=0.9"},"requestHeadersText":"GET /redirects-script.html HTTP/1.1\r\nHost: localhost:10200\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent: Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3\r\nAccept-Encoding: gzip, deflate, br\r\nAccept-Language: en-US,en;q=0.9\r\n","connectionReused":true,"connectionId":36,"remoteIPAddress":"127.0.0.1","remotePort":10200,"fromDiskCache":false,"fromServiceWorker":false,"encodedDataLength":140,"timing":{"requestTime":7162.228635,"proxyStart":-1,"proxyEnd":-1,"dnsStart":-1,"dnsEnd":-1,"connectStart":-1,"connectEnd":-1,"sslStart":-1,"sslEnd":-1,"workerStart":-1,"workerReady":-1,"sendStart":1.195,"sendEnd":1.237,"pushStart":0,"pushEnd":0,"receiveHeadersEnd":2.277},"protocol":"http/1.1","securityState":"neutral"},"frameId":"E6C992E73862A3AB8AEADAC3772D5421"}},
+  {"method":"Page.frameStartedLoading","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421"}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"82A9687A3E396289BF288BE28FAC977B","name":"init","timestamp":7162.233881}},
+  {"method":"Network.dataReceived","params":{"requestId":"82A9687A3E396289BF288BE28FAC977B","timestamp":7162.234907,"dataLength":569,"encodedDataLength":0}},
+  {"method":"Page.frameNavigated","params":{"frame":{"id":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"82A9687A3E396289BF288BE28FAC977B","url":"http://localhost:10200/redirects-script.html","securityOrigin":"http://localhost:10200","mimeType":"text/html"}}},
+  {"method":"Network.loadingFinished","params":{"requestId":"82A9687A3E396289BF288BE28FAC977B","timestamp":7162.231334,"encodedDataLength":721,"shouldReportCorbBlocking":false}},
+  {"method":"Page.loadEventFired","params":{"timestamp":7162.2438}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"82A9687A3E396289BF288BE28FAC977B","name":"load","timestamp":7162.2438}},
+  {"method":"Page.frameStoppedLoading","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421"}},
+  {"method":"Page.domContentEventFired","params":{"timestamp":7162.244328}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"82A9687A3E396289BF288BE28FAC977B","name":"DOMContentLoaded","timestamp":7162.244328}},
+  {"method":"Page.frameAttached","params":{"frameId":"B19E293EA74DA749596009C93D1C1B4C","parentFrameId":"E6C992E73862A3AB8AEADAC3772D5421","stack":{"callFrames":[{"functionName":"","scriptId":"18","url":"http://localhost:10200/redirects-script.html","lineNumber":11,"columnNumber":20}]}}},
+  {"method":"Network.requestWillBeSent","params":{"requestId":"9E5F212F4468007C6952E996764DC56A","loaderId":"9E5F212F4468007C6952E996764DC56A","documentURL":"http://localhost:10200/redirects-script.html?redirect=http%3A%2F%2Flocalhost%3A10503%2Fredirects-script.html%3Fredirect%3Dhttps%253A%252F%252Fairhorner.com%252F","request":{"url":"http://localhost:10200/redirects-script.html?redirect=http%3A%2F%2Flocalhost%3A10503%2Fredirects-script.html%3Fredirect%3Dhttps%253A%252F%252Fairhorner.com%252F","method":"GET","headers":{"Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse","Referer":"http://localhost:10200/redirects-script.html"},"mixedContentType":"none","initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":7162.648846,"wallTime":1551376568.722058,"initiator":{"type":"script","stack":{"callFrames":[{"functionName":"","scriptId":"18","url":"http://localhost:10200/redirects-script.html","lineNumber":11,"columnNumber":20}]}},"type":"Document","frameId":"B19E293EA74DA749596009C93D1C1B4C","hasUserGesture":false}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"B19E293EA74DA749596009C93D1C1B4C","loaderId":"22E839E241B3EFB1229B834C62CE85D2","name":"init","timestamp":7162.646479}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"B19E293EA74DA749596009C93D1C1B4C","loaderId":"22E839E241B3EFB1229B834C62CE85D2","name":"DOMContentLoaded","timestamp":7162.647219}},
+  {"method":"Page.frameStartedLoading","params":{"frameId":"B19E293EA74DA749596009C93D1C1B4C"}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"B19E293EA74DA749596009C93D1C1B4C","loaderId":"FDBAAD6744CF4B5868BA77D740A41F7F","name":"init","timestamp":7162.647934}},
+  {"method":"Network.requestWillBeSent","params":{"requestId":"9E5F212F4468007C6952E996764DC56A","loaderId":"9E5F212F4468007C6952E996764DC56A","documentURL":"http://localhost:10503/redirects-script.html?redirect=https%3A%2F%2Fairhorner.com%2F","request":{"url":"http://localhost:10503/redirects-script.html?redirect=https%3A%2F%2Fairhorner.com%2F","method":"GET","headers":{"Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse","Referer":"http://localhost:10200/redirects-script.html"},"mixedContentType":"none","initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":7162.653028,"wallTime":1551376568.72624,"initiator":{"type":"script","stack":{"callFrames":[{"functionName":"","scriptId":"18","url":"http://localhost:10200/redirects-script.html","lineNumber":11,"columnNumber":20}]}},"redirectResponse":{"url":"http://localhost:10200/redirects-script.html?redirect=http%3A%2F%2Flocalhost%3A10503%2Fredirects-script.html%3Fredirect%3Dhttps%253A%252F%252Fairhorner.com%252F","status":302,"statusText":"Found","headers":{"Location":"http://localhost:10503/redirects-script.html?redirect=https%3A%2F%2Fairhorner.com%2F","Date":"Thu, 28 Feb 2019 17:56:08 GMT","Connection":"keep-alive","Transfer-Encoding":"chunked"},"headersText":"HTTP/1.1 302 Found\r\nLocation: http://localhost:10503/redirects-script.html?redirect=https%3A%2F%2Fairhorner.com%2F\r\nDate: Thu, 28 Feb 2019 17:56:08 GMT\r\nConnection: keep-alive\r\nTransfer-Encoding: chunked\r\n\r\n","mimeType":"","requestHeaders":{"Host":"localhost:10200","Connection":"keep-alive","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3","Referer":"http://localhost:10200/redirects-script.html","Accept-Encoding":"gzip, deflate, br","Accept-Language":"en-US,en;q=0.9"},"requestHeadersText":"GET /redirects-script.html?redirect=http%3A%2F%2Flocalhost%3A10503%2Fredirects-script.html%3Fredirect%3Dhttps%253A%252F%252Fairhorner.com%252F HTTP/1.1\r\nHost: localhost:10200\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent: Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3\r\nReferer: http://localhost:10200/redirects-script.html\r\nAccept-Encoding: gzip, deflate, br\r\nAccept-Language: en-US,en;q=0.9\r\n","connectionReused":true,"connectionId":36,"remoteIPAddress":"127.0.0.1","remotePort":10200,"fromDiskCache":false,"fromServiceWorker":false,"encodedDataLength":207,"timing":{"requestTime":7162.649486,"proxyStart":-1,"proxyEnd":-1,"dnsStart":-1,"dnsEnd":-1,"connectStart":-1,"connectEnd":-1,"sslStart":-1,"sslEnd":-1,"workerStart":-1,"workerReady":-1,"sendStart":0.504,"sendEnd":0.541,"pushStart":0,"pushEnd":0,"receiveHeadersEnd":2.924},"protocol":"http/1.1","securityState":"neutral"},"type":"Document","frameId":"B19E293EA74DA749596009C93D1C1B4C","hasUserGesture":false}},
+  {"method":"Network.requestWillBeSent","params":{"requestId":"9E5F212F4468007C6952E996764DC56A","loaderId":"9E5F212F4468007C6952E996764DC56A","documentURL":"https://airhorner.com/","request":{"url":"https://airhorner.com/","method":"GET","headers":{"Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse","Referer":"http://localhost:10200/redirects-script.html"},"mixedContentType":"none","initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":7162.657095,"wallTime":1551376568.730307,"initiator":{"type":"script","stack":{"callFrames":[{"functionName":"","scriptId":"18","url":"http://localhost:10200/redirects-script.html","lineNumber":11,"columnNumber":20}]}},"redirectResponse":{"url":"http://localhost:10503/redirects-script.html?redirect=https%3A%2F%2Fairhorner.com%2F","status":302,"statusText":"Found","headers":{"Location":"https://airhorner.com/","Date":"Thu, 28 Feb 2019 17:56:08 GMT","Connection":"keep-alive","Transfer-Encoding":"chunked"},"headersText":"HTTP/1.1 302 Found\r\nLocation: https://airhorner.com/\r\nDate: Thu, 28 Feb 2019 17:56:08 GMT\r\nConnection: keep-alive\r\nTransfer-Encoding: chunked\r\n\r\n","mimeType":"","requestHeaders":{"Host":"localhost:10503","Connection":"keep-alive","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3","Referer":"http://localhost:10200/redirects-script.html","Accept-Encoding":"gzip, deflate, br","Accept-Language":"en-US,en;q=0.9"},"requestHeadersText":"GET /redirects-script.html?redirect=https%3A%2F%2Fairhorner.com%2F HTTP/1.1\r\nHost: localhost:10503\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent: Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3\r\nReferer: http://localhost:10200/redirects-script.html\r\nAccept-Encoding: gzip, deflate, br\r\nAccept-Language: en-US,en;q=0.9\r\n","connectionReused":false,"connectionId":54,"remoteIPAddress":"127.0.0.1","remotePort":10503,"fromDiskCache":false,"fromServiceWorker":false,"encodedDataLength":145,"timing":{"requestTime":7162.653422,"proxyStart":-1,"proxyEnd":-1,"dnsStart":0.379,"dnsEnd":0.393,"connectStart":0.393,"connectEnd":0.715,"sslStart":-1,"sslEnd":-1,"workerStart":-1,"workerReady":-1,"sendStart":0.808,"sendEnd":0.846,"pushStart":0,"pushEnd":0,"receiveHeadersEnd":3.006},"protocol":"http/1.1","securityState":"neutral"},"type":"Document","frameId":"B19E293EA74DA749596009C93D1C1B4C","hasUserGesture":false}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"82A9687A3E396289BF288BE28FAC977B","name":"firstPaint","timestamp":7162.716106}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"82A9687A3E396289BF288BE28FAC977B","name":"firstMeaningfulPaintCandidate","timestamp":7162.716115}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"82A9687A3E396289BF288BE28FAC977B","name":"networkAlmostIdle","timestamp":7162.244356}},
+  {"method":"Page.lifecycleEvent","params":{"frameId":"E6C992E73862A3AB8AEADAC3772D5421","loaderId":"82A9687A3E396289BF288BE28FAC977B","name":"networkIdle","timestamp":7162.256479}},
+  {"method":"Network.responseReceived","params":{"requestId":"9E5F212F4468007C6952E996764DC56A","loaderId":"9E5F212F4468007C6952E996764DC56A","timestamp":7162.979774,"type":"Document","response":{"url":"https://airhorner.com/","status":200,"statusText":"","headers":{"status":"200","date":"Thu, 28 Feb 2019 17:56:08 GMT","expires":"Thu, 28 Feb 2019 17:56:18 GMT"},"mimeType":"text/html","requestHeaders":{":method":"GET",":authority":"airhorner.com",":scheme":"https",":path":"/","upgrade-insecure-requests":"1","user-agent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3","referer":"http://localhost:10200/redirects-script.html","accept-encoding":"gzip, deflate, br","accept-language":"en-US,en;q=0.9"},"connectionReused":false,"connectionId":62,"remotePort":443,"fromDiskCache":false,"fromServiceWorker":false,"encodedDataLength":2254,"timing":{"requestTime":7162.657451,"proxyStart":-1,"proxyEnd":-1,"dnsStart":0.35,"dnsEnd":91.4,"connectStart":91.4,"connectEnd":125.871,"sslStart":92.917,"sslEnd":125.864,"workerStart":-1,"workerReady":-1,"sendStart":126.138,"sendEnd":126.281,"pushStart":0,"pushEnd":0,"receiveHeadersEnd":317.295},"protocol":"h2","securityState":"secure","securityDetails":{"protocol":"TLS 1.2","keyExchange":"ECDHE_RSA","keyExchangeGroup":"X25519","cipher":"AES_128_GCM","certificateId":0,"subjectName":"airhorner.com","sanList":["airhorner.com"],"issuer":"Let's Encrypt Authority X3","validFrom":1549374063,"validTo":1557150063,"signedCertificateTimestampList":[],"certificateTransparencyCompliance":"compliant"}},"frameId":"B19E293EA74DA749596009C93D1C1B4C"}},  {"method":"Page.frameStoppedLoading","params":{"frameId":"B19E293EA74DA749596009C93D1C1B4C"}},
+  {"method":"Page.frameDetached","params":{"frameId":"B19E293EA74DA749596009C93D1C1B4C"}}
+]
diff --git a/lighthouse-core/test/gather/fake-driver.js b/lighthouse-core/test/gather/fake-driver.js
index 04992eedc..73e0782e0 100644
--- a/lighthouse-core/test/gather/fake-driver.js
+++ b/lighthouse-core/test/gather/fake-driver.js
@@ -5,6 +5,79 @@
  */
 'use strict';
 
+function makeFakeDriver({protocolGetVersionResponse}) {
+  return {
+    getBrowserVersion() {
+      return Promise.resolve(Object.assign({}, protocolGetVersionResponse, {milestone: 71}));
+    },
+    getBenchmarkIndex() {
+      return Promise.resolve(125.2);
+    },
+    getAppManifest() {
+      return Promise.resolve(null);
+    },
+    connect() {
+      return Promise.resolve();
+    },
+    disconnect() {
+      return Promise.resolve();
+    },
+    gotoURL() {
+      return Promise.resolve('https://www.reddit.com/r/nba');
+    },
+    beginEmulation() {
+      return Promise.resolve();
+    },
+    setThrottling() {
+      return Promise.resolve();
+    },
+    dismissJavaScriptDialogs() {
+      return Promise.resolve();
+    },
+    assertNoSameOriginServiceWorkerClients() {
+      return Promise.resolve();
+    },
+    reloadForCleanStateIfNeeded() {
+      return Promise.resolve();
+    },
+    enableRuntimeEvents() {
+      return Promise.resolve();
+    },
+    evaluateScriptOnLoad() {
+      return Promise.resolve();
+    },
+    cleanBrowserCaches() {},
+    clearDataForOrigin() {},
+    cacheNatives() {
+      return Promise.resolve();
+    },
+    evaluateAsync() {
+      return Promise.resolve({});
+    },
+    registerPerformanceObserver() {
+      return Promise.resolve();
+    },
+    beginTrace() {
+      return Promise.resolve();
+    },
+    endTrace() {
+      return Promise.resolve(
+      require('../fixtures/traces/progressive-app.json')
+      );
+    },
+    beginDevtoolsLog() {},
+    endDevtoolsLog() {
+      return require('../fixtures/artifacts/perflog/defaultPass.devtoolslog.json');
+    },
+    blockUrlPatterns() {
+      return Promise.resolve();
+    },
+    setExtraHTTPHeaders() {
+      return Promise.resolve();
+    },
+  };
+}
+
 // https://chromedevtools.github.io/devtools-protocol/tot/Browser#method-getVersion
 const protocolGetVersionResponse = {
   protocolVersion: '1.3',
@@ -14,77 +87,16 @@ const protocolGetVersionResponse = {
   userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3577.0 Safari/537.36',
   jsVersion: '7.1.314',
 };
+const fakeDriver = makeFakeDriver({protocolGetVersionResponse});
 
-const fakeDriver = {
-  getBrowserVersion() {
-    return Promise.resolve(Object.assign({}, protocolGetVersionResponse, {milestone: 71}));
-  },
-  getBenchmarkIndex() {
-    return Promise.resolve(125.2);
-  },
-  getAppManifest() {
-    return Promise.resolve(null);
-  },
-  connect() {
-    return Promise.resolve();
-  },
-  disconnect() {
-    return Promise.resolve();
-  },
-  gotoURL() {
-    return Promise.resolve('https://www.reddit.com/r/nba');
-  },
-  beginEmulation() {
-    return Promise.resolve();
-  },
-  setThrottling() {
-    return Promise.resolve();
-  },
-  dismissJavaScriptDialogs() {
-    return Promise.resolve();
-  },
-  assertNoSameOriginServiceWorkerClients() {
-    return Promise.resolve();
-  },
-  reloadForCleanStateIfNeeded() {
-    return Promise.resolve();
+const fakeDriverUsingRealMobileDevice = makeFakeDriver({
+  protocolGetVersionResponse: {
+    ...protocolGetVersionResponse,
+    // eslint-disable-next-line max-len
+    userAgent: 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML, like Gecko) Chrome/69.0.3464.0 Mobile Safari/537.36',
   },
-  enableRuntimeEvents() {
-    return Promise.resolve();
-  },
-  evaluateScriptOnLoad() {
-    return Promise.resolve();
-  },
-  cleanBrowserCaches() {},
-  clearDataForOrigin() {},
-  cacheNatives() {
-    return Promise.resolve();
-  },
-  evaluateAsync() {
-    return Promise.resolve({});
-  },
-  registerPerformanceObserver() {
-    return Promise.resolve();
-  },
-  beginTrace() {
-    return Promise.resolve();
-  },
-  endTrace() {
-    return Promise.resolve(
-      require('../fixtures/traces/progressive-app.json')
-    );
-  },
-  beginDevtoolsLog() {},
-  endDevtoolsLog() {
-    return require('../fixtures/artifacts/perflog/defaultPass.devtoolslog.json');
-  },
-  blockUrlPatterns() {
-    return Promise.resolve();
-  },
-  setExtraHTTPHeaders() {
-    return Promise.resolve();
-  },
-};
+});
 
 module.exports = fakeDriver;
+module.exports.fakeDriverUsingRealMobileDevice = fakeDriverUsingRealMobileDevice;
 module.exports.protocolGetVersionResponse = protocolGetVersionResponse;
diff --git a/lighthouse-core/test/gather/gather-runner-test.js b/lighthouse-core/test/gather/gather-runner-test.js
index 44dbc1ed8..c5bd26809 100644
--- a/lighthouse-core/test/gather/gather-runner-test.js
+++ b/lighthouse-core/test/gather/gather-runner-test.js
@@ -33,6 +33,7 @@ class TestGathererNoArtifact extends Gatherer {
 }
 
 const fakeDriver = require('./fake-driver');
+const fakeDriverUsingRealMobileDevice = fakeDriver.fakeDriverUsingRealMobileDevice;
 
 function getMockedEmulationDriver(emulationFn, netThrottleFn, cpuThrottleFn,
   blockUrlFn, extraHeadersFn) {
@@ -156,6 +157,50 @@ describe('GatherRunner', function() {
     });
   });
 
+  describe('collects TestedAsMobileDevice as an artifact', () => {
+    const url = 'https://example.com';
+
+    it('works when running on desktop device without emulation', async () => {
+      const driver = fakeDriver;
+      const config = new Config({passes: [{}]});
+      const settings = {};
+      const options = {url, driver, config, settings};
+
+      const results = await GatherRunner.run(config.passes, options);
+      expect(results.TestedAsMobileDevice).toBe(false);
+    });
+
+    it('works when running on desktop device with mobile emulation', async () => {
+      const driver = fakeDriver;
+      const config = new Config({passes: [{}]});
+      const settings = {emulatedFormFactor: 'mobile'};
+      const options = {url, driver, config, settings};
+
+      const results = await GatherRunner.run(config.passes, options);
+      expect(results.TestedAsMobileDevice).toBe(true);
+    });
+
+    it('works when running on mobile device without emulation', async () => {
+      const driver = fakeDriverUsingRealMobileDevice;
+      const config = new Config({passes: [{}]});
+      const settings = {};
+      const options = {url, driver, config, settings};
+
+      const results = await GatherRunner.run(config.passes, options);
+      expect(results.TestedAsMobileDevice).toBe(true);
+    });
+
+    it('works when running on mobile device with desktop emulation', async () => {
+      const driver = fakeDriverUsingRealMobileDevice;
+      const config = new Config({passes: [{}]});
+      const settings = {emulatedFormFactor: 'desktop'};
+      const options = {url, driver, config, settings};
+
+      const results = await GatherRunner.run(config.passes, options);
+      expect(results.TestedAsMobileDevice).toBe(false);
+    });
+  });
+
   it('sets up the driver to begin emulation when all emulation flags are undefined', () => {
     const tests = {
       calledDeviceEmulation: false,
diff --git a/lighthouse-core/test/lib/network-recorder-test.js b/lighthouse-core/test/lib/network-recorder-test.js
index 0d839bd22..3f36da568 100644
--- a/lighthouse-core/test/lib/network-recorder-test.js
+++ b/lighthouse-core/test/lib/network-recorder-test.js
@@ -10,6 +10,7 @@ const networkRecordsToDevtoolsLog = require('../network-records-to-devtools-log.
 const assert = require('assert');
 const devtoolsLogItems = require('../fixtures/artifacts/perflog/defaultPass.devtoolslog.json');
 const redirectsDevtoolsLog = require('../fixtures/wikipedia-redirect.devtoolslog.json');
+const redirectsScriptDevtoolsLog = require('../fixtures/redirects-from-script.devtoolslog.json');
 
 /* eslint-env jest */
 describe('network recorder', function() {
@@ -46,6 +47,50 @@ describe('network recorder', function() {
     assert.equal(mainDocument.resourceType, 'Document');
   });
 
+  it('sets initiators to redirects when original initiator is script', () => {
+    // The test page features script-initiated redirects:
+    /*
+        <!DOCTYPE html>
+        <script>
+        setTimeout(_ => {
+          // add an iframe to the page via script
+          // the iframe will open :10200/redirects-script.html
+          // which redirects to :10503/redirects-script.html
+          // which redirects to airhorner.com
+          const elem = document.createElement('iframe');
+          elem.src = 'http://localhost:10200/redirects-script.html?redirect=http%3A%2F%2Flocalhost%3A10503%2Fredirects-script.html%3Fredirect%3Dhttps%253A%252F%252Fairhorner.com%252F';
+          document.body.append(elem);
+        }, 400);
+        </script>
+    */
+
+    const records = NetworkRecorder.recordsFromLogs(redirectsScriptDevtoolsLog);
+    assert.equal(records.length, 4);
+
+    const [mainDocument, iframeRedirectA, iframeRedirectB, iframeDocument] = records;
+    assert.equal(mainDocument.initiatorRequest, undefined);
+    assert.equal(mainDocument.redirectSource, undefined);
+    assert.equal(mainDocument.redirectDestination, undefined);
+    assert.equal(iframeRedirectA.initiatorRequest, mainDocument);
+    assert.equal(iframeRedirectA.redirectSource, undefined);
+    assert.equal(iframeRedirectA.redirectDestination, iframeRedirectB);
+    assert.equal(iframeRedirectB.initiatorRequest, iframeRedirectA);
+    assert.equal(iframeRedirectB.redirectSource, iframeRedirectA);
+    assert.equal(iframeRedirectB.redirectDestination, iframeDocument);
+    assert.equal(iframeDocument.initiatorRequest, iframeRedirectB);
+    assert.equal(iframeDocument.redirectSource, iframeRedirectB);
+    assert.equal(iframeDocument.redirectDestination, undefined);
+
+    const redirectURLs = iframeDocument.redirects.map(request => request.url);
+    assert.deepStrictEqual(redirectURLs, [iframeRedirectA.url, iframeRedirectB.url]);
+
+    assert.equal(mainDocument.resourceType, 'Document');
+    assert.equal(iframeRedirectA.resourceType, undefined);
+    assert.equal(iframeRedirectB.resourceType, undefined);
+    assert.equal(iframeDocument.resourceType, 'Document');
+  });
+
+
   it('recordsFromLogs ignores records with an invalid URL', function() {
     const logs = [
       { // valid request
diff --git a/lighthouse-core/test/results/artifacts/artifacts.json b/lighthouse-core/test/results/artifacts/artifacts.json
index 9dd87ffe8..5b770191b 100644
--- a/lighthouse-core/test/results/artifacts/artifacts.json
+++ b/lighthouse-core/test/results/artifacts/artifacts.json
@@ -1,6 +1,7 @@
 {
   "LighthouseRunWarnings": [],
   "BenchmarkIndex": 1000,
+  "TestedAsMobileDevice": true,
   "HostUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3358.0 Safari/537.36",
   "NetworkUserAgent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML, like Gecko) Chrome/66.0.3359.30 Mobile Safari/537.36",
   "fetchTime": "2018-03-13T00:55:45.840Z",