| 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.unregisterProtocolHandler throws the prop
er exceptions and has no-op default implementation.</p> | 6 <p>This test makes sure that navigator.unregisterProtocolHandler throws the prop
er 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.unregisterProtocolHandler) | 12 if (window.navigator.unregisterProtocolHandler) |
| 16 debug('PASS window.navigator.unregisterProtocolHandler is defined.'); | 13 debug('PASS window.navigator.unregisterProtocolHandler is defined.'); |
| 17 else | 14 else |
| 18 debug('FAIL window.navigator.unregisterProtocolHandler is not defined.'); | 15 debug('FAIL window.navigator.unregisterProtocolHandler 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 succeeded = 'SyntaxError' == e.name; | 71 succeeded = 'SyntaxError' == e.name; |
| 75 errorMessage = e.message; | 72 errorMessage = e.message; |
| 76 } | 73 } |
| 77 | 74 |
| 78 if (succeeded) | 75 if (succeeded) |
| 79 debug('PASS Invalid url "' + url + '" threw SyntaxError exception.' + er
rorMessage + '".'); | 76 debug('PASS Invalid url "' + url + '" threw SyntaxError exception.' + er
rorMessage + '".'); |
| 80 else | 77 else |
| 81 debug('FAIL Invalid url "' + url + '" allowed.'); | 78 debug('FAIL Invalid url "' + url + '" allowed.'); |
| 82 }); | 79 }); |
| 83 | 80 |
| 81 // Test that the API throws SecurityError exception if the URL's origin differs
from the document's origin. |
| 82 succeeded = false; |
| 83 var errorMessage; |
| 84 try { |
| 85 window.navigator.unregisterProtocolHandler('web+myprotocol', "http://www.exa
mple.com/soup?url=%s", "title"); |
| 86 } catch (e) { |
| 87 succeeded = true; |
| 88 errorMessage = e.message; |
| 89 } |
| 90 |
| 91 if (succeeded) |
| 92 debug('PASS URL with origin different than document origin threw SecurityErr
or exception: "' + errorMessage + '".'); |
| 93 else |
| 94 debug('FAIL URL with origin different than document origin is allowed.'); |
| 95 |
| 84 // Test that the API has default no-op implementation. | 96 // Test that the API has default no-op implementation. |
| 85 var succeeded = true; | 97 var succeeded = true; |
| 86 try { | 98 try { |
| 87 window.navigator.unregisterProtocolHandler('web+myscheme', "%s", "title"); | 99 window.navigator.unregisterProtocolHandler('web+myscheme', "%s", "title"); |
| 88 } catch (e) { | 100 } catch (e) { |
| 89 succeeded = false; | 101 succeeded = false; |
| 90 } | 102 } |
| 91 | 103 |
| 92 if (succeeded) | 104 if (succeeded) |
| 93 debug('PASS Valid call succeeded.'); | 105 debug('PASS Valid call succeeded.'); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 117 else if (state == "declined") | 129 else if (state == "declined") |
| 118 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin
ed' state. Fail to unregister 'bitcoin' scheme."); | 130 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin
ed' state. Fail to unregister 'bitcoin' scheme."); |
| 119 } catch (e) { | 131 } catch (e) { |
| 120 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "'
+ e.message + '".'); | 132 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "'
+ e.message + '".'); |
| 121 } | 133 } |
| 122 debug("\n"); | 134 debug("\n"); |
| 123 | 135 |
| 124 </script> | 136 </script> |
| 125 </body> | 137 </body> |
| 126 </html> | 138 </html> |
| OLD | NEW |