diff --git a/docs/api.md b/docs/api.md index 7564e251927..84fca31f527 100644 --- a/docs/api.md +++ b/docs/api.md @@ -7,7 +7,6 @@ - [browser.version()](#browserversion) - [browser.close()](#browserclose) - [class: Page](#class-page) - - [page.setBlockedURLs(patterns)](#pagesetblockedurlspatterns) - [page.addScriptTag(url)](#pageaddscripttagurl) - [page.injectFile(filePath)](#pageinjectfilefilepath) - [page.setInPageCallback(name, callback)](#pagesetinpagecallbackname-callback) @@ -75,11 +74,6 @@ browser.newPage().then(page => { ``` Pages could be closed by `page.close()` method. -#### page.setBlockedURLs(patterns) - -- `patterns` [<Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) -- returns: [<Promise>](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) Promise which resolves when blocked URLs have been successfully set. - #### page.addScriptTag(url) - `url` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Url of a script to be added diff --git a/examples/loadurlwithoutcss.js b/examples/loadurlwithoutcss.js index 8cb76019ec9..e11f6a9cf52 100644 --- a/examples/loadurlwithoutcss.js +++ b/examples/loadurlwithoutcss.js @@ -25,7 +25,12 @@ var address = process.argv[2]; var browser = new Browser({headless: false}); browser.newPage().then(async page => { - await page.setBlockedURLs(['*.css']); + page.setRequestInterceptor(request => { + if (request.url().endsWith('.css')) + request.abort(); + else + request.continue(); + }); var success = await page.navigate(address); if (!success) console.log('Unable to load the address!'); diff --git a/lib/Page.js b/lib/Page.js index 4f76771b516..7403428436b 100644 --- a/lib/Page.js +++ b/lib/Page.js @@ -55,8 +55,6 @@ class Page extends EventEmitter { this._sourceURLToPageCallback = new Map(); /** @type {!Map} */ this._scriptIdToPageCallback = new Map(); - /** @type {!Array} */ - this._blockedURLs = []; /** @type {?function(!Request)} */ this._requestInterceptor = null; @@ -86,17 +84,6 @@ class Page extends EventEmitter { this._requestInterceptor(request); } - /** - * @param {!Array} patterns - * @return {!Promise} - */ - async setBlockedURLs(patterns) { - this._blockedURLs = patterns; - await this._client.send('Network.setBlockedURLs', { - urls: patterns - }); - } - /** * @param {string} url * @return {!Promise}