Title: [195715] branches/safari-601-branch
Revision
195715
Author
matthew_han...@apple.com
Date
2016-01-27 17:34:12 -0800 (Wed, 27 Jan 2016)

Log Message

Merge r195075. rdar://problem/24302727

Modified Paths

Added Paths

Diff

Modified: branches/safari-601-branch/LayoutTests/ChangeLog (195714 => 195715)


--- branches/safari-601-branch/LayoutTests/ChangeLog	2016-01-28 01:34:05 UTC (rev 195714)
+++ branches/safari-601-branch/LayoutTests/ChangeLog	2016-01-28 01:34:12 UTC (rev 195715)
@@ -1,3 +1,38 @@
+2016-01-27  Matthew Hanson  <matthew_han...@apple.com>
+
+        Merge r195075. rdar://problem/24302727
+
+    2016-01-14  Daniel Bates  <daba...@apple.com>
+
+            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-20  Babak Shafiei  <bshaf...@apple.com>
 
         Merge r188383.

Added: branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition-expected.txt (0 => 195715)


--- branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition-expected.txt	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition-expected.txt	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,3 @@
+PASS error.code is error.POSITION_UNAVAILABLE.
+PASS error.message is "Origin does not have permission to use Geolocation service".
+

Added: branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition.html (0 => 195715)


--- branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition.html	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/dataURL-getCurrentPosition.html	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<!-- Tests that navigator.geolocation.getCurrentPosition() returns error POSITION_UNAVAILABLE when called from a document with a data URL. -->
+<script src=""
+<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>

Added: branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition-expected.txt (0 => 195715)


--- branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition-expected.txt	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition-expected.txt	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,3 @@
+PASS error.code is error.POSITION_UNAVAILABLE.
+PASS error.message is "Origin does not have permission to use Geolocation service".
+

Added: branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition.html (0 => 195715)


--- branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition.html	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/dataURL-watchPosition.html	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<!-- Tests that navigator.geolocation.watchPosition() returns error POSITION_UNAVAILABLE when called from a document with a data URL. -->
+<script src=""
+<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>

Added: branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition-expected.txt (0 => 195715)


--- branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition-expected.txt	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition-expected.txt	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,9 @@
+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.
+

Added: branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition.html (0 => 195715)


--- branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition.html	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/srcdoc-getCurrentPosition.html	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</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>

Added: branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition-expected.txt (0 => 195715)


--- branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition-expected.txt	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition-expected.txt	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,9 @@
+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.
+

Added: branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition.html (0 => 195715)


--- branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition.html	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/fast/dom/Geolocation/srcdoc-watchPosition.html	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</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>

Added: branches/safari-601-branch/LayoutTests/http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js (0 => 195715)


--- branches/safari-601-branch/LayoutTests/http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/http/tests/security/resources/checkThatPositionErrorCallbackIsCalledWithPositionUnavailableForGeolocationMethod.js	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,57 @@
+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));
+}

Added: branches/safari-601-branch/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-getCurrentPosition.html (0 => 195715)


--- branches/safari-601-branch/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-getCurrentPosition.html	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-getCurrentPosition.html	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<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>

Added: branches/safari-601-branch/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-watchPosition.html (0 => 195715)


--- branches/safari-601-branch/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-watchPosition.html	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/http/tests/security/resources/sandboxed-iframe-geolocation-watchPosition.html	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<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>

Added: branches/safari-601-branch/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition-expected.txt (0 => 195715)


--- branches/safari-601-branch/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition-expected.txt	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition-expected.txt	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,10 @@
+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".
+

Added: branches/safari-601-branch/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html (0 => 195715)


--- branches/safari-601-branch/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-getCurrentPosition.html	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,16 @@
+<!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="" sandbox="allow-scripts" width="100%" height="300"></iframe>
+</body>
+</html>

Added: branches/safari-601-branch/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition-expected.txt (0 => 195715)


--- branches/safari-601-branch/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition-expected.txt	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition-expected.txt	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,10 @@
+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".
+

Added: branches/safari-601-branch/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition.html (0 => 195715)


--- branches/safari-601-branch/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition.html	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/http/tests/security/sandboxed-iframe-geolocation-watchPosition.html	2016-01-28 01:34:12 UTC (rev 195715)
@@ -0,0 +1,16 @@
+<!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="" sandbox="allow-scripts" width="100%" height="300"></iframe>
+</body>
+</html>

Modified: branches/safari-601-branch/Source/WebCore/ChangeLog (195714 => 195715)


