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

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

Issue 293403002: Introduce mock test system for navigator content utils (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../../resources/js-test.js"></script> 4 <script src="../../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <p>This test makes sure that navigator.isProtocolHandlerRegistered throws the pr oper exceptions and returns the default state of handler.</p> 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> 8 <pre id="console"></pre>
9 <script> 9 <script>
10 if (window.testRunner) 10 if (window.testRunner)
11 testRunner.dumpAsText(); 11 testRunner.dumpAsText();
12 12
13 if (window.internals)
14 internals.setNavigatorContentUtilsClientMock(document);
15
13 if (window.navigator.isProtocolHandlerRegistered) 16 if (window.navigator.isProtocolHandlerRegistered)
14 debug('PASS window.navigator.isProtocolHandlerRegistered is defined.'); 17 debug('PASS window.navigator.isProtocolHandlerRegistered is defined.');
15 else 18 else
16 debug('FAIL window.navigator.isProtocolHandlerRegistered is not defined.'); 19 debug('FAIL window.navigator.isProtocolHandlerRegistered is not defined.');
17 20
18 var invalidUrl = "%S"; 21 var invalidUrl = "%S";
19 var succeeded = false; 22 var succeeded = false;
20 try { 23 try {
21 window.navigator.isProtocolHandlerRegistered(protocol, invalidUrl); 24 window.navigator.isProtocolHandlerRegistered(protocol, invalidUrl);
22 succeeded = false; 25 succeeded = false;
(...skipping 13 matching lines...) Expand all
36 } catch (e) { 39 } catch (e) {
37 succeeded = true; 40 succeeded = true;
38 } 41 }
39 42
40 if (succeeded) 43 if (succeeded)
41 debug('PASS Invalid scheme "' + scheme + '" falied.'); 44 debug('PASS Invalid scheme "' + scheme + '" falied.');
42 else 45 else
43 debug('FAIL Invalid scheme "' + scheme + '" allowed.'); 46 debug('FAIL Invalid scheme "' + scheme + '" allowed.');
44 }); 47 });
45 48
46 // FIXME: Need to check if this function can return 'registered' and 'declined' states as well. 49 debug("\nCheck if isProtocolHandlerRegistered() works correctly. If isProtocolHa ndlerRegistered() returns 'new' state, it works well.");
50 debug("'bitcoin' protocol will be registered, and then checks if the 'bitcoin' p rotocol is registered by isProtocolHandlerRegistered().\n");
47 try { 51 try {
52 // Register 'bitcoin' protocol for testing.
53 window.navigator.registerProtocolHandler('bitcoin', 'invalid scheme uri=%s', 'title');
54
48 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p rotocol %s"); 55 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p rotocol %s");
49 if (state == "new") 56 if (state == "registered")
50 debug('PASS window.navigator.isProtocolHandlerRegistered returns "new" s tate'); 57 debug("PASS window.navigator.isProtocolHandlerRegistered returns 'regist ered' state. isProtocolHandlerRegistered() works correctly.");
51 else 58 else if (state == "new")
52 debug("FAIL window.navigator.isProtocolHandlerRegistered doesn't return the default state."); 59 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'new' s tate.");
60 else if (state == "declined")
61 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin ed' state.");
53 } catch (e) { 62 } catch (e) {
54 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".'); 63 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".');
55 } 64 }
65 debug("\n");
66
56 </script> 67 </script>
57 </body> 68 </body>
58 </html> 69 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698