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

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

Issue 130823002: Fix *Fail* tests in unregisterProtocolHandler test (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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/unregister-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.unregisterProtocolHandler throws the prop er exceptions and has no-op default implementation.</p> 3 <p>This test makes sure that navigator.unregisterProtocolHandler throws the prop er 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.unregisterProtocolHandler) 15 if (window.navigator.unregisterProtocolHandler)
16 debug('Pass: window.navigator.unregisterProtocolHandler is defined.'); 16 debug('Pass: window.navigator.unregisterProtocolHandler is defined.');
17 else 17 else
18 debug('Fail: window.navigator.unregisterProtocolHandler is not defined.'); 18 debug('Fail: window.navigator.unregisterProtocolHandler 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 try { 23 try {
24 window.navigator.unregisterProtocolHandler(protocol, "invalid protocol % s", "title"); 24 window.navigator.unregisterProtocolHandler(protocol, "invalid protocol % s", "title");
25 } catch (e) { 25 } catch (e) {
26 succeeded = 'SecurityError' == e.name; 26 succeeded = 'SecurityError' == e.name;
27 errorMessage = e.message;
27 } 28 }
28 29
29 if (succeeded) 30 if (succeeded)
30 debug('Pass: Invalid protocol "' + protocol + '" threw SecurityError exc eption.'); 31 debug('Pass: Invalid protocol "' + protocol + '" threw SecurityError exc eption: "' + errorMessage + '".');
31 else 32 else
32 debug('Fail: Invalid protocol "' + protocol + '" allowed.'); 33 debug('Fail: Invalid protocol "' + protocol + '" allowed.');
33 }); 34 });
34 35
35 var valid_protocols = ['bitcoin', 'geo', 'im', 'irc', 'ircs', 'magnet', 'mailto' , 'mms', 'news', 'nntp', 'sip', 'sms', 'smsto', 'ssh', 'tel', 'urn', 'webcal', ' wtai', 'xmpp']; 36 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) { 37 valid_protocols.forEach(function (protocol) {
37 var succeeded = false; 38 var succeeded = false;
38 try { 39 try {
39 window.navigator.unregisterProtocolHandler(protocol, "valid protocol %s" , "title"); 40 window.navigator.unregisterProtocolHandler(protocol, "valid protocol %s" , "title");
40 succeeded = true; 41 succeeded = true;
41 } catch (e) { 42 } catch (e) {
42 succeeded = false; 43 succeeded = false;
43 } 44 }
44 45
45 if (succeeded) 46 if (succeeded)
46 debug('Pass: Valid protocol "' + protocol + '" allowed.'); 47 debug('Pass: Valid protocol "' + protocol + '" allowed.');
47 else 48 else
48 debug('Fail: Valid protocol "' + protocol + '" failed.'); 49 debug('Fail: Valid protocol "' + protocol + '" failed.');
49 }); 50 });
50 51
51 var invalid_urls = ["", "%S"]; 52 var invalid_urls = ["", "%S"];
52 invalid_urls.forEach(function (url) { 53 invalid_urls.forEach(function (url) {
53 var succeeded = false; 54 var succeeded = false;
54 try { 55 try {
55 window.navigator.unregisterProtocolHandler('web+myprotocol', url, 'title '); 56 window.navigator.unregisterProtocolHandler('web+myprotocol', url, 'title ');
56 } catch (e) { 57 } catch (e) {
57 succeeded = 'SYNTAX_ERR' == e.name; 58 succeeded = 'SyntaxError' == e.name;
59 errorMessage = e.message;
58 } 60 }
59 61
60 if (succeeded) 62 if (succeeded)
61 debug('Pass: Invalid url "' + url + '" threw SYNTAX_ERR exception.'); 63 debug('Pass: Invalid url "' + url + '" threw SyntaxError exception.' + e rrorMessage + '".');
62 else 64 else
63 debug('Fail: Invalid url "' + url + '" allowed.'); 65 debug('Fail: Invalid url "' + url + '" allowed.');
64 }); 66 });
65 67
66 // Test that the API has default no-op implementation. 68 // Test that the API has default no-op implementation.
67 var succeeded = true; 69 var succeeded = true;
68 try { 70 try {
69 window.navigator.unregisterProtocolHandler('web+myprotocol', "%s", "title"); 71 window.navigator.unregisterProtocolHandler('web+myprotocol', "%s", "title");
70 } catch (e) { 72 } catch (e) {
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/unregister-protocol-handler-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698