Repository: GoogleChrome/lighthouse
Pull request #6293 (2018-10-16 15:43:53)

core: remove no-websql audit
**Summary**
This audit is relevant to only 0.6% of sites on HTTPArchive (only 8k out of ~1.3M) . The `websql` gatherer takes at least 500ms for every site that *passes* the audit, so we're spending 1,200,000 seconds a month just on WPT doing nothing :)

My claim is that this audit would not pass our `new-audit` criteria doc if we were to validate it today and should be removed.

**Related Issues**
thought of while investigating #6272 



<details>

<summary>
See Query
</summary>

```sql
SELECT
  JSON_EXTRACT_SCALAR(report, '$.audits.no-websql.score') as score, COUNT(*)
FROM
  httparchive.lighthouse.2018_09_01_mobile
 GROUP BY score
```
</details>




brendankenny: <img width="724" alt="screen shot 2018-10-16 at 10 18 43" src="https://user-images.githubusercontent.com/316891/47034702-f4c33480-d12c-11e8-94d4-2524e76b0bf6.png">

someone playing around this this?
brendankenny: oh, maybe it's new actions or whatever
patrickhulce: > Need to also delete WebSQL in artifacts.d.ts

@brendankenny do you have a way for force vscode show the .d.ts files and have them in find/replace

```
        "**/*.d.ts": {
            "when": "$(basename).ts"
        }
```

hasn't been doing the trick clearly :)
brendankenny: oh, no, and I hadn't even noticed that was a problem...

I was thinking that maybe we need to reverse `artifacts.d.ts` and have it pull the artifact types off of the gatherers that produce them (which would have flagged the change in this case), but I believe our earlier reasoning was that by having the source of truth in that file, bugs in gatherers would be more easily caught, which still seems sound...

