diff --git a/.github/workflows/devtools.yml b/.github/workflows/devtools.yml index 2703cc0cb83d..bfab3a2b14a4 100644 --- a/.github/workflows/devtools.yml +++ b/.github/workflows/devtools.yml @@ -33,7 +33,7 @@ jobs: ${{ env.DEVTOOLS_PATH }} ${{ env.BLINK_TOOLS_PATH }} ${{ github.workspace }}/lighthouse/.tmp/chromium-web-tests/content-shells - key: ${{ runner.os }}-${{ hashFiles('lighthouse/.github/workflows/devtools.yml', 'lighthouse/lighthouse-core/test/chromium-web-tests/download-*', 'lighthouse/clients/devtools-entry.js', 'lighthouse/clients/devtools-report-assets.js', 'lighthouse/build/build-bundle.js', 'lighthouse/build/build-dt-report-resources.js') }} + key: ${{ runner.os }}-${{ hashFiles('lighthouse/.github/workflows/devtools.yml', 'lighthouse/lighthouse-core/test/chromium-web-tests/*', 'lighthouse/clients/devtools-entry.js', 'lighthouse/clients/devtools-report-assets.js', 'lighthouse/build/build-bundle.js', 'lighthouse/build/build-dt-report-resources.js') }} - name: Use Node.js 10.x uses: actions/setup-node@v1 diff --git a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning-expected.txt b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning-expected.txt new file mode 100644 index 000000000000..9104b3dbb12c --- /dev/null +++ b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning-expected.txt @@ -0,0 +1,15 @@ +Tests that Lighthouse panel displays a warning when important data may affect performance. + + +========== Lighthouse Start Audit State ========== +[x] Performance +[ ] Progressive Web App +[ ] Best practices +[ ] Accessibility +[ ] SEO +[ ] Publisher Ads +[x] Clear storage +[x] Simulated throttling +Generate report: enabled visible +Warning Text: There may be stored data affecting loading performance in these locations: Web SQL, IndexedDB. Audit this page in an incognito window to prevent those resources from affecting your scores. + diff --git a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning.js b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning.js new file mode 100644 index 000000000000..a9fb8fb09e49 --- /dev/null +++ b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning.js @@ -0,0 +1,35 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests that Lighthouse panel displays a warning when important data may affect performance.\n'); + await TestRunner.navigatePromise('resources/lighthouse-storage.html'); + + await TestRunner.loadModule('lighthouse_test_runner'); + await TestRunner.showPanel('lighthouse'); + + const containerElement = LighthouseTestRunner.getContainerElement(); + const checkboxes = containerElement.querySelectorAll('.checkbox'); + for (const checkbox of checkboxes) { + if (checkbox.textElement.textContent === 'Performance' || checkbox.textElement.textContent === 'Clear storage') { + continue; + } + + if (checkbox.checkboxElement.checked) { + checkbox.checkboxElement.click(); + } + } + + LighthouseTestRunner.dumpStartAuditState(); + + const Events = Lighthouse.LighthousePanel.getEvents(); + const warningText = containerElement.querySelector('.lighthouse-warning-text'); + + // Wait for warning event to be handled + LighthouseTestRunner._panel()._controller.addEventListener(Events.PageWarningsChanged, () => { + TestRunner.addResult(`Warning Text: ${warningText.textContent}`); + TestRunner.completeTest(); + }); + LighthouseTestRunner.forcePageAuditabilityCheck(); +})(); diff --git a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/resources/lighthouse-storage.html b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/resources/lighthouse-storage.html new file mode 100644 index 000000000000..006acab8792b --- /dev/null +++ b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/resources/lighthouse-storage.html @@ -0,0 +1,18 @@ + +
+ + + + + hi +