re. websocket: mind backward compatibility

This commit is contained in:
gorhill 2017-03-06 17:53:25 -05:00
parent 2213b005a0
commit 7e55ddf16b
2 changed files with 13 additions and 3 deletions

View File

@ -1097,6 +1097,18 @@ vAPI.net.registerListeners = function() {
if ( onBeforeRequest ) { if ( onBeforeRequest ) {
urls = this.onBeforeRequest.urls || ['<all_urls>']; urls = this.onBeforeRequest.urls || ['<all_urls>'];
types = this.onBeforeRequest.types || undefined; types = this.onBeforeRequest.types || undefined;
if (
(validTypes.websocket) &&
(types === undefined || types.indexOf('websocket') !== -1) &&
(urls.indexOf('<all_urls>') === -1)
) {
if ( urls.indexOf('ws://*/*') === -1 ) {
urls.push('ws://*/*');
}
if ( urls.indexOf('wss://*/*') === -1 ) {
urls.push('wss://*/*');
}
}
wrApi.onBeforeRequest.addListener( wrApi.onBeforeRequest.addListener(
onBeforeRequest, onBeforeRequest,
{ urls: urls, types: types }, { urls: urls, types: types },

View File

@ -679,9 +679,7 @@ var headerIndexFromName = function(headerName, headers) {
vAPI.net.onBeforeRequest = { vAPI.net.onBeforeRequest = {
urls: [ urls: [
'http://*/*', 'http://*/*',
'https://*/*', 'https://*/*'
'ws://*/*',
'wss://*/*'
], ],
extra: [ 'blocking' ], extra: [ 'blocking' ],
callback: onBeforeRequest callback: onBeforeRequest