Bug 76114 - REGRESSION (r96257): Selection should be removed when a document is unloaded
Summary: REGRESSION (r96257): Selection should be removed when a document is unloaded
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-11 16:10 PST by Ojan Vafai
Modified: 2021-09-11 10:58 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ojan Vafai 2012-01-11 16:10:33 PST
Test case: http://dvcs.w3.org/hg/editing/raw-file/6aaa4b8455c9/selecttest/unload.html
Mozilla bug: https://bugzilla.mozilla.org/show_bug.cgi?id=717339

The editing spec was just changed to require this. Neither Mozilla nor WebKit do this currently, but IE/Opera do and I think it makes sense.
Comment 1 Alexey Proskuryakov 2012-01-11 17:18:20 PST
Safari 5.1 says Pass. When did this regress?
Comment 2 Aryeh Gregor 2012-01-12 08:26:24 PST
After discussion with Boris Zbarsky and Ian Hickson: actually, the Selection object is supposed to be replaced with a new one.  This is specified in HTML as part of the document.open() algorithm:

"""
Replace the Document's singleton objects with new instances of those objects. (This includes in particular the Window, Location, History, ApplicationCache, and Navigator, objects, the various BarProp objects, the two Storage objects, the various HTMLCollection objects, and objects defined by other specifications, like Selection and the document's UndoManager. It also includes all the Web IDL prototypes in the JavaScript binding, including the Document object's prototype.)
""
http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#dom-document-open

New test: http://dvcs.w3.org/hg/editing/raw-file/56c83bbaa44c/selecttest/Document-open.html

The new test shows that Gecko does replace the selection with a new object, but that object has the same ranges as the old one.  WebKit (Chrome 17 dev) is the same object as before.  Opera clears the ranges but I can't tell if it's the same object, because getSelection() != getSelection() in Opera.  IE returns a different object and clears the ranges, so it's the only one that passes the new test.

This is specific to document.open(), not a general unloading thing.
Comment 3 Alexey Proskuryakov 2012-01-12 09:31:19 PST
Regressed in <http://trac.webkit.org/changeset/96257>.