Bug 15533 - Index check in selection.extend() should be done before node type test.
Summary: Index check in selection.extend() should be done before node type test.
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HTML Editing APIs (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Aryeh Gregor
QA Contact: HTML Editing APIs spec bugbot
URL: http://dvcs.w3.org/hg/editing/raw-fil...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-12 12:51 UTC by Stig Halvorsen
Modified: 2012-01-13 17:05 UTC (History)
2 users (show)

See Also:


Attachments
Test patch, index (1.60 KB, patch)
2012-01-12 12:51 UTC, Stig Halvorsen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stig Halvorsen 2012-01-12 12:51:33 UTC
Created attachment 1066 [details]
Test patch, index

According to the Selection spec for extend [1], the checking of offset compared
to parentNode's length should be done before setting the new boundary points
for the range [2] which would trigger the node type exception for doctype.

In the selecttest/extend.html tests there are a few tests that expect the browser to throw an INVALID_NODE_TYPE_ERR, where in fact the INDEX_SIZE_ERR exception should be checked and thrown first.

Patch attached.

[1]
http://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#dom-selection-extend

[2]
http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-bp-set
Comment 1 Aryeh Gregor 2012-01-12 17:13:08 UTC
Actually, it seems like I should just reference DOM4's "set the start or end" algorithm for simplicity.  This results in throwing InvalidNodeTypeError first.  This:

  document.createRange().setStart(document.doctype, -13);

throws InvalidNodeTypeError in Firefox 12.0a1 and Chrome 17 dev, per DOM4; and IndexSizeError in IE9 and Opera Next 12.00 alpha, not per DOM4.  We should be consistent and throw InvalidNodeTypeError for extend() just like setStart().

I've changed the spec to reference DOM4's algorithm, which I believe makes the tests correct:

http://dvcs.w3.org/hg/editing/rev/0ef300a5c14f

Please tell me if this isn't satisfactory.  Thanks!
Comment 2 Stig Halvorsen 2012-01-13 09:00:37 UTC
(In reply to comment #1)
...
> Please tell me if this isn't satisfactory.  Thanks!

The changes look very good. Thank you for quick response.

Just FYI, I'm currently rewriting the Range and Selection code in Opera, and upcoming versions will match the spec, more or less, to the letter.
Comment 3 Aryeh Gregor 2012-01-13 17:05:35 UTC
Great!  Opera's Range/Selection implementation was always a not-so-good match for the other browsers I tested, and I hope my spec/tests are helpful in improving that.  Please give me any further feedback you have and I'll try to respond ASAP.