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

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

Issue 335783003: Move navigatorcontentutils directory to top of LayoutTests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix wrong include path in tests 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
« no previous file with comments | « no previous file | LayoutTests/fast/dom/navigatorcontentutils/is-protocol-handler-registered-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
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p>This test makes sure that navigator.isProtocolHandlerRegistered throws the pr oper exceptions and returns the default state of handler.</p>
8 <pre id="console"></pre>
9 <script>
10 if (window.testRunner)
11 testRunner.dumpAsText();
12
13 if (window.internals)
14 internals.setNavigatorContentUtilsClientMock(document);
15
16 if (window.navigator.isProtocolHandlerRegistered)
17 debug('PASS window.navigator.isProtocolHandlerRegistered is defined.');
18 else
19 debug('FAIL window.navigator.isProtocolHandlerRegistered is not defined.');
20
21 var invalidUrl = "%S";
22 var succeeded = false;
23 try {
24 window.navigator.isProtocolHandlerRegistered(protocol, invalidUrl);
25 succeeded = false;
26 } catch (e) {
27 succeeded = true;
28 }
29 if (succeeded)
30 debug('PASS Invalid url "' + invalidUrl + '" threw SyntaxError exception.');
31 else
32 debug('FAIL Invalid url "' + invalidUrl + '" allowed.');
33
34 var invalid_schemes = ['mailto:', 'ssh:/', 'magnet:+', 'tel:sip'];
35 invalid_schemes.forEach(function (scheme) {
36 var succeeded = false;
37 try {
38 window.navigator.isProtocolHandlerRegistered(scheme, 'invalid scheme uri =%s');
39 } catch (e) {
40 succeeded = 'SyntaxError' == e.name;
41 errorMessage = e.message;
42 }
43
44 if (succeeded)
45 debug('PASS Invalid scheme "' + scheme + '" falied.');
46 else
47 debug('FAIL Invalid scheme "' + scheme + '" allowed. Threw exception: "' + errorMessage + '".');
48 });
49
50 debug("\nCheck if isProtocolHandlerRegistered() works correctly. If isProtocolHa ndlerRegistered() returns 'new' state, it works well.");
51 debug("'bitcoin' protocol will be registered, and then checks if the 'bitcoin' p rotocol is registered by isProtocolHandlerRegistered().\n");
52 try {
53 // Register 'bitcoin' protocol for testing.
54 window.navigator.registerProtocolHandler('bitcoin', 'invalid scheme uri=%s', 'title');
55
56 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p rotocol %s");
57 if (state == "registered")
58 debug("PASS window.navigator.isProtocolHandlerRegistered returns 'regist ered' state. isProtocolHandlerRegistered() works correctly.");
59 else if (state == "new")
60 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'new' s tate.");
61 else if (state == "declined")
62 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin ed' state.");
63 } catch (e) {
64 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".');
65 }
66 debug("\n");
67
68 </script>
69 </body>
70 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/navigatorcontentutils/is-protocol-handler-registered-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698