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

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
« 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
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 14 matching lines...) Expand all
37 succeeded = 'SyntaxError' == e.name; 40 succeeded = 'SyntaxError' == e.name;
38 errorMessage = e.message; 41 errorMessage = e.message;
39 } 42 }
40 43
41 if (succeeded) 44 if (succeeded)
42 debug('PASS Invalid scheme "' + scheme + '" falied.'); 45 debug('PASS Invalid scheme "' + scheme + '" falied.');
43 else 46 else
44 debug('FAIL Invalid scheme "' + scheme + '" allowed. Threw exception: "' + errorMessage + '".'); 47 debug('FAIL Invalid scheme "' + scheme + '" allowed. Threw exception: "' + errorMessage + '".');
45 }); 48 });
46 49
47 // FIXME: Need to check if this function can return 'registered' and 'declined' states as well. 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");
48 try { 52 try {
53 // Register 'bitcoin' protocol for testing.
54 window.navigator.registerProtocolHandler('bitcoin', 'invalid scheme uri=%s', 'title');
55
49 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p rotocol %s"); 56 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p rotocol %s");
50 if (state == "new") 57 if (state == "registered")
51 debug('PASS window.navigator.isProtocolHandlerRegistered returns "new" s tate'); 58 debug("PASS window.navigator.isProtocolHandlerRegistered returns 'regist ered' state. isProtocolHandlerRegistered() works correctly.");
52 else 59 else if (state == "new")
53 debug("FAIL window.navigator.isProtocolHandlerRegistered doesn't return the default state."); 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.");
54 } catch (e) { 63 } catch (e) {
55 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".'); 64 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".');
56 } 65 }
66 debug("\n");
67
57 </script> 68 </script>
58 </body> 69 </body>
59 </html> 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