Open Bug 827585 Opened 12 years ago Updated 21 days 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 2 open bugs)

Details

(Keywords: testcase, webcompat:platform-bug)

User Story

user-impact-score:135

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.

Blocks: 1967389

Given the recent webcompat breakage on EBay, this may need re-triage and effort assessment

Flags: needinfo?(afarre)

You know about selection, right? Do you have an idea of what's going on?

Flags: needinfo?(afarre) → needinfo?(jjaschke)

:sefeng and :denschub are already on it (in Bug 1967389).

Flags: needinfo?(jjaschke) → needinfo?(sefeng)

What Boris said in comment 3 is still valid.

Basically we don't have a presShell for display:none, so we don't get a selection.

According to the spec The method must return the selection associated with this if this has an associated browsing context, and it must return null otherwise, selection object should be associated with browsing context, so this is a bug in Firefox.

Looks like one fix we could fix this by moving the selection from presshell to browsing context, which doesn't look hard to do.

Flags: needinfo?(sefeng)
User Story: (updated)
User Story: (updated)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: