| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../resources/js-test.js"></script> | 3 <script src="/js-test-resources/js-test.js"></script> |
| 4 </head> | 4 </head> |
| 5 <body> | 5 <body> |
| 6 <p>This test makes sure that navigator.registerProtocolHandler throws the proper
exceptions and has no-op default implementation.</p> | 6 <p>This test makes sure that navigator.registerProtocolHandler throws the proper
exceptions and has no-op default implementation.</p> |
| 7 <pre id="console"></pre> | 7 <pre id="console"></pre> |
| 8 <script> | 8 <script> |
| 9 if (window.testRunner) | |
| 10 testRunner.dumpAsText(); | |
| 11 | |
| 12 if (window.internals) | 9 if (window.internals) |
| 13 internals.setNavigatorContentUtilsClientMock(document); | 10 internals.setNavigatorContentUtilsClientMock(document); |
| 14 | 11 |
| 15 if (window.navigator.registerProtocolHandler) | 12 if (window.navigator.registerProtocolHandler) |
| 16 debug('PASS window.navigator.registerProtocolHandler is defined.'); | 13 debug('PASS window.navigator.registerProtocolHandler is defined.'); |
| 17 else | 14 else |
| 18 debug('FAIL window.navigator.registerProtocolHandler is not defined.'); | 15 debug('FAIL window.navigator.registerProtocolHandler is not defined.'); |
| 19 | 16 |
| 20 var invalid_schemes = ['http', 'https', 'file', 'web+']; | 17 var invalid_schemes = ['http', 'https', 'file', 'web+']; |
| 21 invalid_schemes.forEach(function (scheme) { | 18 invalid_schemes.forEach(function (scheme) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 succeeded = 'SyntaxError' == e.name; | 72 succeeded = 'SyntaxError' == e.name; |
| 76 errorMessage = e.message; | 73 errorMessage = e.message; |
| 77 } | 74 } |
| 78 | 75 |
| 79 if (succeeded) | 76 if (succeeded) |
| 80 debug('PASS Invalid url "' + url + '" threw SyntaxError exception: "' +
errorMessage + '".'); | 77 debug('PASS Invalid url "' + url + '" threw SyntaxError exception: "' +
errorMessage + '".'); |
| 81 else | 78 else |
| 82 debug('FAIL Invalid url "' + url + '" allowed.'); | 79 debug('FAIL Invalid url "' + url + '" allowed.'); |
| 83 }); | 80 }); |
| 84 | 81 |
| 82 // Test that the API throws SecurityError exception if the URL's origin differs
from the document's origin. |
| 83 succeeded = false; |
| 84 var errorMessage; |
| 85 try { |
| 86 window.navigator.registerProtocolHandler('web+myprotocol', "http://www.examp
le.com/soup?url=%s", "title"); |
| 87 } catch (e) { |
| 88 succeeded = true; |
| 89 errorMessage = e.message; |
| 90 } |
| 91 |
| 92 if (succeeded) |
| 93 debug('PASS URL with origin different than document origin threw SecurityErr
or exception: "' + errorMessage + '".'); |
| 94 else |
| 95 debug('FAIL URL with origin different than document origin is allowed.'); |
| 96 |
| 85 // Test that the API has default no-op implementation. | 97 // Test that the API has default no-op implementation. |
| 86 var succeeded = true; | 98 var succeeded = true; |
| 87 try { | 99 try { |
| 88 window.navigator.registerProtocolHandler('web+myscheme', "%s", "title"); | 100 window.navigator.registerProtocolHandler('web+myscheme', "%s", "title"); |
| 89 } catch (e) { | 101 } catch (e) { |
| 90 succeeded = false; | 102 succeeded = false; |
| 91 } | 103 } |
| 92 | 104 |
| 93 if (succeeded) | 105 if (succeeded) |
| 94 debug('PASS Valid call succeeded.'); | 106 debug('PASS Valid call succeeded.'); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 110 else if (state == "declined") | 122 else if (state == "declined") |
| 111 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin
ed' state. Fail to register 'bitcoin' scheme"); | 123 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin
ed' state. Fail to register 'bitcoin' scheme"); |
| 112 } catch (e) { | 124 } catch (e) { |
| 113 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "'
+ e.message + '".'); | 125 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "'
+ e.message + '".'); |
| 114 } | 126 } |
| 115 debug("\n"); | 127 debug("\n"); |
| 116 | 128 |
| 117 </script> | 129 </script> |
| 118 </body> | 130 </body> |
| 119 </html> | 131 </html> |
| OLD | NEW |