--- branches/safari-601-branch/Source/WebCore/ChangeLog	2016-01-28 01:34:05 UTC (rev 195714)
+++ branches/safari-601-branch/Source/WebCore/ChangeLog	2016-01-28 01:34:12 UTC (rev 195715)
@@ -1,5 +1,33 @@
 2016-01-27  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r195075. rdar://problem/24302727
+
+    2016-01-14  Daniel Bates  <daba...@apple.com>
+
+            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-27  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r194559. rdar://problem/24269083
 
     2016-01-04  Tim Horton  <timothy_hor...@apple.com>

Modified: branches/safari-601-branch/Source/WebCore/Modules/geolocation/Geolocation.cpp (195714 => 195715)


--- branches/safari-601-branch/Source/WebCore/Modules/geolocation/Geolocation.cpp	2016-01-28 01:34:05 UTC (rev 195714)
+++ branches/safari-601-branch/Source/WebCore/Modules/geolocation/Geolocation.cpp	2016-01-28 01:34:12 UTC (rev 195715)
@@ -40,6 +40,7 @@
 #include "Geoposition.h"
 #include "Page.h"
 #include "PositionError.h"
+#include "SecurityOrigin.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/Ref.h>
 
@@ -48,6 +49,7 @@
 static const char permissionDeniedErrorMessage[] = "User denied Geolocation";
 static const char failedToStartServiceErrorMessage[] = "Failed to start Geolocation service";
 static const char framelessDocumentErrorMessage[] = "Geolocation cannot be used in frameless documents";
+static const char originCannotRequestGeolocationErrorMessage[] = "Origin does not have permission to use Geolocation service";
 
 static PassRefPtr<Geoposition> createGeoposition(GeolocationPosition* position)
 {
@@ -152,6 +154,11 @@
     return downcast<Document>(scriptExecutionContext());
 }
 
+SecurityOrigin* Geolocation::securityOrigin() const
+{
+    return scriptExecutionContext()->securityOrigin();
+}
+
 Frame* Geolocation::frame() const
 {
     return document() ? document()->frame() : nullptr;
@@ -336,6 +343,11 @@
 
 void Geolocation::startRequest(GeoNotifier *notifier)
 {
+    if (!securityOrigin()->canRequestGeolocation()) {
+        notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, ASCIILiteral(originCannotRequestGeolocationErrorMessage)));
+        return;
+    }
+
     // Check whether permissions have already been denied. Note that if this is the case,
     // the permission state can not change again in the lifetime of this page.
     if (isDenied())

Modified: branches/safari-601-branch/Source/WebCore/Modules/geolocation/Geolocation.h (195714 => 195715)


--- branches/safari-601-branch/Source/WebCore/Modules/geolocation/Geolocation.h	2016-01-28 01:34:05 UTC (rev 195714)
+++ branches/safari-601-branch/Source/WebCore/Modules/geolocation/Geolocation.h	2016-01-28 01:34:12 UTC (rev 195715)
@@ -48,6 +48,7 @@
 class GeolocationPosition;
 class Page;
 class ScriptExecutionContext;
+class SecurityOrigin;
 
 class Geolocation : public ScriptWrappable, public RefCounted<Geolocation>, public ActiveDOMObject
 {
@@ -87,6 +88,7 @@
     bool isDenied() const { return m_allowGeolocation == No; }
 
     Page* page() const;
+    SecurityOrigin* securityOrigin() const;
 
     typedef Vector<RefPtr<GeoNotifier>> GeoNotifierVector;
     typedef HashSet<RefPtr<GeoNotifier>> GeoNotifierSet;

Modified: branches/safari-601-branch/Source/WebCore/page/SecurityOrigin.h (195714 => 195715)


--- branches/safari-601-branch/Source/WebCore/page/SecurityOrigin.h	2016-01-28 01:34:05 UTC (rev 195714)
+++ branches/safari-601-branch/Source/WebCore/page/SecurityOrigin.h	2016-01-28 01:34:12 UTC (rev 195715)
@@ -156,6 +156,7 @@
     bool canAccessPluginStorage(const SecurityOrigin* topOrigin) const { return canAccessStorage(topOrigin); }
     bool canAccessApplicationCache(const SecurityOrigin* topOrigin) const { return canAccessStorage(topOrigin); }
     bool canAccessCookies() const { return !isUnique(); }
+    bool canRequestGeolocation() const { return !isUnique(); }
     Policy canShowNotifications() const;
 
     // The local SecurityOrigin is the most privileged SecurityOrigin.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to