Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding return after rejects in a few places. Implementing Ghostery side of GH-885. Fix for GH-871. #10

Merged
merged 10 commits into from Mar 23, 2018

Conversation

@zarembsky
Copy link
Contributor

@zarembsky zarembsky commented Mar 21, 2018

  • Have you followed the guidelines in CONTRIBUTING.md?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you added an explanation of what your changes do?
  • Does your submission pass tests?
  • Did you lint your code prior to submission?
@zarembsky zarembsky requested review from jsignanini and ghostery/ghostery as code owners Mar 21, 2018
@zarembsky zarembsky changed the title Adding return after rejects in a few places. Adding return after rejects in a few places. Implementing Ghostery side of GH-885. Mar 22, 2018
@zarembsky zarembsky changed the title Adding return after rejects in a few places. Implementing Ghostery side of GH-885. Adding return after rejects in a few places. Implementing Ghostery side of GH-885. Fix for GH-885. Mar 22, 2018
@zarembsky zarembsky changed the title Adding return after rejects in a few places. Implementing Ghostery side of GH-885. Fix for GH-885. Adding return after rejects in a few places. Implementing Ghostery side of GH-885. Fix for GH-871. Mar 22, 2018
if (bug_id) {
app_id = bugDb.db.bugs[bug_id].aid;
cat_id = bugDb.db.apps[app_id].cat;
incognito = tabInfo.getTabInfo(tab_id, 'incognito');
tab_host = tabInfo.getTabInfo(tab_id, 'host');
fromRedirect = globals.REDIRECT_MAP.has(request_id);
block = this._checkBlocking(app_id, cat_id, tab_id, tab_host, page_url, request_id);
const retVal = this._checkBlocking(app_id, cat_id, tab_id, tab_host, page_url, request_id);

This comment has been minimized.

@christophertino

christophertino Mar 23, 2018
Member

const {block, ss_unblock} = this._checkBlocking(app_id, cat_id, tab_id, tab_host, page_url, request_id);

This comment has been minimized.

@zarembsky

zarembsky Mar 23, 2018
Author Contributor

The problem with the code const {block, ss_unblock} = is that block should be visible out of scope if(bug_id) { }. We can get away with extra assignment, like:
const {block1, ss_unblock} = ...
block = block1;

* @param {number} request_id request id
* @return {boolean}
* @return {Object} {block, ss_unblock}
*/
_checkBlocking(app_id, cat_id, tab_id, tab_host, page_url, request_id) {

This comment has been minimized.

@christophertino

christophertino Mar 23, 2018
Member

this should have an object return, correct? looks to just be returning block at the moment, instead of return {block:true, ss_unblock:false} etc

See line 793

This comment has been minimized.

@zarembsky

zarembsky Mar 23, 2018
Author Contributor

block IS object, as it is returned by shouldBlock, which returns object.

*/
shouldBlock(app_id, cat_id, tab_id, tab_host, tab_url) {
if (globals.SESSION.paused_blocking) {
return false;
return { block: false };

This comment has been minimized.

@christophertino

christophertino Mar 23, 2018
Member

we should return {block, ss_unblock} in all cases to prevent undefined errors

This comment has been minimized.

@zarembsky

zarembsky Mar 23, 2018
Author Contributor

You mean if we ever call shouldBlock elsewhere (but we don't)

This comment has been minimized.

@zarembsky

zarembsky Mar 23, 2018
Author Contributor

The reason I did not go with {{block, ss_unblock} was that it is performance-critical, and most of the time ss_unblock is not needed.
I'll make the requested changes though.

Serge Zarembsky and others added 4 commits Mar 23, 2018
Serge Zarembsky
Serge Zarembsky
jsignanini added 3 commits Mar 23, 2018
@jsignanini jsignanini dismissed christophertino’s stale review Mar 23, 2018

Changes updated as requested.

@jsignanini jsignanini merged commit 3db6b2b into ghostery:develop Mar 23, 2018
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants