Skip to content

Commit

Permalink
tests: add devtools test for important data warning (#11544)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine committed Oct 14, 2020
1 parent 8caa938 commit 6a2beb5
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/devtools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

Original file line number Diff line number Diff line change
@@ -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();
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<script>
// Indexeddb
window.indexedDB.open("DataBase", 3);

// WebSQL
var db = openDatabase('mydb', '1.0', 'Test', 2 * 1024 * 1024);
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "foobar")');
});
</script>
</head>
<body>
hi
</body>

0 comments on commit 6a2beb5

Please sign in to comment.