Closed Bug 719518 Opened 12 years ago Closed 12 years ago

Selection.extend() with no ranges should throw standard exception type

Categories

(Core :: DOM: Selection, defect)

x86
Linux
defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla14

People

(Reporter: ayg, Assigned: ayg)

Details

Attachments

(1 file)

Test case:

data:text/html,<!doctype html>
<body>
<script>
try {
getSelection().extend(document.body, 0);
} catch(e) {
document.body.textContent = e;
throw e;
}
document.body.textContent = getSelection().rangeCount;
</script>

Chrome 17 dev outputs "1", Opera Next 12.00 alpha outputs "0", Firefox 12.0a1 outputs

"""
[Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsISelection.extend]" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: data:text/html,<!doctype%20html><body><script>try%20{getSelection().extend(document.body,%200);}%20catch(e)%20{document.body.textContent%20=%20e;throw%20e;}document.body.textContent%20=%20getSelection().rangeCount;</script> :: <TOP_LEVEL> :: line 1" data: no]
"""

IE9 doesn't support extend().  Since there's no interop here at all, I went with Gecko's implementation when I was speccing this a number of months back, since it's the oldest.  But the exception type needs to be something standard, so I specced it as a DOMException, InvalidStateError:

"""
1. If the context object's range is null, throw an InvalidStateError exception and abort these steps.
"""
http://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#dom-selection-extend

Gecko should change the exception thrown here to InvalidStateError.

This causes test failures in <http://dvcs.w3.org/hg/editing/raw-file/tip/selecttest/extend.html>.  If this bug, bug 711047, and bug 719515 are fixed, it looks like Gecko will pass all the tests in that file.
Attached patch Patch v1Splinter Review
Assignee: nobody → ayg
Status: NEW → ASSIGNED
Attachment #605860 - Flags: review?(ehsan)
Whiteboard: [autoland-try:-u all]
Whiteboard: [autoland-try:-u all] → [autoland-in-queue]
Autoland Patchset:
	Patches: 605860
	Branch: mozilla-central => try
Patch 605860 could not be applied to mozilla-central.
hg: unknown command 'qimport'

Patchset could not be applied and pushed.
Whiteboard: [autoland-in-queue]
Attachment #605860 - Flags: review?(ehsan) → review+
The bug 719515 patch is causing failures on the try server, so I'll do a different run with just this patch to see if we can land this even if that one needs more revisions.
Whiteboard: [autoland-try:-u all]
Whiteboard: [autoland-try:-u all] → [autoland-in-queue]
Autoland Patchset:
	Patches: 605860
	Branch: mozilla-central => try
	Destination: http://hg.mozilla.org/try/pushloghtml?changeset=f6af7fe4f2ac
Try run started, revision f6af7fe4f2ac. To cancel or monitor the job, see: https://tbpl.mozilla.org/?tree=Try&rev=f6af7fe4f2ac
Try run for f6af7fe4f2ac is complete.
Detailed breakdown of the results available here:
    https://tbpl.mozilla.org/?tree=Try&rev=f6af7fe4f2ac
Results (out of 216 total builds):
    exception: 2
    success: 172
    warnings: 42
Builds (or logs if builds failed) available at:
http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/autolanduser@mozilla.com-f6af7fe4f2ac
Whiteboard: [autoland-in-queue]
There are some xpcshell failures that I can't pin on any existing bug and that occur on all Windows builds, but are surely unrelated to this commit.
Keywords: checkin-needed
(In reply to Aryeh Gregor from comment #7)
> There are some xpcshell failures that I can't pin on any existing bug and
> that occur on all Windows builds, but are surely unrelated to this commit.

These are my fault, and I fixed them on m-c last night.  I'll push your patch now.
https://hg.mozilla.org/integration/mozilla-inbound/rev/895c2f503553
Flags: in-testsuite+
Target Milestone: --- → mozilla14
https://hg.mozilla.org/mozilla-central/rev/895c2f503553
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: