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

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

Issue 392993005: Custom handlers should throw SecurityError exception if the URL's origin differs from the document'… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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)
(...skipping 29 matching lines...) Expand all
40 succeeded = 'SecurityError' == e.name; 40 succeeded = 'SecurityError' == e.name;
41 errorMessage = e.message; 41 errorMessage = e.message;
42 } 42 }
43 43
44 if (succeeded) 44 if (succeeded)
45 debug('PASS Invalid scheme "' + scheme + '" falied.'); 45 debug('PASS Invalid scheme "' + scheme + '" falied.');
46 else 46 else
47 debug('FAIL Invalid scheme "' + scheme + '" allowed. Threw exception: "' + errorMessage + '".'); 47 debug('FAIL Invalid scheme "' + scheme + '" allowed. Threw exception: "' + errorMessage + '".');
48 }); 48 });
49 49
50 // Test that the API throws SecurityError exception if the URL's origin differs from the document's origin.
51 succeeded = false;
52 var errorMessage;
53 try {
54 window.navigator.isProtocolHandlerRegistered('web+myprotocol', "http://www.e xample.com/soup?url=%s");
55 } catch (e) {
56 succeeded = true;
57 errorMessage = e.message;
58 }
59
60 if (succeeded)
61 debug('PASS Invalid url threw SecurityError exception: "' + errorMessage + ' ".');
62 else
63 debug('FAIL URL with origin different than document origin is allowed.');
64
50 debug("\nCheck if isProtocolHandlerRegistered() works correctly. If isProtocolHa ndlerRegistered() returns 'new' state, it works well."); 65 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"); 66 debug("'bitcoin' protocol will be registered, and then checks if the 'bitcoin' p rotocol is registered by isProtocolHandlerRegistered().\n");
52 try { 67 try {
53 // Register 'bitcoin' protocol for testing. 68 // Register 'bitcoin' protocol for testing.
54 window.navigator.registerProtocolHandler('bitcoin', 'invalid scheme uri=%s', 'title'); 69 window.navigator.registerProtocolHandler('bitcoin', 'invalid scheme uri=%s', 'title');
55 70
56 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p rotocol %s"); 71 var state = window.navigator.isProtocolHandlerRegistered("bitcoin", "valid p rotocol %s");
57 if (state == "registered") 72 if (state == "registered")
58 debug("PASS window.navigator.isProtocolHandlerRegistered returns 'regist ered' state. isProtocolHandlerRegistered() works correctly."); 73 debug("PASS window.navigator.isProtocolHandlerRegistered returns 'regist ered' state. isProtocolHandlerRegistered() works correctly.");
59 else if (state == "new") 74 else if (state == "new")
60 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'new' s tate."); 75 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'new' s tate.");
61 else if (state == "declined") 76 else if (state == "declined")
62 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin ed' state."); 77 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin ed' state.");
63 } catch (e) { 78 } catch (e) {
64 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".'); 79 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".');
65 } 80 }
66 debug("\n"); 81 debug("\n");
67 82
68 </script> 83 </script>
69 </body> 84 </body>
70 </html> 85 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698