Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1097)

Side by Side Diff: LayoutTests/fast/dom/navigatorcontentutils/is-protocol-handler-registered.html

Issue 292203007: Need to check invalid scheme in navigator content utils (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/navigatorcontentutils/is-protocol-handler-registered-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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)
(...skipping 10 matching lines...) Expand all
21 window.navigator.isProtocolHandlerRegistered(protocol, invalidUrl); 21 window.navigator.isProtocolHandlerRegistered(protocol, invalidUrl);
22 succeeded = false; 22 succeeded = false;
23 } catch (e) { 23 } catch (e) {
24 succeeded = true; 24 succeeded = true;
25 } 25 }
26 if (succeeded) 26 if (succeeded)
27 debug('PASS Invalid url "' + invalidUrl + '" threw SyntaxError exception.'); 27 debug('PASS Invalid url "' + invalidUrl + '" threw SyntaxError exception.');
28 else 28 else
29 debug('FAIL Invalid url "' + invalidUrl + '" allowed.'); 29 debug('FAIL Invalid url "' + invalidUrl + '" allowed.');
30 30
31 var invalid_schemes = ['mailto:', 'ssh:/', 'magnet:+', 'tel:sip'];
32 invalid_schemes.forEach(function (scheme) {
33 var succeeded = false;
34 try {
35 window.navigator.registerProtocolHandler(scheme, 'invalid scheme uri=%s' , 'title');
36 } catch (e) {
37 succeeded = true;
38 }
39
40 if (succeeded)
41 debug('PASS Invalid scheme "' + scheme + '" falied.');
42 else
43 debug('FAIL Invalid scheme "' + scheme + '" allowed.');
44 });
45
31 // FIXME: Need to check if this function can return 'registered' and 'declined' states as well. 46 // FIXME: Need to check if this function can return 'registered' and 'declined' states as well.
32 try { 47 try {
33 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p rotocol %s"); 48 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p rotocol %s");
34 if (state == "new") 49 if (state == "new")
35 debug('PASS window.navigator.isProtocolHandlerRegistered returns "new" s tate'); 50 debug('PASS window.navigator.isProtocolHandlerRegistered returns "new" s tate');
36 else 51 else
37 debug("FAIL window.navigator.isProtocolHandlerRegistered doesn't return the default state."); 52 debug("FAIL window.navigator.isProtocolHandlerRegistered doesn't return the default state.");
38 } catch (e) { 53 } catch (e) {
39 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".'); 54 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".');
40 } 55 }
41 </script> 56 </script>
42 </body> 57 </body>
43 </html> 58 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/navigatorcontentutils/is-protocol-handler-registered-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698