Closed Bug 1274806 Opened 8 years ago Closed 8 years ago

got NS_ERROR_UNEXPECTED error when I call range.extractContents() for DOM element with iframe

Categories

(Core :: DOM: Core & HTML, defect)

46 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox50 --- fixed

People

(Reporter: deadem, Assigned: smaug)

References

Details

(Whiteboard: btpp-followup-2016-07-05)

Attachments

(4 files, 1 obsolete file)

Attached file test.html (deleted) —
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36 Steps to reproduce: I've try to grab content from page by range operations, and when I call ange.extractContents() for DOM element with iframe I got NS_ERROR_UNEXPECTED error. If i remove iframe from that element all works fine. Small example in attached file Actual results: NS_ERROR_UNEXPECTED error in browser console Expected results: cut DOM contents and return data
OS: Unspecified → Windows 7
Hardware: Unspecified → x86_64
Component: Untriaged → DOM
Product: Firefox → Core
Olli may know about this.
Flags: needinfo?(bugs)
Whiteboard: btpp-followup-2016-07-05
Blocks: 766426
So MutationGuard doesn't quite work here because of unload event being dispatched and iframe doing its mutations. And ValidateCurrentNode is overly strict here when dealing with character data.
Assignee: nobody → bugs
Attached patch range_validate.diff (obsolete) (deleted) — Splinter Review
mats, perhaps you could review this (bz and sicking are both on vacation)? I need to still write a testcase for this.
Flags: needinfo?(bugs)
Attachment #8765201 - Flags: review?(mats)
Attached patch range_validate.diff (deleted) — Splinter Review
Attachment #8765201 - Attachment is obsolete: true
Attachment #8765201 - Flags: review?(mats)
Attachment #8765203 - Flags: review?(mats)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment on attachment 8765203 [details] [diff] [review] range_validate.diff LGTM, although I think this might actually be too conservative. I think that if 'node' is either the start/end container is proof that it hasn't been removed, so I think you could just "return true" in both these if-statements. You might want to write some tests to figure out what makes most sense for the cut operation though. One nit: 'before'/'after' might be undefined if NS_FAILED(res), so I think you should do an early return in that case (and remove the NS_SUCCEEDED test at the end).
Attachment #8765203 - Flags: review?(mats) → review+
Good catch that uninitialized variables. (a reason to always initialize variables to some value). I'd prefer to be conservative here.
Attached patch range_validate.diff (deleted) — Splinter Review
Pushed by opettay@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/07073e0e98e3 got NS_ERROR_UNEXPECTED error when I call range.extractContents() for DOM element with iframe , r=mats
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: