<!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>[195075] 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/195075">195075</a></dd>
<dt>Author</dt> <dd>dbates@webkit.org</dd>
<dt>Date</dt> <dd>2016-01-14 13:42:35 -0800 (Thu, 14 Jan 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Disallow use of Geolocation service from unique origins
https://bugs.webkit.org/show_bug.cgi?id=153102
<rdar://problem/23055645>
Reviewed by Alexey Proskuryakov.
Source/WebCore:
Tests: fast/dom/Geolocation/dataURL-getCurrentPosition.html
fast/dom/Geolocation/dataURL-watchPosition.html
fast/dom/Geolocation/srcdoc-getCurrentPosition.html
fast/dom/Geolocation/srcdoc-watchPosition.html
http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html
http/tests/security/sandboxed-iframe-geolocation-watchPosition.html
* Modules/geolocation/Geolocation.cpp:
(WebCore::Geolocation::securityOrigin): Convenience function to get the SecurityOrigin object
associated with this script execution context.
(WebCore::Geolocation::startRequest): Notify requester POSITION_UNAVAILABLE when requested
from a document with a unique origin.
* Modules/geolocation/Geolocation.h:
* page/SecurityOrigin.h:
(WebCore::SecurityOrigin::canRequestGeolocation): Added.
LayoutTests:
* fast/dom/Geolocation/dataURL-getCurrentPosition-expected.txt: Added.
* fast/dom/Geolocation/dataURL-getCurrentPosition.html: Added.
* fast/dom/Geolocation/dataURL-watchPosition-expected.txt: Added.
* fast/dom/Geolocation/dataURL-watchPosition.html: Added.
* fast/dom/Geolocation/srcdoc-getCurrentPosition-expected.txt: Added.
* fast/dom/Geolocation/srcdoc-getCurrentPosition.html: Added.
* fast/dom/Geolocation/srcdoc-watchPosition-expected.txt: Added.
* fast/dom/Geolocation/srcdoc-watchPosition.html: Added.
* http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js: Added.
(done):
(logMessage):
(didReceivePosition):
(didReceiveError):
(checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod):
(markupToCheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod):
(dataURLToCheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod):
* http/tests/security/resources/sandboxed-iframe-geolocation-getCurrentPosition.html: Added.
* http/tests/security/resources/sandboxed-iframe-geolocation-watchPosition.html: Added.
* http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition-expected.txt: Added.
* http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html: Added.
* http/tests/security/sandboxed-iframe-geolocation-watchPosition-expected.txt: Added.
* http/tests/security/sandboxed-iframe-geolocation-watchPosition.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="#trunkSourceWebCorepageSecurityOriginh">trunk/Source/WebCore/page/SecurityOrigin.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomGeolocationdataURLgetCurrentPositionexpectedtxt">trunk/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomGeolocationdataURLgetCurrentPositionhtml">trunk/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition.html</a></li>
<li><a href="#trunkLayoutTestsfastdomGeolocationdataURLwatchPositionexpectedtxt">trunk/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomGeolocationdataURLwatchPositionhtml">trunk/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition.html</a></li>
<li><a href="#trunkLayoutTestsfastdomGeolocationsrcdocgetCurrentPositionexpectedtxt">trunk/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomGeolocationsrcdocgetCurrentPositionhtml">trunk/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition.html</a></li>
<li><a href="#trunkLayoutTestsfastdomGeolocationsrcdocwatchPositionexpectedtxt">trunk/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomGeolocationsrcdocwatchPositionhtml">trunk/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityresourcescheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethodjs">trunk/LayoutTests/http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityresourcessandboxediframegeolocationgetCurrentPositionhtml">trunk/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-getCurrentPosition.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityresourcessandboxediframegeolocationwatchPositionhtml">trunk/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-watchPosition.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritysandboxediframegeolocationgetCurrentPositionexpectedtxt">trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritysandboxediframegeolocationgetCurrentPositionhtml">trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritysandboxediframegeolocationwatchPositionexpectedtxt">trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritysandboxediframegeolocationwatchPositionhtml">trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (195074 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-01-14 21:40:13 UTC (rev 195074)
+++ trunk/LayoutTests/ChangeLog        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -1,5 +1,36 @@
</span><span class="cx"> 2016-01-14 Daniel Bates <dabates@apple.com>
</span><span class="cx">
</span><ins>+ Disallow use of Geolocation service from unique origins
+ https://bugs.webkit.org/show_bug.cgi?id=153102
+ <rdar://problem/23055645>
+
+ Reviewed by Alexey Proskuryakov.
+
+ * fast/dom/Geolocation/dataURL-getCurrentPosition-expected.txt: Added.
+ * fast/dom/Geolocation/dataURL-getCurrentPosition.html: Added.
+ * fast/dom/Geolocation/dataURL-watchPosition-expected.txt: Added.
+ * fast/dom/Geolocation/dataURL-watchPosition.html: Added.
+ * fast/dom/Geolocation/srcdoc-getCurrentPosition-expected.txt: Added.
+ * fast/dom/Geolocation/srcdoc-getCurrentPosition.html: Added.
+ * fast/dom/Geolocation/srcdoc-watchPosition-expected.txt: Added.
+ * fast/dom/Geolocation/srcdoc-watchPosition.html: Added.
+ * http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js: Added.
+ (done):
+ (logMessage):
+ (didReceivePosition):
+ (didReceiveError):
+ (checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod):
+ (markupToCheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod):
+ (dataURLToCheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod):
+ * http/tests/security/resources/sandboxed-iframe-geolocation-getCurrentPosition.html: Added.
+ * http/tests/security/resources/sandboxed-iframe-geolocation-watchPosition.html: Added.
+ * http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition-expected.txt: Added.
+ * http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html: Added.
+ * http/tests/security/sandboxed-iframe-geolocation-watchPosition-expected.txt: Added.
+ * http/tests/security/sandboxed-iframe-geolocation-watchPosition.html: Added.
+
+2016-01-14 Daniel Bates <dabates@apple.com>
+
</ins><span class="cx"> [XSS Auditor] Partial bypass when web server collapses path components
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=152872
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomGeolocationdataURLgetCurrentPositionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition-expected.txt (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition-expected.txt        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+PASS error.code is error.POSITION_UNAVAILABLE.
+PASS error.message is "Origin does not have permission to use Geolocation service".
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomGeolocationdataURLgetCurrentPositionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition.html (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition.html        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<!-- Tests that navigator.geolocation.getCurrentPosition() returns error POSITION_UNAVAILABLE when called from a document with a data URL. -->
+<script src="../../../http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js"></script>
+<script>
+var PositionUnavailableMockMessage = "Origin does not have permission to use Geolocation service";
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ testRunner.setGeolocationPermission(true);
+ testRunner.setMockGeolocationPositionUnavailableError(PositionUnavailableMockMessage);
+ testRunner.setMockGeolocationPosition(37.3317115, -122.0323722, 100.0);
+}
+
+function done()
+{
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+window.location = dataURLToCheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod("getCurrentPosition", PositionUnavailableMockMessage, done);
+</script>
+</head>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomGeolocationdataURLwatchPositionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition-expected.txt (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition-expected.txt        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+PASS error.code is error.POSITION_UNAVAILABLE.
+PASS error.message is "Origin does not have permission to use Geolocation service".
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomGeolocationdataURLwatchPositionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition.html (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition.html        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<!-- Tests that navigator.geolocation.watchPosition() returns error POSITION_UNAVAILABLE when called from a document with a data URL. -->
+<script src="../../../http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js"></script>
+<script>
+var PositionUnavailableMockMessage = "Origin does not have permission to use Geolocation service";
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ testRunner.setGeolocationPermission(true);
+ testRunner.setMockGeolocationPositionUnavailableError(PositionUnavailableMockMessage);
+ testRunner.setMockGeolocationPosition(37.3317115, -122.0323722, 100.0);
+}
+
+function done()
+{
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+window.location = dataURLToCheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod("watchPosition", PositionUnavailableMockMessage, done);
+</script>
+</head>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomGeolocationsrcdocgetCurrentPositionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition-expected.txt (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition-expected.txt        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+Tests that navigator.geolocation.getCurrentPosition() returns error POSITION_UNAVAILABLE when called from a srcdoc.
+
+
+
+--------
+Frame: 'frame'
+--------
+FAIL should have invoked error callback, but invoked success callback.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomGeolocationsrcdocgetCurrentPositionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition.html (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition.html        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js"></script>
+</head>
+<body>
+<p>Tests that navigator.geolocation.getCurrentPosition() returns error POSITION_UNAVAILABLE when called from a srcdoc.</p>
+<iframe id="frame" width="100%" height="300"></iframe>
+<script>
+var PositionUnavailableMockMessage = "Origin does not have permission to use Geolocation service";
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.dumpChildFramesAsText();
+ testRunner.waitUntilDone();
+ testRunner.setGeolocationPermission(true);
+ testRunner.setMockGeolocationPositionUnavailableError(PositionUnavailableMockMessage);
+ testRunner.setMockGeolocationPosition(37.3317115, -122.0323722, 100.0);
+}
+
+function done()
+{
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+document.getElementById("frame").srcdoc = markupToCheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod("getCurrentPosition", PositionUnavailableMockMessage, done);
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomGeolocationsrcdocwatchPositionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition-expected.txt (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition-expected.txt        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+Tests that navigator.geolocation.watchPosition() returns error POSITION_UNAVAILABLE when called from a srcdoc.
+
+
+
+--------
+Frame: 'frame'
+--------
+FAIL should have invoked error callback, but invoked success callback.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomGeolocationsrcdocwatchPositionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition.html (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition.html        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js"></script>
+</head>
+<body>
+<p>Tests that navigator.geolocation.watchPosition() returns error POSITION_UNAVAILABLE when called from a srcdoc.</p>
+<iframe id="frame" width="100%" height="300"></iframe>
+<script>
+var PositionUnavailableMockMessage = "Origin does not have permission to use Geolocation service";
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.dumpChildFramesAsText();
+ testRunner.waitUntilDone();
+ testRunner.setGeolocationPermission(true);
+ testRunner.setMockGeolocationPositionUnavailableError(PositionUnavailableMockMessage);
+ testRunner.setMockGeolocationPosition(37.3317115, -122.0323722, 100.0);
+}
+
+function done()
+{
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+document.getElementById("frame").srcdoc = markupToCheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod("watchPosition", PositionUnavailableMockMessage, done);
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityresourcescheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethodjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js         (rev 0)
+++ trunk/LayoutTests/http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+function checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod(geolocationMethodName, expectedPositionUnavailableErrorMessage, callbackFunction)
+{
+ function done()
+ {
+ if (callbackFunction)
+ callbackFunction();
+ }
+
+ function logMessage(message)
+ {
+ document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
+ }
+
+ function didReceivePosition()
+ {
+ logMessage("FAIL should have invoked error callback, but invoked success callback.");
+ done();
+ }
+
+ function didReceiveError(error)
+ {
+ if (error.code === error.POSITION_UNAVAILABLE)
+ logMessage("PASS error.code is error.POSITION_UNAVAILABLE.");
+ else
+ logMessage("FAIL error.code should be " + error.POSITION_UNAVAILABLE + ". Was " + error.code + ".");
+
+ if (error.message === expectedPositionUnavailableErrorMessage)
+ logMessage('PASS error.message is "' + expectedPositionUnavailableErrorMessage + '".');
+ else
+ logMessage('FAIL error.message should be "' + expectedPositionUnavailableErrorMessage + '". Was "' + error.message + '".');
+ done();
+ }
+
+ navigator.geolocation[geolocationMethodName](didReceivePosition, didReceiveError);
+}
+
+function markupToCheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod(geolocationMethodNameAsString, expectedPositionUnavailableErrorMessage, callbackFunction)
+{
+ var result = "<!DOCTYPE html>"
+ result += "<html>";
+ result += "<head>";
+ result += "<script>";
+ result += checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.toString() + ";";
+ result += "checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod(" + JSON.stringify(geolocationMethodNameAsString) + ", " + JSON.stringify(expectedPositionUnavailableErrorMessage) + ", " + callbackFunction.toString() + ");";
+ result += "</" + "script>";
+ result += "</head>";
+ result += "<body>";
+ result += '<pre id="console"></pre>';
+ result += "</body>";
+ result += "</html>";
+ return result;
+}
+
+function dataURLToCheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod(geolocationMethodNameAsString, expectedPositionUnavailableErrorMessage, callbackFunction)
+{
+ return "data:text/html," + encodeURIComponent(markupToCheckThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod(geolocationMethodNameAsString, expectedPositionUnavailableErrorMessage, callbackFunction));
+}
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityresourcessandboxediframegeolocationgetCurrentPositionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-getCurrentPosition.html (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-getCurrentPosition.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-getCurrentPosition.html        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="http://127.0.0.1:8000/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js"></script>
+<script>
+var PositionUnavailableMockMessage = "Origin does not have permission to use Geolocation service";
+if (window.testRunner) {
+ testRunner.setGeolocationPermission(true);
+ testRunner.setMockGeolocationPositionUnavailableError(PositionUnavailableMockMessage);
+ testRunner.setMockGeolocationPosition(37.3317115, -122.0323722, 100.0);
+}
+
+function done()
+{
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod("getCurrentPosition", PositionUnavailableMockMessage, done);
+</script>
+</head>
+<body>
+<pre id="console"></pre>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityresourcessandboxediframegeolocationwatchPositionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-watchPosition.html (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-watchPosition.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-watchPosition.html        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="http://127.0.0.1:8000/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js"></script>
+<script>
+var PositionUnavailableMockMessage = "Origin does not have permission to use Geolocation service";
+if (window.testRunner) {
+ testRunner.setGeolocationPermission(true);
+ testRunner.setMockGeolocationPositionUnavailableError(PositionUnavailableMockMessage);
+ testRunner.setMockGeolocationPosition(37.3317115, -122.0323722, 100.0);
+}
+
+function done()
+{
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod("watchPosition", PositionUnavailableMockMessage, done);
+</script>
+</head>
+<body>
+<pre id="console"></pre>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritysandboxediframegeolocationgetCurrentPositionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition-expected.txt (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition-expected.txt        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Tests that navigator.geolocation.getCurrentPosition() returns error POSITION_UNAVAILABLE when called from a document in a sandboxed iframe.
+
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+PASS error.code is error.POSITION_UNAVAILABLE.
+PASS error.message is "Origin does not have permission to use Geolocation service".
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritysandboxediframegeolocationgetCurrentPositionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.dumpChildFramesAsText();
+ testRunner.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<p>Tests that navigator.geolocation.getCurrentPosition() returns error POSITION_UNAVAILABLE when called from a document in a sandboxed iframe.</p>
+<iframe src="resources/sandboxed-iframe-geolocation-getCurrentPosition.html" sandbox="allow-scripts" width="100%" height="300"></iframe>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritysandboxediframegeolocationwatchPositionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition-expected.txt (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition-expected.txt        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Tests that navigator.geolocation.watchPosition() returns error POSITION_UNAVAILABLE when called from a document in a sandboxed iframe.
+
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+PASS error.code is error.POSITION_UNAVAILABLE.
+PASS error.message is "Origin does not have permission to use Geolocation service".
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritysandboxediframegeolocationwatchPositionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition.html (0 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition.html        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.dumpChildFramesAsText();
+ testRunner.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<p>Tests that navigator.geolocation.watchPosition() returns error POSITION_UNAVAILABLE when called from a document in a sandboxed iframe.</p>
+<iframe src="resources/sandboxed-iframe-geolocation-watchPosition.html" sandbox="allow-scripts" width="100%" height="300"></iframe>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (195074 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-14 21:40:13 UTC (rev 195074)
+++ trunk/Source/WebCore/ChangeLog        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -1,5 +1,29 @@
</span><span class="cx"> 2016-01-14 Daniel Bates <dabates@apple.com>
</span><span class="cx">
</span><ins>+ Disallow use of Geolocation service from unique origins
+ https://bugs.webkit.org/show_bug.cgi?id=153102
+ <rdar://problem/23055645>
+
+ Reviewed by Alexey Proskuryakov.
+
+ Tests: fast/dom/Geolocation/dataURL-getCurrentPosition.html
+ fast/dom/Geolocation/dataURL-watchPosition.html
+ fast/dom/Geolocation/srcdoc-getCurrentPosition.html
+ fast/dom/Geolocation/srcdoc-watchPosition.html
+ http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html
+ http/tests/security/sandboxed-iframe-geolocation-watchPosition.html
+
+ * Modules/geolocation/Geolocation.cpp:
+ (WebCore::Geolocation::securityOrigin): Convenience function to get the SecurityOrigin object
+ associated with this script execution context.
+ (WebCore::Geolocation::startRequest): Notify requester POSITION_UNAVAILABLE when requested
+ from a document with a unique origin.
+ * Modules/geolocation/Geolocation.h:
+ * page/SecurityOrigin.h:
+ (WebCore::SecurityOrigin::canRequestGeolocation): Added.
+
+2016-01-14 Daniel Bates <dabates@apple.com>
+
</ins><span class="cx"> [XSS Auditor] Extract attribute truncation logic and formalize string canonicalization
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=152874
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesgeolocationGeolocationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp (195074 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp        2016-01-14 21:40:13 UTC (rev 195074)
+++ trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> #include "Geoposition.h"
</span><span class="cx"> #include "Page.h"
</span><span class="cx"> #include "PositionError.h"
</span><ins>+#include "SecurityOrigin.h"
</ins><span class="cx"> #include <wtf/CurrentTime.h>
</span><span class="cx"> #include <wtf/Ref.h>
</span><span class="cx">
</span><span class="lines">@@ -48,6 +49,7 @@
</span><span class="cx"> static const char permissionDeniedErrorMessage[] = "User denied Geolocation";
</span><span class="cx"> static const char failedToStartServiceErrorMessage[] = "Failed to start Geolocation service";
</span><span class="cx"> static const char framelessDocumentErrorMessage[] = "Geolocation cannot be used in frameless documents";
</span><ins>+static const char originCannotRequestGeolocationErrorMessage[] = "Origin does not have permission to use Geolocation service";
</ins><span class="cx">
</span><span class="cx"> static RefPtr<Geoposition> createGeoposition(GeolocationPosition* position)
</span><span class="cx"> {
</span><span class="lines">@@ -151,6 +153,11 @@
</span><span class="cx"> return downcast<Document>(scriptExecutionContext());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+SecurityOrigin* Geolocation::securityOrigin() const
+{
+ return scriptExecutionContext()->securityOrigin();
+}
+
</ins><span class="cx"> Frame* Geolocation::frame() const
</span><span class="cx"> {
</span><span class="cx"> return document() ? document()->frame() : nullptr;
</span><span class="lines">@@ -332,6 +339,11 @@
</span><span class="cx">
</span><span class="cx"> void Geolocation::startRequest(GeoNotifier* notifier)
</span><span class="cx"> {
</span><ins>+ if (!securityOrigin()->canRequestGeolocation()) {
+ notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, ASCIILiteral(originCannotRequestGeolocationErrorMessage)));
+ return;
+ }
+
</ins><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 class="cx"> if (isDenied())
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesgeolocationGeolocationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/geolocation/Geolocation.h (195074 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/geolocation/Geolocation.h        2016-01-14 21:40:13 UTC (rev 195074)
+++ trunk/Source/WebCore/Modules/geolocation/Geolocation.h        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> class GeolocationPosition;
</span><span class="cx"> class Page;
</span><span class="cx"> class ScriptExecutionContext;
</span><ins>+class SecurityOrigin;
</ins><span class="cx">
</span><span class="cx"> class Geolocation : public ScriptWrappable, public RefCounted<Geolocation>, public ActiveDOMObject
</span><span class="cx"> {
</span><span class="lines">@@ -87,6 +88,7 @@
</span><span class="cx"> bool isDenied() const { return m_allowGeolocation == No; }
</span><span class="cx">
</span><span class="cx"> Page* page() const;
</span><ins>+ SecurityOrigin* securityOrigin() const;
</ins><span class="cx">
</span><span class="cx"> typedef Vector<RefPtr<GeoNotifier>> GeoNotifierVector;
</span><span class="cx"> typedef HashSet<RefPtr<GeoNotifier>> GeoNotifierSet;
</span></span></pre></div>
<a id="trunkSourceWebCorepageSecurityOriginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/SecurityOrigin.h (195074 => 195075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/SecurityOrigin.h        2016-01-14 21:40:13 UTC (rev 195074)
+++ trunk/Source/WebCore/page/SecurityOrigin.h        2016-01-14 21:42:35 UTC (rev 195075)
</span><span class="lines">@@ -156,6 +156,7 @@
</span><span class="cx"> bool canAccessPluginStorage(const SecurityOrigin* topOrigin) const { return canAccessStorage(topOrigin); }
</span><span class="cx"> bool canAccessApplicationCache(const SecurityOrigin* topOrigin) const { return canAccessStorage(topOrigin); }
</span><span class="cx"> bool canAccessCookies() const { return !isUnique(); }
</span><ins>+ bool canRequestGeolocation() const { return !isUnique(); }
</ins><span class="cx"> Policy canShowNotifications() const;
</span><span class="cx">
</span><span class="cx"> // The local SecurityOrigin is the most privileged SecurityOrigin.
</span></span></pre>
</div>
</div>
</body>
</html>