Commit a05aaad4 authored by eric@webkit.org's avatar eric@webkit.org

2009-09-18 Steve Block <steveblock@google.com>

        Reviewed by Dimitri Glazkov.

        Geolocation does not correctly handle Infinity for PositionOptions properties.
        https://bugs.webkit.org/show_bug.cgi?id=29099

        * fast/dom/Geolocation/resources/argument-types.js: Modified. Test passing positive and negative Infinity to Geolocation methods.
        * fast/dom/Geolocation/argument-types-expected.txt: Modified. Expected result for above test.
2009-09-18  Steve Block  <steveblock@google.com>

        Reviewed by Dimitri Glazkov.

        Geolocation does not correctly handle Infinity for PositionOptions properties.
        https://bugs.webkit.org/show_bug.cgi?id=29099

        * bindings/js/JSGeolocationCustom.cpp: Modified.
        (WebCore::createPositionOptions): Modified. If timeout or maximumAge is positive infinity, applies these values as a special case.
        * page/PositionOptions.h: Modified.
        (WebCore::PositionOptions::hasMaximumAge): Added. Determines whether the object has a maximum age.
        (WebCore::PositionOptions::maximumAge): Modified. Asserts that the object has a maximum age.
        (WebCore::PositionOptions::clearMaximumAge): Added. Clears the maximum age.
        (WebCore::PositionOptions::setMaximumAge): Modified. Registers that the maximum age has been set.
        (WebCore::PositionOptions::PositionOptions): Modified. Registers that the maximum age has been set.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48503 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ee26bcb7
