Commit 3e90d7df authored by Reilly Grant's avatar Reilly Grant Committed by Commit Bot

[geolocation] Rename interfaces and remove [NoInterfaceObject]

This change renames the following interfaces and removes the
[NoInterfaceObject] annotation so that these types are now exposed to
script:

  Coordinates   -> GeolocationCoordinates
  Position      -> GeolocationPosition
  PositionError -> GeolocationPositionError

This is done in response to an effort to remove this annotation from
WebIDL.

Spec pull requests (merged):
https://github.com/w3c/geolocation-api/pull/20
https://github.com/w3c/geolocation-api/pull/23

Intent to Ship:
https://groups.google.com/a/chromium.org/d/msg/blink-dev/Xig9oewsQMA/eyC7dbtiAAAJ

Bug: 931847
Change-Id: I38d0172afc33d5757b664e2807356d8727e82d7f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1471230
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarYoav Weiss <yoavweiss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695573}
parent 25f5ad74
...@@ -6,18 +6,18 @@ import("//third_party/blink/renderer/modules/modules.gni") ...@@ -6,18 +6,18 @@ import("//third_party/blink/renderer/modules/modules.gni")
blink_modules_sources("geolocation") { blink_modules_sources("geolocation") {
sources = [ sources = [
"coordinates.cc",
"coordinates.h",
"geo_notifier.cc", "geo_notifier.cc",
"geo_notifier.h", "geo_notifier.h",
"geolocation.cc", "geolocation.cc",
"geolocation.h", "geolocation.h",
"geolocation_coordinates.cc",
"geolocation_coordinates.h",
"geolocation_error.h", "geolocation_error.h",
"geolocation_position_error.h",
"geolocation_watchers.cc", "geolocation_watchers.cc",
"geolocation_watchers.h", "geolocation_watchers.h",
"geoposition.h", "geoposition.h",
"navigator_geolocation.cc", "navigator_geolocation.cc",
"navigator_geolocation.h", "navigator_geolocation.h",
"position_error.h",
] ]
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/modules/geolocation/geolocation.h" #include "third_party/blink/renderer/modules/geolocation/geolocation.h"
#include "third_party/blink/renderer/modules/geolocation/position_error.h" #include "third_party/blink/renderer/modules/geolocation/geolocation_position_error.h"
#include "third_party/blink/renderer/modules/geolocation/position_options.h" #include "third_party/blink/renderer/modules/geolocation/position_options.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h" #include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h" #include "third_party/blink/renderer/platform/wtf/assertions.h"
...@@ -45,7 +45,7 @@ void GeoNotifier::Trace(blink::Visitor* visitor) { ...@@ -45,7 +45,7 @@ void GeoNotifier::Trace(blink::Visitor* visitor) {
visitor->Trace(fatal_error_); visitor->Trace(fatal_error_);
} }
void GeoNotifier::SetFatalError(PositionError* error) { void GeoNotifier::SetFatalError(GeolocationPositionError* error) {
// If a fatal error has already been set, stick with it. This makes sure that // If a fatal error has already been set, stick with it. This makes sure that
// when permission is denied, this is the error reported, as required by the // when permission is denied, this is the error reported, as required by the
// spec. // spec.
...@@ -67,7 +67,7 @@ void GeoNotifier::RunSuccessCallback(Geoposition* position) { ...@@ -67,7 +67,7 @@ void GeoNotifier::RunSuccessCallback(Geoposition* position) {
success_callback_->InvokeAndReportException(nullptr, position); success_callback_->InvokeAndReportException(nullptr, position);
} }
void GeoNotifier::RunErrorCallback(PositionError* error) { void GeoNotifier::RunErrorCallback(GeolocationPositionError* error) {
if (error_callback_) if (error_callback_)
error_callback_->InvokeAndReportException(nullptr, error); error_callback_->InvokeAndReportException(nullptr, error);
} }
...@@ -132,8 +132,8 @@ void GeoNotifier::TimerFired(TimerBase*) { ...@@ -132,8 +132,8 @@ void GeoNotifier::TimerFired(TimerBase*) {
if (error_callback_) { if (error_callback_) {
error_callback_->InvokeAndReportException( error_callback_->InvokeAndReportException(
nullptr, MakeGarbageCollected<PositionError>(PositionError::kTimeout, nullptr, MakeGarbageCollected<GeolocationPositionError>(
"Timeout expired")); GeolocationPositionError::kTimeout, "Timeout expired"));
} }
DEFINE_STATIC_LOCAL(CustomCountHistogram, timeout_expired_histogram, DEFINE_STATIC_LOCAL(CustomCountHistogram, timeout_expired_histogram,
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
namespace blink { namespace blink {
class Geolocation; class Geolocation;
class GeolocationPositionError;
class Geoposition; class Geoposition;
class PositionError;
class GeoNotifier final : public GarbageCollectedFinalized<GeoNotifier>, class GeoNotifier final : public GarbageCollectedFinalized<GeoNotifier>,
public NameClient { public NameClient {
...@@ -34,7 +34,7 @@ class GeoNotifier final : public GarbageCollectedFinalized<GeoNotifier>, ...@@ -34,7 +34,7 @@ class GeoNotifier final : public GarbageCollectedFinalized<GeoNotifier>,
// Sets the given error as the fatal error if there isn't one yet. // Sets the given error as the fatal error if there isn't one yet.
// Starts the timer with an interval of 0. // Starts the timer with an interval of 0.
void SetFatalError(PositionError*); void SetFatalError(GeolocationPositionError*);
bool UseCachedPosition() const { return use_cached_position_; } bool UseCachedPosition() const { return use_cached_position_; }
...@@ -43,7 +43,7 @@ class GeoNotifier final : public GarbageCollectedFinalized<GeoNotifier>, ...@@ -43,7 +43,7 @@ class GeoNotifier final : public GarbageCollectedFinalized<GeoNotifier>,
void SetUseCachedPosition(); void SetUseCachedPosition();
void RunSuccessCallback(Geoposition*); void RunSuccessCallback(Geoposition*);
void RunErrorCallback(PositionError*); void RunErrorCallback(GeolocationPositionError*);
void StartTimer(); void StartTimer();
void StopTimer(); void StopTimer();
...@@ -83,7 +83,7 @@ class GeoNotifier final : public GarbageCollectedFinalized<GeoNotifier>, ...@@ -83,7 +83,7 @@ class GeoNotifier final : public GarbageCollectedFinalized<GeoNotifier>,
Member<V8PositionErrorCallback> error_callback_; Member<V8PositionErrorCallback> error_callback_;
Member<const PositionOptions> options_; Member<const PositionOptions> options_;
Member<Timer> timer_; Member<Timer> timer_;
Member<PositionError> fatal_error_; Member<GeolocationPositionError> fatal_error_;
bool use_cached_position_; bool use_cached_position_;
}; };
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "third_party/blink/renderer/core/frame/settings.h" #include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/inspector/console_message.h" #include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/probe/core_probes.h" #include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/modules/geolocation/coordinates.h" #include "third_party/blink/renderer/modules/geolocation/geolocation_coordinates.h"
#include "third_party/blink/renderer/modules/geolocation/geolocation_error.h" #include "third_party/blink/renderer/modules/geolocation/geolocation_error.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h" #include "third_party/blink/renderer/platform/wtf/assertions.h"
...@@ -55,7 +55,7 @@ const char kFeaturePolicyConsoleWarning[] = ...@@ -55,7 +55,7 @@ const char kFeaturePolicyConsoleWarning[] =
Geoposition* CreateGeoposition( Geoposition* CreateGeoposition(
const device::mojom::blink::Geoposition& position) { const device::mojom::blink::Geoposition& position) {
auto* coordinates = MakeGarbageCollected<Coordinates>( auto* coordinates = MakeGarbageCollected<GeolocationCoordinates>(
position.latitude, position.longitude, position.latitude, position.longitude,
// Lowest point on land is at approximately -400 meters. // Lowest point on land is at approximately -400 meters.
position.altitude > -10000., position.altitude, position.accuracy, position.altitude > -10000., position.altitude, position.accuracy,
...@@ -67,23 +67,24 @@ Geoposition* CreateGeoposition( ...@@ -67,23 +67,24 @@ Geoposition* CreateGeoposition(
ConvertSecondsToDOMTimeStamp(position.timestamp.ToDoubleT())); ConvertSecondsToDOMTimeStamp(position.timestamp.ToDoubleT()));
} }
PositionError* CreatePositionError( GeolocationPositionError* CreatePositionError(
device::mojom::blink::Geoposition::ErrorCode mojom_error_code, device::mojom::blink::Geoposition::ErrorCode mojom_error_code,
const String& error) { const String& error) {
PositionError::ErrorCode error_code = PositionError::kPositionUnavailable; GeolocationPositionError::ErrorCode error_code =
GeolocationPositionError::kPositionUnavailable;
switch (mojom_error_code) { switch (mojom_error_code) {
case device::mojom::blink::Geoposition::ErrorCode::PERMISSION_DENIED: case device::mojom::blink::Geoposition::ErrorCode::PERMISSION_DENIED:
error_code = PositionError::kPermissionDenied; error_code = GeolocationPositionError::kPermissionDenied;
break; break;
case device::mojom::blink::Geoposition::ErrorCode::POSITION_UNAVAILABLE: case device::mojom::blink::Geoposition::ErrorCode::POSITION_UNAVAILABLE:
error_code = PositionError::kPositionUnavailable; error_code = GeolocationPositionError::kPositionUnavailable;
break; break;
case device::mojom::blink::Geoposition::ErrorCode::NONE: case device::mojom::blink::Geoposition::ErrorCode::NONE:
case device::mojom::blink::Geoposition::ErrorCode::TIMEOUT: case device::mojom::blink::Geoposition::ErrorCode::TIMEOUT:
NOTREACHED(); NOTREACHED();
break; break;
} }
return MakeGarbageCollected<PositionError>(error_code, error); return MakeGarbageCollected<GeolocationPositionError>(error_code, error);
} }
static void ReportGeolocationViolation(Document* doc) { static void ReportGeolocationViolation(Document* doc) {
...@@ -100,8 +101,7 @@ static void ReportGeolocationViolation(Document* doc) { ...@@ -100,8 +101,7 @@ static void ReportGeolocationViolation(Document* doc) {
} // namespace } // namespace
Geolocation* Geolocation::Create(ExecutionContext* context) { Geolocation* Geolocation::Create(ExecutionContext* context) {
Geolocation* geolocation = MakeGarbageCollected<Geolocation>(context); return MakeGarbageCollected<Geolocation>(context);
return geolocation;
} }
Geolocation::Geolocation(ExecutionContext* context) Geolocation::Geolocation(ExecutionContext* context)
...@@ -221,8 +221,8 @@ void Geolocation::StartRequest(GeoNotifier* notifier) { ...@@ -221,8 +221,8 @@ void Geolocation::StartRequest(GeoNotifier* notifier) {
String error_message; String error_message;
if (!GetFrame()->GetSettings()->GetAllowGeolocationOnInsecureOrigins() && if (!GetFrame()->GetSettings()->GetAllowGeolocationOnInsecureOrigins() &&
!GetExecutionContext()->IsSecureContext(error_message)) { !GetExecutionContext()->IsSecureContext(error_message)) {
notifier->SetFatalError(MakeGarbageCollected<PositionError>( notifier->SetFatalError(MakeGarbageCollected<GeolocationPositionError>(
PositionError::kPermissionDenied, error_message)); GeolocationPositionError::kPermissionDenied, error_message));
return; return;
} }
...@@ -231,8 +231,9 @@ void Geolocation::StartRequest(GeoNotifier* notifier) { ...@@ -231,8 +231,9 @@ void Geolocation::StartRequest(GeoNotifier* notifier) {
ReportOptions::kReportOnFailure, kFeaturePolicyConsoleWarning)) { ReportOptions::kReportOnFailure, kFeaturePolicyConsoleWarning)) {
UseCounter::Count(GetDocument(), UseCounter::Count(GetDocument(),
WebFeature::kGeolocationDisabledByFeaturePolicy); WebFeature::kGeolocationDisabledByFeaturePolicy);
notifier->SetFatalError(MakeGarbageCollected<PositionError>( notifier->SetFatalError(MakeGarbageCollected<GeolocationPositionError>(
PositionError::kPermissionDenied, kFeaturePolicyErrorMessage)); GeolocationPositionError::kPermissionDenied,
kFeaturePolicyErrorMessage));
return; return;
} }
...@@ -326,7 +327,7 @@ void Geolocation::StopTimers() { ...@@ -326,7 +327,7 @@ void Geolocation::StopTimers() {
} }
} }
void Geolocation::HandleError(PositionError* error) { void Geolocation::HandleError(GeolocationPositionError* error) {
DCHECK(error); DCHECK(error);
DCHECK(one_shots_being_invoked_.IsEmpty()); DCHECK(one_shots_being_invoked_.IsEmpty());
...@@ -509,8 +510,9 @@ void Geolocation::OnGeolocationConnectionError() { ...@@ -509,8 +510,9 @@ void Geolocation::OnGeolocationConnectionError() {
StopUpdating(); StopUpdating();
// The only reason that we would fail to get a ConnectionError is if we lack // The only reason that we would fail to get a ConnectionError is if we lack
// sufficient permission. // sufficient permission.
auto* error = MakeGarbageCollected<PositionError>( auto* error = MakeGarbageCollected<GeolocationPositionError>(
PositionError::kPermissionDenied, kPermissionDeniedErrorMessage); GeolocationPositionError::kPermissionDenied,
kPermissionDeniedErrorMessage);
error->SetIsFatal(true); error->SetIsFatal(true);
HandleError(error); HandleError(error);
} }
......
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
#include "third_party/blink/renderer/core/execution_context/context_lifecycle_observer.h" #include "third_party/blink/renderer/core/execution_context/context_lifecycle_observer.h"
#include "third_party/blink/renderer/core/page/page_visibility_observer.h" #include "third_party/blink/renderer/core/page/page_visibility_observer.h"
#include "third_party/blink/renderer/modules/geolocation/geo_notifier.h" #include "third_party/blink/renderer/modules/geolocation/geo_notifier.h"
#include "third_party/blink/renderer/modules/geolocation/geolocation_position_error.h"
#include "third_party/blink/renderer/modules/geolocation/geolocation_watchers.h" #include "third_party/blink/renderer/modules/geolocation/geolocation_watchers.h"
#include "third_party/blink/renderer/modules/geolocation/geoposition.h" #include "third_party/blink/renderer/modules/geolocation/geoposition.h"
#include "third_party/blink/renderer/modules/geolocation/position_error.h"
#include "third_party/blink/renderer/modules/geolocation/position_options.h" #include "third_party/blink/renderer/modules/geolocation/position_options.h"
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
...@@ -173,7 +173,7 @@ class MODULES_EXPORT Geolocation final ...@@ -173,7 +173,7 @@ class MODULES_EXPORT Geolocation final
// Sends the given error to all notifiers, unless the error is not fatal and // Sends the given error to all notifiers, unless the error is not fatal and
// the notifier is due to receive a cached position. Clears the oneshots, // the notifier is due to receive a cached position. Clears the oneshots,
// and also clears the watchers if the error is fatal. // and also clears the watchers if the error is fatal.
void HandleError(PositionError*); void HandleError(GeolocationPositionError*);
// Connects to the Geolocation mojo service and starts polling for updates. // Connects to the Geolocation mojo service and starts polling for updates.
void StartUpdating(GeoNotifier*); void StartUpdating(GeoNotifier*);
...@@ -184,15 +184,15 @@ class MODULES_EXPORT Geolocation final ...@@ -184,15 +184,15 @@ class MODULES_EXPORT Geolocation final
void QueryNextPosition(); void QueryNextPosition();
// Attempts to obtain a position for the given notifier, either by using // Attempts to obtain a position for the given notifier, either by using
// the cached position or by requesting one from the Geolocation. // the cached position or by requesting one from the Geolocation service.
// Sets a fatal error if permission is denied or no position can be // Sets a fatal error if permission is denied or no position can be
// obtained. // obtained.
void StartRequest(GeoNotifier*); void StartRequest(GeoNotifier*);
bool HaveSuitableCachedPosition(const PositionOptions*); bool HaveSuitableCachedPosition(const PositionOptions*);
// Record whether the origin trying to access Geolocation would be allowed // Record whether the origin trying to access Geolocation would be
// to access a feature that can only be accessed by secure origins. // allowed to access a feature that can only be accessed by secure origins.
// See https://goo.gl/Y0ZkNV // See https://goo.gl/Y0ZkNV
void RecordOriginTypeAccess() const; void RecordOriginTypeAccess() const;
...@@ -209,10 +209,10 @@ class MODULES_EXPORT Geolocation final ...@@ -209,10 +209,10 @@ class MODULES_EXPORT Geolocation final
// //
// |HandleError(error)| and |MakeSuccessCallbacks| need to clear |one_shots_| // |HandleError(error)| and |MakeSuccessCallbacks| need to clear |one_shots_|
// (and optionally |watchers_|) before invoking the callbacks, in order to // (and optionally |watchers_|) before invoking the callbacks, in order to
// avoid clearing notifiers added by calls to Geolocation methods from the // avoid clearing notifiers added by calls to Geolocation methods
// callbacks. Thus, something else needs to make the notifiers being invoked // from the callbacks. Thus, something else needs to make the notifiers being
// alive with wrapper-tracing because V8 GC may run during the callbacks. // invoked alive with wrapper-tracing because V8 GC may run during the
// |one_shots_being_invoked_| and |watchers_being_invoked_| perform // callbacks. |one_shots_being_invoked_| and |watchers_being_invoked_| perform
// wrapper-tracing. // wrapper-tracing.
// TODO(https://crbug.com/796145): Remove this hack once on-stack objects // TODO(https://crbug.com/796145): Remove this hack once on-stack objects
// get supported by either of wrapper-tracing or unified GC. // get supported by either of wrapper-tracing or unified GC.
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
// https://www.w3.org/TR/geolocation-API/#geolocation_interface // https://www.w3.org/TR/geolocation-API/#geolocation_interface
[ [
ActiveScriptWrappable, ActiveScriptWrappable,
Exposed=Window, Exposed=Window
NoInterfaceObject
] interface Geolocation { ] interface Geolocation {
[ [
LogActivity, LogActivity,
...@@ -51,7 +50,8 @@ ...@@ -51,7 +50,8 @@
}; };
// https://www.w3.org/TR/geolocation-API/#position-callback // https://www.w3.org/TR/geolocation-API/#position-callback
callback PositionCallback = void(Position position); callback PositionCallback = void(GeolocationPosition position);
// https://www.w3.org/TR/geolocation-API/#error-callback // https://www.w3.org/TR/geolocation-API/#error-callback
callback PositionErrorCallback = void (PositionError positionError); callback PositionErrorCallback =
void (GeolocationPositionError positionError);
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "third_party/blink/renderer/modules/geolocation/coordinates.h" #include "third_party/blink/renderer/modules/geolocation/geolocation_coordinates.h"
namespace blink { namespace blink {
double Coordinates::altitude(bool& is_null) const { double GeolocationCoordinates::altitude(bool& is_null) const {
if (can_provide_altitude_) if (can_provide_altitude_)
return altitude_; return altitude_;
...@@ -35,7 +35,7 @@ double Coordinates::altitude(bool& is_null) const { ...@@ -35,7 +35,7 @@ double Coordinates::altitude(bool& is_null) const {
return 0; return 0;
} }
double Coordinates::altitudeAccuracy(bool& is_null) const { double GeolocationCoordinates::altitudeAccuracy(bool& is_null) const {
if (can_provide_altitude_accuracy_) if (can_provide_altitude_accuracy_)
return altitude_accuracy_; return altitude_accuracy_;
...@@ -43,7 +43,7 @@ double Coordinates::altitudeAccuracy(bool& is_null) const { ...@@ -43,7 +43,7 @@ double Coordinates::altitudeAccuracy(bool& is_null) const {
return 0; return 0;
} }
double Coordinates::heading(bool& is_null) const { double GeolocationCoordinates::heading(bool& is_null) const {
if (can_provide_heading_) if (can_provide_heading_)
return heading_; return heading_;
...@@ -51,7 +51,7 @@ double Coordinates::heading(bool& is_null) const { ...@@ -51,7 +51,7 @@ double Coordinates::heading(bool& is_null) const {
return 0; return 0;
} }
double Coordinates::speed(bool& is_null) const { double GeolocationCoordinates::speed(bool& is_null) const {
if (can_provide_speed_) if (can_provide_speed_)
return speed_; return speed_;
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_COORDINATES_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_GEOLOCATION_COORDINATES_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_COORDINATES_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_GEOLOCATION_COORDINATES_H_
#include "third_party/blink/renderer/modules/event_modules.h" #include "third_party/blink/renderer/modules/event_modules.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
...@@ -32,11 +32,11 @@ ...@@ -32,11 +32,11 @@
namespace blink { namespace blink {
class Coordinates : public ScriptWrappable { class GeolocationCoordinates : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
Coordinates(double latitude, GeolocationCoordinates(double latitude,
double longitude, double longitude,
bool provides_altitude, bool provides_altitude,
double altitude, double altitude,
...@@ -84,4 +84,4 @@ class Coordinates : public ScriptWrappable { ...@@ -84,4 +84,4 @@ class Coordinates : public ScriptWrappable {
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_COORDINATES_H_ #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_GEOLOCATION_COORDINATES_H_
...@@ -24,9 +24,8 @@ ...@@ -24,9 +24,8 @@
*/ */
[ [
Exposed=Window, Exposed=Window
NoInterfaceObject ] interface GeolocationCoordinates {
] interface Coordinates {
readonly attribute double latitude; readonly attribute double latitude;
readonly attribute double longitude; readonly attribute double longitude;
readonly attribute double? altitude; readonly attribute double? altitude;
......
...@@ -27,9 +27,8 @@ ...@@ -27,9 +27,8 @@
[ [
Exposed=Window, Exposed=Window,
NoInterfaceObject,
ImplementedAs=Geoposition ImplementedAs=Geoposition
] interface Position { ] interface GeolocationPosition {
readonly attribute Coordinates coords; readonly attribute GeolocationCoordinates coords;
readonly attribute DOMTimeStamp timestamp; readonly attribute DOMTimeStamp timestamp;
}; };
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_POSITION_ERROR_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_GEOLOCATION_POSITION_ERROR_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_POSITION_ERROR_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_GEOLOCATION_POSITION_ERROR_H_
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
namespace blink { namespace blink {
class PositionError final : public ScriptWrappable { class GeolocationPositionError final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
...@@ -42,7 +42,7 @@ class PositionError final : public ScriptWrappable { ...@@ -42,7 +42,7 @@ class PositionError final : public ScriptWrappable {
kTimeout = 3 kTimeout = 3
}; };
PositionError(ErrorCode code, const String& message) GeolocationPositionError(ErrorCode code, const String& message)
: code_(code), message_(message), is_fatal_(false) {} : code_(code), message_(message), is_fatal_(false) {}
ErrorCode code() const { return code_; } ErrorCode code() const { return code_; }
...@@ -60,4 +60,4 @@ class PositionError final : public ScriptWrappable { ...@@ -60,4 +60,4 @@ class PositionError final : public ScriptWrappable {
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_POSITION_ERROR_H_ #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_GEOLOCATION_GEOLOCATION_POSITION_ERROR_H_
...@@ -24,9 +24,8 @@ ...@@ -24,9 +24,8 @@
*/ */
[ [
Exposed=Window, Exposed=Window
NoInterfaceObject ] interface GeolocationPositionError {
] interface PositionError {
readonly attribute unsigned short code; readonly attribute unsigned short code;
readonly attribute DOMString message; readonly attribute DOMString message;
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "third_party/blink/renderer/core/dom/dom_time_stamp.h" #include "third_party/blink/renderer/core/dom/dom_time_stamp.h"
#include "third_party/blink/renderer/modules/event_modules.h" #include "third_party/blink/renderer/modules/event_modules.h"
#include "third_party/blink/renderer/modules/geolocation/coordinates.h" #include "third_party/blink/renderer/modules/geolocation/geolocation_coordinates.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h" #include "third_party/blink/renderer/platform/wtf/assertions.h"
...@@ -39,7 +39,7 @@ class Geoposition final : public ScriptWrappable { ...@@ -39,7 +39,7 @@ class Geoposition final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
Geoposition(Coordinates* coordinates, DOMTimeStamp timestamp) Geoposition(GeolocationCoordinates* coordinates, DOMTimeStamp timestamp)
: coordinates_(coordinates), timestamp_(timestamp) { : coordinates_(coordinates), timestamp_(timestamp) {
DCHECK(coordinates_); DCHECK(coordinates_);
} }
...@@ -50,10 +50,10 @@ class Geoposition final : public ScriptWrappable { ...@@ -50,10 +50,10 @@ class Geoposition final : public ScriptWrappable {
} }
DOMTimeStamp timestamp() const { return timestamp_; } DOMTimeStamp timestamp() const { return timestamp_; }
Coordinates* coords() const { return coordinates_; } GeolocationCoordinates* coords() const { return coordinates_; }
private: private:
Member<Coordinates> coordinates_; Member<GeolocationCoordinates> coordinates_;
DOMTimeStamp timestamp_; DOMTimeStamp timestamp_;
}; };
......
...@@ -51,9 +51,10 @@ Geolocation* NavigatorGeolocation::geolocation(Navigator& navigator) { ...@@ -51,9 +51,10 @@ Geolocation* NavigatorGeolocation::geolocation(Navigator& navigator) {
} }
Geolocation* NavigatorGeolocation::geolocation() { Geolocation* NavigatorGeolocation::geolocation() {
if (!geolocation_ && GetSupplementable()->GetFrame()) if (!geolocation_ && GetSupplementable()->GetFrame()) {
geolocation_ = geolocation_ =
Geolocation::Create(GetSupplementable()->GetFrame()->GetDocument()); Geolocation::Create(GetSupplementable()->GetFrame()->GetDocument());
}
return geolocation_; return geolocation_;
} }
......
...@@ -30,8 +30,7 @@ namespace blink { ...@@ -30,8 +30,7 @@ namespace blink {
class Geolocation; class Geolocation;
class Navigator; class Navigator;
class NavigatorGeolocation final class NavigatorGeolocation final : public GarbageCollected<Geolocation>,
: public GarbageCollected<NavigatorGeolocation>,
public Supplement<Navigator>, public Supplement<Navigator>,
public NameClient { public NameClient {
USING_GARBAGE_COLLECTED_MIXIN(NavigatorGeolocation); USING_GARBAGE_COLLECTED_MIXIN(NavigatorGeolocation);
......
...@@ -163,10 +163,10 @@ modules_idl_files = ...@@ -163,10 +163,10 @@ modules_idl_files =
"gamepad/gamepad_haptic_actuator.idl", "gamepad/gamepad_haptic_actuator.idl",
"gamepad/gamepad_list.idl", "gamepad/gamepad_list.idl",
"gamepad/gamepad_pose.idl", "gamepad/gamepad_pose.idl",
"geolocation/coordinates.idl",
"geolocation/geolocation.idl", "geolocation/geolocation.idl",
"geolocation/position.idl", "geolocation/geolocation_coordinates.idl",
"geolocation/position_error.idl", "geolocation/geolocation_position.idl",
"geolocation/geolocation_position_error.idl",
"hid/hid.idl", "hid/hid.idl",
"hid/hid_collection_info.idl", "hid/hid_collection_info.idl",
"hid/hid_connection_event.idl", "hid/hid_connection_event.idl",
......
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL Geolocation report only mode promise_test: Unhandled rejection with value: object "[object PositionError]" FAIL Geolocation report only mode promise_test: Unhandled rejection with value: object "[object GeolocationPositionError]"
Harness: the test ran to completion. Harness: the test ran to completion.
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL getCurrentPosition success callback tests assert_unreached: Error callback called in error Reached unreachable code FAIL getCurrentPosition success callback tests assert_unreached: Error callback called in error Reached unreachable code
PASS getCurrentPosition error callback tests PASS getCurrentPosition error callback tests
PASS PositionError toString PASS GeolocationPositionError toString
PASS PERMISSION_DENIED value is 1 PASS PERMISSION_DENIED value is 1
PASS POSITION_UNAVAILABLE is 2 PASS POSITION_UNAVAILABLE is 2
PASS TIMEOUT value is 3 PASS TIMEOUT value is 3
......
...@@ -20,31 +20,29 @@ function successCallback(position) ...@@ -20,31 +20,29 @@ function successCallback(position)
var ii, oldval; var ii, oldval;
/* /*
[NoInterfaceObject] interface GeolocationPosition {
interface Position { readonly attribute GeolocationCoordinates coords;
readonly attribute Coordinates coords;
readonly attribute DOMTimeStamp timestamp; readonly attribute DOMTimeStamp timestamp;
}; };
*/ */
test(function() { test(function() {
assert_equals(position.toString(), "[object Position]", assert_equals(position.toString(), "[object GeolocationPosition]",
"Position.toString should result in '[object Position]' was: " + position.toString()); "position.toString should result in '[object GeolocationPosition]' was: " + position.toString());
}, "Position toString"); }, "GeolocationPosition toString");
test(function() { test(function() {
assert_equals(position.coords.toString(), "[object Coordinates]", assert_equals(position.coords.toString(), "[object GeolocationCoordinates]",
"position.coords.toString should result in '[object Coordinates]' was: " + position.coords.toString()); "position.coords.toString should result in '[object GeolocationCoordinates]' was: " + position.coords.toString());
}, "Position.coordinates toString"); }, "GeolocationCoordinates toString");
test(function() { test(function() {
assert_equals(typeof(position.timestamp), "number", assert_equals(typeof(position.timestamp), "number",
"Position.timestamp should be of type 'number' was: " + typeof(position.timestamp)); "position.timestamp should be of type 'number' was: " + typeof(position.timestamp));
}, "Position.timestamp is type number"); }, "GeolocationPosition.timestamp is type number");
/* /*
[NoInterfaceObject] interface GeolocationCoordinates {
interface Coordinates {
readonly attribute double latitude; readonly attribute double latitude;
readonly attribute double longitude; readonly attribute double longitude;
readonly attribute double? altitude; readonly attribute double? altitude;
...@@ -103,10 +101,10 @@ function BadSuccessCallback(position) ...@@ -103,10 +101,10 @@ function BadSuccessCallback(position)
function errorCallback(error) function errorCallback(error)
{ {
test(function() { test(function() {
assert_equals(error.toString(), "[object PositionError]", assert_equals(error.toString(), "[object GeolocationPositionError]",
"PositionError.toString should result in '[object PositionError]' was: " + "error.toString should result in '[object GeolocationPositionError]' was: " +
error.toString()); error.toString());
}, "PositionError toString"); }, "GeolocationPositionError toString");
test(function() { test(function() {
assert_equals(error.PERMISSION_DENIED, 1, assert_equals(error.PERMISSION_DENIED, 1,
......
This is a testharness.js-based test.
Found 56 tests; 11 PASS, 45 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup
PASS Partial interface Navigator: original interface defined
FAIL Geolocation interface: existence and properties of interface object assert_own_property: self does not have own property "Geolocation" expected property "Geolocation" missing
FAIL Geolocation interface object length assert_own_property: self does not have own property "Geolocation" expected property "Geolocation" missing
FAIL Geolocation interface object name assert_own_property: self does not have own property "Geolocation" expected property "Geolocation" missing
FAIL Geolocation interface: existence and properties of interface prototype object assert_own_property: self does not have own property "Geolocation" expected property "Geolocation" missing
FAIL Geolocation interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "Geolocation" expected property "Geolocation" missing
FAIL Geolocation interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "Geolocation" expected property "Geolocation" missing
FAIL Geolocation interface: operation getCurrentPosition(PositionCallback, PositionErrorCallback, PositionOptions) assert_own_property: self does not have own property "Geolocation" expected property "Geolocation" missing
FAIL Geolocation interface: operation watchPosition(PositionCallback, PositionErrorCallback, PositionOptions) assert_own_property: self does not have own property "Geolocation" expected property "Geolocation" missing
FAIL Geolocation interface: operation clearWatch(long) assert_own_property: self does not have own property "Geolocation" expected property "Geolocation" missing
FAIL Geolocation must be primary interface of navigator.geolocation assert_own_property: self does not have own property "Geolocation" expected property "Geolocation" missing
PASS Stringification of navigator.geolocation
PASS Geolocation interface: navigator.geolocation must inherit property "getCurrentPosition(PositionCallback, PositionErrorCallback, PositionOptions)" with the proper type
PASS Geolocation interface: calling getCurrentPosition(PositionCallback, PositionErrorCallback, PositionOptions) on navigator.geolocation with too few arguments must throw TypeError
PASS Geolocation interface: navigator.geolocation must inherit property "watchPosition(PositionCallback, PositionErrorCallback, PositionOptions)" with the proper type
PASS Geolocation interface: calling watchPosition(PositionCallback, PositionErrorCallback, PositionOptions) on navigator.geolocation with too few arguments must throw TypeError
PASS Geolocation interface: navigator.geolocation must inherit property "clearWatch(long)" with the proper type
PASS Geolocation interface: calling clearWatch(long) on navigator.geolocation with too few arguments must throw TypeError
FAIL GeolocationPosition interface: existence and properties of interface object assert_own_property: self does not have own property "GeolocationPosition" expected property "GeolocationPosition" missing
FAIL GeolocationPosition interface object length assert_own_property: self does not have own property "GeolocationPosition" expected property "GeolocationPosition" missing
FAIL GeolocationPosition interface object name assert_own_property: self does not have own property "GeolocationPosition" expected property "GeolocationPosition" missing
FAIL GeolocationPosition interface: existence and properties of interface prototype object assert_own_property: self does not have own property "GeolocationPosition" expected property "GeolocationPosition" missing
FAIL GeolocationPosition interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "GeolocationPosition" expected property "GeolocationPosition" missing
FAIL GeolocationPosition interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "GeolocationPosition" expected property "GeolocationPosition" missing
FAIL GeolocationPosition interface: attribute coords assert_own_property: self does not have own property "GeolocationPosition" expected property "GeolocationPosition" missing
FAIL GeolocationPosition interface: attribute timestamp assert_own_property: self does not have own property "GeolocationPosition" expected property "GeolocationPosition" missing
FAIL GeolocationCoordinates interface: existence and properties of interface object assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationCoordinates interface object length assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationCoordinates interface object name assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationCoordinates interface: existence and properties of interface prototype object assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationCoordinates interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationCoordinates interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationCoordinates interface: attribute latitude assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationCoordinates interface: attribute longitude assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationCoordinates interface: attribute altitude assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationCoordinates interface: attribute accuracy assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationCoordinates interface: attribute altitudeAccuracy assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationCoordinates interface: attribute heading assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationCoordinates interface: attribute speed assert_own_property: self does not have own property "GeolocationCoordinates" expected property "GeolocationCoordinates" missing
FAIL GeolocationPositionError interface: existence and properties of interface object assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface object length assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface object name assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface: existence and properties of interface prototype object assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface: constant PERMISSION_DENIED on interface object assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface: constant PERMISSION_DENIED on interface prototype object assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface: constant POSITION_UNAVAILABLE on interface object assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface: constant POSITION_UNAVAILABLE on interface prototype object assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface: constant TIMEOUT on interface object assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface: constant TIMEOUT on interface prototype object assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface: attribute code assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
FAIL GeolocationPositionError interface: attribute message assert_own_property: self does not have own property "GeolocationPositionError" expected property "GeolocationPositionError" missing
PASS Navigator interface: attribute geolocation
PASS Navigator interface: navigator must inherit property "geolocation" with the proper type
Harness: the test ran to completion.
...@@ -5,8 +5,8 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -5,8 +5,8 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS position.coords.latitude is mockLatitude PASS position.coords.latitude is mockLatitude
PASS position.coords.longitude is mockLongitude PASS position.coords.longitude is mockLongitude
PASS position.coords.accuracy is mockAccuracy PASS position.coords.accuracy is mockAccuracy
PASS position.toString() is "[object Position]" PASS position.toString() is "[object GeolocationPosition]"
PASS position.coords.toString() is "[object Coordinates]" PASS position.coords.toString() is "[object GeolocationCoordinates]"
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -30,8 +30,8 @@ navigator.geolocation.getCurrentPosition(function(p) { ...@@ -30,8 +30,8 @@ navigator.geolocation.getCurrentPosition(function(p) {
shouldBe('position.coords.latitude', 'mockLatitude'); shouldBe('position.coords.latitude', 'mockLatitude');
shouldBe('position.coords.longitude', 'mockLongitude'); shouldBe('position.coords.longitude', 'mockLongitude');
shouldBe('position.coords.accuracy', 'mockAccuracy'); shouldBe('position.coords.accuracy', 'mockAccuracy');
shouldBe('position.toString()', '"[object Position]"'); shouldBe('position.toString()', '"[object GeolocationPosition]"');
shouldBe('position.coords.toString()', '"[object Coordinates]"'); shouldBe('position.coords.toString()', '"[object GeolocationCoordinates]"');
finishJSTest(); finishJSTest();
}, function(e) { }, function(e) {
testFailed('Error callback invoked unexpectedly'); testFailed('Error callback invoked unexpectedly');
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
run_permission_default_header_policy_tests( run_permission_default_header_policy_tests(
location.protocol + '//localhost:' + location.port, location.protocol + '//localhost:' + location.port,
'geolocation', 'geolocation',
'PositionError', 'GeolocationPositionError',
function() { return new Promise((resolve, reject) => { function() { return new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(resolve, reject); }); }); navigator.geolocation.getCurrentPosition(resolve, reject); }); });
......
...@@ -1914,6 +1914,35 @@ interface GamepadHapticActuator ...@@ -1914,6 +1914,35 @@ interface GamepadHapticActuator
method constructor method constructor
method playEffect method playEffect
method reset method reset
interface Geolocation
attribute @@toStringTag
method clearWatch
method constructor
method getCurrentPosition
method watchPosition
interface GeolocationCoordinates
attribute @@toStringTag
getter accuracy
getter altitude
getter altitudeAccuracy
getter heading
getter latitude
getter longitude
getter speed
method constructor
interface GeolocationPosition
attribute @@toStringTag
getter coords
getter timestamp
method constructor
interface GeolocationPositionError
attribute @@toStringTag
attribute PERMISSION_DENIED
attribute POSITION_UNAVAILABLE
attribute TIMEOUT
getter code
getter message
method constructor
interface Gyroscope : Sensor interface Gyroscope : Sensor
attribute @@toStringTag attribute @@toStringTag
getter x getter x
......
...@@ -2513,6 +2513,35 @@ interface GamepadPose ...@@ -2513,6 +2513,35 @@ interface GamepadPose
getter orientation getter orientation
getter position getter position
method constructor method constructor
interface Geolocation
attribute @@toStringTag
method clearWatch
method constructor
method getCurrentPosition
method watchPosition
interface GeolocationCoordinates
attribute @@toStringTag
getter accuracy
getter altitude
getter altitudeAccuracy
getter heading
getter latitude
getter longitude
getter speed
method constructor
interface GeolocationPosition
attribute @@toStringTag
getter coords
getter timestamp
method constructor
interface GeolocationPositionError
attribute @@toStringTag
attribute PERMISSION_DENIED
attribute POSITION_UNAVAILABLE
attribute TIMEOUT
getter code
getter message
method constructor
interface Gyroscope : Sensor interface Gyroscope : Sensor
attribute @@toStringTag attribute @@toStringTag
getter x getter x
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment