Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

Show error page on firefox v49 and below #339

Merged
merged 7 commits into from Jul 28, 2017
Merged

Show error page on firefox v49 and below #339

merged 7 commits into from Jul 28, 2017

Conversation

ericawright
Copy link
Contributor

@ericawright ericawright commented Jul 27, 2017

@abhinadduri can you create an appropriate GA event for this?

Everyone else, any opinions on what should be shown on this page?

/unsupported/outdated now looks like this:
screen shot 2017-07-27 at 2 21 43 pm

very similar to /unsupported/gcm

link goes to "https://support.mozilla.org/kb/update-firefox-latest-version" which offers advice on how to update firefox

Fixes: #319.
Ref: #127.

abhinadduri
abhinadduri previously approved these changes Jul 27, 2017
gcmCompliant().catch(err => {
$('#page-one').attr('hidden', true);
$('#download').attr('hidden', true);
sendEvent('sender', 'unsupported', {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below this was "recipient" in /frontend/src/download.js (but "sender" in the upload.js).
Is this fine here as "sender" always?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not. Good catch, we might have to take this out of common.js.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, yeah, didn't see that

if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1 &&
parseInt(navigator.userAgent.toLowerCase().match(/firefox\/*([^\n\r]*)\./)[1]) <= 49) {
sendEvent('sender', 'unsupported', {
cd6: 'Unsupported Firefox'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this fine as a string?
In every other instance of cd6 I grepped, the cd6 was an error object.

Disclaimer: I know nothing about metrics collection.

@abhinadduri abhinadduri dismissed their stale review July 27, 2017 16:55

Pushed changes.

@abhinadduri
Copy link
Collaborator

abhinadduri commented Jul 27, 2017

Do you think we should keep it in common and maybe look through the url for a 'download' to determine if it's the recipient or the sender? Or do you think it would be better to move it out of common and into upload and download?

@ericawright
Copy link
Contributor Author

ericawright commented Jul 27, 2017

I like not having to repeat the code twice, but then it does add an extra step to figure out which page.

@abhinadduri
Copy link
Collaborator

abhinadduri commented Jul 27, 2017

I've added a check in common to address this, let me know what you think.

@pdehaan
Copy link
Collaborator

pdehaan commented Jul 27, 2017

Semi related, but do we want to do similar UA sniffing and redirect IE users to /unsupported?
Ref: #127 (comment)

@ericawright
Copy link
Contributor Author

@pdehaan yeah, that's my plan at least

@ericawright
Copy link
Contributor Author

ericawright commented Jul 27, 2017

@SoftVision-CiprianMuresan can you test on IE for me to ensure that it is being redirected to the unsupported page?

Also, should we block Edge as well, or just some versions of it. If so, which versions?

@@ -67,6 +67,8 @@ expiredPageHeader = This link has expired or never existed in the first place!
notSupportedHeader = Your browser is not supported.
// Firefox Send is a brand name and should not be localized.
notSupportedDetail = Unfortunately this browser does not support the web technology that powers Firefox Send. You’ll need to try another browser. We recommend Firefox!
notSupportedOutdatedDetail = Unfortunately this version of Firefox does not support the web technology that powers Firefox Send. You’ll need to update your browser.
updateFirefox = Update Firefox
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @flodolo since this adds some l10n strings.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Feel free to use the testpilot solution to ping automatically ;-)
https://github.com/mozilla/testpilot/blob/master/CODEOWNERS

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I just learnt something new today!
Filed as #343, which I can create a PR for shortly.

server/server.js Outdated
app.get('/unsupported', (req, res) => {
res.render('unsupported');
app.get('/unsupported/:reason', (req, res) => {
const outdated = req.params.reason === 'outdated'? true : false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ? true : false sorcery is unnecessary here since req.params.reason === 'outdated' should be Boolean-enough(tm).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

</div>
</a>
{{#if outdated}}
<div class="description" data-l10n-id="notSupportedOutdatedDetail"></div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re: notSupportedOutdatedDetail = Unfortunately this version of Firefox does not support the web technology that powers Firefox Send. You’ll need to update your browser.

Then below you send me to a SUMO page. It may be more useful to send users right to the Firefox download page here. :unsolicted_advice:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the users already have firefox...they just need to know how to update it

</a>
{{#if outdated}}
<div class="description" data-l10n-id="notSupportedOutdatedDetail"></div>
<a id="update-firefox" href="https://support.mozilla.org/az/kb/update-firefox-latest-version">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly, we're sending everybody to the Azerbaijani (az) locale of the page. We may just want to neuter the /az/ portion of the URL.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (navigator.userAgent.toLowerCase().indexOf('msie') > -1 ||
navigator.userAgent.toLowerCase().match(/trident\/7\./)) {
window.location.replace('/unsupported/ie');
}
Copy link
Collaborator

@pdehaan pdehaan Jul 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we go too far down a UA+regex abyss, not sure if we want to consider something like https://github.com/faisalman/ua-parser-js maybe.
https://www.npmjs.com/package/ua-parser-js#using-jqueryzepto-ua

const UAParser = require('ua-parser-js');
const parser = new UAParser();
const uaBrowser = parser.getResult().browser;

console.log(uaBrowser); // { name: "Firefox", version: "55.0", major: "55" }

UPDATE: A bit more verbose than I was hoping for, but it reads OK-ish. Pseudo-code ahoy!

const UAParser = require('ua-parser-js');
const uaBrowser = new UAParser().getResult().browser;
const isSender = !location.pathname.includes('/download');
const senderOrRecipient = isSender ? 'sender' : 'recipient';

gcmCompliant().catch(err => {
  sendEvent(senderOrRecipient, 'unsupported', {
    cd6: err
  })
  window.location.replace('/unsupported/gcm');
});

checkUserAgent(uaBrowser, senderOrRecipient);

function checkUserAgent(browser, type) {
  const majorVersion = parseInt(browser.major, 10);
  switch (browser.name.toLowerCase()) {
    case 'firefox':
      if (majorVersion <= 49) {
        sendEvent(type, 'unsupported', {
          cd6: new Error('Firefox is outdated.')
        });
        location.replace('/unsupported/outdated');
        return;
      }
      break;

    case 'explorer': // NOTE: I made this value up.
      location.replace('/unsupported/ie');
      break;
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of including npm modules for everything that seems like overkill. I'm open to it, but the regex is already written and really not a big problem, I don't see too many more UA checks being added in...


if (navigator.userAgent.toLowerCase().indexOf('msie') > -1 ||
navigator.userAgent.toLowerCase().match(/trident\/7\./)) {
window.location.replace('/unsupported/ie');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a sendEvent() here (before the location.replace())?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea. @abhinadduri would you like a different event, or the same event as gets sent for outdated firefox?

@SoftVision-CiprianMuresan

@ericawright, using a local server I've run branch v49 on a Mac and connected remotely from my Windows machine.
Unfortunately Internet Explorer does not show the "Browser not supported" page:

image

It does, however, work on Firefox 49 and lower.

image

And to answer your other question, in my opinion we should only block Microsoft Edge v.25.10586.672.0 . The other two versions of Edge work as expected (see Cosmin's comment in #127).

@ericawright
Copy link
Contributor Author

@SoftVision-CiprianMuresan @dannycoates @pdehaan (and others) we have some options to deal with IE. what's happening is that it doesn't support ES6. And it errors in our scripts then fails to run any part of them. So @dnarcese and I have come up with a few solutions.

  1. We create a separate script included in all html files that checks for IE, then redirects to our error page without any ES6 syntax.
  2. We use babelify/browserify to interpret our code to es5 in the bundles.

1 is easier, but we may end up never supporting IE if we go that route.
2 causes us to lose some of the benefits of new ES6 speed, though it shouldn't be too big a problem.

@pdehaan
Copy link
Collaborator

pdehaan commented Jul 28, 2017

I think +1 to using babel to transpile to ES5 for maximum compatibility (although we'd still need GCM support, so we wouldnt get that much compatibility from older browsers anyways).

Also, while trying to hack on UA options yesterday, I found https://github.com/biggora/express-useragent. Maybe we can just detect the IE browsers using Express middleware on the servers and do the redirect there for your option 1. Then it can easily use a custom layout if needed.

@pdehaan
Copy link
Collaborator

pdehaan commented Jul 28, 2017

@SoftVision-CiprianMuresan Any chance you can send us your IE user agent string: http://www.whatismyuseragent.net/?

@ericawright
Copy link
Contributor Author

@pdehaan turns out @dnarcese has ie11 set up so we've been using that this morning.
"Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; rv:11.0) like Gecko”

@pdehaan
Copy link
Collaborator

pdehaan commented Jul 28, 2017

And to answer your other question, in my opinion we should only block Microsoft Edge v.25.10586.672.0 .

@SoftVision-CiprianMuresan I guess of you have a UserAgent string for that too, it would be helpful.

@SoftVision-CiprianMuresan
Copy link

Here's my Edge user-agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586

And my IE one is:
Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

@pdehaan
Copy link
Collaborator

pdehaan commented Jul 28, 2017

Well, the IE one would fail, because the RegExp works for /trident\/7\./i, but neither of your IE user agent strings contain the "msie" substring.

+if (navigator.userAgent.toLowerCase().indexOf('msie') > -1 ||
+    !!navigator.userAgent.toLowerCase().match(/trident\/7\./)) {
+  window.location.replace('/unsupported/ie');
+}

UPDATE: I take that back... re-reading your if(){}, it has an || not an &&, so the /trident/ regexp should still have been truthy-enough to make that work.

@ericawright
Copy link
Contributor Author

@pdehaan this is true. I'll find another way to identify IE (outside of IE11)

@ericawright
Copy link
Contributor Author

we're struggling with babelify. Since @dannycoates talked about doing a new release today, maybe we merge this without the IE changes. Then either get babelify working or do a last minute fix using option one from above.
(the problem is that it's not correctly changing the class keyword if anyone wants to look into it)

@pdehaan

I take that back... re-reading your if(){}, it has an || not an &&, so the /trident/ regexp should still have been truthy-enough to make that work.

Yes, the 'msie' check is for IE < 11, and the 'trident' check is for IE11

@pdehaan
Copy link
Collaborator

pdehaan commented Jul 28, 2017

we're struggling with babelify

I was starting to look into replacing browserify with webpack the other day, but then got side tracked by other projects... If I have a few minutes today I may see if I can get a basic webpack config+minification working, then try adding in babel into the stack-of-doom.

@pdehaan
Copy link
Collaborator

pdehaan commented Jul 28, 2017

But I'm 👍 for merging whatever we have, and filing new bugs for sorting out the older IE issues in a future bug/PR.

I really thought IE would have been caught by the GCM check anyways. But maybe that's an issue w/ the promise being async and it trying to run the UA regexes before the GCM check has had a chance to fail out. Or something else entirely.

@ericawright
Copy link
Contributor Author

It seems that because of the ES6 syntax, IE just gives up and doesn't run anything if there is any ES6 syntax anywhere in the file. So the GCM check might have otherwise caught on it. it's the same with the redirect I'm trying to do. the code is correct. and will run in the console, but it sees the file as being corrupted.

@ericawright
Copy link
Contributor Author

Ok, I took out the IE code. So it's ready for review from whoever would like to give one :)

@pdehaan pdehaan requested a review from dannycoates July 28, 2017 18:30
Copy link
Contributor

@dannycoates dannycoates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@pdehaan
Copy link
Collaborator

pdehaan commented Jul 28, 2017

Submitted new bug to re-add IE detection code: #351 "Redirect IE users to an /unsupported/ie page".

@pdehaan pdehaan deleted the v49 branch July 31, 2017 05:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants