mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-13 16:38:56 +02:00
feat(browse): allow CPU and network throttling for performance measurement
Adds Emulation.setCPUThrottlingRate and Network.emulateNetworkConditions to
CDP_ALLOWLIST.
Motivation: diagnosing a real "uploads take 1-2 minutes" report, the only
machine available was a fast developer workstation. Client-side processing
measured 1.4s where the user experienced minutes, so the conclusion had to be
reached arithmetically rather than observed. Throttling would have let the
measurement reproduce the reporter's conditions directly.
Both fit the existing posture rather than widening it:
- Emulation already allows setDeviceMetricsOverride, clearDeviceMetricsOverride
and setUserAgentOverride, which are equally mutating and scoped to the tab.
- Neither method reads page content. setCPUThrottlingRate affects only timing;
emulateNetworkConditions constrains traffic rather than inspecting it, so no
request bodies, headers or cookies are exposed. Both are output: 'trusted'
because they return no page-derived data.
scope 'tab' for both, matching the surrounding Emulation entries.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
0762fab809
commit
63ef693d02
@@ -82,6 +82,19 @@ describe('CDP allowlist (T2: deny-default)', () => {
|
||||
expect(e!.output).toBe('trusted');
|
||||
});
|
||||
|
||||
it('CPU + network throttling are allowed, tab-scoped, trusted (#2602)', () => {
|
||||
// Perf-measurement emulation (PR #2602 by @henbima): both constrain the
|
||||
// tab's timing/traffic, read nothing, and return empty results — same
|
||||
// posture argument as setEmulatedMedia (#2419) and setDeviceMetricsOverride.
|
||||
for (const method of ['Emulation.setCPUThrottlingRate', 'Network.emulateNetworkConditions']) {
|
||||
expect(isCdpMethodAllowed(method)).toBe(true);
|
||||
const e = lookupCdpMethod(method);
|
||||
expect(e).not.toBeNull();
|
||||
expect(e!.scope).toBe('tab');
|
||||
expect(e!.output).toBe('trusted');
|
||||
}
|
||||
});
|
||||
|
||||
it('untrusted-output methods cover the read-everything-attacker-controlled cases', () => {
|
||||
// Anything that reads attacker-controlled strings (DOM/AX/CSS selectors)
|
||||
// should be tagged untrusted so the envelope wraps the result.
|
||||
|
||||
Reference in New Issue
Block a user