mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Redirect Safari <= 13 to unsupported browsers page (#17123)
GitOrigin-RevId: 8cc508eb7f4f68c5864e102b2d4af9c8920800ae
This commit is contained in:
parent
3e11ee6e5a
commit
680c9b9570
3 changed files with 107 additions and 73 deletions
|
@ -899,6 +899,7 @@ module.exports = {
|
|||
|
||||
unsupportedBrowsers: {
|
||||
ie: '<=11',
|
||||
safari: '<=13',
|
||||
},
|
||||
|
||||
// ID of the IEEE brand in the rails app
|
||||
|
|
|
@ -240,10 +240,6 @@ module.exports = {
|
|||
|
||||
reconfirmNotificationDays: 14,
|
||||
|
||||
unsupportedBrowsers: {
|
||||
ie: '<=11',
|
||||
},
|
||||
|
||||
recaptcha: {
|
||||
siteKey: 'siteKey',
|
||||
disabled: {
|
||||
|
|
|
@ -1,68 +1,113 @@
|
|||
const { expect } = require('chai')
|
||||
const User = require('./helpers/User')
|
||||
|
||||
const botUserAgents = new Map([
|
||||
[
|
||||
'Googlebot',
|
||||
'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
|
||||
],
|
||||
])
|
||||
|
||||
const unsupportedUserAgents = new Map([
|
||||
['IE 11', 'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko'],
|
||||
[
|
||||
'Safari 13',
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_12_2) AppleWebKit/629.24.7 (KHTML, like Gecko) Version/13.0.26 Safari/629.24.7',
|
||||
],
|
||||
])
|
||||
|
||||
const supportedUserAgents = new Map([
|
||||
[
|
||||
'Chrome 90',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36',
|
||||
],
|
||||
[
|
||||
'Chrome 121',
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
|
||||
],
|
||||
[
|
||||
'Firefox 122',
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:122.0) Gecko/20100101 Firefox/122.0',
|
||||
],
|
||||
[
|
||||
'Safari 14',
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_5_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15',
|
||||
],
|
||||
[
|
||||
'Safari 17',
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3.1 Safari/605.1.15',
|
||||
],
|
||||
])
|
||||
|
||||
describe('UnsupportedBrowsers', function () {
|
||||
beforeEach(function (done) {
|
||||
beforeEach(function () {
|
||||
this.user = new User()
|
||||
this.user.login(done)
|
||||
})
|
||||
|
||||
it('allows bots', function (done) {
|
||||
this.user.request(
|
||||
{
|
||||
url: '/project',
|
||||
headers: {
|
||||
// Googlebot user agent
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
|
||||
},
|
||||
},
|
||||
(error, response) => {
|
||||
expect(error).to.not.exist
|
||||
expect(response.statusCode).to.equal(200)
|
||||
done()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('allows supported browsers', function (done) {
|
||||
this.user.request(
|
||||
{
|
||||
url: '/project',
|
||||
headers: {
|
||||
// Chrome 90 user agent
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36',
|
||||
},
|
||||
},
|
||||
(error, response) => {
|
||||
expect(error).to.not.exist
|
||||
expect(response.statusCode).to.equal(200)
|
||||
done()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('redirects unsupported browsers to unsupported page', function (done) {
|
||||
const url = '/project'
|
||||
this.user.request(
|
||||
{
|
||||
url,
|
||||
headers: {
|
||||
// IE11 user agent
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko',
|
||||
},
|
||||
},
|
||||
(error, response) => {
|
||||
expect(error).to.not.exist
|
||||
expect(response.statusCode).to.equal(302)
|
||||
expect(response.headers.location).to.equal(
|
||||
'/unsupported-browser?fromURL=' + encodeURIComponent(url)
|
||||
describe('allows bots', function () {
|
||||
const url = '/login'
|
||||
for (const [name, userAgent] of botUserAgents) {
|
||||
it(name, function (done) {
|
||||
this.user.request(
|
||||
{
|
||||
url,
|
||||
headers: {
|
||||
'user-agent': userAgent,
|
||||
},
|
||||
},
|
||||
(error, response) => {
|
||||
expect(error).to.not.exist
|
||||
expect(response.statusCode).to.equal(200)
|
||||
done()
|
||||
}
|
||||
)
|
||||
done()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
describe('allows supported browsers', function () {
|
||||
const url = '/login'
|
||||
for (const [name, userAgent] of supportedUserAgents) {
|
||||
it(name, function (done) {
|
||||
this.user.request(
|
||||
{
|
||||
url,
|
||||
headers: {
|
||||
'user-agent': userAgent,
|
||||
},
|
||||
},
|
||||
(error, response) => {
|
||||
expect(error).to.not.exist
|
||||
expect(response.statusCode).to.equal(200)
|
||||
done()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
describe('redirects unsupported browsers to unsupported page', function () {
|
||||
const url = '/login'
|
||||
for (const [name, userAgent] of unsupportedUserAgents) {
|
||||
it(name, function (done) {
|
||||
this.user.request(
|
||||
{
|
||||
url,
|
||||
headers: {
|
||||
'user-agent': userAgent,
|
||||
},
|
||||
},
|
||||
(error, response) => {
|
||||
expect(error).to.not.exist
|
||||
expect(response.statusCode).to.equal(302)
|
||||
expect(response.headers.location).to.equal(
|
||||
'/unsupported-browser?fromURL=' + encodeURIComponent(url)
|
||||
)
|
||||
done()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
it('redirects unsupported browsers from any page', function (done) {
|
||||
|
@ -71,9 +116,7 @@ describe('UnsupportedBrowsers', function () {
|
|||
{
|
||||
url,
|
||||
headers: {
|
||||
// IE11 user agent
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko',
|
||||
'user-agent': unsupportedUserAgents.get('IE 11'),
|
||||
},
|
||||
},
|
||||
(error, response) => {
|
||||
|
@ -94,9 +137,7 @@ describe('UnsupportedBrowsers', function () {
|
|||
{
|
||||
url,
|
||||
headers: {
|
||||
// IE11 user agent
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko',
|
||||
'user-agent': unsupportedUserAgents.get('IE 11'),
|
||||
},
|
||||
},
|
||||
(error, response) => {
|
||||
|
@ -113,9 +154,7 @@ describe('UnsupportedBrowsers', function () {
|
|||
{
|
||||
url: '/unsupported-browser?fromURL=' + encodeURIComponent(url),
|
||||
headers: {
|
||||
// IE11 user agent
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko',
|
||||
'user-agent': unsupportedUserAgents.get('IE 11'),
|
||||
},
|
||||
},
|
||||
(error, response, body) => {
|
||||
|
@ -134,9 +173,7 @@ describe('UnsupportedBrowsers', function () {
|
|||
{
|
||||
url: '/unsupported-browser?fromURL=' + encodeURIComponent(url),
|
||||
headers: {
|
||||
// IE11 user agent
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko',
|
||||
'user-agent': unsupportedUserAgents.get('IE 11'),
|
||||
},
|
||||
},
|
||||
(error, response, body) => {
|
||||
|
|
Loading…
Reference in a new issue