| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <body> | 2 <body> |
| 3 <p>This test makes sure that navigator.unregisterProtocolHandler throws the prop
er exceptions and has no-op default implementation.</p> | 3 <p>This test makes sure that navigator.unregisterProtocolHandler throws the prop
er exceptions and has no-op default implementation.</p> |
| 4 <pre id="console"></pre> | 4 <pre id="console"></pre> |
| 5 <script> | 5 <script> |
| 6 if (window.testRunner) | 6 if (window.testRunner) |
| 7 testRunner.dumpAsText(); | 7 testRunner.dumpAsText(); |
| 8 | 8 |
| 9 function debug(str) | 9 function debug(str) |
| 10 { | 10 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 if (succeeded) | 46 if (succeeded) |
| 47 debug('Pass: Valid protocol "' + protocol + '" allowed.'); | 47 debug('Pass: Valid protocol "' + protocol + '" allowed.'); |
| 48 else | 48 else |
| 49 debug('Fail: Valid protocol "' + protocol + '" failed.'); | 49 debug('Fail: Valid protocol "' + protocol + '" failed.'); |
| 50 }); | 50 }); |
| 51 | 51 |
| 52 var invalid_schemes = ['mailto:', 'ssh:/', 'magnet:+', 'tel:sip']; | 52 var invalid_schemes = ['mailto:', 'ssh:/', 'magnet:+', 'tel:sip']; |
| 53 invalid_schemes.forEach(function (scheme) { | 53 invalid_schemes.forEach(function (scheme) { |
| 54 var succeeded = false; | 54 var succeeded = false; |
| 55 try { | 55 try { |
| 56 window.navigator.registerProtocolHandler(scheme, 'invalid scheme uri=%s'
, 'title'); | 56 window.navigator.unregisterProtocolHandler(scheme, 'invalid scheme uri=%
s', 'title'); |
| 57 } catch (e) { | 57 } catch (e) { |
| 58 succeeded = true; | 58 succeeded = 'SyntaxError' == e.name; |
| 59 errorMessage = e.message; |
| 59 } | 60 } |
| 60 | 61 |
| 61 if (succeeded) | 62 if (succeeded) |
| 62 debug('Pass: Invalid scheme "' + scheme + '" falied.'); | 63 debug('Pass: Invalid scheme "' + scheme + '" falied.'); |
| 63 else | 64 else |
| 64 debug('Fail: Invalid scheme "' + scheme + '" allowed.'); | 65 debug('Fail: Invalid scheme "' + scheme + '" allowed. Threw exception: "
' + errorMessage + '".'); |
| 65 }); | 66 }); |
| 66 | 67 |
| 67 var invalid_urls = ["", "%S"]; | 68 var invalid_urls = ["", "%S"]; |
| 68 invalid_urls.forEach(function (url) { | 69 invalid_urls.forEach(function (url) { |
| 69 var succeeded = false; | 70 var succeeded = false; |
| 70 try { | 71 try { |
| 71 window.navigator.unregisterProtocolHandler('web+myprotocol', url, 'title
'); | 72 window.navigator.unregisterProtocolHandler('web+myprotocol', url, 'title
'); |
| 72 } catch (e) { | 73 } catch (e) { |
| 73 succeeded = 'SyntaxError' == e.name; | 74 succeeded = 'SyntaxError' == e.name; |
| 74 errorMessage = e.message; | 75 errorMessage = e.message; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 88 succeeded = false; | 89 succeeded = false; |
| 89 } | 90 } |
| 90 | 91 |
| 91 if (succeeded) | 92 if (succeeded) |
| 92 debug('Pass: Valid call succeeded.'); | 93 debug('Pass: Valid call succeeded.'); |
| 93 else | 94 else |
| 94 debug('Fail: Invalid call did not succeed.'); | 95 debug('Fail: Invalid call did not succeed.'); |
| 95 </script> | 96 </script> |
| 96 </body> | 97 </body> |
| 97 </html> | 98 </html> |
| OLD | NEW |