Changeset 48503 in webkit


Ignore:
Timestamp:
Sep 18, 2009 2:35:20 AM (15 years ago)
Author:
eric@webkit.org
Message:

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.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r48498 r48503  
     12009-09-18  Steve Block  <steveblock@google.com>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Geolocation does not correctly handle Infinity for PositionOptions properties.
     6        https://bugs.webkit.org/show_bug.cgi?id=29099
     7
     8        * fast/dom/Geolocation/resources/argument-types.js: Modified. Test passing positive and negative Infinity to Geolocation methods.
     9        * fast/dom/Geolocation/argument-types-expected.txt: Modified. Expected result for above test.
     10
    1112009-09-17  Brian Weinstein  <bweinstein@apple.com>
    212
  • trunk/LayoutTests/fast/dom/Geolocation/argument-types-expected.txt

    r47252 r48503  
    1313PASS navigator.geolocation.getCurrentPosition(true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    1414PASS navigator.geolocation.getCurrentPosition(42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     15PASS navigator.geolocation.getCurrentPosition(Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     16PASS navigator.geolocation.getCurrentPosition(-Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    1517PASS navigator.geolocation.getCurrentPosition("string") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    1618PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined) did not throw exception.
     
    2224PASS navigator.geolocation.getCurrentPosition(emptyFunction, true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    2325PASS navigator.geolocation.getCurrentPosition(emptyFunction, 42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     26PASS navigator.geolocation.getCurrentPosition(emptyFunction, Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     27PASS navigator.geolocation.getCurrentPosition(emptyFunction, -Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    2428PASS navigator.geolocation.getCurrentPosition(emptyFunction, "string") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    2529PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, undefined) did not throw exception.
     
    3034PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, true) did not throw exception.
    3135PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, 42) did not throw exception.
     36PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, Infinity) did not throw exception.
     37PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, -Infinity) did not throw exception.
    3238PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, "string") did not throw exception.
    3339PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:undefined}) did not throw exception.
     
    3844PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:true}) did not throw exception.
    3945PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:42}) did not throw exception.
     46PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:Infinity}) did not throw exception.
     47PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:-Infinity}) did not throw exception.
    4048PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:"string"}) did not throw exception.
    4149PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:undefined}) did not throw exception.
     
    4654PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:true}) did not throw exception.
    4755PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:42}) did not throw exception.
     56PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:Infinity}) did not throw exception.
     57PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:-Infinity}) did not throw exception.
    4858PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:"string"}) did not throw exception.
    4959PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:undefined}) did not throw exception.
     
    5464PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:true}) did not throw exception.
    5565PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:42}) did not throw exception.
     66PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:Infinity}) did not throw exception.
     67PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:-Infinity}) did not throw exception.
    5668PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:"string"}) did not throw exception.
    5769PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:undefined}) did not throw exception.
     
    6274PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:true}) did not throw exception.
    6375PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:42}) did not throw exception.
     76PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:Infinity}) did not throw exception.
     77PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:-Infinity}) did not throw exception.
    6478PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:"string"}) did not throw exception.
    6579PASS successfullyParsed is true
  • trunk/LayoutTests/fast/dom/Geolocation/resources/argument-types.js

    r47252 r48503  
    4444test('navigator.geolocation.getCurrentPosition(true)', true);
    4545test('navigator.geolocation.getCurrentPosition(42)', true);
     46test('navigator.geolocation.getCurrentPosition(Infinity)', true);
     47test('navigator.geolocation.getCurrentPosition(-Infinity)', true);
    4648test('navigator.geolocation.getCurrentPosition("string")', true);
    4749
     
    5456test('navigator.geolocation.getCurrentPosition(emptyFunction, true)', true);
    5557test('navigator.geolocation.getCurrentPosition(emptyFunction, 42)', true);
     58test('navigator.geolocation.getCurrentPosition(emptyFunction, Infinity)', true);
     59test('navigator.geolocation.getCurrentPosition(emptyFunction, -Infinity)', true);
    5660test('navigator.geolocation.getCurrentPosition(emptyFunction, "string")', true);
    5761
     
    6367test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, true)', false);
    6468test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, 42)', false);
     69test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, Infinity)', false);
     70test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, -Infinity)', false);
    6571test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, "string")', false);
    6672
     
    7278test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:true})', false);
    7379test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:42})', false);
     80test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:Infinity})', false);
     81test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:-Infinity})', false);
    7482test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:"string"})', false);
    7583
     
    8189test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:true})', false);
    8290test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:42})', false);
     91test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:Infinity})', false);
     92test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:-Infinity})', false);
    8393test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:"string"})', false);
    8494
     
    90100test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:true})', false);
    91101test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:42})', false);
     102test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:Infinity})', false);
     103test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:-Infinity})', false);
    92104test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:"string"})', false);
    93105
     
    99111test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:true})', false);
    100112test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:42})', false);
     113test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:Infinity})', false);
     114test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:-Infinity})', false);
    101115test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:"string"})', false);
    102116
  • trunk/WebCore/ChangeLog

    r48500 r48503  
     12009-09-18  Steve Block  <steveblock@google.com>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Geolocation does not correctly handle Infinity for PositionOptions properties.
     6        https://bugs.webkit.org/show_bug.cgi?id=29099
     7
     8        * bindings/js/JSGeolocationCustom.cpp: Modified.
     9        (WebCore::createPositionOptions): Modified. If timeout or maximumAge is positive infinity, applies these values as a special case.
     10        * page/PositionOptions.h: Modified.
     11        (WebCore::PositionOptions::hasMaximumAge): Added. Determines whether the object has a maximum age.
     12        (WebCore::PositionOptions::maximumAge): Modified. Asserts that the object has a maximum age.
     13        (WebCore::PositionOptions::clearMaximumAge): Added. Clears the maximum age.
     14        (WebCore::PositionOptions::setMaximumAge): Modified. Registers that the maximum age has been set.
     15        (WebCore::PositionOptions::PositionOptions): Modified. Registers that the maximum age has been set.
     16
    1172009-09-17  Sam Weinig  <sam@webkit.org>
    218
  • trunk/WebCore/bindings/js/JSGeolocationCustom.cpp

    r48453 r48503  
    101101        return 0;
    102102    if (!timeoutValue.isUndefined()) {
    103         // Wrap to int32 and force non-negative to match behavior of window.setTimeout.
    104         options->setTimeout(max(0, timeoutValue.toInt32(exec)));
     103        double timeoutNumber = timeoutValue.toNumber(exec);
    105104        if (exec->hadException())
    106105            return 0;
     106        // If the value is positive infinity, there's nothing to do.
     107        if (!(isinf(timeoutNumber) && (timeoutNumber > 0))) {
     108            // Wrap to int32 and force non-negative to match behavior of window.setTimeout.
     109            options->setTimeout(max(0, timeoutValue.toInt32(exec)));
     110            if (exec->hadException())
     111                return 0;
     112        }
    107113    }
    108114
     
    111117        return 0;
    112118    if (!maximumAgeValue.isUndefined()) {
    113         // Wrap to int32 and force non-negative to match behavior of window.setTimeout.
    114         options->setMaximumAge(max(0, maximumAgeValue.toInt32(exec)));
     119        double maximumAgeNumber = maximumAgeValue.toNumber(exec);
    115120        if (exec->hadException())
    116121            return 0;
     122        if (isinf(maximumAgeNumber) && (maximumAgeNumber > 0)) {
     123            // If the value is positive infinity, clear maximumAge.
     124            options->clearMaximumAge();
     125        } else {
     126            // Wrap to int32 and force non-negative to match behavior of window.setTimeout.
     127            options->setMaximumAge(max(0, maximumAgeValue.toInt32(exec)));
     128            if (exec->hadException())
     129                return 0;
     130        }
    117131    }
    118132
  • trunk/WebCore/page/PositionOptions.h

    r47252 r48503  
    5050        m_timeout = timeout;
    5151    }
    52     int maximumAge() const { return m_maximumAge; }
     52    bool hasMaximumAge() const { return m_hasMaximumAge; }
     53    int maximumAge() const
     54    {
     55        ASSERT(hasMaximumAge());
     56        return m_maximumAge;
     57    }
     58    void clearMaximumAge() { m_hasMaximumAge = false; }
    5359    void setMaximumAge(int age)
    5460    {
    5561        ASSERT(age >= 0);
     62        m_hasMaximumAge = true;
    5663        m_maximumAge = age;
    5764    }
     
    6168        : m_highAccuracy(false)
    6269        , m_hasTimeout(false)
    63         , m_maximumAge(0)
    6470    {
     71        setMaximumAge(0);
    6572    }
    6673   
     
    6875    bool m_hasTimeout;
    6976    int m_timeout;
     77    bool m_hasMaximumAge;
    7078    int m_maximumAge;
    7179};
Note: See TracChangeset for help on using the changeset viewer.