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.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) | 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.registerProtocolHandler) | 17 if (window.navigator.registerProtocolHandler) |
16 debug('PASS window.navigator.registerProtocolHandler is defined.'); | 18 debug('PASS window.navigator.registerProtocolHandler is defined.'); |
17 else | 19 else |
18 debug('FAIL window.navigator.registerProtocolHandler is not defined.'); | 20 debug('FAIL window.navigator.registerProtocolHandler is not defined.'); |
19 | 21 |
20 var invalid_protocols = ['http', 'https', 'file', 'web+']; | 22 var invalid_protocols = ['http', 'https', 'file', 'web+']; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 succeeded = 'SyntaxError' == e.name; | 77 succeeded = 'SyntaxError' == e.name; |
76 errorMessage = e.message; | 78 errorMessage = e.message; |
77 } | 79 } |
78 | 80 |
79 if (succeeded) | 81 if (succeeded) |
80 debug('PASS Invalid url "' + url + '" threw SyntaxError exception: "' +
errorMessage + '".'); | 82 debug('PASS Invalid url "' + url + '" threw SyntaxError exception: "' +
errorMessage + '".'); |
81 else | 83 else |
82 debug('FAIL Invalid url "' + url + '" allowed.'); | 84 debug('FAIL Invalid url "' + url + '" allowed.'); |
83 }); | 85 }); |
84 | 86 |
| 87 // Test that the API throws SecurityError exception if the URL's origin differs
from the document's origin. |
| 88 succeeded = false; |
| 89 var errorMessage; |
| 90 try { |
| 91 window.navigator.registerProtocolHandler('web+myprotocol', "http://www.examp
le.com/soup?url=%s", "title"); |
| 92 } catch (e) { |
| 93 succeeded = true; |
| 94 errorMessage = e.message; |
| 95 } |
| 96 |
| 97 if (succeeded) |
| 98 debug('PASS URL with origin different than document origin threw SecurityErr
or exception: "' + errorMessage + '".'); |
| 99 else |
| 100 debug('FAIL URL with origin different than document origin is allowed.'); |
| 101 |
85 // Test that the API has default no-op implementation. | 102 // Test that the API has default no-op implementation. |
86 var succeeded = true; | 103 var succeeded = true; |
87 try { | 104 try { |
88 window.navigator.registerProtocolHandler('web+myprotocol', "%s", "title"); | 105 window.navigator.registerProtocolHandler('web+myprotocol', "%s", "title"); |
89 } catch (e) { | 106 } catch (e) { |
90 succeeded = false; | 107 succeeded = false; |
91 } | 108 } |
92 | 109 |
93 if (succeeded) | 110 if (succeeded) |
94 debug('PASS Valid call succeeded.'); | 111 debug('PASS Valid call succeeded.'); |
(...skipping 15 matching lines...) Expand all Loading... |
110 else if (state == "declined") | 127 else if (state == "declined") |
111 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin
ed' state. Fail to register 'bitcoin' protocol"); | 128 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin
ed' state. Fail to register 'bitcoin' protocol"); |
112 } catch (e) { | 129 } catch (e) { |
113 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "'
+ e.message + '".'); | 130 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "'
+ e.message + '".'); |
114 } | 131 } |
115 debug("\n"); | 132 debug("\n"); |
116 | 133 |
117 </script> | 134 </script> |
118 </body> | 135 </body> |
119 </html> | 136 </html> |
OLD | NEW |