OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <p>This test makes sure that navigator.isProtocolHandlerRegistered throws the pr
oper exceptions and returns the default state of handler.</p> | 7 <p>This test makes sure that navigator.isProtocolHandlerRegistered throws the pr
oper exceptions and returns the default state of handler.</p> |
8 <pre id="console"></pre> | 8 <pre id="console"></pre> |
9 <script> | 9 <script> |
10 if (window.testRunner) | 10 if (window.testRunner) |
(...skipping 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 if (succeeded) | 26 if (succeeded) |
27 debug('PASS Invalid url "' + invalidUrl + '" threw SyntaxError exception.'); | 27 debug('PASS Invalid url "' + invalidUrl + '" threw SyntaxError exception.'); |
28 else | 28 else |
29 debug('FAIL Invalid url "' + invalidUrl + '" allowed.'); | 29 debug('FAIL Invalid url "' + invalidUrl + '" allowed.'); |
30 | 30 |
31 var invalid_schemes = ['mailto:', 'ssh:/', 'magnet:+', 'tel:sip']; | 31 var invalid_schemes = ['mailto:', 'ssh:/', 'magnet:+', 'tel:sip']; |
32 invalid_schemes.forEach(function (scheme) { | 32 invalid_schemes.forEach(function (scheme) { |
33 var succeeded = false; | 33 var succeeded = false; |
34 try { | 34 try { |
35 window.navigator.registerProtocolHandler(scheme, 'invalid scheme uri=%s'
, 'title'); | 35 window.navigator.isProtocolHandlerRegistered(scheme, 'invalid scheme uri
=%s'); |
36 } catch (e) { | 36 } catch (e) { |
37 succeeded = true; | 37 succeeded = 'SyntaxError' == e.name; |
| 38 errorMessage = e.message; |
38 } | 39 } |
39 | 40 |
40 if (succeeded) | 41 if (succeeded) |
41 debug('PASS Invalid scheme "' + scheme + '" falied.'); | 42 debug('PASS Invalid scheme "' + scheme + '" falied.'); |
42 else | 43 else |
43 debug('FAIL Invalid scheme "' + scheme + '" allowed.'); | 44 debug('FAIL Invalid scheme "' + scheme + '" allowed. Threw exception: "'
+ errorMessage + '".'); |
44 }); | 45 }); |
45 | 46 |
46 // FIXME: Need to check if this function can return 'registered' and 'declined'
states as well. | 47 // FIXME: Need to check if this function can return 'registered' and 'declined'
states as well. |
47 try { | 48 try { |
48 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p
rotocol %s"); | 49 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p
rotocol %s"); |
49 if (state == "new") | 50 if (state == "new") |
50 debug('PASS window.navigator.isProtocolHandlerRegistered returns "new" s
tate'); | 51 debug('PASS window.navigator.isProtocolHandlerRegistered returns "new" s
tate'); |
51 else | 52 else |
52 debug("FAIL window.navigator.isProtocolHandlerRegistered doesn't return
the default state."); | 53 debug("FAIL window.navigator.isProtocolHandlerRegistered doesn't return
the default state."); |
53 } catch (e) { | 54 } catch (e) { |
54 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "'
+ e.message + '".'); | 55 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "'
+ e.message + '".'); |
55 } | 56 } |
56 </script> | 57 </script> |
57 </body> | 58 </body> |
58 </html> | 59 </html> |
OLD | NEW |