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

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

Issue 22791007: Improve SecurityError message on verifyProtocolHandlerScheme() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 4 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/register-protocol-handler-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 <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 {
11 var c = document.getElementById('console') 11 var c = document.getElementById('console')
12 c.appendChild(document.createTextNode(str + '\n')); 12 c.appendChild(document.createTextNode(str + '\n'));
13 } 13 }
14 14
15 if (window.navigator.registerProtocolHandler) 15 if (window.navigator.registerProtocolHandler)
16 debug('Pass: window.navigator.registerProtocolHandler is defined.'); 16 debug('Pass: window.navigator.registerProtocolHandler is defined.');
17 else 17 else
18 debug('Fail: window.navigator.registerProtocolHandler is not defined.'); 18 debug('Fail: window.navigator.registerProtocolHandler is not defined.');
19 19
20 var invalid_protocols = ['http', 'https', 'file', 'web+']; 20 var invalid_protocols = ['http', 'https', 'file', 'web+'];
21 invalid_protocols.forEach(function (protocol) { 21 invalid_protocols.forEach(function (protocol) {
22 var succeeded = false; 22 var succeeded = false;
23 var errorMessage;
23 try { 24 try {
24 window.navigator.registerProtocolHandler(protocol, "invalid protocol %s" , "title"); 25 window.navigator.registerProtocolHandler(protocol, "invalid protocol %s" , "title");
25 } catch (e) { 26 } catch (e) {
26 succeeded = 'SecurityError' == e.name; 27 succeeded = 'SecurityError' == e.name;
28 errorMessage = e.message;
27 } 29 }
28 30
29 if (succeeded) 31 if (succeeded) {
30 debug('Pass: Invalid protocol "' + protocol + '" threw SecurityError exc eption.'); 32 debug('Pass: Invalid protocol "' + protocol + '" threw SecurityError exc eption: "' + errorMessage + '".');
31 else 33 }else
32 debug('Fail: Invalid protocol "' + protocol + '" allowed.'); 34 debug('Fail: Invalid protocol "' + protocol + '" allowed.');
33 }); 35 });
34 36
35 var valid_protocols = ['bitcoin', 'geo', 'im', 'irc', 'ircs', 'magnet', 'mailto' , 'mms', 'news', 'nntp', 'sip', 'sms', 'smsto', 'ssh', 'tel', 'urn', 'webcal', ' wtai', 'xmpp']; 37 var valid_protocols = ['bitcoin', 'geo', 'im', 'irc', 'ircs', 'magnet', 'mailto' , 'mms', 'news', 'nntp', 'sip', 'sms', 'smsto', 'ssh', 'tel', 'urn', 'webcal', ' wtai', 'xmpp'];
36 valid_protocols.forEach(function (protocol) { 38 valid_protocols.forEach(function (protocol) {
37 var succeeded = false; 39 var succeeded = false;
38 try { 40 try {
39 window.navigator.registerProtocolHandler(protocol, "valid protocol %s", "title"); 41 window.navigator.registerProtocolHandler(protocol, "valid protocol %s", "title");
40 succeeded = true; 42 succeeded = true;
41 } catch (e) { 43 } catch (e) {
(...skipping 29 matching lines...) Expand all
71 succeeded = false; 73 succeeded = false;
72 } 74 }
73 75
74 if (succeeded) 76 if (succeeded)
75 debug('Pass: Valid call succeeded.'); 77 debug('Pass: Valid call succeeded.');
76 else 78 else
77 debug('Fail: Invalid call did not succeed.'); 79 debug('Fail: Invalid call did not succeed.');
78 </script> 80 </script>
79 </body> 81 </body>
80 </html> 82 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/register-protocol-handler-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698