-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add devtools test for important data warning (#11544)
- Loading branch information
Showing
4 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...btests/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
35 changes: 35 additions & 0 deletions
35
...hromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
})(); |
18 changes: 18 additions & 0 deletions
18
...romium-webtests/webtests/http/tests/devtools/lighthouse/resources/lighthouse-storage.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |