feat(offline): implement offline in firefox (#1476)
This commit is contained in:
parent
ac5852f302
commit
c68cee9fb7
|
|
@ -9,7 +9,7 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"playwright": {
|
"playwright": {
|
||||||
"chromium_revision": "751710",
|
"chromium_revision": "751710",
|
||||||
"firefox_revision": "1048",
|
"firefox_revision": "1049",
|
||||||
"webkit_revision": "1182"
|
"webkit_revision": "1182"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
||||||
|
|
@ -171,12 +171,12 @@ export class FFBrowserContext extends BrowserContextBase {
|
||||||
await this.grantPermissions(this._options.permissions);
|
await this.grantPermissions(this._options.permissions);
|
||||||
if (this._options.extraHTTPHeaders || this._options.locale)
|
if (this._options.extraHTTPHeaders || this._options.locale)
|
||||||
await this.setExtraHTTPHeaders(this._options.extraHTTPHeaders || {});
|
await this.setExtraHTTPHeaders(this._options.extraHTTPHeaders || {});
|
||||||
if (this._options.offline)
|
|
||||||
await this.setOffline(this._options.offline);
|
|
||||||
if (this._options.httpCredentials)
|
if (this._options.httpCredentials)
|
||||||
await this.setHTTPCredentials(this._options.httpCredentials);
|
await this.setHTTPCredentials(this._options.httpCredentials);
|
||||||
if (this._options.geolocation)
|
if (this._options.geolocation)
|
||||||
await this.setGeolocation(this._options.geolocation);
|
await this.setGeolocation(this._options.geolocation);
|
||||||
|
if (this._options.offline)
|
||||||
|
await this.setOffline(this._options.offline);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ffPages(): FFPage[] {
|
_ffPages(): FFPage[] {
|
||||||
|
|
@ -264,9 +264,8 @@ export class FFBrowserContext extends BrowserContextBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
async setOffline(offline: boolean): Promise<void> {
|
async setOffline(offline: boolean): Promise<void> {
|
||||||
if (offline)
|
|
||||||
throw new Error('Offline mode is not implemented in Firefox');
|
|
||||||
this._options.offline = offline;
|
this._options.offline = offline;
|
||||||
|
await this._browser._connection.send('Browser.setOnlineOverride', { browserContextId: this._browserContextId || undefined, override: offline ? 'offline' : 'online' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async setHTTPCredentials(httpCredentials: types.Credentials | null): Promise<void> {
|
async setHTTPCredentials(httpCredentials: types.Credentials | null): Promise<void> {
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, FF
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.fail(FFOX)('BrowserContext.setOffline', function() {
|
describe('BrowserContext.setOffline', function() {
|
||||||
it('should work with initial option', async({browser, server}) => {
|
it('should work with initial option', async({browser, server}) => {
|
||||||
const context = await browser.newContext({offline: true});
|
const context = await browser.newContext({offline: true});
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue