Skip to content

Commit

Permalink
Merge pull request #992 from patrickkettner/registerProtocolHandler
Browse files Browse the repository at this point in the history
improve custom-protocol-handler.js
  • Loading branch information
patrickkettner committed Mar 7, 2014
2 parents 6714aa7 + ad6ab10 commit 30b5d55
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions feature-detects/custom-protocol-handler.js
Expand Up @@ -16,9 +16,25 @@
!*/
/* DOC
Detects support for the `window.registerProtocolHandler()` API to allow web sites to register themselves as possible handlers for particular protocols.
Detects support for the `window.registerProtocolHandler()` API to allow web
sites to register themselves as possible handlers for particular protocols.
*/
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;
}

return false;
});
});

0 comments on commit 30b5d55

Please sign in to comment.