Skip to content

Commit

Permalink
fix(notifications): showing notification for blocked web request, as …
Browse files Browse the repository at this point in the history
…did-fail-load event not being triggered
  • Loading branch information
hunterlester authored and joshuef committed Apr 22, 2019
1 parent 4ff1909 commit 45818d8
Show file tree
Hide file tree
Showing 4 changed files with 384 additions and 436 deletions.
4 changes: 0 additions & 4 deletions app/components/Tab/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,7 @@ export default class Tab extends Component<TabProps, TabState> {
}
this.updateBrowserState( { loading: false, mountedAndReady: true } );
if ( url && url !== 'about:blank' ) {
<<<<<<< HEAD
this.loadURL( url ).catch( ( error ) => console.info( 'err in loadurl', error ) );
=======
this.loadURL( url ).catch( ( err ) => console.info( 'err in loadurl', err ) );
>>>>>>> feat( electron ): Update to electron v 4.x
this.setCurrentWebId( null );
}
}
Expand Down
8 changes: 7 additions & 1 deletion app/extensions/safe/blockNonSafeReqs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { remote, shell } from 'electron';
import { parse as parseURL } from 'url';
import path from 'path';
import { CONFIG, isRunningTestCafeProcess, allowedHttp } from '$Constants';
import { addNotification } from '$Actions/notification_actions';
import { logger } from '$Logger';
import { urlIsAllowedBySafe } from './utils/safeHelpers';

// const isForLocalServer = ( parsedUrlObject ) =>
// parsedUrlObject.protocol === 'localhost:' || parsedUrlObject.hostname === '127.0.0.1';

const blockNonSAFERequests = () => {
const blockNonSAFERequests = ( store ) => {
const filter = {
urls: ['*://*']
};
Expand Down Expand Up @@ -52,6 +53,11 @@ const blockNonSAFERequests = () => {
}

logger.error( 'Blocked URL:', details.url );
const notification = {
title: 'Blocked URL',
body: details.url
};
store.dispatch( addNotification( notification ) );
callback( { cancel: true } );
} );
};
Expand Down
2 changes: 1 addition & 1 deletion app/extensions/safe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const onInitBgProcess = async ( store ) => {

registerSafeProtocol( store );
registerSafeAuthProtocol( store );
blockNonSAFERequests();
blockNonSAFERequests( store );
} catch ( e ) {
logger.error( 'Load extensions error: ', e );
}
Expand Down
Loading

0 comments on commit 45818d8

Please sign in to comment.