improve custom-protocol-handler.js #992

Merged
merged 1 commit into from Mar 7, 2014

Projects

None yet

2 participants

@patrickkettner
Member

As documented in the Undetectables
navigator.registerProtocolHandler was stubbed in webkit for a while, and doesn't actually do anything there.
This test forces a failure and ensures it's the right type of failure.

Android 2.* showed this behavior previously, and this test fixes that false positive.

@patrickkettner
Member

aye yo @stucox

@stucox stucox commented on the diff Mar 4, 2014
feature-detects/custom-protocol-handler.js
*/
define(['Modernizr'], function( Modernizr ) {
- Modernizr.addTest('customprotocolhandler', !!navigator.registerProtocolHandler);
+ Modernizr.addTest('customprotocolhandler', function() {
+ // early bailout where it doesn't exist at all
+ if ( !navigator.registerProtocolHandler ) return false;
+
+ // registerProtocolHandler was stubbed in webkit for a while, and didn't
+ // actually do anything. We intentionally set it improperly to test for
+ // the proper sort of failure
+ try {
+ navigator.registerProtocolHandler('thisShouldFail');
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+
@stucox
stucox Mar 4, 2014 Member

Fancy sticking a return false; here, just in case some browser for some reason doesn’t throw an error on L32?

@patrickkettner
patrickkettner Mar 4, 2014 Member

pah. morning brain. thanks so much stu

On Tue, Mar 4, 2014 at 9:43 AM, Stu Cox notifications@github.com wrote:

In feature-detects/custom-protocol-handler.js:

*/
define(['Modernizr'], function( Modernizr ) {

  • Modernizr.addTest('customprotocolhandler', !!navigator.registerProtocolHandler);
  • Modernizr.addTest('customprotocolhandler', function() {
  • // early bailout where it doesn't exist at all
  • if ( !navigator.registerProtocolHandler ) return false;
  • // registerProtocolHandler was stubbed in webkit for a while, and didn't
  • // actually do anything. We intentionally set it improperly to test for
  • // the proper sort of failure
  • try {
  •  navigator.registerProtocolHandler('thisShouldFail');
    
  • }
  • catch (e) {
  •  return e instanceof TypeError;
    
  • }

Fancy sticking a return false; here, just in case some browser for some
reason doesn't throw an error on L32?

Reply to this email directly or view it on GitHubhttps://github.com/Modernizr/Modernizr/pull/992/files#r10265252
.

patrick

@patrickkettner patrickkettner improve custom-protocol-handler.js
As documented in the Undetectables -
https://github.com/Modernizr/Modernizr/wiki/Undetectables -
navigator.registerProtocolHandler was stubbed in webkit for a while, and
doesn't actually do anything there. This test forces a failure and ensures it's
the right type of failure.
ad6ab10
@patrickkettner
Member

updatleydoodled

@stucox
Member
stucox commented Mar 6, 2014

Good things.

Minor thing, for discussion really – I wonder if we should avoid linebreaks (except where we want paragraph breaks) in our DOC block – seeing that we extract those and push them through a Markdown parser, I think line breaks might be interpreted as new paragraphs. Although I haven’t checked this and probably should have done before saying this.

@patrickkettner
Member

seems like they are

simple fix, will PR soon. this is good to merge?

@patrickkettner patrickkettner merged commit 30b5d55 into Modernizr:master Mar 7, 2014

1 check passed

default The Travis CI build passed
Details
@patrickkettner patrickkettner deleted the patrickkettner:registerProtocolHandler branch Mar 7, 2014
@stucox
Member
stucox commented Mar 7, 2014

👍

@stucox stucox referenced this pull request May 21, 2014
Closed

v3.0 release notes #805

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment