Bug 148483

Summary: Range.compareBoundaryPoints() should throw a NotSupportedError for invalid compareHow values
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue
Priority: P2 Keywords: WebExposed
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
URL: https://dom.spec.whatwg.org/#dom-range-compareboundarypoints
Attachments:
Description Flags
Patch
none
Patch none

Chris Dumez
Reported 2015-08-26 11:09:50 PDT
Range.compareBoundaryPoints() should throw a NotSupportedError for invalid compareHow values: https://dom.spec.whatwg.org/#dom-range-compareboundarypoints (step 1) Firefox and Chrome conform to the specification already. W3C test suite: http://w3c-test.org/dom/ranges/Range-compareBoundaryPoints.html
Attachments
Patch (14.03 KB, patch)
2015-08-26 14:15 PDT, Chris Dumez
no flags
Patch (14.02 KB, patch)
2015-08-27 14:46 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2015-08-26 14:15:13 PDT
Geoffrey Garen
Comment 2 2015-08-27 14:42:55 PDT
Comment on attachment 259981 [details] Patch r=me
Chris Dumez
Comment 3 2015-08-27 14:46:02 PDT
Chris Dumez
Comment 4 2015-08-27 15:33:55 PDT
Comment on attachment 260091 [details] Patch Clearing flags on attachment: 260091 Committed r189062: <http://trac.webkit.org/changeset/189062>
Chris Dumez
Comment 5 2015-08-27 15:34:00 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 6 2015-08-31 18:59:47 PDT
Comment on attachment 260091 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=260091&action=review > LayoutTests/fast/dom/Range/compareBoundaryPoints-compareHow-exception-expected.txt:10 > +PASS range.compareBoundaryPoints(65536, sourceRange) is -1 This is the desired behavior? Why not an exception in this case?
Chris Dumez
Comment 7 2015-08-31 19:33:24 PDT
Comment on attachment 260091 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=260091&action=review >> LayoutTests/fast/dom/Range/compareBoundaryPoints-compareHow-exception-expected.txt:10 >> +PASS range.compareBoundaryPoints(65536, sourceRange) is -1 > > This is the desired behavior? Why not an exception in this case? Because 65536 wraps to 0, which is the value of the START_TO_START constant. compareHow is an unsigned short so it is in the range [0, 65535] as per: https://heycam.github.io/webidl/#idl-unsigned-short The unsigned short conversion is documented at: https://heycam.github.io/webidl/#es-unsigned-short which says to call ToUint16(x) in this case: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint16 (which specifies the wrapping around behavior) We would only throw a TypeError if the IDL specified [EnforceRange]: https://heycam.github.io/webidl/#EnforceRange
Chris Dumez
Comment 8 2015-08-31 19:34:04 PDT
Comment on attachment 260091 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=260091&action=review > LayoutTests/fast/dom/Range/compareBoundaryPoints-compareHow-exception.html:20 > +shouldBe("range.compareBoundaryPoints(65536, sourceRange)", "-1"); // 65536 should wrap around to 0. By the way, I documented the wrapping around to 0 here already.
Chris Dumez
Comment 9 2015-08-31 19:38:00 PDT
Comment on attachment 260091 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=260091&action=review >>> LayoutTests/fast/dom/Range/compareBoundaryPoints-compareHow-exception-expected.txt:10 >>> +PASS range.compareBoundaryPoints(65536, sourceRange) is -1 >> >> This is the desired behavior? Why not an exception in this case? > > Because 65536 wraps to 0, which is the value of the START_TO_START constant. compareHow is an unsigned short so it is in the range [0, 65535] as per: > https://heycam.github.io/webidl/#idl-unsigned-short > > The unsigned short conversion is documented at: > https://heycam.github.io/webidl/#es-unsigned-short > which says to call ToUint16(x) in this case: > http://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint16 (which specifies the wrapping around behavior) > > We would only throw a TypeError if the IDL specified [EnforceRange]: > https://heycam.github.io/webidl/#EnforceRange This layout test is also passing in the latest Firefox and Chrome.
Note You need to log in before you can comment on or make changes to this bug.