| 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) { |
| 11 testRunner.setAllowUniversalAccessFromFileURLs(false); |
| 11 testRunner.dumpAsText(); | 12 testRunner.dumpAsText(); |
| 13 } |
| 12 | 14 |
| 13 if (window.internals) | 15 if (window.internals) |
| 14 internals.setNavigatorContentUtilsClientMock(document); | 16 internals.setNavigatorContentUtilsClientMock(document); |
| 15 | 17 |
| 16 if (window.navigator.isProtocolHandlerRegistered) | 18 if (window.navigator.isProtocolHandlerRegistered) |
| 17 debug('PASS window.navigator.isProtocolHandlerRegistered is defined.'); | 19 debug('PASS window.navigator.isProtocolHandlerRegistered is defined.'); |
| 18 else | 20 else |
| 19 debug('FAIL window.navigator.isProtocolHandlerRegistered is not defined.'); | 21 debug('FAIL window.navigator.isProtocolHandlerRegistered is not defined.'); |
| 20 | 22 |
| 21 var invalidUrl = "%S"; | 23 var invalidUrl = "%S"; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 40 succeeded = 'SecurityError' == e.name; | 42 succeeded = 'SecurityError' == e.name; |
| 41 errorMessage = e.message; | 43 errorMessage = e.message; |
| 42 } | 44 } |
| 43 | 45 |
| 44 if (succeeded) | 46 if (succeeded) |
| 45 debug('PASS Invalid scheme "' + scheme + '" falied.'); | 47 debug('PASS Invalid scheme "' + scheme + '" falied.'); |
| 46 else | 48 else |
| 47 debug('FAIL Invalid scheme "' + scheme + '" allowed. Threw exception: "'
+ errorMessage + '".'); | 49 debug('FAIL Invalid scheme "' + scheme + '" allowed. Threw exception: "'
+ errorMessage + '".'); |
| 48 }); | 50 }); |
| 49 | 51 |
| 52 // Test that the API throws SecurityError exception if the URL's origin differs
from the document's origin. |
| 53 succeeded = false; |
| 54 var errorMessage; |
| 55 try { |
| 56 window.navigator.isProtocolHandlerRegistered('web+myprotocol', "http://www.e
xample.com/soup?url=%s"); |
| 57 } catch (e) { |
| 58 succeeded = true; |
| 59 errorMessage = e.message; |
| 60 } |
| 61 |
| 62 if (succeeded) |
| 63 debug('PASS URL with origin different than document origin threw SecurityErr
or exception: "' + errorMessage + '".'); |
| 64 else |
| 65 debug('FAIL URL with origin different than document origin is allowed.'); |
| 66 |
| 50 debug("\nCheck if isProtocolHandlerRegistered() works correctly. If isProtocolHa
ndlerRegistered() returns 'new' state, it works well."); | 67 debug("\nCheck if isProtocolHandlerRegistered() works correctly. If isProtocolHa
ndlerRegistered() returns 'new' state, it works well."); |
| 51 debug("'bitcoin' protocol will be registered, and then checks if the 'bitcoin' p
rotocol is registered by isProtocolHandlerRegistered().\n"); | 68 debug("'bitcoin' protocol will be registered, and then checks if the 'bitcoin' p
rotocol is registered by isProtocolHandlerRegistered().\n"); |
| 52 try { | 69 try { |
| 53 // Register 'bitcoin' protocol for testing. | 70 // Register 'bitcoin' protocol for testing. |
| 54 window.navigator.registerProtocolHandler('bitcoin', 'invalid scheme uri=%s',
'title'); | 71 window.navigator.registerProtocolHandler('bitcoin', 'invalid scheme uri=%s',
'title'); |
| 55 | 72 |
| 56 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p
rotocol %s"); | 73 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p
rotocol %s"); |
| 57 if (state == "registered") | 74 if (state == "registered") |
| 58 debug("PASS window.navigator.isProtocolHandlerRegistered returns 'regist
ered' state. isProtocolHandlerRegistered() works correctly."); | 75 debug("PASS window.navigator.isProtocolHandlerRegistered returns 'regist
ered' state. isProtocolHandlerRegistered() works correctly."); |
| 59 else if (state == "new") | 76 else if (state == "new") |
| 60 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'new' s
tate."); | 77 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'new' s
tate."); |
| 61 else if (state == "declined") | 78 else if (state == "declined") |
| 62 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin
ed' state."); | 79 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin
ed' state."); |
| 63 } catch (e) { | 80 } catch (e) { |
| 64 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "'
+ e.message + '".'); | 81 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "'
+ e.message + '".'); |
| 65 } | 82 } |
| 66 debug("\n"); | 83 debug("\n"); |
| 67 | 84 |
| 68 </script> | 85 </script> |
| 69 </body> | 86 </body> |
| 70 </html> | 87 </html> |
| OLD | NEW |