Closed Bug 1587716 Opened 6 years ago Closed 6 years ago

`RangeBoundary` constructor receives negative offsets, but converts them to an unsigned integer

Categories

(Core :: DOM: Selection, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla72
Tracking Status
firefox72 --- fixed

People

(Reporter: mbrodesser, Assigned: mbrodesser)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

STR:

  1. Add assertion:
   RangeBoundaryBase(nsINode* aContainer, int32_t aOffset)
-      : mParent(aContainer), mRef(nullptr), mOffset(mozilla::Some(aOffset)) {
+      : mParent(aContainer), mRef(nullptr), mOffset(mozilla::Some<uint32_t>(aOffset)) {
+    MOZ_ASSERT(aOffset >= 0)
  1. Run ./testing/web-platform/tests/selection/collapse-00.html

Expected: assertion not triggered.

Actual: assertion triggered.

(P2 given that we probably will start working on this in following months, please free feel to change the priority if I misunderstand anything)

Priority: -- → P2

One problem here is: nsRange::ComparePoint has a uint32_t argument, which is required by https://dom.spec.whatwg.org/#interface-range. But it internally calls RangeBoundaryBase::RangeBoundaryBase, which takes a int32_t.
Reproducible with dom/base/test/test_bug737565.html.

Another violation of the assertion is triggered after running and successfully finishing editor/libeditor/tests/test_bug1270235.html.

Assignee: nobody → mbrodesser

uint32_t, because nsRange::ComparePoints requires it -- by webidl
interface -- to be unsigned long.

Moreover it makes RangeBoundaryBase's interface cleaner, because it
already exposes the offset as a uint32_t.

Pushed by mbrodesser@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8e233a18ab9a change `RangeBoundaryBase`'s offset argument to `uint32_t`. r=smaug
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: