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

Side by Side Diff: LayoutTests/navigatorcontentutils/unregister-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.unregisterProtocolHandler throws the prop er exceptions and has no-op default implementation.</p> 6 <p>This test makes sure that navigator.unregisterProtocolHandler throws the prop er 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 window.navigator.unregisterProtocolHandler('web+myprotocol', "%s", "title"); 87 window.navigator.unregisterProtocolHandler('web+myprotocol', "%s", "title");
88 } catch (e) { 88 } catch (e) {
89 succeeded = false; 89 succeeded = false;
90 } 90 }
91 91
92 if (succeeded) 92 if (succeeded)
93 debug('PASS Valid call succeeded.'); 93 debug('PASS Valid call succeeded.');
94 else 94 else
95 debug('FAIL Invalid call did not succeed.'); 95 debug('FAIL Invalid call did not succeed.');
96 96
97 // Test that the API throws SecurityError exception if the URL's origin differs from the document's origin.
98 succeeded = false;
99 var errorMessage;
100 try {
101 window.navigator.unregisterProtocolHandler('web+myprotocol', "http://www.exa mple.com/soup?url=%s", "title");
102 } catch (e) {
103 succeeded = true;
104 errorMessage = e.message;
105 }
106
107 if (succeeded)
108 debug('PASS Invalid url threw SecurityError exception: "' + errorMessage + ' ".');
109 else
110 debug('FAIL URL with origin different than document origin is allowed.');
111
97 // Check if unregisterProtocolHandler can unregister protocol. 112 // Check if unregisterProtocolHandler can unregister protocol.
98 debug("\nCheck if unregisterProtocolHandler can unregister protocol correctly. I f isProtocolHandlerRegistered() returns 'new' state, unregisterProtoclHandler() works well."); 113 debug("\nCheck if unregisterProtocolHandler can unregister protocol correctly. I f isProtocolHandlerRegistered() returns 'new' state, unregisterProtoclHandler() works well.");
99 debug("'bitcoin' protocol will be registered and unregistered for testing.\n"); 114 debug("'bitcoin' protocol will be registered and unregistered for testing.\n");
100 try { 115 try {
101 // Register 'bitcoin' protocol for testing. 116 // Register 'bitcoin' protocol for testing.
102 window.navigator.registerProtocolHandler('bitcoin', 'invalid scheme uri=%s', 'title'); 117 window.navigator.registerProtocolHandler('bitcoin', 'invalid scheme uri=%s', 'title');
103 var state = window.navigator.isProtocolHandlerRegistered('bitcoin', 'valid p rotocol %s'); 118 var state = window.navigator.isProtocolHandlerRegistered('bitcoin', 'valid p rotocol %s');
104 if (state == "registered") 119 if (state == "registered")
105 debug("PASS window.navigator.isProtocolHandlerRegistered returns 'regist ered' state. 'bitcoin' is registered successfully."); 120 debug("PASS window.navigator.isProtocolHandlerRegistered returns 'regist ered' state. 'bitcoin' is registered successfully.");
106 else if (state == "new") 121 else if (state == "new")
(...skipping 10 matching lines...) Expand all
117 else if (state == "declined") 132 else if (state == "declined")
118 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin ed' state. Fail to unregister 'bitcoin' protocol."); 133 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin ed' state. Fail to unregister 'bitcoin' protocol.");
119 } catch (e) { 134 } catch (e) {
120 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".'); 135 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".');
121 } 136 }
122 debug("\n"); 137 debug("\n");
123 138
124 </script> 139 </script>
125 </body> 140 </body>
126 </html> 141 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698