diff --git a/experimental/puppeteer-firefox/lib/Page.js b/experimental/puppeteer-firefox/lib/Page.js index 8d195ac9..064928ff 100644 --- a/experimental/puppeteer-firefox/lib/Page.js +++ b/experimental/puppeteer-firefox/lib/Page.js @@ -110,6 +110,20 @@ class Page extends EventEmitter { await this._session.send('Page.setUserAgent', {userAgent}); } + /** + * @param {string} userAgent + */ + async setJavaScriptEnabled(enabled) { + await this._session.send('Page.setJavascriptEnabled', {enabled}); + } + + /** + * @param {string} userAgent + */ + async setCacheEnabled(enabled) { + await this._session.send('Page.setCacheDisabled', {cacheDisabled: !enabled}); + } + /** * @param {{viewport: !Puppeteer.Viewport, userAgent: string}} options */ diff --git a/experimental/puppeteer-firefox/package.json b/experimental/puppeteer-firefox/package.json index 00afacc6..e18958da 100644 --- a/experimental/puppeteer-firefox/package.json +++ b/experimental/puppeteer-firefox/package.json @@ -9,7 +9,7 @@ "node": ">=8.9.4" }, "puppeteer": { - "firefox_revision": "ba500612786aac157fa44e6b4d04c852f51ea35c" + "firefox_revision": "592ca01fa3d2566a9f494e2df8ca6876c5b5b4bb" }, "scripts": { "install": "node install.js", diff --git a/test/page.spec.js b/test/page.spec.js index 114af156..f70d0701 100644 --- a/test/page.spec.js +++ b/test/page.spec.js @@ -908,7 +908,7 @@ module.exports.addTests = function({testRunner, expect, headless, Errors, Device }); }); - describe_fails_ffox('Page.setJavaScriptEnabled', function() { + describe('Page.setJavaScriptEnabled', function() { it('should work', async({page, server}) => { await page.setJavaScriptEnabled(false); await page.goto('data:text/html, '); @@ -922,18 +922,22 @@ module.exports.addTests = function({testRunner, expect, headless, Errors, Device }); }); - describe_fails_ffox('Page.setCacheEnabled', function() { + describe('Page.setCacheEnabled', function() { it('should enable or disable the cache based on the state passed', async({page, server}) => { - const responses = new Map(); - page.on('response', r => responses.set(r.url().split('/').pop(), r)); - await page.goto(server.PREFIX + '/cached/one-style.html'); - await page.reload(); - expect(responses.get('one-style.css').fromCache()).toBe(true); + const [cachedRequest] = await Promise.all([ + server.waitForRequest('/cached/one-style.html'), + page.reload(), + ]); + // Rely on "if-modified-since" caching in our test server. + expect(cachedRequest.headers['if-modified-since']).not.toBe(undefined); await page.setCacheEnabled(false); - await page.reload({waitUntil: 'networkidle2'}); - expect(responses.get('one-style.css').fromCache()).toBe(false); + const [nonCachedRequest] = await Promise.all([ + server.waitForRequest('/cached/one-style.html'), + page.reload(), + ]); + expect(nonCachedRequest.headers['if-modified-since']).toBe(undefined); }); });