Patch:
diff --git a/lighthouse-core/audits/dobetterweb/no-websql.js b/lighthouse-core/audits/dobetterweb/no-websql.js
deleted file mode 100644
index ae328e794..000000000
--- a/lighthouse-core/audits/dobetterweb/no-websql.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * @license Copyright 2016 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.
- */
-
-/**
- * @fileoverview Audit a page to ensure that it does not open a database using
- * the WebSQL API.
- */
-
-'use strict';
-
-const Audit = require('../audit');
-
-class NoWebSQLAudit extends Audit {
-  /**
-   * @return {LH.Audit.Meta}
-   */
-  static get meta() {
-    return {
-      id: 'no-websql',
-      title: 'Avoids WebSQL DB',
-      failureTitle: 'Uses WebSQL DB',
-      description: 'Web SQL is deprecated. Consider using IndexedDB instead. ' +
-          '[Learn more](https://developers.google.com/web/tools/lighthouse/audits/web-sql).',
-      requiredArtifacts: ['WebSQL'],
-    };
-  }
-
-  /**
-   * @param {LH.Artifacts} artifacts
-   * @return {LH.Audit.Product}
-   */
-  static audit(artifacts) {
-    const db = artifacts.WebSQL;
-    const displayValue = (db ?
-        `Found "${db.name}" (v${db.version})` : '');
-
-    return {
-      rawValue: !db,
-      displayValue,
-    };
-  }
-}
-
-module.exports = NoWebSQLAudit;
diff --git a/lighthouse-core/config/default-config.js b/lighthouse-core/config/default-config.js
index a6f1a0b5a..547a1296b 100644
--- a/lighthouse-core/config/default-config.js
+++ b/lighthouse-core/config/default-config.js
@@ -65,7 +65,6 @@ const defaultConfig = {
       'dobetterweb/password-inputs-with-prevented-paste',
       'dobetterweb/response-compression',
       'dobetterweb/tags-blocking-first-paint',
-      'dobetterweb/websql',
       'seo/meta-description',
       'seo/font-size',
       'seo/crawlable-links',
@@ -197,7 +196,6 @@ const defaultConfig = {
     'dobetterweb/no-document-write',
     'dobetterweb/no-vulnerable-libraries',
     'dobetterweb/js-libraries',
-    'dobetterweb/no-websql',
     'dobetterweb/notification-on-start',
     'dobetterweb/password-inputs-can-be-pasted-into',
     'dobetterweb/uses-http2',
@@ -399,7 +397,6 @@ const defaultConfig = {
       title: 'Best Practices',
       auditRefs: [
         {id: 'appcache-manifest', weight: 1},
-        {id: 'no-websql', weight: 1},
         {id: 'is-on-https', weight: 1},
         {id: 'uses-http2', weight: 1},
         {id: 'uses-passive-event-listeners', weight: 1},
diff --git a/lighthouse-core/gather/gatherers/dobetterweb/websql.js b/lighthouse-core/gather/gatherers/dobetterweb/websql.js
deleted file mode 100644
index e37c53537..000000000
--- a/lighthouse-core/gather/gatherers/dobetterweb/websql.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * @license Copyright 2016 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 Gatherer = require('../gatherer');
-const Driver = require('../../driver.js'); // eslint-disable-line no-unused-vars
-
-const MAX_WAIT_TIMEOUT = 500;
-
-class WebSQL extends Gatherer {
-  /**
-   * @param {Driver} driver
-   * @return {Promise<?LH.Crdp.Database.AddDatabaseEvent>}
-   */
-  listenForDatabaseEvents(driver) {
-    /** @type {NodeJS.Timer} */
-    let timeout;
-
-    return new Promise((resolve, reject) => {
-      driver.once('Database.addDatabase', db => {
-        clearTimeout(timeout);
-        driver.sendCommand('Database.disable').then(_ => resolve(db), reject);
-      });
-
-      driver.sendCommand('Database.enable').catch(reject);
-
-      // Wait for a websql db to be opened. Reject the Promise no dbs were created.
-      // TODO(ericbidelman): this assumes dbs are opened on page load.
-      // load. Figure out a better strategy (code greping, user interaction) later.
-      timeout = setTimeout(function() {
-        resolve(null);
-      }, MAX_WAIT_TIMEOUT);
-    });
-  }
-
-  /**
-   * Returns WebSQL database information or null if none was found.
-   * @param {LH.Gatherer.PassContext} passContext
-   * @return {Promise<LH.Artifacts['WebSQL']>}
-   */
-  afterPass(passContext) {
-    return this.listenForDatabaseEvents(passContext.driver)
-      .then(result => {
-        return result && result.database;
-      });
-  }
-}
-
-module.exports = WebSQL;
diff --git a/proto/sample_v2_round_trip.json b/proto/sample_v2_round_trip.json
index e3c15bf4e..9f844dfc8 100644
--- a/proto/sample_v2_round_trip.json
+++ b/proto/sample_v2_round_trip.json
@@ -1602,14 +1602,6 @@
             "scoreDisplayMode": "binary", 
             "title": "Includes front-end JavaScript libraries with known security vulnerabilities"
         }, 
-        "no-websql": {
-            "description": "Web SQL is deprecated. Consider using IndexedDB instead. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/web-sql).", 
-            "displayValue": "Found \"mydb\" (v1.0)", 
-            "id": "no-websql", 
-            "score": 0.0, 
-            "scoreDisplayMode": "binary", 
-            "title": "Uses WebSQL DB"
-        }, 
         "notification-on-start": {
             "description": "Users are mistrustful of or confused by sites that request to send notifications without context. Consider tying the request to user gestures instead. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/notifications-on-load).", 
             "details": {
@@ -2820,10 +2812,6 @@
                     "id": "appcache-manifest", 
                     "weight": 1.0
                 }, 
-                {
-                    "id": "no-websql", 
-                    "weight": 1.0
-                }, 
                 {
                     "id": "is-on-https", 
                     "weight": 1.0
diff --git a/typings/artifacts.d.ts b/typings/artifacts.d.ts
index 33e7ac12c..bd74e86a6 100644
--- a/typings/artifacts.d.ts
+++ b/typings/artifacts.d.ts
@@ -117,8 +117,6 @@ declare global {
       Viewport: string|null;
       /** The dimensions and devicePixelRatio of the loaded viewport. */
       ViewportDimensions: Artifacts.ViewportDimensions;
-      /** WebSQL database information for the page or null if none was found. */
-      WebSQL: Crdp.Database.Database | null;
     }
 
     module Artifacts {


Test patch:
diff --git a/lighthouse-cli/test/cli/__snapshots__/index-test.js.snap b/lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
index 080648356..716e9943a 100644
--- a/lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
+++ b/lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
@@ -312,9 +312,6 @@ Object {
     Object {
       "path": "dobetterweb/js-libraries",
     },
-    Object {
-      "path": "dobetterweb/no-websql",
-    },
     Object {
       "path": "dobetterweb/notification-on-start",
     },
@@ -594,10 +591,6 @@ Object {
           "id": "appcache-manifest",
           "weight": 1,
         },
-        Object {
-          "id": "no-websql",
-          "weight": 1,
-        },
         Object {
           "id": "is-on-https",
           "weight": 1,
@@ -1077,9 +1070,6 @@ Object {
         Object {
           "path": "dobetterweb/tags-blocking-first-paint",
         },
-        Object {
-          "path": "dobetterweb/websql",
-        },
         Object {
           "path": "seo/meta-description",
         },
diff --git a/lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html b/lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html
index 0627ee7af..e8df9bdcc 100644
--- a/lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html
+++ b/lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html
@@ -204,10 +204,6 @@ function documentWriteTest() {
   document.write('2.0!'); // FAIL
 }
 
-function websqlTest() {
-  const db = openDatabase('mydb', '1.0', 'my first database', 1024);
-}
-
 function passiveEventsListenerTest() {
   // FAIL or PASS - field trial for document level defaulting to passive M71+
   window.addEventListener('wheel', function(e) {
@@ -325,7 +321,6 @@ if (location.search === '') {
   documentWriteTest();
   dateNowTest();
   consoleTimeTest();
-  websqlTest();
   passiveEventsListenerTest();
   geolocationOnStartTest();
   notificationOnStartTest();
@@ -345,9 +340,6 @@ if (location.search === '') {
   if (params.has('consoleTime')) {
     consoleTimeTest();
   }
-  if (params.has('websql')) {
-    websqlTest();
-  }
   if (params.has('passiveEvents')) {
     passiveEventsListenerTest();
   }
diff --git a/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js b/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js
index b3ae12bf8..d9c61466f 100644
--- a/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js
+++ b/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js
@@ -69,10 +69,6 @@ module.exports = [
           },
         },
       },
-      'no-websql': {
-        score: 0,
-        displayValue: 'Found "mydb" (v1.0)',
-      },
       'notification-on-start': {
         score: 0,
       },
diff --git a/lighthouse-cli/test/smokehouse/offline-local/offline-expectations.js b/lighthouse-cli/test/smokehouse/offline-local/offline-expectations.js
index 8020f93f0..12f3f23f3 100644
--- a/lighthouse-cli/test/smokehouse/offline-local/offline-expectations.js
+++ b/lighthouse-cli/test/smokehouse/offline-local/offline-expectations.js
@@ -36,9 +36,6 @@ module.exports = [
       'no-document-write': {
         score: 1,
       },
-      'no-websql': {
-        score: 1,
-      },
       'uses-passive-event-listeners': {
         score: 1,
       },
diff --git a/lighthouse-core/test/audits/dobetterweb/no-websql-test.js b/lighthouse-core/test/audits/dobetterweb/no-websql-test.js
deleted file mode 100644
index c99cc81f1..000000000
--- a/lighthouse-core/test/audits/dobetterweb/no-websql-test.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * @license Copyright 2016 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 NoWebSQLAudit = require('../../../audits/dobetterweb/no-websql.js');
-const assert = require('assert');
-
-/* eslint-env jest */
-
-describe('No websql audit', () => {
-  it('passes when no database is created', () => {
-    assert.equal(NoWebSQLAudit.audit({
-      WebSQL: null,
-    }).rawValue, true);
-  });
-
-  it('fails when database is created', () => {
-    const auditResult = NoWebSQLAudit.audit({
-      WebSQL: {
-        id: '1',
-        domain: 'example.com',
-        name: 'db-name',
-        version: '1.0',
-      },
-    });
-
-    assert.equal(auditResult.rawValue, false);
-    assert.ok(auditResult.displayValue.match(/db-name.*1.0/));
-  });
-});
diff --git a/lighthouse-core/test/results/sample_v2.json b/lighthouse-core/test/results/sample_v2.json
index 4c64c64cc..f9616950b 100644
--- a/lighthouse-core/test/results/sample_v2.json
+++ b/lighthouse-core/test/results/sample_v2.json
@@ -2402,15 +2402,6 @@
         "summary": {}
       }
     },
-    "no-websql": {
-      "id": "no-websql",
-      "title": "Uses WebSQL DB",
-      "description": "Web SQL is deprecated. Consider using IndexedDB instead. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/web-sql).",
-      "score": 0,
-      "scoreDisplayMode": "binary",
-      "rawValue": false,
-      "displayValue": "Found \"mydb\" (v1.0)"
-    },
     "notification-on-start": {
       "id": "notification-on-start",
       "title": "Requests the notification permission on page load",
@@ -3233,10 +3224,6 @@
           "id": "appcache-manifest",
           "weight": 1
         },
-        {
-          "id": "no-websql",
-          "weight": 1
-        },
         {
           "id": "is-on-https",
           "weight": 1