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

fix: 156 obsolete browsers #159

Merged
merged 2 commits into from
Oct 21, 2021
Merged

fix: 156 obsolete browsers #159

merged 2 commits into from
Oct 21, 2021

Conversation

tihuan
Copy link
Contributor

@tihuan tihuan commented Oct 19, 2021

Reviewers

Functional:
@seve
Readability:
@dimple-jethani

Changes

This PR replaces obsolete-webpack-plugin and uses browserslist-useragent-regexp to generate a REGEX to test the navigator.userAgent instead

The strategy is:

  1. Use browserslist-useragent-regexp to generate REGEX based on browserslist and output a file configuration/webpack/SUPPORTED_BROWSERS_REGEX.js
  2. configuration/webpack/webpack.config.shared.js imports the REGEX and obsolete html template and inject them into both index.html and index_template.html on the designated script tag.
  3. configuration/webpack/webpack.config.shared.js also copies the static file configuration/webpack/obsoleteBrowsers.js into the /build/static/ directory, so the servers know how to handle the request for the file
  4. index.html and index_template.html then loads the script file script tag in step 2 via src="obsoleteBrowsers.js". NOTE: we continue to use relative path here instead of absolute path, so the request will still be prefixed with data root path (the namespace needed for CloudFront)
  5. obsoleteBrowsers.js is now downloaded asynchronously and parse REGEX and HTML template from its script tag attributes and test the browser and render the obsolete HTML as needed

Safari:

Screen Shot 2021-10-19 at 3 30 38 AM

Chrome:

Screen Shot 2021-10-19 at 3 31 26 AM

🚨🚨🚨 TODO 🚨🚨🚨
1. Still need to remove associated script hash in single-cell-infra repo False alarm

@tihuan tihuan requested review from seve and dimple-jethani October 19, 2021 10:46
@tihuan tihuan force-pushed the thuang-fix-obsolete-browsers branch 2 times, most recently from a75b3b4 to a6e95ad Compare October 19, 2021 10:49
@tihuan tihuan changed the title fix: obsolete browsers fix: 156 obsolete browsers Oct 19, 2021
@codecov
Copy link

codecov bot commented Oct 19, 2021

Codecov Report

Merging #159 (223d3f3) into main (ec826f2) will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #159      +/-   ##
==========================================
+ Coverage   71.84%   71.85%   +0.01%     
==========================================
  Files         126      126              
  Lines       10108    10106       -2     
==========================================
  Hits         7262     7262              
+ Misses       2846     2844       -2     
Flag Coverage Δ
frontend 71.85% <ø> (+0.01%) ⬆️
javascript 71.85% <ø> (+0.01%) ⬆️
smokeTest ?
unitTest 71.85% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
server/eb/app.py 0.00% <ø> (ø)
eb/app.py 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec826f2...223d3f3. Read the comment docs.

Comment on lines -1 to -9
<script>
/** Reflect ANY changes to this script in the script hash in `server/eb/app.py` **/
var root = document.getElementById("root");
root.remove();
var portals = document.getElementsByClassName("bp3-portal");
for (var i = 0; i < portals.length; i += 1) {
portals[i].remove();
}
</script>
Copy link
Contributor

Choose a reason for hiding this comment

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

We're going to need to update CSP

Copy link
Contributor Author

@tihuan tihuan Oct 19, 2021

Choose a reason for hiding this comment

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

Ah thank you! Yeah we can remove the associated hash now! I'll add it as a TODO in the PR and ticket descriptions 👍

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! It's just in the BE code not in Infra repo lol Updated! Thank you!

@tihuan tihuan force-pushed the thuang-fix-obsolete-browsers branch from a6e95ad to 078e2de Compare October 19, 2021 19:10
@tihuan tihuan requested a review from seve October 19, 2021 19:44
@tihuan
Copy link
Contributor Author

tihuan commented Oct 20, 2021

@seve PTAL again thank you 🙏

Comment on lines +45 to +51
<script
async
src="static/obsoleteBrowsers.js"
id="obsolete-browsers"
data-template="<%= OBSOLETE_TEMPLATE %>"
data-regex="<%= OBSOLETE_REGEX %>"
></script>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this going to need to be reflected in CSP?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great question! Since the script will be served from the same domain as the HTML page, script-src "'self'" should cover it. Only inline scripts need hashes 👍

@@ -0,0 +1,22 @@
/* eslint-disable @blueprintjs/classes-constants -- do not import files */
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this too will need to be included in CSP?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see comment above!

@seve seve self-requested a review October 21, 2021 17:51
@tihuan tihuan enabled auto-merge (squash) October 21, 2021 18:30
@tihuan tihuan merged commit 656b63e into main Oct 21, 2021
@tihuan tihuan deleted the thuang-fix-obsolete-browsers branch October 21, 2021 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants