[Webkit-unassigned] [Bug 83305] New: toNativeArray should not require a real array

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Apr 5 12:34:53 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=83305

           Summary: toNativeArray should not require a real array
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: Unspecified
               URL: http://www.w3.org/TR/WebIDL/#es-sequence
        OS/Version: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: HTML DOM
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: arv at chromium.org
                CC: cam at mcc.id.au, ojan at chromium.org, adamk at chromium.org


Our toNativeArray checks if the value is a real array. This is not correct. 

Cameron: The WebIDL spec here seems like it could use some improvements to better behave like the generic Array methods in JS.

1. Initialize i to be 0.
2. Let A be the result of calling ToObject(V).
3. Let length be the result of calling [[Get]] on A with property name “length”.
4. Let n be the result of calling ToUint32(length).
5. Initialize S0..n−1 to be an IDL sequence with elements of type T, where each element is uninitialized.
6. While i < n:
  1. Let P be the result of calling ToString(i).
  2. Let E be the result of calling [[Get]] on A with property name P.
  3. Set Si to the result of converting E to an IDL value of type T.
  4. Set i to i + 1.
7. Return S.

Note that ToObject throws a TypeError if V is null or undefined according to 9.9 of ES5.1 spec

We could add a step between 2 and 3 to check if the object has a "length" property. It is not what ES does but it might lead to less confusion.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list