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

Unified Diff: LayoutTests/http/tests/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: Done Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/navigatorcontentutils/unregister-protocol-handler.html
diff --git a/LayoutTests/navigatorcontentutils/unregister-protocol-handler.html b/LayoutTests/http/tests/navigatorcontentutils/unregister-protocol-handler.html
similarity index 88%
rename from LayoutTests/navigatorcontentutils/unregister-protocol-handler.html
rename to LayoutTests/http/tests/navigatorcontentutils/unregister-protocol-handler.html
index f18e11d50cbfed3a96154b8f00c3fb50964915e8..90ccfc0fa85c684169a345d232a1a7509802d635 100644
--- a/LayoutTests/navigatorcontentutils/unregister-protocol-handler.html
+++ b/LayoutTests/http/tests/navigatorcontentutils/unregister-protocol-handler.html
@@ -1,14 +1,11 @@
<html>
<head>
-<script src="../resources/js-test.js"></script>
+<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<p>This test makes sure that navigator.unregisterProtocolHandler throws the proper exceptions and has no-op default implementation.</p>
<pre id="console"></pre>
<script>
-if (window.testRunner)
- testRunner.dumpAsText();
-
if (window.internals)
internals.setNavigatorContentUtilsClientMock(document);
@@ -81,6 +78,21 @@ invalid_urls.forEach(function (url) {
debug('FAIL Invalid url "' + url + '" allowed.');
});
+// Test that the API throws SecurityError exception if the URL's origin differs from the document's origin.
+succeeded = false;
+var errorMessage;
+try {
+ window.navigator.unregisterProtocolHandler('web+myprotocol', "http://www.example.com/soup?url=%s", "title");
+} catch (e) {
+ succeeded = true;
+ errorMessage = e.message;
+}
+
+if (succeeded)
+ debug('PASS URL with origin different than document origin threw SecurityError exception: "' + errorMessage + '".');
+else
+ debug('FAIL URL with origin different than document origin is allowed.');
+
// Test that the API has default no-op implementation.
var succeeded = true;
try {

Powered by Google App Engine
This is Rietveld 408576698