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

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

Issue 23135009: Improve IDB module's SecurityError messages. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: test 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 | Annotate | Revision Log
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 <script src="../js/resources/js-test-pre.js"></script>
4 <pre id="console"></pre>
5 <script> 4 <script>
6 if (window.testRunner) 5 description("This test makes sure that navigator.registerProtocolHandler thr ows the proper exceptions and has no-op default implementation.");
7 testRunner.dumpAsText();
8 6
9 function debug(str) 7 if (window.navigator.registerProtocolHandler)
10 { 8 testPassed('window.navigator.registerProtocolHandler is defined.');
11 var c = document.getElementById('console') 9 else
12 c.appendChild(document.createTextNode(str + '\n')); 10 testFailed('window.navigator.registerProtocolHandler is not defined.');
13 }
14 11
15 if (window.navigator.registerProtocolHandler) 12 var protocol;
16 debug('Pass: window.navigator.registerProtocolHandler is defined.'); 13 var invalid_protocols = ['http', 'https', 'file', 'web+'];
17 else 14 invalid_protocols.forEach(function (protocol) {
18 debug('Fail: window.navigator.registerProtocolHandler is not defined.'); 15 shouldThrow("window.navigator.registerProtocolHandler('" + protocol + "' , 'invalid protocol %s', 'title');");
16 });
19 17
20 var invalid_protocols = ['http', 'https', 'file', 'web+']; 18 var valid_protocols = ['bitcoin', 'geo', 'im', 'irc', 'ircs', 'magnet', 'mai lto', 'mms', 'news', 'nntp', 'sip', 'sms', 'smsto', 'ssh', 'tel', 'urn', 'webcal ', 'wtai', 'xmpp'];
21 invalid_protocols.forEach(function (protocol) { 19 valid_protocols.forEach(function (protocol) {
22 var succeeded = false; 20 shouldNotThrow("window.navigator.registerProtocolHandler('" + protocol + "', 'valid protocol %s', 'title');");
23 try { 21 });
24 window.navigator.registerProtocolHandler(protocol, "invalid protocol %s" , "title");
25 } catch (e) {
26 succeeded = 'SecurityError' == e.name;
27 }
28 22
29 if (succeeded) 23 var invalid_urls = ["", "%S"];
30 debug('Pass: Invalid protocol "' + protocol + '" threw SecurityError exc eption.'); 24 invalid_urls.forEach(function (url) {
31 else 25 shouldThrow("window.navigator.registerProtocolHandler('web+myprotocol', '" + url + "', 'title');");
32 debug('Fail: Invalid protocol "' + protocol + '" allowed.'); 26 });
33 });
34 27
35 var valid_protocols = ['bitcoin', 'geo', 'im', 'irc', 'ircs', 'magnet', 'mailto' , 'mms', 'news', 'nntp', 'sip', 'sms', 'smsto', 'ssh', 'tel', 'urn', 'webcal', ' wtai', 'xmpp']; 28 // Test that the API has default no-op implementation.
36 valid_protocols.forEach(function (protocol) { 29 shouldNotThrow("window.navigator.registerProtocolHandler('web+myprotocol', ' %s', 'title');");
37 var succeeded = false;
38 try {
39 window.navigator.registerProtocolHandler(protocol, "valid protocol %s", "title");
40 succeeded = true;
41 } catch (e) {
42 succeeded = false;
43 }
44
45 if (succeeded)
46 debug('Pass: Valid protocol "' + protocol + '" allowed.');
47 else
48 debug('Fail: Valid protocol "' + protocol + '" failed.');
49 });
50
51 var invalid_urls = ["", "%S"];
52 invalid_urls.forEach(function (url) {
53 var succeeded = false;
54 try {
55 window.navigator.registerProtocolHandler('web+myprotocol', url, 'title') ;
56 } catch (e) {
57 succeeded = 'SyntaxError' == e.name;
58 }
59
60 if (succeeded)
61 debug('Pass: Invalid url "' + url + '" threw SyntaxError exception.');
62 else
63 debug('Fail: Invalid url "' + url + '" allowed.');
64 });
65
66 // Test that the API has default no-op implementation.
67 var succeeded = true;
68 try {
69 window.navigator.registerProtocolHandler('web+myprotocol', "%s", "title");
70 } catch (e) {
71 succeeded = false;
72 }
73
74 if (succeeded)
75 debug('Pass: Valid call succeeded.');
76 else
77 debug('Fail: Invalid call did not succeed.');
78 </script> 30 </script>
31 <script src="../js/resources/js-test-post.js"></script>
79 </body> 32 </body>
80 </html> 33 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/register-protocol-handler-expected.txt » ('j') | Source/modules/indexeddb/IDBFactory.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698