Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore LCP background image Opp & Exp #2454

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions www/experiments/lcp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
// LCP info!
$category = "Quick";
$events = $testStepResult->getMetric('largestPaints');
$lcpType = $testStepResult->getMetric('LargestContentfulPaintType');
$lcpNodeType = $testStepResult->getMetric('LargestContentfulPaintNodeType');
$lcpImageURL = $testStepResult->getMetric('LargestContentfulPaintImageURL');

$lcp = null;
if (isset($events) && is_array($events)) {
// Find the actual LCP event
Expand Down Expand Up @@ -43,6 +47,8 @@ if (isset($lcp)) {
$lcpSource = $srcmatches[1][0];
}
}

// old bg check, which may still capture bg images from old test data
if (isset($lcp['element']['background-image'])) {
preg_match_all('/url\(([\s])?([\"|\'])?(.*?)([\"|\'])?([\s])?\)/i', $lcp['element']['background-image'], $matches, PREG_PATTERN_ORDER);
if ($matches) {
Expand All @@ -52,6 +58,12 @@ if (isset($lcp)) {
}
}

// new bg check - still doesn't find bg images set via inline style
if (isset($lcpType) && $lcpType === "background-image" && isset($lcpImageURL)) {
$lcpSource = $lcpImageURL;
$lcpFullSource = $lcpImageURL;
$isBG = true;
}

$expsToAdd = array();
$expsToAdd[] = (object) [
Expand Down