Skip to content

Commit 86f530f

Browse files
committed
fix: follow-up with offline comments on implementation of deprecation
This moves all extra deprecation messages from vendor implementations into a single vendor-neutral land.
1 parent 5bb018e commit 86f530f

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

src/browserContext.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import { Writable } from 'stream';
19-
import { helper } from './helper';
19+
import { isUnderTest, helper, deprecate} from './helper';
2020
import * as network from './network';
2121
import { Page, PageBinding } from './page';
2222
import { TimeoutSettings } from './timeoutSettings';
@@ -123,7 +123,7 @@ export abstract class BrowserContextBase extends EventEmitter implements Browser
123123
abstract _doGrantPermissions(origin: string, permissions: string[]): Promise<void>;
124124
abstract _doClearPermissions(): Promise<void>;
125125
abstract setGeolocation(geolocation: types.Geolocation | null): Promise<void>;
126-
abstract setHTTPCredentials(httpCredentials: types.Credentials | null): Promise<void>;
126+
abstract _doSetHTTPCredentials(httpCredentials: types.Credentials | null): Promise<void>;
127127
abstract setExtraHTTPHeaders(headers: types.Headers): Promise<void>;
128128
abstract setOffline(offline: boolean): Promise<void>;
129129
abstract _doAddInitScript(expression: string): Promise<void>;
@@ -142,6 +142,13 @@ export abstract class BrowserContextBase extends EventEmitter implements Browser
142142
await this.exposeBinding(name, (options, ...args: any) => playwrightFunction(...args));
143143
}
144144

145+
setHTTPCredentials(httpCredentials: types.Credentials | null): Promise<void> {
146+
if (!isUnderTest()) {
147+
deprecate(`context.setHTTPCredentials`, `warning: method |context.setHTTPCredentials()| is deprecated. Instead of changing credentials, create another browser context with new credentials.`);
148+
}
149+
return this._doSetHTTPCredentials(httpCredentials);
150+
}
151+
145152
async exposeBinding(name: string, playwrightBinding: frames.FunctionWithSource): Promise<void> {
146153
for (const page of this.pages()) {
147154
if (page._pageBindings.has(name))

src/chromium/crBrowser.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import { BrowserBase, BrowserOptions, BrowserContextOptions } from '../browser';
1919
import { assertBrowserContextIsNotOwned, BrowserContext, BrowserContextBase, validateBrowserContextOptions, verifyGeolocation } from '../browserContext';
2020
import { Events as CommonEvents } from '../events';
21-
import { assert, deprecate } from '../helper';
21+
import { assert } from '../helper';
2222
import * as network from '../network';
2323
import { Page, PageBinding, Worker } from '../page';
2424
import { ConnectionTransport, SlowMoTransport } from '../transport';
@@ -392,8 +392,7 @@ export class CRBrowserContext extends BrowserContextBase {
392392
await (page._delegate as CRPage).updateOffline();
393393
}
394394

395-
async setHTTPCredentials(httpCredentials: types.Credentials | null): Promise<void> {
396-
deprecate(`context.setHTTPCredentials`, `warning: method |context.setHTTPCredentials()| is deprecated. Instead of changing credentials, create another browser context with new credentials.`);
395+
async _doSetHTTPCredentials(httpCredentials: types.Credentials | null): Promise<void> {
397396
this._options.httpCredentials = httpCredentials || undefined;
398397
for (const page of this.pages())
399398
await (page._delegate as CRPage).updateHttpCredentials();

src/firefox/ffBrowser.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import { BrowserBase, BrowserOptions, BrowserContextOptions } from '../browser';
1919
import { assertBrowserContextIsNotOwned, BrowserContext, BrowserContextBase, validateBrowserContextOptions, verifyGeolocation } from '../browserContext';
2020
import { Events } from '../events';
21-
import { assert, deprecate, helper, RegisteredListener } from '../helper';
21+
import { assert, helper, RegisteredListener } from '../helper';
2222
import * as network from '../network';
2323
import { Page, PageBinding } from '../page';
2424
import { ConnectionTransport, SlowMoTransport } from '../transport';
@@ -291,8 +291,7 @@ export class FFBrowserContext extends BrowserContextBase {
291291
await this._browser._connection.send('Browser.setOnlineOverride', { browserContextId: this._browserContextId || undefined, override: offline ? 'offline' : 'online' });
292292
}
293293

294-
async setHTTPCredentials(httpCredentials: types.Credentials | null): Promise<void> {
295-
deprecate(`context.setHTTPCredentials`, `warning: method |context.setHTTPCredentials()| is deprecated. Instead of changing credentials, create another browser context with new credentials.`);
294+
async _doSetHTTPCredentials(httpCredentials: types.Credentials | null): Promise<void> {
296295
this._options.httpCredentials = httpCredentials || undefined;
297296
await this._browser._connection.send('Browser.setHTTPCredentials', { browserContextId: this._browserContextId || undefined, credentials: httpCredentials });
298297
}

src/webkit/wkBrowser.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import { BrowserBase, BrowserOptions, BrowserContextOptions } from '../browser';
1919
import { assertBrowserContextIsNotOwned, BrowserContext, BrowserContextBase, validateBrowserContextOptions, verifyGeolocation } from '../browserContext';
2020
import { Events } from '../events';
21-
import { helper, deprecate, RegisteredListener, assert } from '../helper';
21+
import { helper, RegisteredListener, assert } from '../helper';
2222
import * as network from '../network';
2323
import { Page, PageBinding } from '../page';
2424
import { ConnectionTransport, SlowMoTransport } from '../transport';
@@ -304,8 +304,7 @@ export class WKBrowserContext extends BrowserContextBase {
304304
await (page._delegate as WKPage).updateOffline();
305305
}
306306

307-
async setHTTPCredentials(httpCredentials: types.Credentials | null): Promise<void> {
308-
deprecate(`context.setHTTPCredentials`, `warning: method |context.setHTTPCredentials()| is deprecated. Instead of changing credentials, create another browser context with new credentials.`);
307+
async _doSetHTTPCredentials(httpCredentials: types.Credentials | null): Promise<void> {
309308
this._options.httpCredentials = httpCredentials || undefined;
310309
for (const page of this.pages())
311310
await (page._delegate as WKPage).updateHttpCredentials();

0 commit comments

Comments
 (0)