From 5044d69f7913096306cb352a4e3fb2138bd27e3d Mon Sep 17 00:00:00 2001 From: Pavel Date: Sun, 22 Mar 2020 10:57:58 -0700 Subject: [PATCH] feat(offline): implement offline in firefox --- package.json | 2 +- src/firefox/ffBrowser.ts | 7 +++---- test/browsercontext.spec.js | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 95ac9a236bae9..38f4dd2784bf1 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "main": "index.js", "playwright": { "chromium_revision": "751710", - "firefox_revision": "1048", + "firefox_revision": "1049", "webkit_revision": "1182" }, "scripts": { diff --git a/src/firefox/ffBrowser.ts b/src/firefox/ffBrowser.ts index de283870e81fa..7a2e67879b322 100644 --- a/src/firefox/ffBrowser.ts +++ b/src/firefox/ffBrowser.ts @@ -171,12 +171,12 @@ export class FFBrowserContext extends BrowserContextBase { await this.grantPermissions(this._options.permissions); if (this._options.extraHTTPHeaders || this._options.locale) await this.setExtraHTTPHeaders(this._options.extraHTTPHeaders || {}); - if (this._options.offline) - await this.setOffline(this._options.offline); if (this._options.httpCredentials) await this.setHTTPCredentials(this._options.httpCredentials); if (this._options.geolocation) await this.setGeolocation(this._options.geolocation); + if (this._options.offline) + await this.setOffline(this._options.offline); } _ffPages(): FFPage[] { @@ -264,9 +264,8 @@ export class FFBrowserContext extends BrowserContextBase { } async setOffline(offline: boolean): Promise { - if (offline) - throw new Error('Offline mode is not implemented in Firefox'); 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 { diff --git a/test/browsercontext.spec.js b/test/browsercontext.spec.js index 5b0523eadd0f1..4ccc3a81b2c89 100644 --- a/test/browsercontext.spec.js +++ b/test/browsercontext.spec.js @@ -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}) => { const context = await browser.newContext({offline: true}); const page = await context.newPage();