2009-09-18 Steve Block <steveblock@google.com>
Reviewed by Dimitri Glazkov.
Geolocation does not correctly handle Infinity for PositionOptions properties.
https://bugs.webkit.org/show_bug.cgi?id=29099
* fast/dom/Geolocation/resources/argument-types.js: Modified. Test passing positive and negative Infinity to Geolocation methods.
* fast/dom/Geolocation/argument-types-expected.txt: Modified. Expected result for above test.
2009-09-17 Brian Weinstein <bweinstein@apple.com>
Rubber-stamped by Steve Falkenburg.
......
......@@ -12,6 +12,8 @@ PASS navigator.geolocation.getCurrentPosition(emptyFunction) did not throw excep
PASS navigator.geolocation.getCurrentPosition(Math.abs) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(-Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition("string") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, null) did not throw exception.
......@@ -21,6 +23,8 @@ PASS navigator.geolocation.getCurrentPosition(emptyFunction, emptyFunction) did
PASS navigator.geolocation.getCurrentPosition(emptyFunction, Math.abs) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, 42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, -Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, "string") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, undefined) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, null) did not throw exception.
......@@ -29,6 +33,8 @@ PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, objectTh
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, emptyFunction) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, true) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, 42) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, Infinity) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, -Infinity) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, "string") did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:undefined}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:null}) did not throw exception.
......@@ -37,6 +43,8 @@ PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyPr
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:emptyFunction}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:true}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:42}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:Infinity}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:-Infinity}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:"string"}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:undefined}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:null}) did not throw exception.
......@@ -45,6 +53,8 @@ PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableH
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:emptyFunction}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:true}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:42}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:Infinity}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:-Infinity}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:"string"}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:undefined}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:null}) did not throw exception.
......@@ -53,6 +63,8 @@ PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximum
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:emptyFunction}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:true}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:42}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:Infinity}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:-Infinity}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:"string"}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:undefined}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:null}) did not throw exception.
......@@ -61,6 +73,8 @@ PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:emptyFunction}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:true}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:42}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:Infinity}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:-Infinity}) did not throw exception.
PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:"string"}) did not throw exception.
PASS successfullyParsed is true
......
......@@ -43,6 +43,8 @@ test('navigator.geolocation.getCurrentPosition(emptyFunction)', false);
test('navigator.geolocation.getCurrentPosition(Math.abs)', false);
test('navigator.geolocation.getCurrentPosition(true)', true);
test('navigator.geolocation.getCurrentPosition(42)', true);
test('navigator.geolocation.getCurrentPosition(Infinity)', true);
test('navigator.geolocation.getCurrentPosition(-Infinity)', true);
test('navigator.geolocation.getCurrentPosition("string")', true);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined)', false);
......@@ -53,6 +55,8 @@ test('navigator.geolocation.getCurrentPosition(emptyFunction, emptyFunction)', f
test('navigator.geolocation.getCurrentPosition(emptyFunction, Math.abs)', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, true)', true);
test('navigator.geolocation.getCurrentPosition(emptyFunction, 42)', true);
test('navigator.geolocation.getCurrentPosition(emptyFunction, Infinity)', true);
test('navigator.geolocation.getCurrentPosition(emptyFunction, -Infinity)', true);
test('navigator.geolocation.getCurrentPosition(emptyFunction, "string")', true);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, undefined)', false);
......@@ -62,6 +66,8 @@ test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, objectT
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, emptyFunction)', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, true)', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, 42)', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, Infinity)', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, -Infinity)', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, "string")', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:undefined})', false);
......@@ -71,6 +77,8 @@ test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyP
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:emptyFunction})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:true})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:42})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:Infinity})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:-Infinity})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:"string"})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:undefined})', false);
......@@ -80,6 +88,8 @@ test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enable
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:emptyFunction})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:true})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:42})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:Infinity})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:-Infinity})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:"string"})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:undefined})', false);
......@@ -89,6 +99,8 @@ test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximu
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:emptyFunction})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:true})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:42})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:Infinity})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:-Infinity})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:"string"})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:undefined})', false);
......@@ -98,6 +110,8 @@ test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeou
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:emptyFunction})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:true})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:42})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:Infinity})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:-Infinity})', false);
test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:"string"})', false);
var successfullyParsed = true;
......
2009-09-18 Steve Block <steveblock@google.com>
Reviewed by Dimitri Glazkov.
Geolocation does not correctly handle Infinity for PositionOptions properties.
https://bugs.webkit.org/show_bug.cgi?id=29099
* bindings/js/JSGeolocationCustom.cpp: Modified.
(WebCore::createPositionOptions): Modified. If timeout or maximumAge is positive infinity, applies these values as a special case.
* page/PositionOptions.h: Modified.
(WebCore::PositionOptions::hasMaximumAge): Added. Determines whether the object has a maximum age.
(WebCore::PositionOptions::maximumAge): Modified. Asserts that the object has a maximum age.
(WebCore::PositionOptions::clearMaximumAge): Added. Clears the maximum age.
(WebCore::PositionOptions::setMaximumAge): Modified. Registers that the maximum age has been set.
(WebCore::PositionOptions::PositionOptions): Modified. Registers that the maximum age has been set.
2009-09-17 Sam Weinig <sam@webkit.org>
Reviewed by Adele Peterson.
......@@ -100,20 +100,34 @@ static PassRefPtr<PositionOptions> createPositionOptions(ExecState* exec, JSValu
if (exec->hadException())
return 0;
if (!timeoutValue.isUndefined()) {
// Wrap to int32 and force non-negative to match behavior of window.setTimeout.
options->setTimeout(max(0, timeoutValue.toInt32(exec)));
double timeoutNumber = timeoutValue.toNumber(exec);
if (exec->hadException())
return 0;
// If the value is positive infinity, there's nothing to do.
if (!(isinf(timeoutNumber) && (timeoutNumber > 0))) {
// Wrap to int32 and force non-negative to match behavior of window.setTimeout.
options->setTimeout(max(0, timeoutValue.toInt32(exec)));
if (exec->hadException())
return 0;
}
}
JSValue maximumAgeValue = object->get(exec, Identifier(exec, "maximumAge"));
if (exec->hadException())
return 0;
if (!maximumAgeValue.isUndefined()) {
// Wrap to int32 and force non-negative to match behavior of window.setTimeout.
options->setMaximumAge(max(0, maximumAgeValue.toInt32(exec)));
double maximumAgeNumber = maximumAgeValue.toNumber(exec);
if (exec->hadException())
return 0;
if (isinf(maximumAgeNumber) && (maximumAgeNumber > 0)) {
// If the value is positive infinity, clear maximumAge.
options->clearMaximumAge();
} else {
// Wrap to int32 and force non-negative to match behavior of window.setTimeout.
options->setMaximumAge(max(0, maximumAgeValue.toInt32(exec)));
if (exec->hadException())
return 0;
}
}
return options.release();
......
......@@ -49,10 +49,17 @@ public:
m_hasTimeout = true;
m_timeout = timeout;
}
int maximumAge() const { return m_maximumAge; }
bool hasMaximumAge() const { return m_hasMaximumAge; }
int maximumAge() const
{
ASSERT(hasMaximumAge());
return m_maximumAge;
}
void clearMaximumAge() { m_hasMaximumAge = false; }
void setMaximumAge(int age)
{
ASSERT(age >= 0);
m_hasMaximumAge = true;
m_maximumAge = age;
}
......@@ -60,13 +67,14 @@ private:
PositionOptions()
: m_highAccuracy(false)
, m_hasTimeout(false)
, m_maximumAge(0)
{
setMaximumAge(0);
}
bool m_highAccuracy;
bool m_hasTimeout;
int m_timeout;
bool m_hasMaximumAge;
int m_maximumAge;
};
......
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