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

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

Issue 298273008: Improve scheme validation check in NavigatorContentUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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
OLDNEW
1 <html> 1 <html>
2 <body> 2 <body>
3 <p>This test makes sure that navigator.registerProtocolHandler throws the proper exceptions and has no-op default implementation.</p> 3 <p>This test makes sure that navigator.registerProtocolHandler throws the proper exceptions and has no-op default implementation.</p>
4 <pre id="console"></pre> 4 <pre id="console"></pre>
5 <script> 5 <script>
6 if (window.testRunner) 6 if (window.testRunner)
7 testRunner.dumpAsText(); 7 testRunner.dumpAsText();
8 8
9 function debug(str) 9 function debug(str)
10 { 10 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 else 49 else
50 debug('Fail: Valid protocol "' + protocol + '" failed.'); 50 debug('Fail: Valid protocol "' + protocol + '" failed.');
51 }); 51 });
52 52
53 var invalid_schemes = ['mailto:', 'ssh:/', 'magnet:+', 'tel:sip']; 53 var invalid_schemes = ['mailto:', 'ssh:/', 'magnet:+', 'tel:sip'];
54 invalid_schemes.forEach(function (scheme) { 54 invalid_schemes.forEach(function (scheme) {
55 var succeeded = false; 55 var succeeded = false;
56 try { 56 try {
57 window.navigator.registerProtocolHandler(scheme, 'invalid scheme uri=%s' , 'title'); 57 window.navigator.registerProtocolHandler(scheme, 'invalid scheme uri=%s' , 'title');
58 } catch (e) { 58 } catch (e) {
59 succeeded = true; 59 succeeded = 'SyntaxError' == e.name;
60 errorMessage = e.message;
60 } 61 }
61 62
62 if (succeeded) 63 if (succeeded)
63 debug('Pass: Invalid scheme "' + scheme + '" falied.'); 64 debug('Pass: Invalid scheme "' + scheme + '" falied.');
64 else 65 else
65 debug('Fail: Invalid scheme "' + scheme + '" allowed.'); 66 debug('Fail: Invalid scheme "' + scheme + '" allowed. Threw exception: " ' + errorMessage + '".');
66 }); 67 });
67 68
68 var invalid_urls = ["", "%S"]; 69 var invalid_urls = ["", "%S"];
69 invalid_urls.forEach(function (url) { 70 invalid_urls.forEach(function (url) {
70 var succeeded = false; 71 var succeeded = false;
71 try { 72 try {
72 window.navigator.registerProtocolHandler('web+myprotocol', url, 'title') ; 73 window.navigator.registerProtocolHandler('web+myprotocol', url, 'title') ;
73 } catch (e) { 74 } catch (e) {
74 succeeded = 'SyntaxError' == e.name; 75 succeeded = 'SyntaxError' == e.name;
75 errorMessage = e.message; 76 errorMessage = e.message;
(...skipping 13 matching lines...) Expand all
89 succeeded = false; 90 succeeded = false;
90 } 91 }
91 92
92 if (succeeded) 93 if (succeeded)
93 debug('Pass: Valid call succeeded.'); 94 debug('Pass: Valid call succeeded.');
94 else 95 else
95 debug('Fail: Invalid call did not succeed.'); 96 debug('Fail: Invalid call did not succeed.');
96 </script> 97 </script>
97 </body> 98 </body>
98 </html> 99 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698