<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[200686] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/200686">200686</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2016-05-11 08:52:09 -0700 (Wed, 11 May 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Sites served over insecure connections should not be allowed to use geolocation.
https://bugs.webkit.org/show_bug.cgi?id=157423
<rdar://problem/23751632>
Patch by Pranjal Jumde <pjumde@apple.com> on 2016-05-11
Reviewed by Brent Fulgham.
Source/WebCore:
Tests: http/tests/security/insecure-geolocation.html
http/tests/security/mixedcontent-geolocation-block-insecure-content.html
http/tests/security/mixedcontent-geolocation.html
* Modules/geolocation/Geolocation.cpp:
(WebCore::Geolocation::logError):
(WebCore::Geolocation::startRequest):
Access to Geolocation will be blocked if site is not secure. An error will be logged when access to Geolocation is blocked.
(WebCore::Geolocation::shouldBlockGeolocationRequests)
Returns true if the access to the geolocation should be blocked.
* Modules/geolocation/Geolocation.h:
* dom/SecurityContext.h:
(WebCore::SecurityContext::foundMixedContent):
Returns true if insecure content was accessed over secure connection.
(WebCore::SecurityContext::setFoundMixedContent):
Sets m_foundMixedContent to true if insecure content is accessed over secure connection.
(WebCore::SecurityContext::geolocationAccessed):
Returns true if geolocation was accessed
(WebCore::SecurityContext::setGeolocationAccessed):
Sets m_geolocationAccessed to true if geolocation was accessed.
* loader/MixedContentChecker.cpp:
(WebCore::MixedContentChecker::canDisplayInsecureContent):
Insecure content will be blocked if geolocation was accessed by the page. Updates document to keep track of mixed content.
(WebCore::MixedContentChecker::canRunInsecureContent):
Insecure content will be blocked if geolocation was accessed by the page. Updates document to keep track of mixed content.
LayoutTests:
* http/tests/security/geolocation-over-insecure-content.html: Added.
* http/tests/security/geolocation-over-mixed-content-block.html: Added.
* http/tests/security/geolocation-over-mixed-content.html: Added.
* http/tests/security/insecure-geolocation-expected.txt: Added.
* http/tests/security/insecure-geolocation.html: Added.
* http/tests/security/mixedcontent-geolocation-block-insecure-content-expected.txt: Added.
* http/tests/security/mixedcontent-geolocation-block-insecure-content.html: Added.
* http/tests/security/mixedcontent-geolocation-expected.txt: Added.
* http/tests/security/mixedcontent-geolocation.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesgeolocationGeolocationcpp">trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesgeolocationGeolocationh">trunk/Source/WebCore/Modules/geolocation/Geolocation.h</a></li>
<li><a href="#trunkSourceWebCoredomSecurityContexth">trunk/Source/WebCore/dom/SecurityContext.h</a></li>
<li><a href="#trunkSourceWebCoreloaderMixedContentCheckercpp">trunk/Source/WebCore/loader/MixedContentChecker.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestssecuritygeolocationoverinsecurecontenthtml">trunk/LayoutTests/http/tests/security/geolocation-over-insecure-content.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritygeolocationovermixedcontentblockhtml">trunk/LayoutTests/http/tests/security/geolocation-over-mixed-content-block.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritygeolocationovermixedcontenthtml">trunk/LayoutTests/http/tests/security/geolocation-over-mixed-content.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityinsecuregeolocationexpectedtxt">trunk/LayoutTests/http/tests/security/insecure-geolocation-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityinsecuregeolocationhtml">trunk/LayoutTests/http/tests/security/insecure-geolocation.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritymixedcontentgeolocationblockinsecurecontentexpectedtxt">trunk/LayoutTests/http/tests/security/mixedcontent-geolocation-block-insecure-content-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritymixedcontentgeolocationblockinsecurecontenthtml">trunk/LayoutTests/http/tests/security/mixedcontent-geolocation-block-insecure-content.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritymixedcontentgeolocationexpectedtxt">trunk/LayoutTests/http/tests/security/mixedcontent-geolocation-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritymixedcontentgeolocationhtml">trunk/LayoutTests/http/tests/security/mixedcontent-geolocation.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (200685 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-05-11 08:20:27 UTC (rev 200685)
+++ trunk/LayoutTests/ChangeLog        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2016-05-11 Pranjal Jumde <pjumde@apple.com>
+
+ Sites served over insecure connections should not be allowed to use geolocation.
+ https://bugs.webkit.org/show_bug.cgi?id=157423
+ <rdar://problem/23751632>
+
+ Reviewed by Brent Fulgham.
+
+ * http/tests/security/geolocation-over-insecure-content.html: Added.
+ * http/tests/security/geolocation-over-mixed-content-block.html: Added.
+ * http/tests/security/geolocation-over-mixed-content.html: Added.
+ * http/tests/security/insecure-geolocation-expected.txt: Added.
+ * http/tests/security/insecure-geolocation.html: Added.
+ * http/tests/security/mixedcontent-geolocation-block-insecure-content-expected.txt: Added.
+ * http/tests/security/mixedcontent-geolocation-block-insecure-content.html: Added.
+ * http/tests/security/mixedcontent-geolocation-expected.txt: Added.
+ * http/tests/security/mixedcontent-geolocation.html: Added.
+
</ins><span class="cx"> 2016-05-11 Youenn Fablet <youenn.fablet@crf.canon.fr>
</span><span class="cx">
</span><span class="cx"> Ensure DOM iterators remain done
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritygeolocationoverinsecurecontenthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/geolocation-over-insecure-content.html (0 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/geolocation-over-insecure-content.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/geolocation-over-insecure-content.html        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+<body onload="loaded()">
+<script>
+if (navigator.geolocation) {
+ navigator.geolocation.getCurrentPosition(showPosition);
+}
+function showPosition(position) {
+ console.log("Latitude: " + position.coords.latitude + "Longitude: " + position.coords.longitude);        
+}
+function loaded() {
+ if (window.opener)
+ window.opener.postMessage('done', '*');
+}
+</script>
+</body>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritygeolocationovermixedcontentblockhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/geolocation-over-mixed-content-block.html (0 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/geolocation-over-mixed-content-block.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/geolocation-over-mixed-content-block.html        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+<body onload="loaded()">
+<script>
+if (navigator.geolocation) {
+ navigator.geolocation.getCurrentPosition(showPosition);
+}
+function showPosition(position) {
+ console.log("Latitude: " + position.coords.latitude + "Longitude: " + position.coords.longitude);
+}
+function loaded() {
+ if (window.opener)
+ window.opener.postMessage('done', '*');
+}
+</script>
+<img src="http://127.0.0.1:8080/security/resources/compass.jpg">
+</body>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritygeolocationovermixedcontenthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/geolocation-over-mixed-content.html (0 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/geolocation-over-mixed-content.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/geolocation-over-mixed-content.html        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+<body onload="loaded()">
+<img src="http://127.0.0.1:8080/security/resources/compass.jpg">
+<script>
+if (navigator.geolocation) {
+ navigator.geolocation.getCurrentPosition(showPosition);
+}
+function showPosition(position) {
+ console.log("Latitude: " + position.coords.latitude + "Longitude: " + position.coords.longitude);
+}
+function loaded() {
+ if (window.opener)
+ window.opener.postMessage('done', '*');
+}
+</script>
+</body>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityinsecuregeolocationexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/insecure-geolocation-expected.txt (0 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/insecure-geolocation-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/security/insecure-geolocation-expected.txt        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+CONSOLE MESSAGE: line 4: [blocked] Access to geolocation was blocked over insecure connection to http://127.0.0.1:8080.
+
+This test loads an insecure frame that tries to access geolocation. Access to geolocation is blocked over insecure connections.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityinsecuregeolocationhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/insecure-geolocation.html (0 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/insecure-geolocation.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/insecure-geolocation.html        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+<html>
+<body>
+<script>
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+ testRunner.setCanOpenWindows();
+ testRunner.setCloseRemainingWindowsWhenComplete(true);
+}
+window.addEventListener("message", function (e) {
+ if (window.testRunner)
+ testRunner.notifyDone();
+}, false);
+</script>
+<p>This test loads an insecure frame that tries to access geolocation. Access to geolocation is blocked over insecure connections.</p>
+<script>
+onload = function() {
+ window.open("http://127.0.0.1:8080/security/geolocation-over-insecure-content.html");
+}
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedcontentgeolocationblockinsecurecontentexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/mixedcontent-geolocation-block-insecure-content-expected.txt (0 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedcontent-geolocation-block-insecure-content-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedcontent-geolocation-block-insecure-content-expected.txt        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+CONSOLE MESSAGE: line 14: [blocked] The page at https://127.0.0.1:8443/security/geolocation-over-mixed-content-block.html was not allowed to display insecure content from http://127.0.0.1:8080/security/resources/compass.jpg.
+
+This test loads a secure frame with insecure content that tries to access geolocation before loading insecure content. Access to insecure content is blocked over secure connections when geolocation is accessed.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedcontentgeolocationblockinsecurecontenthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/mixedcontent-geolocation-block-insecure-content.html (0 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedcontent-geolocation-block-insecure-content.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedcontent-geolocation-block-insecure-content.html        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+<html>
+<body>
+<script>
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+ testRunner.setCanOpenWindows();
+ testRunner.setCloseRemainingWindowsWhenComplete(true);
+}
+window.addEventListener("message", function (e) {
+ if (window.testRunner)
+ testRunner.notifyDone();
+}, false);
+</script>
+<p>This test loads a secure frame with insecure content that tries to access geolocation before loading insecure content. Access to insecure content is blocked over secure connections when geolocation is accessed.</p>
+<script>
+onload = function() {
+ window.open("https://127.0.0.1:8443/security/geolocation-over-mixed-content-block.html");
+}
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedcontentgeolocationexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/mixedcontent-geolocation-expected.txt (0 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedcontent-geolocation-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedcontent-geolocation-expected.txt        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+CONSOLE MESSAGE: line 2: The page at https://127.0.0.1:8443/security/geolocation-over-mixed-content.html was allowed to display insecure content from http://127.0.0.1:8080/security/resources/compass.jpg.
+
+CONSOLE MESSAGE: line 5: [blocked] Access to geolocation was blocked over secure connection with mixed content to https://127.0.0.1:8443.
+
+This test loads a secure frame with mixed content that tries to access geolocation. Access to geolocation is blocked over secure connections with mixed content.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedcontentgeolocationhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/mixedcontent-geolocation.html (0 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedcontent-geolocation.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedcontent-geolocation.html        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+<html>
+<body>
+<script>
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+ testRunner.setCanOpenWindows();
+ testRunner.setCloseRemainingWindowsWhenComplete(true);
+}
+window.addEventListener("message", function (e) {
+ if (window.testRunner)
+ testRunner.notifyDone();
+}, false);
+</script>
+<p>This test loads a secure frame with mixed content that tries to access geolocation. Access to geolocation is blocked over secure connections with mixed content.</p>
+<script>
+onload = function() {
+ window.open("https://127.0.0.1:8443/security/geolocation-over-mixed-content.html");
+}
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200685 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-11 08:20:27 UTC (rev 200685)
+++ trunk/Source/WebCore/ChangeLog        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2016-05-11 Pranjal Jumde <pjumde@apple.com>
+
+ Sites served over insecure connections should not be allowed to use geolocation.
+ https://bugs.webkit.org/show_bug.cgi?id=157423
+ <rdar://problem/23751632>
+
+ Reviewed by Brent Fulgham.
+
+ Tests: http/tests/security/insecure-geolocation.html
+ http/tests/security/mixedcontent-geolocation-block-insecure-content.html
+ http/tests/security/mixedcontent-geolocation.html
+
+ * Modules/geolocation/Geolocation.cpp:
+ (WebCore::Geolocation::logError):
+ (WebCore::Geolocation::startRequest):
+ Access to Geolocation will be blocked if site is not secure. An error will be logged when access to Geolocation is blocked.
+ (WebCore::Geolocation::shouldBlockGeolocationRequests)
+ Returns true if the access to the geolocation should be blocked.
+ * Modules/geolocation/Geolocation.h:
+ * dom/SecurityContext.h:
+ (WebCore::SecurityContext::foundMixedContent):
+ Returns true if insecure content was accessed over secure connection.
+ (WebCore::SecurityContext::setFoundMixedContent):
+ Sets m_foundMixedContent to true if insecure content is accessed over secure connection.
+ (WebCore::SecurityContext::geolocationAccessed):
+ Returns true if geolocation was accessed
+ (WebCore::SecurityContext::setGeolocationAccessed):
+ Sets m_geolocationAccessed to true if geolocation was accessed.
+ * loader/MixedContentChecker.cpp:
+ (WebCore::MixedContentChecker::canDisplayInsecureContent):
+ Insecure content will be blocked if geolocation was accessed by the page. Updates document to keep track of mixed content.
+ (WebCore::MixedContentChecker::canRunInsecureContent):
+ Insecure content will be blocked if geolocation was accessed by the page. Updates document to keep track of mixed content.
+
</ins><span class="cx"> 2016-05-11 Youenn Fablet <youenn.fablet@crf.canon.fr>
</span><span class="cx">
</span><span class="cx"> Ensure DOM iterators remain done
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesgeolocationGeolocationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp (200685 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp        2016-05-11 08:20:27 UTC (rev 200685)
+++ trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved.
</del><ins>+ * Copyright (C) 2008-2016 Apple Inc. All Rights Reserved.
</ins><span class="cx"> * Copyright (C) 2009 Torch Mobile, Inc.
</span><span class="cx"> * Copyright 2010, The Android Open Source Project
</span><span class="cx"> *
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> #include "SecurityOrigin.h"
</span><span class="cx"> #include <wtf/CurrentTime.h>
</span><span class="cx"> #include <wtf/Ref.h>
</span><ins>+#include <wtf/text/StringBuilder.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -172,6 +173,23 @@
</span><span class="cx"> {
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><ins>+
+static void logError(const String& target, const bool isSecure, const bool isMixedContent, Document* document)
+{
+ StringBuilder message;
+ message.append("[blocked] Access to geolocation was blocked over");
+
+ if (!isSecure)
+ message.append(" insecure connection to ");
+ else if (isMixedContent)
+ message.append(" secure connection with mixed content to ");
+ else
+ return;
+
+ message.append(target);
+ message.append(".\n");
+ document->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message.toString());
+}
</ins><span class="cx">
</span><span class="cx"> void Geolocation::suspend(ReasonForSuspension reason)
</span><span class="cx"> {
</span><span class="lines">@@ -337,12 +355,24 @@
</span><span class="cx"> return watchID;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool Geolocation::shouldBlockGeolocationRequests()
+{
+ bool isSecure = SecurityOrigin::isSecure(document()->url());
+ bool hasMixedContent = document()->foundMixedContent();
+ if (securityOrigin()->canRequestGeolocation() && isSecure && !hasMixedContent)
+ return false;
+
+ logError(securityOrigin()->toString(), isSecure, hasMixedContent, document());
+ return true;
+}
+
</ins><span class="cx"> void Geolocation::startRequest(GeoNotifier* notifier)
</span><span class="cx"> {
</span><del>- if (!securityOrigin()->canRequestGeolocation()) {
</del><ins>+ if (shouldBlockGeolocationRequests()) {
</ins><span class="cx"> notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, ASCIILiteral(originCannotRequestGeolocationErrorMessage)));
</span><span class="cx"> return;
</span><span class="cx"> }
</span><ins>+ document()->setGeolocationAccessed();
</ins><span class="cx">
</span><span class="cx"> // Check whether permissions have already been denied. Note that if this is the case,
</span><span class="cx"> // the permission state can not change again in the lifetime of this page.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesgeolocationGeolocationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/geolocation/Geolocation.h (200685 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/geolocation/Geolocation.h        2016-05-11 08:20:27 UTC (rev 200685)
+++ trunk/Source/WebCore/Modules/geolocation/Geolocation.h        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved.
</del><ins>+ * Copyright (C) 2008-2016 Apple Inc. All Rights Reserved.
</ins><span class="cx"> * Copyright 2010, The Android Open Source Project
</span><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -72,6 +72,7 @@
</span><span class="cx">
</span><span class="cx"> void positionChanged();
</span><span class="cx"> void setError(GeolocationError*);
</span><ins>+ bool shouldBlockGeolocationRequests();
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> explicit Geolocation(ScriptExecutionContext*);
</span></span></pre></div>
<a id="trunkSourceWebCoredomSecurityContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/SecurityContext.h (200685 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/SecurityContext.h        2016-05-11 08:20:27 UTC (rev 200685)
+++ trunk/Source/WebCore/dom/SecurityContext.h        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -75,6 +75,10 @@
</span><span class="cx"> WEBCORE_EXPORT SecurityOrigin* securityOrigin() const;
</span><span class="cx">
</span><span class="cx"> static SandboxFlags parseSandboxPolicy(const String& policy, String& invalidTokensErrorMessage);
</span><ins>+ bool foundMixedContent() const { return m_foundMixedContent; }
+ void setFoundMixedContent() { m_foundMixedContent = true; }
+ bool geolocationAccessed() const { return m_geolocationAccessed; }
+ void setGeolocationAccessed() { m_geolocationAccessed = true; }
</ins><span class="cx">
</span><span class="cx"> protected:
</span><span class="cx"> SecurityContext();
</span><span class="lines">@@ -90,6 +94,8 @@
</span><span class="cx"> SandboxFlags m_sandboxFlags;
</span><span class="cx"> RefPtr<SecurityOriginPolicy> m_securityOriginPolicy;
</span><span class="cx"> std::unique_ptr<ContentSecurityPolicy> m_contentSecurityPolicy;
</span><ins>+ bool m_foundMixedContent { false };
+ bool m_geolocationAccessed { false };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderMixedContentCheckercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/MixedContentChecker.cpp (200685 => 200686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/MixedContentChecker.cpp        2016-05-11 08:20:27 UTC (rev 200685)
+++ trunk/Source/WebCore/loader/MixedContentChecker.cpp        2016-05-11 15:52:09 UTC (rev 200686)
</span><span class="lines">@@ -65,11 +65,13 @@
</span><span class="cx"> if (!isMixedContent(securityOrigin, url))
</span><span class="cx"> return true;
</span><span class="cx">
</span><del>- bool allowed = m_frame.settings().allowDisplayOfInsecureContent() || type == ContentType::ActiveCanWarn;
</del><ins>+ bool allowed = (m_frame.settings().allowDisplayOfInsecureContent() || type == ContentType::ActiveCanWarn) && !m_frame.document()->geolocationAccessed();
</ins><span class="cx"> logWarning(allowed, "display", url);
</span><span class="cx">
</span><del>- if (allowed)
</del><ins>+ if (allowed) {
+ m_frame.document()->setFoundMixedContent();
</ins><span class="cx"> client().didDisplayInsecureContent();
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> return allowed;
</span><span class="cx"> }
</span><span class="lines">@@ -79,11 +81,13 @@
</span><span class="cx"> if (!isMixedContent(securityOrigin, url))
</span><span class="cx"> return true;
</span><span class="cx">
</span><del>- bool allowed = m_frame.settings().allowRunningOfInsecureContent();
</del><ins>+ bool allowed = m_frame.settings().allowRunningOfInsecureContent() && !m_frame.document()->geolocationAccessed();
</ins><span class="cx"> logWarning(allowed, "run", url);
</span><span class="cx">
</span><del>- if (allowed)
</del><ins>+ if (allowed) {
+ m_frame.document()->setFoundMixedContent();
</ins><span class="cx"> client().didRunInsecureContent(securityOrigin, url);
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> return allowed;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>