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

[Editor preview]: Use unmapped hostname for the preview #39859

Merged
merged 3 commits into from
Mar 20, 2020

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Mar 4, 2020

Changes proposed in this Pull Request

This PR is a test to see whether using the unmapped site urls for the preview window iframe urls will prevent re-occurring 404s. See: p58i-89x-p2

Safari, it is reported, suffers from the 404 preview bug the most.

Naughty Safari!

Testing instructions

  1. In Calypso, and using a custom domain (*.blog or *.com or something), create a new post over at /block-editor/post/YOUR_SWEET_SWEET_CUSTOM_SITE
  2. Type some stuff and preview immediately
  3. Do you get a 404?

Fixes #30145 (I hope)

@matticbot
Copy link
Contributor

@ramonjd ramonjd self-assigned this Mar 4, 2020
@ramonjd ramonjd requested a review from a team March 4, 2020 05:32
@matticbot
Copy link
Contributor

matticbot commented Mar 4, 2020

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~50 bytes added 📈 [gzipped])

name              parsed_size           gzip_size
gutenberg-editor       +120 B  (+0.0%)      +50 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@andrewserong
Copy link
Member

Just had a quick look with a private site in Chrome where I ran into the issue with previewing, and I can't replicate the issue on this PR. I'm not quite sure how to test on Safari though because I'm blocked by not being able to log in on calypso.localhost:3000 or calypso.live. Also did a quick test to make sure that the preview on a Jetpack site is still working as expected, and didn't run into any issues.

@ramonjd
Copy link
Member Author

ramonjd commented Mar 5, 2020

because I'm blocked by not being able to log in on calypso.localhost:3000 or calypso.live.

Thanks @andrewserong

Testing in Safari locally is becoming a real pain. I hope it will be addressed by the ITP squad. There are some interesting ideas over at p58i-8wz-p2#comment-44673

@noahtallen
Copy link
Contributor

I hope it will be addressed by the ITP squad

Do we have one now? Seems like there weren't many volunteers on the original post.

@ramonjd
Copy link
Member Author

ramonjd commented Mar 5, 2020

Do we have one now? Seems like there weren't many volunteers on the original post.

Good question. The comments aren't exactly active as I expected them to be.

I've been (mostly unsuccessfully) experimenting with document.requestStorageAccess in the proxy iframe's index file, but I feel like I'm just throwing sand around a sandless pit, and all the kids have taken their toys home already.

@ramonjd ramonjd added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] Needs e2e Testing [Type] Bug When a feature is broken and / or not performing as intended [Feature] Post/Page Editor The editor for editing posts and pages. labels Mar 5, 2020
@ramonjd ramonjd marked this pull request as ready for review March 5, 2020 23:49
@ramonjd ramonjd requested review from a team as code owners March 5, 2020 23:49
Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

In my testing, this seems to be an improvement 👍

Tested with a private site in Safari with production and calypso.live (this branch).

I also attempted to test an Atomic site, but I couldn't get visit block-editor in Calypso for the Atomic site, I was redirected to WP Admin (plugins page 😕). I'm not sure if this is true of all atomic sites, but the unmapped URL will not be a wordpress.com URL in those cases.

@ramonjd
Copy link
Member Author

ramonjd commented Mar 8, 2020

Tested with a private site in Safari with production and calypso.live (this branch).

Thanks for testing @sirreal !!!

You got further than I did with Safari, hence the reason behind the feature flag. I was going to try out Atomic et. al., on wpcalypso since Safari was giving me so much grief.

@ramonjd
Copy link
Member Author

ramonjd commented Mar 8, 2020

since Safari was giving me so much grief.

Forgot to login to WordPress.com first, then test on calypso.live 😊

I also attempted to test an Atomic site

This PR only affects WordPress.com.

I created an Atomic site, and creating a draft post + preview worked only. I was only testing via https://hash-9578bc560b5b8723624e02c8ffcf5334f742431f.calypso.live/block-editor/post/SITE_SLUG/SITE_ID however

@lancewillett
Copy link
Contributor

lancewillett commented Mar 15, 2020

Testing in Safari desktop version 13.0.5 on macOS Catalina.

Using a mapped domain on a WordPress.com Simple site:

First, in production:

  1. Create a new post, save, and click "Preview" button in block editor
  2. The page flashes an overlay quickly, but it disappears with no warning
  3. JS console shows an error like this:

[Error] Refused to display '[YOUR_SWEET_SWEET_CUSTOM_SITE/?p=767&preview=true&frame-nonce=1234&iframe=true&calypso_token=1234' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

Next, on the live branch from this pull request:

  1. Create a new post, save, and click "Preview" button in block editor
  2. The preview overlay launches successfully 🎉

I do see a JS console error, but it doesn't seem to block the preview action.

[Error] Preflight response is not successful
[Error] XMLHttpRequest cannot load http://YOUR_SWEET_SWEET_CUSTOM_SITE/?get-xpost-data due to access control checks.
[Error] Failed to load resource: Preflight response is not successful (YOUR_SWEET_SWEET_CUSTOM_SITE, line 0)

Extra note — this WordPress.com Simple site is also marked "Private" in "Settings > Privacy."

@ramonjd ramonjd force-pushed the try/use-unmapped-blog-url-in-editor-preview branch from 9578bc5 to c6b4588 Compare March 20, 2020 01:12
Copy link
Member

@michaeldcain michaeldcain left a comment

Choose a reason for hiding this comment

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

:vegemite:

@lancewillett lancewillett added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Mar 20, 2020
@lancewillett
Copy link
Contributor

🚢

@ramonjd ramonjd merged commit b305681 into master Mar 20, 2020
@ramonjd ramonjd deleted the try/use-unmapped-blog-url-in-editor-preview branch March 20, 2020 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Post/Page Editor The editor for editing posts and pages. [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preview sometimes 404s (more often on Safari)
7 participants