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

Pulling in feature-detection tests from modernizr-plugins #419

Merged
merged 8 commits into from
Dec 4, 2011
Merged

Pulling in feature-detection tests from modernizr-plugins #419

merged 8 commits into from
Dec 4, 2011

Conversation

addyosmani
Copy link
Contributor

This repository contains additional feature-tests for Modernizr covering the following:

  • DataView API
  • Microdata
  • Mozilla Audio API
  • WebAudio API
  • Track element
  • getUserMedia/device API
  • GamePad API
  • EventSource API
  • Animated PNG
  • Progress element
  • ClassList

It also has a test for ContextMenu support (which I've excluded as @codepo8 pushed something similar recently) and a combined test for both Mozilla and WebKit's Audio APIs (which I'm excluding unless it's specifically asked for).

At this time it would be awesome if someone could do a code-review to make sure these tests are solid.

@paulirish
Copy link
Member

i think the filenames need some tweaking otherwise this is looking strong :)

thx for the audio test changes :)

@addyosmani
Copy link
Contributor Author

My pleasure! :)

I'll try tweaking the filenames up a little sooon.

@ryanseddon
Copy link
Member

I saw these the other day and was going to ask you to do a pull request, awesome work.

The test names should probably all be lowercase to be inline with the others plugins (we should document that in docs on what is preferred?).

I'm getting errors with the apng test not liking the following line because of the preceding cast to bool operator being outside the parentheses.

if !! (typeof canvas.getContext == 'undefined') {

Also since this is an async test I'd put the the Modernizr.addTest call inside the onload event. The same way the webp plugin does it.

@addyosmani
Copy link
Contributor Author

@ryanseddon How does the updated PR look?

There are a few different ways the async test could be done, but I figured that wrapping the load/onerror event handler attachment inside the context test would avoid a little overhead. If you have a preferred alternative structure to it, let me know and I'll happily update further.

Cheers!

@addyosmani
Copy link
Contributor Author

As requested by @paulirish, I've updated the PR to include the additional tests I added to the other repo today.

(thanks to @mathiasbynens and @timmywil for the head's up on naming)

@paulirish
Copy link
Member

Awesome thank you. :)

@ryanseddon
Copy link
Member

Looks good.

What I was saying about the async test was to do the addTest inside the onload as that covers both passing and failing. I'm not sure if the onerror will ever fire in any browser?

@mathiasbynens
Copy link
Contributor

As @ryanseddon said:

The test names should probably all be lowercase to be inline with the others plugins (we should document that in docs on what is preferred?).

All tests on http://modernizr.github.com/Modernizr/test/ have lowercase names.

@davidmurdoch
Copy link
Contributor

addTest toLowerCase()s feature names: addTest("featureName", bool) => Modernizr.featurename === bool

@mathiasbynens
Copy link
Contributor

@davidmurdoch Exactly; it would be much less confusing to lowercase the test names manually for people reading the feature test source code.

@davidmurdoch
Copy link
Contributor

Agreed.

aside: addTest should probably not enforce casing for feature names at all. The "official" Modernizr policy could be lowercase - but devs should be free to use whatever convention they like. Right? (Line 863 as well as addTest would need to be updated).

@addyosmani
Copy link
Contributor Author

Sounds good. I'll update the PR today to fall in line with the letter casing in other tests :)

Sent from my iPad

On 2 Dec 2011, at 09:50, David Murdochreply@reply.github.com wrote:

Agreed.

aside: addTest should probably not enforce casing for feature names at all. The "official" Modernizr policy could be lowercase - but devs should be free to use whatever convention they like. Right? (Line 863 as well as addTest would need to be updated).


Reply to this email directly or view it on GitHub:
#419 (comment)

@addyosmani
Copy link
Contributor Author

Cases updated <3

can someone review?

@paulirish
Copy link
Member

im gonna tweak these filenames a touch more and kill some superfluous !! casting since we're using in operator.
followups coming..

but THANK YOU Addy! great stuff. I think this kills a few outstanding things in the issue tracker too.

paulirish added a commit that referenced this pull request Dec 4, 2011
Pulling in feature-detection tests from modernizr-plugins
@paulirish paulirish merged commit 75afc46 into Modernizr:master Dec 4, 2011
@addyosmani
Copy link
Contributor Author

My pleasure @paulirish! Glad they could come in useful for something :)

patrickkettner pushed a commit to patrickkettner/Modernizr that referenced this pull request Feb 22, 2015
Pulling in feature-detection tests from modernizr-plugins
patrickkettner pushed a commit to patrickkettner/Modernizr that referenced this pull request Feb 22, 2015
patrickkettner pushed a commit to patrickkettner/Modernizr that referenced this pull request Feb 22, 2015
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.

5 participants