Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../resources/js-test.js"></script> | 3 <script src="../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) | 9 if (window.testRunner) { |
| 10 testRunner.setAllowUniversalAccessFromFileURLs(false); | |
| 10 testRunner.dumpAsText(); | 11 testRunner.dumpAsText(); |
| 12 } | |
| 11 | 13 |
| 12 if (window.internals) | 14 if (window.internals) |
| 13 internals.setNavigatorContentUtilsClientMock(document); | 15 internals.setNavigatorContentUtilsClientMock(document); |
| 14 | 16 |
| 15 if (window.navigator.unregisterProtocolHandler) | 17 if (window.navigator.unregisterProtocolHandler) |
| 16 debug('PASS window.navigator.unregisterProtocolHandler is defined.'); | 18 debug('PASS window.navigator.unregisterProtocolHandler is defined.'); |
| 17 else | 19 else |
| 18 debug('FAIL window.navigator.unregisterProtocolHandler is not defined.'); | 20 debug('FAIL window.navigator.unregisterProtocolHandler is not defined.'); |
| 19 | 21 |
| 20 var invalid_protocols = ['http', 'https', 'file', 'web+']; | 22 var invalid_protocols = ['http', 'https', 'file', 'web+']; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 succeeded = 'SyntaxError' == e.name; | 76 succeeded = 'SyntaxError' == e.name; |
| 75 errorMessage = e.message; | 77 errorMessage = e.message; |
| 76 } | 78 } |
| 77 | 79 |
| 78 if (succeeded) | 80 if (succeeded) |
| 79 debug('PASS Invalid url "' + url + '" threw SyntaxError exception.' + er rorMessage + '".'); | 81 debug('PASS Invalid url "' + url + '" threw SyntaxError exception.' + er rorMessage + '".'); |
| 80 else | 82 else |
| 81 debug('FAIL Invalid url "' + url + '" allowed.'); | 83 debug('FAIL Invalid url "' + url + '" allowed.'); |
| 82 }); | 84 }); |
| 83 | 85 |
| 86 // Test that the API throws SecurityError exception if the URL's origin differs from the document's origin. | |
| 87 succeeded = false; | |
| 88 var errorMessage; | |
| 89 try { | |
| 90 window.navigator.unregisterProtocolHandler('web+myprotocol', "http://www.exa mple.com/soup?url=%s", "title"); | |
| 91 } catch (e) { | |
| 92 succeeded = true; | |
| 93 errorMessage = e.message; | |
| 94 } | |
| 95 | |
| 96 if (succeeded) | |
| 97 debug('PASS Invalid url threw SecurityError exception: "' + errorMessage + ' ".'); | |
|
gyuyoung-inactive
2014/07/23 00:07:12
ditto.
pals
2014/07/23 05:39:29
Done.
| |
| 98 else | |
| 99 debug('FAIL URL with origin different than document origin is allowed.'); | |
| 100 | |
| 84 // Test that the API has default no-op implementation. | 101 // Test that the API has default no-op implementation. |
| 85 var succeeded = true; | 102 var succeeded = true; |
| 86 try { | 103 try { |
| 87 window.navigator.unregisterProtocolHandler('web+myprotocol', "%s", "title"); | 104 window.navigator.unregisterProtocolHandler('web+myprotocol', "%s", "title"); |
| 88 } catch (e) { | 105 } catch (e) { |
| 89 succeeded = false; | 106 succeeded = false; |
| 90 } | 107 } |
| 91 | 108 |
| 92 if (succeeded) | 109 if (succeeded) |
| 93 debug('PASS Valid call succeeded.'); | 110 debug('PASS Valid call succeeded.'); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 117 else if (state == "declined") | 134 else if (state == "declined") |
| 118 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin ed' state. Fail to unregister 'bitcoin' protocol."); | 135 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin ed' state. Fail to unregister 'bitcoin' protocol."); |
| 119 } catch (e) { | 136 } catch (e) { |
| 120 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".'); | 137 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".'); |
| 121 } | 138 } |
| 122 debug("\n"); | 139 debug("\n"); |
| 123 | 140 |
| 124 </script> | 141 </script> |
| 125 </body> | 142 </body> |
| 126 </html> | 143 </html> |
| OLD | NEW |