Skip to content

Commit 413b2ca

Browse files
author
Adam Barth
committed
Add tests of optional arguments for Geolocation
https://bugs.webkit.org/show_bug.cgi?id=65810 Reviewed by Sam Weinig. Source/WebCore: Geolocation's treatment of not-enough-arguments almost matches the spec. getCurrentPosition and watchPosition work properly, but, because they are custom, we should use the prettier form of the [Optional] attribute. Before this series of patches, clearWatch argument was optional, but that doesn't match the spec or other browsers. Calling this function with zero arguments is pretty non-sensical, so there shouldn't be much compat risk to tightening up our behavior here. Matching other browsers and the spec seems like the bigger win. If we run into compat problems, we can re-evaluate this decision. Test: fast/dom/Geolocation/not-enough-arguments.html * page/Geolocation.idl: LayoutTests: Test what happens when calling geolocation APIs with too few arguments. * fast/dom/Geolocation/not-enough-arguments-expected.txt: Added. * fast/dom/Geolocation/not-enough-arguments.html: Added. Canonical link: https://commits.webkit.org/81888@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@92816 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 7657dbf commit 413b2ca

5 files changed

Lines changed: 75 additions & 6 deletions

File tree

LayoutTests/ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2011-08-10 Adam Barth <abarth@webkit.org>
2+
3+
Add tests of optional arguments for Geolocation
4+
https://bugs.webkit.org/show_bug.cgi?id=65810
5+
6+
Reviewed by Sam Weinig.
7+
8+
Test what happens when calling geolocation APIs with too few arguments.
9+
10+
* fast/dom/Geolocation/not-enough-arguments-expected.txt: Added.
11+
* fast/dom/Geolocation/not-enough-arguments.html: Added.
12+
113
2011-08-10 Anders Carlsson <andersca@apple.com>
214

315
Skip some more tests on Lion.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Tests how Geolocation handles receiving too few arguments.
2+
3+
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4+
5+
6+
PASS window.navigator.geolocation.getCurrentPosition() threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
7+
PASS window.navigator.geolocation.watchPosition() threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
8+
PASS window.navigator.geolocation.clearWatch() threw exception TypeError: Not enough arguments.
9+
PASS successfullyParsed is true
10+
11+
TEST COMPLETE
12+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
5+
<script src="../../js/resources/js-test-pre.js"></script>
6+
</head>
7+
<body>
8+
<p id="description"></p>
9+
<div id="console"></div>
10+
<script>
11+
description("Tests how Geolocation handles receiving too few arguments.");
12+
13+
shouldThrow("window.navigator.geolocation.getCurrentPosition()");
14+
shouldThrow("window.navigator.geolocation.watchPosition()");
15+
shouldThrow("window.navigator.geolocation.clearWatch()");
16+
17+
window.successfullyParsed = true;
18+
</script>
19+
<script src="../../js/resources/js-test-post.js"></script>
20+
</body>
21+
</html>

Source/WebCore/ChangeLog

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
2011-08-10 Adam Barth <abarth@webkit.org>
2+
3+
Add tests of optional arguments for Geolocation
4+
https://bugs.webkit.org/show_bug.cgi?id=65810
5+
6+
Reviewed by Sam Weinig.
7+
8+
Geolocation's treatment of not-enough-arguments almost matches the
9+
spec. getCurrentPosition and watchPosition work properly, but, because
10+
they are custom, we should use the prettier form of the [Optional]
11+
attribute.
12+
13+
Before this series of patches, clearWatch argument was optional, but
14+
that doesn't match the spec or other browsers. Calling this function
15+
with zero arguments is pretty non-sensical, so there shouldn't be much
16+
compat risk to tightening up our behavior here. Matching other
17+
browsers and the spec seems like the bigger win. If we run into compat
18+
problems, we can re-evaluate this decision.
19+
20+
Test: fast/dom/Geolocation/not-enough-arguments.html
21+
22+
* page/Geolocation.idl:
23+
124
2011-08-10 Tim Horton <timothy_horton@apple.com>
225

326
SVGAElement check for internal non-view anchors is inside ENABLE(SVG_ANIMATION)

Source/WebCore/page/Geolocation.idl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,19 @@
2525

2626
module core {
2727

28+
// http://www.w3.org/TR/geolocation-API/#geolocation_interface
2829
interface [
2930
Conditional=GEOLOCATION,
3031
GenerateIsReachable=ImplFrame,
3132
OmitConstructor
3233
] Geolocation {
33-
[Custom] void getCurrentPosition(in PositionCallback successCallback,
34-
in [Optional=CallWithDefaultValue] PositionErrorCallback errorCallback,
35-
in [Optional=CallWithDefaultValue] PositionOptions options);
34+
[Custom] void getCurrentPosition(in PositionCallback successCallback,
35+
in [Optional] PositionErrorCallback errorCallback,
36+
in [Optional] PositionOptions options);
3637

37-
[Custom] long watchPosition(in PositionCallback successCallback,
38-
in [Optional=CallWithDefaultValue] PositionErrorCallback errorCallback,
39-
in [Optional=CallWithDefaultValue] PositionOptions options);
38+
[Custom] long watchPosition(in PositionCallback successCallback,
39+
in [Optional] PositionErrorCallback errorCallback,
40+
in [Optional] PositionOptions options);
4041

4142
void clearWatch(in long watchId);
4243
};

0 commit comments

Comments
 (0)