Skip to content

WebIDL conversion to clamped i64 is incorrect #41638

@jdm

Description

@jdm

Specification: https://webidl.spec.whatwg.org/#abstract-opdef-converttoint
Gecko's implementation: https://searchfox.org/firefox-main/rev/aee7c0f24f488cd7f5a835803b48dd0c0cb2fd5f/dom/bindings/PrimitiveConversions.h#225-269
Servo's implementation: https://github.com/servo/mozjs/blob/4d290e8a270f1bf6cc18aa5860427243a39cc128/mozjs/src/conversions.rs#L227-L244

We just end up using f32 as i64, which is incorrect. We should port the rest of the logic from Gecko; the resulting implementation should make the remaining tests in

// Test double start/end values
[
["abcd"],
[{start: 0.5, contents: "abcd"},
{start: 1.5, contents: "cd"},
{start: 2.5, contents: "cd"},
{start: 3.5, contents: ""},
{start: 0, end: 0.5, contents: ""},
{start: 0, end: 1.5, contents: "ab"},
{start: 0, end: 2.5, contents: "ab"},
{start: 0, end: 3.5, contents: "abcd"},
{start: 1.5, end: 2.5, contents: ""},
{start: 1.5, end: 3.5, contents: "cd"}]
],
start passing.

Tests: ./mach test-wpt tests/wpt/tests/FileAPI/blob/Blob-slice.any.js

Metadata

Metadata

Assignees

Labels

A-content/bindingsThe DOM bindingsE-less-complexStraightforward. Recommended for a new contributor.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions