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

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: Rebased the *expected.txt 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.setAllowUniversalAccessFromFileURLs(false);
10 testRunner.dumpAsText(); 11 testRunner.dumpAsText();
12 }
11 13
12 if (window.internals) 14 if (window.internals)
13 internals.setNavigatorContentUtilsClientMock(document); 15 internals.setNavigatorContentUtilsClientMock(document);
14 16
15 if (window.navigator.registerProtocolHandler) 17 if (window.navigator.registerProtocolHandler)
16 debug('PASS window.navigator.registerProtocolHandler is defined.'); 18 debug('PASS window.navigator.registerProtocolHandler is defined.');
17 else 19 else
18 debug('FAIL window.navigator.registerProtocolHandler is not defined.'); 20 debug('FAIL window.navigator.registerProtocolHandler is not defined.');
19 21
20 var invalid_protocols = ['http', 'https', 'file', 'web+']; 22 var invalid_protocols = ['http', 'https', 'file', 'web+'];
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 succeeded = 'SyntaxError' == e.name; 77 succeeded = 'SyntaxError' == e.name;
76 errorMessage = e.message; 78 errorMessage = e.message;
77 } 79 }
78 80
79 if (succeeded) 81 if (succeeded)
80 debug('PASS Invalid url "' + url + '" threw SyntaxError exception: "' + errorMessage + '".'); 82 debug('PASS Invalid url "' + url + '" threw SyntaxError exception: "' + errorMessage + '".');
81 else 83 else
82 debug('FAIL Invalid url "' + url + '" allowed.'); 84 debug('FAIL Invalid url "' + url + '" allowed.');
83 }); 85 });
84 86
87 // Test that the API throws SecurityError exception if the URL's origin differs from the document's origin.
88 succeeded = false;
89 var errorMessage;
90 try {
91 window.navigator.registerProtocolHandler('web+myprotocol', "http://www.examp le.com/soup?url=%s", "title");
92 } catch (e) {
93 succeeded = true;
94 errorMessage = e.message;
95 }
96
97 if (succeeded)
98 debug('PASS Invalid url threw SecurityError exception: "' + errorMessage + ' ".');
gyuyoung-inactive 2014/07/23 00:07:12 Isn't this test for different origin ? It looks "I
pals 2014/07/23 05:39:29 Good catch. Done.
99 else
100 debug('FAIL URL with origin different than document origin is allowed.');
101
85 // Test that the API has default no-op implementation. 102 // Test that the API has default no-op implementation.
86 var succeeded = true; 103 var succeeded = true;
87 try { 104 try {
88 window.navigator.registerProtocolHandler('web+myprotocol', "%s", "title"); 105 window.navigator.registerProtocolHandler('web+myprotocol', "%s", "title");
89 } catch (e) { 106 } catch (e) {
90 succeeded = false; 107 succeeded = false;
91 } 108 }
92 109
93 if (succeeded) 110 if (succeeded)
94 debug('PASS Valid call succeeded.'); 111 debug('PASS Valid call succeeded.');
(...skipping 15 matching lines...) Expand all
110 else if (state == "declined") 127 else if (state == "declined")
111 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin ed' state. Fail to register 'bitcoin' protocol"); 128 debug("FAIL window.navigator.isProtocolHandlerRegistered returns 'declin ed' state. Fail to register 'bitcoin' protocol");
112 } catch (e) { 129 } catch (e) {
113 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".'); 130 debug('FAIL window.navigator.isProtocolHandlerRegistered call is failed: "' + e.message + '".');
114 } 131 }
115 debug("\n"); 132 debug("\n");
116 133
117 </script> 134 </script>
118 </body> 135 </body>
119 </html> 136 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698