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

[edge browsers]: filter out by userAgent #26

Merged
merged 1 commit into from
May 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ function browserSupportsLogStyles () {
return false
}

// edge browser? https://msdn.microsoft.com/en-us/library/hh869301%28v=vs.85%29.aspx
var isEdge = navigator.userAgent.toLowerCase().indexOf('edge') > -1
// http://stackoverflow.com/a/16459606/376773
var isWebkit = 'WebkitAppearance' in document.documentElement.style
// http://stackoverflow.com/a/398120/376773
var isFirebug = window.console && (window.console.firebug || (window.console.exception && window.console.table)) && true
// firefox >= v31? https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
var isFirefoxWithLogStyleSupport = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31

return isWebkit || isFirebug || isFirefoxWithLogStyleSupport || false
return (isWebkit && !isEdge) || isFirebug || isFirefoxWithLogStyleSupport || false
}
19 changes: 19 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ test('browserSupportsLogStyles in WebKit browser', function (t) {
t.end()
})

test('browserSupportsLogStyles in Edge browser', function (t) {
resetBrowserEnvironment({
document: {
documentElement: {
style: {
WebkitAppearance: 'foo'
}
}
},
navigator: {
userAgent: 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136'
}
})

t.is(browserSupportsLogStyles(), false, 'is false')

t.end()
})

test('browserSupportsLogStyles in Firefox 30', function (t) {
resetBrowserEnvironment({
navigator: {
Expand Down