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

Side by Side Diff: LayoutTests/navigatorcontentutils/register-protocol-handler.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 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../resources/js-test.js"></script> 3 <script src="../resources/js-test.js"></script>
4 </head> 4 </head>
5 <body> 5 <body>
6 <p>This test makes sure that navigator.registerProtocolHandler throws the proper exceptions and has no-op default implementation.</p> 6 <p>This test makes sure that navigator.registerProtocolHandler throws the proper exceptions and has no-op default implementation.</p>
7 <pre id="console"></pre> 7 <pre id="console"></pre>
8 <script> 8 <script>
9 if (window.testRunner) 9 if (window.testRunner)
10 testRunner.dumpAsText(); 10 testRunner.dumpAsText();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 window.navigator.registerProtocolHandler('web+myprotocol', "%s", "title"); 88 window.navigator.registerProtocolHandler('web+myprotocol', "%s", "title");
89 } catch (e) { 89 } catch (e) {
90 succeeded = false; 90 succeeded = false;
91 } 91 }
92 92
93 if (succeeded) 93 if (succeeded)
94 debug('PASS Valid call succeeded.'); 94 debug('PASS Valid call succeeded.');
95 else 95 else
96 debug('FAIL Invalid call did not succeed.'); 96 debug('FAIL Invalid call did not succeed.');
97 97
98 // Test that the API throws SecurityError exception if the URL's origin differs from the document's origin.
gyuyoung-inactive 2014/07/16 06:20:17 I think it would be nicer to move this test to inv
pals 2014/07/18 14:17:53 Done.
99 succeeded = false;
100 var errorMessage;
101 try {
102 window.navigator.registerProtocolHandler('web+myprotocol', "http://www.examp le.com/soup?url=%s", "title");
103 } catch (e) {
104 succeeded = true;
105 errorMessage = e.message;
106 }
107
108 if (succeeded)
109 debug('PASS Invalid url threw SecurityError exception: "' + errorMessage + ' ".');
110 else
111 debug('FAIL URL with origin different than document origin is allowed.');
112
98 // Check if registerProtocolHandler can register protocol. 113 // Check if registerProtocolHandler can register protocol.
99 debug("\nCheck if registerProtocolHandler can register protocol correctly. If is ProtocolHandlerRegistered() returns 'registered' state, registerProtoclHandler() works well."); 114 debug("\nCheck if registerProtocolHandler can register protocol correctly. If is ProtocolHandlerRegistered() returns 'registered' state, registerProtoclHandler() works well.");
100 debug("'bitcoin' protocol will be registered for testing.\n"); 115 debug("'bitcoin' protocol will be registered for testing.\n");
101 try { 116 try {
102 // Register 'bitcoin' protocol for testing. 117 // Register 'bitcoin' protocol for testing.
103 window.navigator.registerProtocolHandler('bitcoin', 'invalid scheme uri=%s', 'title'); 118 window.navigator.registerProtocolHandler('bitcoin', 'invalid scheme uri=%s', 'title');
104 119
105 var state = window.navigator.isProtocolHandlerRegistered('bitcoin', 'valid p rotocol %s'); 120 var state = window.navigator.isProtocolHandlerRegistered('bitcoin', 'valid p rotocol %s');
106 if (state == "registered") 121 if (state == "registered")
107 debug("PASS window.navigator.isProtocolHandlerRegistered returns 'regist ered' state. 'bitcoin' is registered successfully."); 122 debug("PASS window.navigator.isProtocolHandlerRegistered returns 'regist ered' state. 'bitcoin' is registered successfully.");
108 else if (state == "new") 123 else if (state == "new")
109 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'new' s tate. Fail to register 'bitcoin' protocol."); 124 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'new' s tate. Fail to register 'bitcoin' protocol.");
110 else if (state == "declined") 125 else if (state == "declined")
111 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin ed' state. Fail to register 'bitcoin' protocol"); 126 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin ed' state. Fail to register 'bitcoin' protocol");
112 } catch (e) { 127 } catch (e) {
113 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".'); 128 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".');
114 } 129 }
115 debug("\n"); 130 debug("\n");
116 131
117 </script> 132 </script>
118 </body> 133 </body>
119 </html> 134 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698