Skip to content

Commit 488f905

Browse files
Release build 11.32.0 [ci release]
1 parent 258b5d3 commit 488f905

File tree

14 files changed

+907
-36
lines changed

14 files changed

+907
-36
lines changed

CHANGELOG.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
- [Google Takeout Automation] Bookmark import on Android (#1935)
1+
- Get expanded performance results (#1989)
2+
- build(deps-dev): bump jasmine from 5.10.0 to 5.11.0 (#1984)

build/android/adsjsContentScope.js

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5556,17 +5556,111 @@
55565556
const firstPaint = paintResources.find((entry) => entry.name === "first-contentful-paint");
55575557
return firstPaint ? [firstPaint.startTime] : [];
55585558
}
5559+
function returnError(errorMessage) {
5560+
return { error: errorMessage, success: false };
5561+
}
5562+
function waitForLCP(timeoutMs = 500) {
5563+
return new Promise((resolve) => {
5564+
let timeoutId;
5565+
let observer;
5566+
const cleanup = () => {
5567+
if (observer) observer.disconnect();
5568+
if (timeoutId) clearTimeout(timeoutId);
5569+
};
5570+
timeoutId = setTimeout(() => {
5571+
cleanup();
5572+
resolve(null);
5573+
}, timeoutMs);
5574+
observer = new PerformanceObserver((list) => {
5575+
const entries = list.getEntries();
5576+
const lastEntry = entries[entries.length - 1];
5577+
if (lastEntry) {
5578+
cleanup();
5579+
resolve(lastEntry.startTime);
5580+
}
5581+
});
5582+
try {
5583+
observer.observe({ type: "largest-contentful-paint", buffered: true });
5584+
} catch (error) {
5585+
cleanup();
5586+
resolve(null);
5587+
}
5588+
});
5589+
}
5590+
async function getExpandedPerformanceMetrics() {
5591+
try {
5592+
if (document.readyState !== "complete") {
5593+
return returnError("Document not ready");
5594+
}
5595+
const navigation = (
5596+
/** @type {PerformanceNavigationTiming} */
5597+
performance.getEntriesByType("navigation")[0]
5598+
);
5599+
const paint = performance.getEntriesByType("paint");
5600+
const resources = (
5601+
/** @type {PerformanceResourceTiming[]} */
5602+
performance.getEntriesByType("resource")
5603+
);
5604+
const fcp = paint.find((p) => p.name === "first-contentful-paint");
5605+
let largestContentfulPaint = null;
5606+
if (PerformanceObserver.supportedEntryTypes.includes("largest-contentful-paint")) {
5607+
largestContentfulPaint = await waitForLCP();
5608+
}
5609+
const totalResourceSize = resources.reduce((sum, r) => sum + (r.transferSize || 0), 0);
5610+
if (navigation) {
5611+
return {
5612+
success: true,
5613+
metrics: {
5614+
// Core timing metrics (in milliseconds)
5615+
loadComplete: navigation.loadEventEnd - navigation.fetchStart,
5616+
domComplete: navigation.domComplete - navigation.fetchStart,
5617+
domContentLoaded: navigation.domContentLoadedEventEnd - navigation.fetchStart,
5618+
domInteractive: navigation.domInteractive - navigation.fetchStart,
5619+
// Paint metrics
5620+
firstContentfulPaint: fcp ? fcp.startTime : null,
5621+
largestContentfulPaint,
5622+
// Network metrics
5623+
timeToFirstByte: navigation.responseStart - navigation.fetchStart,
5624+
responseTime: navigation.responseEnd - navigation.responseStart,
5625+
serverTime: navigation.responseStart - navigation.requestStart,
5626+
// Size metrics (in octets)
5627+
transferSize: navigation.transferSize,
5628+
encodedBodySize: navigation.encodedBodySize,
5629+
decodedBodySize: navigation.decodedBodySize,
5630+
// Resource metrics
5631+
resourceCount: resources.length,
5632+
totalResourcesSize: totalResourceSize,
5633+
// Additional metadata
5634+
protocol: navigation.nextHopProtocol,
5635+
redirectCount: navigation.redirectCount,
5636+
navigationType: navigation.type
5637+
}
5638+
};
5639+
}
5640+
return returnError("No navigation timing found");
5641+
} catch (e) {
5642+
return returnError("JavaScript execution error: " + e.message);
5643+
}
5644+
}
55595645

55605646
// src/features/breakage-reporting.js
55615647
var BreakageReporting = class extends ContentFeature {
55625648
init() {
5563-
this.messaging.subscribe("getBreakageReportValues", () => {
5649+
const isExpandedPerformanceMetricsEnabled = this.getFeatureSettingEnabled("expandedPerformanceMetrics", "enabled");
5650+
this.messaging.subscribe("getBreakageReportValues", async () => {
55645651
const jsPerformance = getJsPerformanceMetrics();
55655652
const referrer = document.referrer;
5566-
this.messaging.notify("breakageReportResult", {
5653+
const result = {
55675654
jsPerformance,
55685655
referrer
5569-
});
5656+
};
5657+
if (isExpandedPerformanceMetricsEnabled) {
5658+
const expandedPerformanceMetrics = await getExpandedPerformanceMetrics();
5659+
if (expandedPerformanceMetrics.success) {
5660+
result.expandedPerformanceMetrics = expandedPerformanceMetrics.metrics;
5661+
}
5662+
}
5663+
this.messaging.notify("breakageReportResult", result);
55705664
});
55715665
}
55725666
};

build/android/contentScope.js

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7475,17 +7475,111 @@
74757475
const firstPaint = paintResources.find((entry) => entry.name === "first-contentful-paint");
74767476
return firstPaint ? [firstPaint.startTime] : [];
74777477
}
7478+
function returnError(errorMessage) {
7479+
return { error: errorMessage, success: false };
7480+
}
7481+
function waitForLCP(timeoutMs = 500) {
7482+
return new Promise((resolve) => {
7483+
let timeoutId;
7484+
let observer;
7485+
const cleanup = () => {
7486+
if (observer) observer.disconnect();
7487+
if (timeoutId) clearTimeout(timeoutId);
7488+
};
7489+
timeoutId = setTimeout(() => {
7490+
cleanup();
7491+
resolve(null);
7492+
}, timeoutMs);
7493+
observer = new PerformanceObserver((list) => {
7494+
const entries = list.getEntries();
7495+
const lastEntry = entries[entries.length - 1];
7496+
if (lastEntry) {
7497+
cleanup();
7498+
resolve(lastEntry.startTime);
7499+
}
7500+
});
7501+
try {
7502+
observer.observe({ type: "largest-contentful-paint", buffered: true });
7503+
} catch (error) {
7504+
cleanup();
7505+
resolve(null);
7506+
}
7507+
});
7508+
}
7509+
async function getExpandedPerformanceMetrics() {
7510+
try {
7511+
if (document.readyState !== "complete") {
7512+
return returnError("Document not ready");
7513+
}
7514+
const navigation = (
7515+
/** @type {PerformanceNavigationTiming} */
7516+
performance.getEntriesByType("navigation")[0]
7517+
);
7518+
const paint = performance.getEntriesByType("paint");
7519+
const resources = (
7520+
/** @type {PerformanceResourceTiming[]} */
7521+
performance.getEntriesByType("resource")
7522+
);
7523+
const fcp = paint.find((p) => p.name === "first-contentful-paint");
7524+
let largestContentfulPaint = null;
7525+
if (PerformanceObserver.supportedEntryTypes.includes("largest-contentful-paint")) {
7526+
largestContentfulPaint = await waitForLCP();
7527+
}
7528+
const totalResourceSize = resources.reduce((sum, r) => sum + (r.transferSize || 0), 0);
7529+
if (navigation) {
7530+
return {
7531+
success: true,
7532+
metrics: {
7533+
// Core timing metrics (in milliseconds)
7534+
loadComplete: navigation.loadEventEnd - navigation.fetchStart,
7535+
domComplete: navigation.domComplete - navigation.fetchStart,
7536+
domContentLoaded: navigation.domContentLoadedEventEnd - navigation.fetchStart,
7537+
domInteractive: navigation.domInteractive - navigation.fetchStart,
7538+
// Paint metrics
7539+
firstContentfulPaint: fcp ? fcp.startTime : null,
7540+
largestContentfulPaint,
7541+
// Network metrics
7542+
timeToFirstByte: navigation.responseStart - navigation.fetchStart,
7543+
responseTime: navigation.responseEnd - navigation.responseStart,
7544+
serverTime: navigation.responseStart - navigation.requestStart,
7545+
// Size metrics (in octets)
7546+
transferSize: navigation.transferSize,
7547+
encodedBodySize: navigation.encodedBodySize,
7548+
decodedBodySize: navigation.decodedBodySize,
7549+
// Resource metrics
7550+
resourceCount: resources.length,
7551+
totalResourcesSize: totalResourceSize,
7552+
// Additional metadata
7553+
protocol: navigation.nextHopProtocol,
7554+
redirectCount: navigation.redirectCount,
7555+
navigationType: navigation.type
7556+
}
7557+
};
7558+
}
7559+
return returnError("No navigation timing found");
7560+
} catch (e) {
7561+
return returnError("JavaScript execution error: " + e.message);
7562+
}
7563+
}
74787564

74797565
// src/features/breakage-reporting.js
74807566
var BreakageReporting = class extends ContentFeature {
74817567
init() {
7482-
this.messaging.subscribe("getBreakageReportValues", () => {
7568+
const isExpandedPerformanceMetricsEnabled = this.getFeatureSettingEnabled("expandedPerformanceMetrics", "enabled");
7569+
this.messaging.subscribe("getBreakageReportValues", async () => {
74837570
const jsPerformance = getJsPerformanceMetrics();
74847571
const referrer = document.referrer;
7485-
this.messaging.notify("breakageReportResult", {
7572+
const result = {
74867573
jsPerformance,
74877574
referrer
7488-
});
7575+
};
7576+
if (isExpandedPerformanceMetricsEnabled) {
7577+
const expandedPerformanceMetrics = await getExpandedPerformanceMetrics();
7578+
if (expandedPerformanceMetrics.success) {
7579+
result.expandedPerformanceMetrics = expandedPerformanceMetrics.metrics;
7580+
}
7581+
}
7582+
this.messaging.notify("breakageReportResult", result);
74897583
});
74907584
}
74917585
};

build/apple/contentScopeIsolated.js

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12256,6 +12256,92 @@ ul.messages {
1225612256
const firstPaint = paintResources.find((entry) => entry.name === "first-contentful-paint");
1225712257
return firstPaint ? [firstPaint.startTime] : [];
1225812258
}
12259+
function returnError(errorMessage) {
12260+
return { error: errorMessage, success: false };
12261+
}
12262+
function waitForLCP(timeoutMs = 500) {
12263+
return new Promise((resolve) => {
12264+
let timeoutId;
12265+
let observer;
12266+
const cleanup = () => {
12267+
if (observer) observer.disconnect();
12268+
if (timeoutId) clearTimeout(timeoutId);
12269+
};
12270+
timeoutId = setTimeout(() => {
12271+
cleanup();
12272+
resolve(null);
12273+
}, timeoutMs);
12274+
observer = new PerformanceObserver((list) => {
12275+
const entries = list.getEntries();
12276+
const lastEntry = entries[entries.length - 1];
12277+
if (lastEntry) {
12278+
cleanup();
12279+
resolve(lastEntry.startTime);
12280+
}
12281+
});
12282+
try {
12283+
observer.observe({ type: "largest-contentful-paint", buffered: true });
12284+
} catch (error) {
12285+
cleanup();
12286+
resolve(null);
12287+
}
12288+
});
12289+
}
12290+
async function getExpandedPerformanceMetrics() {
12291+
try {
12292+
if (document.readyState !== "complete") {
12293+
return returnError("Document not ready");
12294+
}
12295+
const navigation = (
12296+
/** @type {PerformanceNavigationTiming} */
12297+
performance.getEntriesByType("navigation")[0]
12298+
);
12299+
const paint = performance.getEntriesByType("paint");
12300+
const resources = (
12301+
/** @type {PerformanceResourceTiming[]} */
12302+
performance.getEntriesByType("resource")
12303+
);
12304+
const fcp = paint.find((p) => p.name === "first-contentful-paint");
12305+
let largestContentfulPaint = null;
12306+
if (PerformanceObserver.supportedEntryTypes.includes("largest-contentful-paint")) {
12307+
largestContentfulPaint = await waitForLCP();
12308+
}
12309+
const totalResourceSize = resources.reduce((sum, r) => sum + (r.transferSize || 0), 0);
12310+
if (navigation) {
12311+
return {
12312+
success: true,
12313+
metrics: {
12314+
// Core timing metrics (in milliseconds)
12315+
loadComplete: navigation.loadEventEnd - navigation.fetchStart,
12316+
domComplete: navigation.domComplete - navigation.fetchStart,
12317+
domContentLoaded: navigation.domContentLoadedEventEnd - navigation.fetchStart,
12318+
domInteractive: navigation.domInteractive - navigation.fetchStart,
12319+
// Paint metrics
12320+
firstContentfulPaint: fcp ? fcp.startTime : null,
12321+
largestContentfulPaint,
12322+
// Network metrics
12323+
timeToFirstByte: navigation.responseStart - navigation.fetchStart,
12324+
responseTime: navigation.responseEnd - navigation.responseStart,
12325+
serverTime: navigation.responseStart - navigation.requestStart,
12326+
// Size metrics (in octets)
12327+
transferSize: navigation.transferSize,
12328+
encodedBodySize: navigation.encodedBodySize,
12329+
decodedBodySize: navigation.decodedBodySize,
12330+
// Resource metrics
12331+
resourceCount: resources.length,
12332+
totalResourcesSize: totalResourceSize,
12333+
// Additional metadata
12334+
protocol: navigation.nextHopProtocol,
12335+
redirectCount: navigation.redirectCount,
12336+
navigationType: navigation.type
12337+
}
12338+
};
12339+
}
12340+
return returnError("No navigation timing found");
12341+
} catch (e) {
12342+
return returnError("JavaScript execution error: " + e.message);
12343+
}
12344+
}
1225912345

1226012346
// src/features/performance-metrics.js
1226112347
var PerformanceMetrics = class extends ContentFeature {
@@ -12264,6 +12350,23 @@ ul.messages {
1226412350
const vitals = getJsPerformanceMetrics();
1226512351
this.messaging.notify("vitalsResult", { vitals });
1226612352
});
12353+
if (isBeingFramed()) return;
12354+
if (this.getFeatureSettingEnabled("expandedPerformanceMetricsOnLoad", "enabled")) {
12355+
this.waitForPageLoad(() => {
12356+
this.triggerExpandedPerformanceMetrics();
12357+
});
12358+
}
12359+
}
12360+
waitForPageLoad(callback) {
12361+
if (document.readyState === "complete") {
12362+
callback();
12363+
} else {
12364+
window.addEventListener("load", callback, { once: true });
12365+
}
12366+
}
12367+
async triggerExpandedPerformanceMetrics() {
12368+
const expandedPerformanceMetrics = await getExpandedPerformanceMetrics();
12369+
this.messaging.notify("expandedPerformanceMetricsResult", expandedPerformanceMetrics);
1226712370
}
1226812371
};
1226912372

0 commit comments

Comments
 (0)