node icon indicating copy to clipboard operation
node copied to clipboard

test: update `FileAPI` wpt

Open avivkeller opened this issue 1 year ago • 3 comments

git node wpt FileAPI

Note one new failure: Passing a Float16Array as element of the blobParts array should work.

Note that several tests now pass that previously failed.

avivkeller avatar Sep 30 '24 19:09 avivkeller

Review requested:

  • [ ] @nodejs/web-standards

nodejs-github-bot avatar Sep 30 '24 19:09 nodejs-github-bot

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 88.40%. Comparing base (89a2f56) to head (b1c015c). Report is 1252 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55194      +/-   ##
==========================================
+ Coverage   88.39%   88.40%   +0.01%     
==========================================
  Files         652      652              
  Lines      186565   186565              
  Branches    36046    36038       -8     
==========================================
+ Hits       164916   164936      +20     
+ Misses      14908    14902       -6     
+ Partials     6741     6727      -14     

see 22 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Oct 01 '24 00:10 codecov[bot]

CI: https://ci.nodejs.org/job/node-test-pull-request/63173/

nodejs-github-bot avatar Oct 18 '24 10:10 nodejs-github-bot

Seemingly related test failures:

    [EXPECTED_FAILURE][FAIL] Getters and value conversions should happen in order until an exception is thrown.
    assert_array_equals: lengths differ, expected array ["Symbol.iterator", "length getter", "length valueOf", "0 getter", "0 toString", "length getter", "length valueOf", "1 getter"] length 8, got ["Symbol.iterator", "Symbol.iterator", "length getter", "length valueOf", "0 getter", "0 toString", "length getter", "length valueOf", "1 getter"] length 9
        at Test.<anonymous> (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js:179:3)
        at Test.step (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/resources/testharness.js:2599:25)
        at test (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/resources/testharness.js:628:30)
        at /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js:142:1
        at Script.runInThisContext (node:vm:137:12)
    Command: /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/out/Release/node  /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/wpt/test-blob.js 'Blob-constructor.any.js'
    
    [PASS] ToString should be called on elements of the blobParts array and any exceptions should be propagated.
    [EXPECTED_FAILURE][FAIL] options properties should be accessed in lexicographic order.
    assert_array_equals: expected property 0 to be "endings" but got "type" (expected array ["endings", "type"] got ["type", "endings"])
        at Test.<anonymous> (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js:398:3)
        at Test.step (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/resources/testharness.js:2599:25)
        at test (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/resources/testharness.js:628:30)
        at /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js:386:1
        at Script.runInThisContext (node:vm:137:12)
    Command: /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/out/Release/node  /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/wpt/test-blob.js 'Blob-constructor.any.js'
    
    [EXPECTED_FAILURE][FAIL] Arguments should be evaluated from left to right.
    assert_unreached: type getter should not be called. Reached unreachable code
        at get type (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js:407:22)
        at new Blob (node:internal/blob:152:7)
        at /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js:404:5
        at assert_throws_exactly_impl (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/resources/testharness.js:2332:18)
        at assert_throws_exactly (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/resources/testharness.js:2319:9)
    Command: /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/out/Release/node  /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/wpt/test-blob.js 'Blob-constructor.any.js'
    
    [PASS] Passing 123 for options should throw
    [PASS] Passing 123.4 for options should throw
    [PASS] Passing true for options should throw
    [PASS] Passing "abc" for options should throw
    [PASS] Blob with type ""
    [PASS] Blob with type "a"
    [PASS] Blob with type "A"
    [PASS] Blob with type "text/html"
    [PASS] Blob with type "TEXT/HTML"
    [PASS] Blob with type "text/plain;charset=utf-8"
    [PASS] Blob with type "å"
    [PASS] Blob with type "𐑾"
    [PASS] Blob with type " image/gif "
    [PASS] Blob with type "\timage/gif\t"
    [PASS] Blob with type "image/gif;"
    [PASS] Blob with type "İmage/gif"
    [PASS] Blob with type "ımage/gif"
    [PASS] Blob with type "image/gif\0"
    [PASS] Blob with type "unknown/unknown"
    [PASS] Blob with type "text/plain"
    [PASS] Blob with type "image/png"
    [PASS] A plain object with @@iterator should be treated as a sequence for the blobParts argument.
    [PASS] A plain object with @@iterator and a length property should be treated as a sequence for the blobParts argument.
    [PASS] A String object should be treated as a sequence for the blobParts argument.
    [PASS] A Uint8Array object should be treated as a sequence for the blobParts argument.
    [PASS] Changes to the blobParts array should be reflected in the returned Blob (pop).
    [PASS] Changes to the blobParts array should be reflected in the returned Blob (unshift).
    [PASS] ToString should be called on elements of the blobParts array.
    [PASS] ArrayBuffer elements of the blobParts array should be supported.
    [UNEXPECTED_FAILURE][FAIL] Passing typed arrays as elements of the blobParts array should work.
    assert_equals: expected "PASSPASSPASSPASSPASSPASSPASS" but got "PASSPASSAPSSAPSSSSAPSSAPSSAP"
        at Test.<anonymous> (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/FileAPI/support/Blob.js:16:5)
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    Command: /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/out/Release/node  /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/wpt/test-blob.js 'Blob-constructor.any.js'
    
    [EXPECTED_FAILURE][FAIL] Passing a Float16Array as element of the blobParts array should work.
    promise_test: Unhandled rejection with value: object "ReferenceError: Float16Array is not defined"
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    Command: /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/out/Release/node  /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/wpt/test-blob.js 'Blob-constructor.any.js'
    
    [UNEXPECTED_FAILURE][FAIL] Passing a Float64Array as element of the blobParts array should work.
    assert_equals: expected "PASSPASS" but got "SSAPSSAP"
        at Test.<anonymous> (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/FileAPI/support/Blob.js:16:5)
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    Command: /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/out/Release/node  /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/wpt/test-blob.js 'Blob-constructor.any.js'
    

