Closed Bug 1298977 Opened 9 years ago Closed 9 years ago

NS_ERROR_FAILURE when changing location.hash for iframe with srcdoc

Categories

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

48 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: rdvornov, Assigned: bzbarsky)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Steps to reproduce: 1. Create a iframe with srcdoc 2. Change iframe's location.hash on document load Example: <iframe srcdoc="&lt;html&gt;&lt;/html&gt;" onload=" this.contentWindow.location.hash = 'test'; "></iframe> Actual results: location.hash doesn't change but NS_ERROR_FAILURE exception occurs Expected results: location.hash should be changed with no exception. Setting hash via location.href works as expected, i.e. <iframe srcdoc="&lt;html&gt;&lt;/html&gt;" onload=" this.contentWindow.location.href += '#test'; "></iframe>
Thank you for filing this. So per spec, we start off at https://html.spec.whatwg.org/multipage/browsers.html#dom-location-hash and end up calling https://html.spec.whatwg.org/multipage/browsers.html#location-object-setter-navigate with "about:srcdoc#test" as the url. That lands at https://html.spec.whatwg.org/multipage/browsers.html#location-object-navigate which calls into https://html.spec.whatwg.org/multipage/browsers.html#navigate with the exceptions enabled flag set. We should get to step 6, do an anchor scroll and stop. No exception should be thrown. The problem is that in nsLocation::SetHash we have an immutable uri, because all about: URIs flag themselves as immutable (see nsAboutProtocolHandler::NewURI). So the SetRef call we make there fails. We should be using CloneWithNewRef instead.
Status: UNCONFIRMED → NEW
Component: Untriaged → DOM
Ever confirmed: true
Product: Firefox → Core
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Comment on attachment 8786228 [details] [diff] [review] Fix setting location.hash for documents with about:something URIs to actually work Review of attachment 8786228 [details] [diff] [review]: ----------------------------------------------------------------- Looks good. Thanks for linking the relevant spec text.
Attachment #8786228 - Flags: review?(bkelly) → review+
Pushed by bzbarsky@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/0a4166cfb914 Fix setting location.hash for documents with about:something URIs to actually work. r=bkelly
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: