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

GH-1911 Remove edge legacy code #492

Merged
merged 3 commits into from Jan 30, 2020
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -1,6 +1,6 @@
language: node_js
node_js:
- "lts/carbon"
- "lts/dubnium"
sudo: false

cache:
@@ -12,7 +12,7 @@ Ghostery helps you browse smarter by giving you control over ads and tracking te

**Opera** – [Download](https://addons.opera.com/en/extensions/details/ghostery/)

**Edge** – [Download](https://www.microsoft.com/en-us/store/p/ghostery/9nblggh52ngz)
**Edge** – [Download](https://microsoftedge.microsoft.com/addons/detail/fclbdkbhjlgkbpfldjodgjncejkkjcme)

## Installation

@@ -145,7 +145,7 @@ $ ./fern.js build configs/ghostery.js --environment=production --no-debug
+ Firefox Android: 55+
+ Chrome: 58+
+ Opera: 45+
+ Edge: 34.14291+
+ Edge: 79+

## Contribute

@@ -727,9 +727,6 @@
"panel_detail_rewards_cliqz_text": {
"message": "Feature already active in the Cliqz MyOffrz control panel."
},
"panel_detail_rewards_edge_text": {
"message": "Ghostery Rewards is not currently supported in Microsoft Edge."
},
"panel_detail_rewards_loading": {
"message": "Loading Rewards..."
},
@@ -26,7 +26,6 @@ import bigLogoImage from '../data-images/popup/bigLogoImage';
const msg = msgModule('notifications');
const { sendMessage } = msg;
const { onMessage } = chrome.runtime;
const IS_EDGE = (globals.BROWSER_INFO.name === 'edge');

/**
* Use to call init to initialize functionality
@@ -621,15 +620,11 @@ const NotificationsContentScript = (function(win, doc) {
url = window.webkitURL.createObjectURL(textFileAsBlob);
}

if (IS_EDGE) { // @EDGE does not support chrome.downloads
window.navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);
} else {
const link = createEl('a');
link.href = url;
link.setAttribute('download', fileNameToSaveAs);
document.body.appendChild(link);
link.click();
}
const link = createEl('a');
link.href = url;
link.setAttribute('download', fileNameToSaveAs);
document.body.appendChild(link);
link.click();
};
/**
* Determine if a DOM element is visible to user.
@@ -20,7 +20,6 @@ import { ToggleCheckbox } from '../../../shared-components';

const { IS_CLIQZ } = globals;
const IS_FIREFOX = (globals.BROWSER_INFO.name === 'firefox');
const IS_EDGE = (globals.BROWSER_INFO.name === 'edge');

/**
* A Functional React component for rendering the Home View
@@ -43,7 +42,7 @@ const HomeView = (props) => {
if (globals.BROWSER_INFO) {
if (IS_FIREFOX) {
headerInfoText = t('hub_home_header_info_opted_out');
} else if (IS_CLIQZ || IS_EDGE) {
} else if (IS_CLIQZ) {
headerInfoText = t('hub_home_header_info_cliqz');
}
}
@@ -29,7 +29,6 @@ import SetupDoneView from '../SetupViews/SetupDoneView';

const { BROWSER_INFO } = globals;
const IS_FIREFOX = (BROWSER_INFO.name === 'firefox');
const IS_EDGE = (BROWSER_INFO.name === 'edge');

/**
* @class Implement the Setup View for the Ghostery Hub
@@ -105,7 +104,7 @@ class SetupViewContainer extends Component {
this.props.actions.setAntiTracking({ enable_anti_tracking: true });
this.props.actions.setAdBlock({ enable_ad_block: true });
this.props.actions.setSmartBlocking({ enable_smart_block: true });
this.props.actions.setGhosteryRewards({ enable_ghostery_rewards: !IS_FIREFOX && !IS_EDGE });
this.props.actions.setGhosteryRewards({ enable_ghostery_rewards: !IS_FIREFOX });
this.props.actions.setHumanWeb({ enable_human_web: !IS_FIREFOX });
}

@@ -18,7 +18,6 @@ import globals from '../../../../../src/classes/Globals';

// simple consts
const { IS_CLIQZ } = globals;
const IS_EDGE = (globals.BROWSER_INFO.name === 'edge');

/**
* @class Implement the Setup Anti-Suite View for the Ghostery Hub
@@ -132,7 +131,7 @@ class SetupAntiSuiteViewContainer extends Component {
}
];

if (!IS_CLIQZ && !IS_EDGE) {
if (!IS_CLIQZ) {
features.push({
id: 'ghostery-rewards',
name: t('hub_setup_ghosteryrewards_name_rewards'),
@@ -17,7 +17,6 @@ import SideNavigationView from './SideNavigationView';
import globals from '../../../../src/classes/Globals';

const { IS_CLIQZ } = globals;
const IS_EDGE = (globals.BROWSER_INFO.name === 'edge');

/**
* @class Implement the Side Navigation View for the Ghostery Hub
@@ -54,7 +53,7 @@ class SideNavigationViewContainer extends Component {
{ href: '/setup', icon: 'setup', text: t('customize_setup') },
{ href: '/tutorial', icon: 'tutorial', text: t('hub_side_navigation_tutorial') },
{ href: '/plus', icon: 'plus', text: t('get_ghostery_plus') },
...((IS_CLIQZ || IS_EDGE) ? [] : [{ href: '/rewards', icon: 'rewards', text: t('hub_side_navigation_rewards') }]),
...((IS_CLIQZ) ? [] : [{ href: '/rewards', icon: 'rewards', text: t('hub_side_navigation_rewards') }]),
{ href: '/products', icon: 'products', text: t('hub_side_navigation_products') }
];
const bottomItems = user ? [
@@ -117,8 +117,7 @@ export function exportSettings(pageUrl) {
const url = pageUrl || '';
// Check if this is http(s) page
return function(dispatch) {
if (url.search('http') === -1 ||
(globals.BROWSER_INFO.name === 'edge' && url.search('www.msn.com/spartan') !== -1)) {
if (url.search('http') === -1) {
dispatch({
type: EXPORT_SETTINGS,
data: 'RESERVED_PAGE',
@@ -56,7 +56,6 @@ class ClickOutside extends React.Component {
*/
clickHandler(e) {
// Simple polyfill for Event.composedPath
// Edge does not support path or composedPath
if (!('composedPath' in Event.prototype)) {
Event.prototype.composedPath = function() {
const path = [];
@@ -21,7 +21,6 @@ import globals from '../../../src/classes/Globals';
import { log } from '../../../src/utils/common';

const IS_CLIQZ = (globals.BROWSER_INFO.name === 'cliqz');
const IS_EDGE = (globals.BROWSER_INFO.name === 'edge');

/**
* @class The Rewards Panel shows offers generated by Ghostery Rewards.
@@ -178,7 +177,7 @@ class Rewards extends React.Component {
const { enable_offers } = this.props;
const headerClassNames = ClassNames('RewardsPanel__header', 'flex-container', 'align-middle', 'align-justify');
const headerTitleClassNames = ClassNames('RewardsPanel__title');
const shouldHideSlider = IS_CLIQZ || IS_EDGE;
const shouldHideSlider = IS_CLIQZ;

return (
<div className={headerClassNames}>
@@ -229,15 +228,6 @@ class Rewards extends React.Component {
);
}

renderEDGEtext() {
return (
<div className="RewardsPanel__info">
{ this.renderRewardSvg() }
<div>{ t('panel_detail_rewards_edge_text') }</div>
</div>
);
}

renderRewardsTurnoffText() {
return (
<div className="RewardsPanel__info">
@@ -262,7 +252,6 @@ class Rewards extends React.Component {
*/
renderRewardListComponent() {
if (IS_CLIQZ) { return this.renderCLIQZtext(); }
if (IS_EDGE) { return this.renderEDGEtext(); }
const { enable_offers, is_expanded } = this.props;
if (!enable_offers) { return this.renderRewardsTurnoffText(); }

@@ -55,7 +55,7 @@ class Account extends React.Component {
*/
clickImportSettings = () => {
const browserName = globals.BROWSER_INFO.name;
if (browserName === 'edge' || browserName === 'firefox') {
if (browserName === 'firefox') {
// show ghostery dialog window for import
this.props.actions.importSettingsDialog(this.props.settingsData.pageUrl);
} else {
@@ -15,7 +15,6 @@ import React from 'react';
import globals from '../../../../src/classes/Globals';

const IS_CLIQZ = (globals.BROWSER_INFO.name === 'cliqz');
const IS_EDGE = (globals.BROWSER_INFO.name === 'edge');

/**
* @class Implement Opt In subview as a React component.
@@ -58,7 +57,7 @@ const OptIn = (props) => {
</div>
</div>
)}
{!IS_CLIQZ && !IS_EDGE && (
{!IS_CLIQZ && (
<div className="s-option-group" id="offers-section">
<div className="s-square-checkbox">
<input type="checkbox" id="settings-allow-offers" name="enable_offers" defaultChecked={settingsData.enable_offers} onClick={props.toggleCheckbox} />
@@ -136,9 +136,6 @@ const _exportSettings = (state, action) => {
let updated_exportResultText = state.exportResultText;
if (result && result !== 'RESERVED_PAGE') {
updated_settings_last_exported = Number((new Date()).getTime());
if (globals.BROWSER_INFO.name === 'edge') {
window.close();
}
moment.locale(state.language).toLowerCase().replace('_', '-');
updated_exportResultText = `${t('settings_export_success')} ${moment(updated_settings_last_exported).format('LLL')}`;
updated_actionSuccess = true;
@@ -11,12 +11,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0
*/

import globals from '../../../src/classes/Globals';
import { log } from '../../../src/utils/common';

const { onMessage } = chrome.runtime;
const IS_EDGE = (globals.BROWSER_INFO.name === 'edge');

/**
* Default callback handler for sendMessage. Allows us to handle
* 'Unchecked runtime.lastError: The message port closed before a response was received' errors.
@@ -38,49 +34,7 @@ const defaultCallback = () => {
* @param {Object} message message data
* @return {Promise}
*/
let MESSAGE_ID = 0;
const listenerSet = new Set();
const resolveMap = new Map();
const NO_ORIGIN = 'no_origin';
export function sendMessageInPromise(name, message, origin = '') {
// On Edge 39.14965.1001.0 callback is not called when multiple
// Edge instances are running. So instead we pass the message back
// from background. See onMessageHandler, HANDLE UNIVERSAL EVENTS HERE
// in src/background.js. To be removed, once Edge is fixed.
if (IS_EDGE) {
MESSAGE_ID++;
const messageId = MESSAGE_ID.toString();
return new Promise((resolve) => {
resolveMap.set(messageId, resolve);
const key = (origin === '') ? NO_ORIGIN : origin;
if (!listenerSet.has(key)) {
listenerSet.add(key);
// We need to map individual listeners by origin for each
// instantiation (panel, hub, content scripts) since Edge does
// not allow a global listener for all uses
onMessage.addListener((request, sender, sendResponse) => {
const callback = resolveMap.get(request.name);
if (callback) {
callback(request.message);
resolveMap.delete(request.message);
}
if (sendResponse) {
sendResponse();
}
});
}
chrome.runtime.sendMessage({
name,
message,
messageId,
origin,
}, () => {
if (chrome.runtime.lastError) {
log('sendMessageInPromise error:', chrome.runtime.lastError);
}
});
});
}
return new Promise((resolve) => {
chrome.runtime.sendMessage({
name,
@@ -110,9 +64,6 @@ export function sendMessageInPromise(name, message, origin = '') {
*/
export function sendMessage(name, message, origin = '', callback = defaultCallback()) {
log('Panel sendMessage: sending to background', name);
// @EDGE chrome.runtime.sendMessage(message) works, but the `callback` of
// chrome.runtime.sendMessage(message, callback) fails to
// execute and chrome.runtime.lastError is undefined.
return chrome.runtime.sendMessage({
name,
message,
@@ -95,7 +95,7 @@
],
"persistent": true
},
"minimum_edge_version": "33.14281.1000.0",
"minimum_edge_version": "79.0.309",
"minimum_chrome_version": "58",
"minimum_opera_version": "45",
"web_accessible_resources": [
@@ -662,30 +662,10 @@ function onMessageHandler(request, sender, callback) {
return;
}
const {
name, message, messageId, origin
name, message, origin
} = request;
const { tab } = sender;
const tab_id = tab && tab.id;
// Edge does not have url on tab object, as of Build 14342_rc1
// const tab_url = tab && (tab.url ? tab.url : (sender.url ? sender.url : ''));

// On Edge 39.14965.1001.0 callback is lost when multiple
// Edge instances running. So instead we shoot message back
// See sendMessageInPromise in app/js/utils/msg.js where we
// listen to this message. To be removed, once Edge fixed
if (IS_EDGE && messageId) {
if (tab_id) {
// eslint-disable-next-line no-param-reassign
callback = function(result) {
utils.sendMessage(tab_id, messageId, result);
};
} else {
// eslint-disable-next-line no-param-reassign
callback = function(result) {
utils.sendMessageToPanel(messageId, result);
};
}
}

// HANDLE PAGE EVENTS HERE
if (origin === 'account_pages') {
@@ -803,10 +783,6 @@ function onMessageHandler(request, sender, callback) {
return true;
}
if (name === 'account.register') {
if (!IS_EDGE) {
const senderOrigin = (sender.url.indexOf('templates/panel.html') >= 0) ? 'extension' : 'setup';
metrics.ping(`create_account_${senderOrigin}`);
}
const {
email, confirmEmail, password, firstName, lastName
} = message;
@@ -1333,7 +1309,6 @@ function addCommonGhosteryAndAntitrackingListeners() {
let urlFilters = ['http://*/*', 'https://*/*', 'ws://*/*', 'wss://*/*'];
if (IS_EDGE || IS_FIREFOX) {
// Prevent Firefox from asking users to re-validate permissions on upgrade
// Edge doesn't support WebSockets
urlFilters = urlFilters.reduce((accumulator, currentValue) => {
if (!currentValue.match(/^wss?:\/\//)) {
accumulator.push(currentValue);
@@ -1451,7 +1426,7 @@ function initializeEventListeners() {
});

// Fired when another extension sends a message, accepts message if it's from Ghostery Tab
// NOTE: not supported on Edge and Firefox < v54
// NOTE: not supported on Firefox < v54
if (typeof chrome.runtime.onMessageExternal === 'object') {
chrome.runtime.onMessageExternal.addListener((request, sender, sendResponse) => {
const recognized = [
@@ -1598,7 +1573,7 @@ function initializeGhosteryModules() {
// We introduce these new features initially disabled.
conf.enable_ad_block = false;
conf.enable_anti_tracking = false;
// Enable Offers except on Edge or Cliqz
// Enable Offers except or Cliqz
conf.enable_offers = true;
} else if (globals.JUST_UPGRADED_FROM_8_1) {
// These users already had human web, adblocker and antitracking, so we respect their choice
@@ -1612,7 +1587,7 @@ function initializeGhosteryModules() {
conf.enable_ad_block = !adblocker.isDisabled;
conf.enable_anti_tracking = !antitracking.isDisabled;
conf.enable_human_web = !humanweb.isDisabled && !(IS_FIREFOX && globals.JUST_INSTALLED);
conf.enable_offers = !offers.isDisabled && !(IS_FIREFOX && globals.JUST_INSTALLED) && !IS_EDGE;
conf.enable_offers = !offers.isDisabled && !(IS_FIREFOX && globals.JUST_INSTALLED);
}

const myoffrzShouldMigrate = conf.rewards_opted_in !== undefined && cliqz.prefs.get('myoffrz.opted_in', undefined) === undefined;
@@ -93,7 +93,6 @@ class BrowserButton {
// provide callbacks, we must check that the tab exists again to compensate for a race
// condition that occurs if a user closes the tab while the trackers are still loading
getTab(tabId, () => {
// @EDGE setTitle not currently supported by EDGE
if (typeof chrome.browserAction.setTitle === 'function') {
chrome.browserAction.setTitle({
title: chrome.i18n.getMessage('browser_button_tooltip'),
ProTip! Use n and p to navigate between commits in a pull request.