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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/navigatorcontentutils/is-protocol-handler-registered.html
diff --git a/LayoutTests/navigatorcontentutils/is-protocol-handler-registered.html b/LayoutTests/navigatorcontentutils/is-protocol-handler-registered.html
index c015588eb72d2f1d91f65860245c6d39fdb8fd1f..244265ce7430216d36d78a10363cca3ff655dcac 100644
--- a/LayoutTests/navigatorcontentutils/is-protocol-handler-registered.html
+++ b/LayoutTests/navigatorcontentutils/is-protocol-handler-registered.html
@@ -7,8 +7,10 @@
<p>This test makes sure that navigator.isProtocolHandlerRegistered throws the proper exceptions and returns the default state of handler.</p>
<pre id="console"></pre>
<script>
-if (window.testRunner)
+if (window.testRunner) {
+ testRunner.setAllowUniversalAccessFromFileURLs(false);
testRunner.dumpAsText();
+}
if (window.internals)
internals.setNavigatorContentUtilsClientMock(document);
@@ -47,6 +49,21 @@ invalid_schemes.forEach(function (scheme) {
debug('FAIL Invalid scheme "' + scheme + '" allowed. Threw exception: "' + errorMessage + '".');
});
+// 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.isProtocolHandlerRegistered('web+myprotocol', "http://www.example.com/soup?url=%s");
+} catch (e) {
+ succeeded = true;
+ errorMessage = e.message;
+}
+
+if (succeeded)
+ debug('PASS Invalid url threw SecurityError exception: "' + errorMessage + '".');
+else
+ debug('FAIL URL with origin different than document origin is allowed.');
+
debug("\nCheck if isProtocolHandlerRegistered() works correctly. If isProtocolHandlerRegistered() returns 'new' state, it works well.");
debug("'bitcoin' protocol will be registered, and then checks if the 'bitcoin' protocol is registered by isProtocolHandlerRegistered().\n");
try {

Powered by Google App Engine
This is Rietveld 408576698