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

Console warning #11625

Closed
wants to merge 4 commits into from
Closed

Console warning #11625

wants to merge 4 commits into from

Conversation

tfroseman
Copy link

@tfroseman tfroseman commented Feb 27, 2017

Added warning to console. Fixes #15
screen shot 2017-02-27 at 6 14 26 pm

Added warning to console.
@matticbot matticbot added OSS Citizen [Size] S Small sized issue labels Feb 27, 2017
@lancewillett lancewillett added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Mar 1, 2017
@umurkontaci
Copy link
Contributor

console.log is not initialized on all browsers until the devtools is actually opened. We should check for the existence of console.

Not all browsers support color input. We should determine if the console supports color and print according.

We should i18nize the message.

I guess for added security, we could run the console call in a setTimeout or try-catch so any error doesn't prevent the rest of the execution.

What do you think @mtias ?

@umurkontaci umurkontaci added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Apr 3, 2017
@dmsnell
Copy link
Contributor

dmsnell commented May 6, 2017

@tfroseman are you still interested in pushing out this PR?

@tfroseman
Copy link
Author

tfroseman commented May 8, 2017

Definitely @dmsnell. Wasn't certain if I needed input from @mitas. If not I can go about adding the desired checks for console and errors.

@dmsnell
Copy link
Contributor

dmsnell commented May 9, 2017

awesome - thanks @tfroseman! yeah I would suggest going ahead and addressing what @umurkontaci raised.

@umurkontaci do we have numbers on that behavior for console.log() or colors not being available? I would hate to get too deep into it and find out that only our "non supported" browsers are the ones causing trouble.

likewise I'm curious about translation since this is just an eval'd JS string in the HTML header. if we wanted to translate it seems like we would need a lot more code (maybe it belongs in the app and not the HTML header…?)

@umurkontaci
Copy link
Contributor

do we have numbers on that behavior for console.log() or colors not being available?

I think IE < 10 doesn't have console before you open the dev tools, it could be the same in IE > 10 as well. I don't have any data on how browsers behave regarding colored console commands when they don't support it.

But this will execute very early and on every load, so we can't have any errors thrown.

Although I think it might be a better to fit to run this after the app is loaded. That way we'll have access to translation module and error capturing.

Added try catch to log errors, and check for console.
}
} catch (exception) {
// Do something with error
}
Copy link
Contributor

Choose a reason for hiding this comment

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

why the try/catch if we are also checking for the presence of window.console? seems like we would only need one or the other

Copy link
Author

Choose a reason for hiding this comment

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

Made sense at the time as a way to meet the the need for error capturing if needed this early in app loading. Not really sure what errors could/would get thrown from writing to console.

@dmsnell
Copy link
Contributor

dmsnell commented Jun 21, 2017

@tfroseman what's the status on this PR? would you like to continue to refine it or have you moved on? are you waiting on feedback from one of us?

@tfroseman
Copy link
Author

@dmsnell Wasn't sure if the ability to support localization would fall under the scope of this issue. With that said I would like to have this added, I'll remove the redundant check.

@dmsnell
Copy link
Contributor

dmsnell commented Jun 26, 2017

I'm all for it. @yoavf @mtias or @ehg any thoughts on this? seems like waiting for localization would put a big hold on this PR since it's in the initial HTML file. can we get a 👍 or a 👎 vote for if you think this warning adds enough value to add, and to do so in English-only?

}
console.log("If someone told you to type or paste something into this area it could compromise the security of your account.");

}
Copy link
Contributor

Choose a reason for hiding this comment

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

@tfroseman do you think you could fix the formatting issues here? I think that if we get that updated we can ship. We will also prefer single quotes on the strings.

Copy link
Author

Choose a reason for hiding this comment

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

@dmsnell Yeah I'll clean that up. Also I was testing console on safari and realized that it and IE do not support 'rich' console output. Can I just do agent sniffing and only output plain text to log?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seemed to work in Safari. What specific troubles did you find there? We'd probably prefer not to try and sniff browser agent.

If it's a big problem we can probably start by leaving it all black.

Copy link
Author

@tfroseman tfroseman Jun 26, 2017

Choose a reason for hiding this comment

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

screen shot 2017-06-26 at 12 48 11 pm
The css styled output.
I am on Version 10.0.1 (11602.2.14.0.7) if that makes any difference.

Edit: I had to select the view all filter within developer tools.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm on 10.1.1 and that's working. I'm fine leaving it in for Safari. IE is the bigger question.

@tfroseman
Copy link
Author

@dmsnell You are correct works on everything but IE as it does not yet support css in console.

@gziolo
Copy link
Member

gziolo commented Sep 20, 2017

There is also a similar solution proposed by @kloon with #18088.

@dmsnell
Copy link
Contributor

dmsnell commented Nov 5, 2017

Resolved with the merge of #18088

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants