Skip to content

Commit e44d900

Browse files
feat(webdriver): implement page.setCacheEnabled (#12691)
Co-authored-by: Julian Descottes <[email protected]>
1 parent 820512e commit e44d900

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

packages/puppeteer-core/src/bidi/Page.ts

+6
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,12 @@ export class BidiPage extends Page {
537537
}
538538

539539
override async setCacheEnabled(enabled?: boolean): Promise<void> {
540+
if (!this.#browserContext.browser().cdpSupported) {
541+
await this.#frame.browsingContext.setCacheBehavior(
542+
enabled ? 'default' : 'bypass'
543+
);
544+
return;
545+
}
540546
// TODO: handle CDP-specific cases such as mprach.
541547
await this._client().send('Network.setCacheDisabled', {
542548
cacheDisabled: !enabled,

packages/puppeteer-core/src/bidi/core/BrowsingContext.ts

+12
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,18 @@ export class BrowsingContext extends EventEmitter<{
417417
});
418418
}
419419

420+
@throwIfDisposed<BrowsingContext>(context => {
421+
// SAFETY: Disposal implies this exists.
422+
return context.#reason!;
423+
})
424+
async setCacheBehavior(cacheBehavior: 'default' | 'bypass'): Promise<void> {
425+
// @ts-expect-error not in BiDi types yet.
426+
await this.#session.send('network.setCacheBehavior', {
427+
contexts: [this.id],
428+
cacheBehavior,
429+
});
430+
}
431+
420432
@throwIfDisposed<BrowsingContext>(context => {
421433
// SAFETY: Disposal implies this exists.
422434
return context.#reason!;

test/TestExpectations.json

-14
Original file line numberDiff line numberDiff line change
@@ -2911,20 +2911,6 @@
29112911
"expectations": ["FAIL"],
29122912
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
29132913
},
2914-
{
2915-
"testIdPattern": "[page.spec] Page Page.setCacheEnabled should enable or disable the cache based on the state passed",
2916-
"platforms": ["darwin", "linux", "win32"],
2917-
"parameters": ["firefox", "webDriverBiDi"],
2918-
"expectations": ["FAIL"],
2919-
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
2920-
},
2921-
{
2922-
"testIdPattern": "[page.spec] Page Page.setCacheEnabled should stay disabled when toggling request interception on/off",
2923-
"platforms": ["darwin", "linux", "win32"],
2924-
"parameters": ["firefox", "webDriverBiDi"],
2925-
"expectations": ["FAIL"],
2926-
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
2927-
},
29282914
{
29292915
"testIdPattern": "[page.spec] Page Page.setCacheEnabled should stay disabled when toggling request interception on/off",
29302916
"platforms": ["darwin", "linux", "win32"],

0 commit comments

Comments
 (0)