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

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

Issue 144313006: Move test cases of the navigator content utils to own directory (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
OLDNEW
(Empty)
1 <html>
2 <body>
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>
5 <script>
6 if (window.testRunner)
7 testRunner.dumpAsText();
8
9 function debug(str)
10 {
11 var c = document.getElementById('console')
12 c.appendChild(document.createTextNode(str + '\n'));
13 }
14
15 if (window.navigator.unregisterProtocolHandler)
16 debug('Pass: window.navigator.unregisterProtocolHandler is defined.');
17 else
18 debug('Fail: window.navigator.unregisterProtocolHandler is not defined.');
19
20 var invalid_protocols = ['http', 'https', 'file', 'web+'];
21 invalid_protocols.forEach(function (protocol) {
22 var succeeded = false;
23 try {
24 window.navigator.unregisterProtocolHandler(protocol, "invalid protocol % s", "title");
25 } catch (e) {
26 succeeded = 'SecurityError' == e.name;
27 errorMessage = e.message;
28 }
29
30 if (succeeded)
31 debug('Pass: Invalid protocol "' + protocol + '" threw SecurityError exc eption: "' + errorMessage + '".');
32 else
33 debug('Fail: Invalid protocol "' + protocol + '" allowed.');
34 });
35
36 var valid_protocols = ['bitcoin', 'geo', 'im', 'irc', 'ircs', 'magnet', 'mailto' , 'mms', 'news', 'nntp', 'sip', 'sms', 'smsto', 'ssh', 'tel', 'urn', 'webcal', ' wtai', 'xmpp'];
37 valid_protocols.forEach(function (protocol) {
38 var succeeded = false;
39 try {
40 window.navigator.unregisterProtocolHandler(protocol, "valid protocol %s" , "title");
41 succeeded = true;
42 } catch (e) {
43 succeeded = false;
44 }
45
46 if (succeeded)
47 debug('Pass: Valid protocol "' + protocol + '" allowed.');
48 else
49 debug('Fail: Valid protocol "' + protocol + '" failed.');
50 });
51
52 var invalid_urls = ["", "%S"];
53 invalid_urls.forEach(function (url) {
54 var succeeded = false;
55 try {
56 window.navigator.unregisterProtocolHandler('web+myprotocol', url, 'title ');
57 } catch (e) {
58 succeeded = 'SyntaxError' == e.name;
59 errorMessage = e.message;
60 }
61
62 if (succeeded)
63 debug('Pass: Invalid url "' + url + '" threw SyntaxError exception.' + e rrorMessage + '".');
64 else
65 debug('Fail: Invalid url "' + url + '" allowed.');
66 });
67
68 // Test that the API has default no-op implementation.
69 var succeeded = true;
70 try {
71 window.navigator.unregisterProtocolHandler('web+myprotocol', "%s", "title");
72 } catch (e) {
73 succeeded = false;
74 }
75
76 if (succeeded)
77 debug('Pass: Valid call succeeded.');
78 else
79 debug('Fail: Invalid call did not succeed.');
80 </script>
81 </body>
82 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698