[headless] Deflake screencast background change tests
Screencast background change tests appeared to be flake, presumably due to the page under test changing background color automatically. This CL changes logic so that the background color is changed in response to the background color detection on the received screencast frame which should make the test more deterministic. The screen casting test still consistently fails on Windows due to timeout. This is probably unrelated to flakiness on other platforms. Bug: 1411976 Change-Id: I330a4cd54283db45cd6553d865c3754a4b2974f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4763524 Reviewed-by: Andrey Kosyakov <caseq@chromium.org> Commit-Queue: Peter Kvitek <kvitekp@chromium.org> Cr-Commit-Position: refs/heads/main@{#1181526}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
1708956fd0
commit
d844672c9a
chrome/browser/headless
headless/test/data/protocol/sanity
@ -256,7 +256,12 @@ HEADLESS_MODE_PROTOCOL_TEST_F(HeadlessModeInputSelectFileDialogTest,
|
||||
"input/input-select-file-dialog.js")
|
||||
|
||||
// https://crbug.com/1411976
|
||||
HEADLESS_MODE_PROTOCOL_TEST(DISABLED_ScreencastBasics,
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#define MAYBE_ScreencastBasics DISABLED_ScreencastBasics
|
||||
#else
|
||||
#define MAYBE_ScreencastBasics ScreencastBasics
|
||||
#endif
|
||||
HEADLESS_MODE_PROTOCOL_TEST(MAYBE_ScreencastBasics,
|
||||
"sanity/screencast-basics.js")
|
||||
|
||||
HEADLESS_MODE_PROTOCOL_TEST(LargeBrowserWindowSize,
|
||||
|
@ -1,11 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<script>
|
||||
let count = 0;
|
||||
setInterval(() => {
|
||||
document.body.style.backgroundColor =
|
||||
(count++ & 1) ? "#0000ff" : "#00ff00";
|
||||
}, 0);
|
||||
</script>
|
||||
<body></body>
|
||||
</html>
|
@ -9,6 +9,10 @@
|
||||
let seenGreen = 0;
|
||||
let seenBlue = 0;
|
||||
|
||||
function setBkgrColor(bkgrColor) {
|
||||
session.evaluate(`document.body.style.backgroundColor = "${bkgrColor}"`);
|
||||
}
|
||||
|
||||
async function loadPngAndCountPixelColor(pngBase64) {
|
||||
const image = new Image();
|
||||
|
||||
@ -27,9 +31,13 @@
|
||||
if (rgba[0] === 0 && rgba[3] === 255) {
|
||||
if (rgba[1] === 255 && rgba[2] === 0) {
|
||||
++seenGreen;
|
||||
setBkgrColor('#0000ff');
|
||||
} else if (rgba[1] === 0 && rgba[2] === 255) {
|
||||
++seenBlue;
|
||||
setBkgrColor('#00ff00');
|
||||
}
|
||||
} else {
|
||||
setBkgrColor('#00ff00');
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +46,7 @@
|
||||
dp.Page.onScreencastFrame(async (data) => {
|
||||
const pngBase64 = data.params.data;
|
||||
await loadPngAndCountPixelColor(pngBase64);
|
||||
if (seenGreen > 1 && seenBlue > 1) {
|
||||
if (seenGreen > 2 && seenBlue > 2) {
|
||||
await dp.Page.stopScreencast();
|
||||
testRunner.log(`Seen both green and blue page backgrounds.`);
|
||||
testRunner.completeTest();
|
||||
@ -50,7 +58,5 @@
|
||||
|
||||
dp.Page.bringToFront();
|
||||
|
||||
dp.Page.navigate({url: testRunner.url('/resources/blue-green-dance.html')});
|
||||
|
||||
dp.Page.startScreencast({format: 'png'});
|
||||
})
|
||||
|
@ -1,11 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<script>
|
||||
let count = 0;
|
||||
setInterval(() => {
|
||||
document.body.style.backgroundColor =
|
||||
(count++ & 1) ? "#0000ff" : "#00ff00";
|
||||
}, 0);
|
||||
</script>
|
||||
<body></body>
|
||||
</html>
|
@ -9,6 +9,10 @@
|
||||
let seenGreen = 0;
|
||||
let seenBlue = 0;
|
||||
|
||||
function setBkgrColor(bkgrColor) {
|
||||
session.evaluate(`document.body.style.backgroundColor = "${bkgrColor}"`);
|
||||
}
|
||||
|
||||
async function loadPngAndCountPixelColor(pngBase64) {
|
||||
const image = new Image();
|
||||
|
||||
@ -27,9 +31,13 @@
|
||||
if (rgba[0] === 0 && rgba[3] === 255) {
|
||||
if (rgba[1] === 255 && rgba[2] === 0) {
|
||||
++seenGreen;
|
||||
setBkgrColor('#0000ff');
|
||||
} else if (rgba[1] === 0 && rgba[2] === 255) {
|
||||
++seenBlue;
|
||||
setBkgrColor('#00ff00');
|
||||
}
|
||||
} else {
|
||||
setBkgrColor('#00ff00');
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +46,7 @@
|
||||
dp.Page.onScreencastFrame(async (data) => {
|
||||
const pngBase64 = data.params.data;
|
||||
await loadPngAndCountPixelColor(pngBase64);
|
||||
if (seenGreen > 1 && seenBlue > 1) {
|
||||
if (seenGreen > 2 && seenBlue > 2) {
|
||||
await dp.Page.stopScreencast();
|
||||
testRunner.log(`Seen both green and blue page backgrounds.`);
|
||||
testRunner.completeTest();
|
||||
@ -50,7 +58,5 @@
|
||||
|
||||
dp.Page.bringToFront();
|
||||
|
||||
dp.Page.navigate({url: testRunner.url('/resources/blue-green-dance.html')});
|
||||
|
||||
dp.Page.startScreencast({format: 'png'});
|
||||
})
|
||||
|
Reference in New Issue
Block a user