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 avoid javascript error when preview is https #5163

Merged
merged 2 commits into from Mar 14, 2016

Conversation

mikenz
Copy link
Contributor

@mikenz mikenz commented Mar 9, 2016

When the admin interface is http but the preview is https, javascript isn't able to read the contentDocument of the secure preview iframe. This currently results in a javascript error. Patch wraps try/catches around the two instances,

When the admin interface is http but the preview is https, javascript isn't able to read the contentDocument of the secure preview iframe. This currently results in a javascript error. Patch wraps try/catches around the two instances,
@dhensby
Copy link
Contributor

dhensby commented Mar 9, 2016

Can we do some kind of console.warn to signify we caught an error - otherwise this is just silently swallowed up.

I appreciate fixing this issue, but how is it coming about that the preview is secure but the CMS isn't? If the site is enforcing SSL (which is the only way I can imagine this is happening) then shouldn't the CMS be https too?

I'll accept this PR with a console.warn added to the catches and also a console.log for the if (!doc) { return; } bit

@mikenz
Copy link
Contributor Author

mikenz commented Mar 9, 2016

We use static publishing in our installation. Once the page has been statically published its viewable on a static domain. CMS is on http://admin.www.example.com (internal access only) pages are statically published to https://www.example.com

I'm not willing to have console.warn and console.log in there as there's nothing to warn anyone about, this will be too noisy for my users. Happy to just keep this in my branch.

@dhensby
Copy link
Contributor

dhensby commented Mar 9, 2016

I think that if a user opens the browser console, they probably want to see this kind of thing (and until now they'd have seen exceptions that were thrown instead).

Silently catching exceptions gives devs no way to figure out what is wrong and will make debugging more difficult. I don't think a noisy console for Admin users is a valid reason to deliberately stifle the use of a developer tool

@mikenz
Copy link
Contributor Author

mikenz commented Mar 9, 2016

Currently if a user triggers this scenario the JS stops running and CMS becomes unusable until the page is reloaded.

@tractorcow
Copy link
Contributor

Silently catching exceptions gives devs no way to figure out what is wrong and will make debugging more difficult. I don't think a noisy console for Admin users is a valid reason to deliberately stifle the use of a developer tool

+1 on this.

I think we need the console.warn in this case. If this is really an error condition, should it be console.error instead, though?

@dhensby
Copy link
Contributor

dhensby commented Mar 14, 2016

I'm not too fussed about error vs warn.

dhensby added a commit to dhensby/silverstripe-framework that referenced this pull request Mar 14, 2016
Build dist assets and added console.warn
@dhensby dhensby merged commit 0b81bbe into silverstripe:master Mar 14, 2016
@dhensby
Copy link
Contributor

dhensby commented Mar 14, 2016

merged by hand and added the console.warn as well as built the dist files

@patricknelson
Copy link
Contributor

patricknelson commented Jun 13, 2016

Just wanted to point out that this affects older versions. Is there a particular reason this was done in master and not in 3? I can submit a quick PR to help ensure we address this bug in older versions as well -- just let me know what branch (here or on the other issue I opened): #5683

patricknelson added a commit to patricknelson/silverstripe-framework that referenced this pull request Jun 13, 2016
…pting to access <iframe> contents (Back-porting fix from PR silverstripe#5163)
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.

None yet

4 participants