feat(firefox): support Page.setJavascriptEnabled (#3970)
This patch implements: - Page.setJavascriptEnabled - Page.setCacheEnabled
This commit is contained in:
parent
edb6f62824
commit
b82cc150d1
@ -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
|
||||
*/
|
||||
|
@ -9,7 +9,7 @@
|
||||
"node": ">=8.9.4"
|
||||
},
|
||||
"puppeteer": {
|
||||
"firefox_revision": "ba500612786aac157fa44e6b4d04c852f51ea35c"
|
||||
"firefox_revision": "592ca01fa3d2566a9f494e2df8ca6876c5b5b4bb"
|
||||
},
|
||||
"scripts": {
|
||||
"install": "node install.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, <script>var something = "forbidden"</script>');
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user