aduh95 avatar Oct 22 '24 07:10 aduh95

I can't reproduce the failures locally

avivkeller avatar Oct 24 '24 21:10 avivkeller

Removing [EXPECTED_FAILURE] and [PASS]:

Seemingly related test failures:

    [UNEXPECTED_FAILURE][FAIL] Passing typed arrays as elements of the blobParts array should work.
    assert_equals: expected "PASSPASSPASSPASSPASSPASSPASS" but got "PASSPASSAPSSAPSSSSAPSSAPSSAP"
        at Test.<anonymous> (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/FileAPI/support/Blob.js:16:5)
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    Command: /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/out/Release/node  /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/wpt/test-blob.js 'Blob-constructor.any.js'
    
...
    
    [UNEXPECTED_FAILURE][FAIL] Passing a Float64Array as element of the blobParts array should work.
    assert_equals: expected "PASSPASS" but got "SSAPSSAP"
        at Test.<anonymous> (/home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/fixtures/wpt/FileAPI/support/Blob.js:16:5)
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    Command: /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/out/Release/node  /home/iojs/build/workspace/node-test-commit-aix/nodes/aix72-ppc64/test/wpt/test-blob.js 'Blob-constructor.any.js'
    

These look very much like endianness issues, especially since they're failing on AIX and LinuxONE which are both big endian platforms.

richardlau avatar Oct 24 '24 22:10 richardlau

I don't have a big endian machine to test this one, but it's likely, there may be a bug :thinking:. Drafting until whatever this is is resolved.

avivkeller avatar Oct 25 '24 22:10 avivkeller

I don't have a big endian machine to test this one, but it's likely, there may be a bug 🤔. Drafting until whatever this is is resolved.

I think it's a bug in WPT. Taking, for example, https://github.com/nodejs/node/blob/b1c015cc9b56f004362398567e708c7aecb65be4/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js#L285-L299 Typed arrays are by definition

Typed arrays always use the platform's native byte order.

which means, e.g. that the bytes for new Uint16Array([0x4150, 0x5353]) will be different on little endian vs big endian platforms.

richardlau avatar Oct 31 '24 19:10 richardlau

This is a bug in node. I will give some more context in a little bit.

KhafraDev avatar Oct 31 '24 19:10 KhafraDev

I forgot to follow up, but here are the steps (this follows through multiple specs so I will link each one).

  1. The Blob constructor calls process blob parts.
  2. process blob parts calls get a copy of the bytes held by the buffer source
  3. which calls GetValueFromBuffer for each element in a webidl BufferSource (a TypedArray, DataView, or ArrayBuffer)
  4. which calls RawBytesToNumeric (note the isLittleEndian flag
  5. which is where we FINALLY get the step
  1. If isLittleEndian is false, reverse the order of the elements of rawBytes.

KhafraDev avatar Nov 01 '24 22:11 KhafraDev

Thanks for the details! I'll update these files later today, and if this is still the case, I'll open an issue in the WPT repository

avivkeller avatar Nov 03 '24 11:11 avivkeller

Thanks for the details! I'll update these files later today, and if this is still the case, I'll open an issue in the WPT repository

@KhafraDev 's analysis is that this is a Node.js bug, not a WPT one.

richardlau avatar Nov 03 '24 13:11 richardlau

Oh, I misunderstood. Got it, keeping this is a draft until that's fixed

avivkeller avatar Nov 03 '24 16:11 avivkeller