Open Bug 827585 Opened 12 years ago Updated 5 months ago

window.getSelection() returns null for hidden iframe

Categories

(Core :: DOM: Selection, defect)

17 Branch
x86_64
Windows 7
defect

Tracking

()

REOPENED
Webcompat Priority P3

People

(Reporter: timdown, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: testcase)

Attachments

(2 files)

620 bytes, application/octet-stream
Details
325 bytes, text/html
Details
Attached file ffbug.zip
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0
Build ID: 20121128204232

Steps to reproduce:

Created an HTML document containing another HTML document in an iframe hidden via CSS display: none and examined the result of calling window.getSelection() in the iframe's document


Actual results:

null was returned


Expected results:

Per spec, since the iframe's document has a defaultView property, a Selection object should be returned. See 

http://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#dom-window-getselection
Attachment #698927 - Attachment mime type: text/plain → application/octet-stream
Attached file Reporter's testcase
Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
Actually, I guess we should just make the other depend on this one.

In any case, right now selection objects are tied to a presentation and there is no presentation in display:none iframes.  So fixing this bug requires revamping how selections work.  Well, or giving display:none stuff a presshell.
Blocks: 495230
Status: RESOLVED → REOPENED
Component: DOM: Core & HTML → Selection
Ever confirmed: true
Resolution: DUPLICATE → ---
Webcompat Priority: --- → ?

P3 from a WebCompat perspective. We've only seen one live site breakage, and we could probably fix this via a site intervention.

Webcompat Priority: ? → P3
Severity: normal → S3

I've just been bitten by this bug using a third-party script library on a page loaded into an iframe inside a Bootstrap modal dialog.

https://github.com/yairEO/tagify/issues/1338

The MDN documentation for getSelection makes no mention of the fact that the method could return null, which to me suggests this behaviour is not expected even if the page is in a hidden iframe.

Checking the document.visibilityState doesn't help, since that returns "visible". Similarly, document.hidden returns false.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: