Calling location.assign with a relative URL causes incorrect URL resolution

RESOLVED WORKSFORME

Status

()

RESOLVED WORKSFORME
10 years ago
7 months ago

People

(Reporter: lists.bugzilla, Unassigned)

Tracking

({html5, testcase})

Trunk
html5, testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [urispec])

Attachments

(1 attachment)

(Reporter)

Description

10 years ago
User-Agent:       Opera/9.61 (Windows NT 5.1; U; en) Presto/2.1.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7

According to the HTML5 draft spec, setting location.href=foo should be equivalent to calling location.assign(foo), and in both cases the URL foo should be resolved against the "first script's base URL". However, this is not the case in Firefox; calling assign will resolve the URL foo against the other window's current URL instead. Sample code to demonstrate the problem below:

  <iframe style="display:none" src="some/sub/folder/"></iframe>
  <iframe style="display:none" src="some/sub/folder/"></iframe>
  <script type="text/javascript">
    function verify() {
        if (window[0].location.href == window[1].location.href) {
            alert( 'PASS' );
        } else {
            alert( 'FAIL' );
        }
    }

    function setLoc() {
        window[0].location.assign( 'index.html' );
        window[1].location = 'index.html';
        setTimeout( verify, 1000 );
    }
  </script>
  <button onclick="setLoc()">Demonstrate bug</button>

Reproducible: Always

Steps to Reproduce:
1. Put the above code in a .html file and load it in firefox. (The name of the file or folder it's in doesn't matter)
2. Click on the button that is displayed.
3. Wait for just over a second.
Actual Results:  
An alert dialog box with the text 'FAIL' is displayed.

Expected Results:  
An alert dialog box with the text 'PASS' should be displayed.

Opera and Chrome pass this test. The relevant sentences from the HTML5 draft spec are in section 5.9.4:

On setting, the user agent must act as if the assign() method had been called with the new value as its argument.

When the assign(url) method is invoked, the UA must resolve the argument, relative to the first script's base URL, and if that is successful, must navigate the browsing context to the specified url.

Updated

10 years ago
Component: General → DOM: Core & HTML
Product: Firefox → Core
QA Contact: general → general
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: html5, testcase
OS: Windows XP → All
Hardware: x86 → All
Whiteboard: [urispec]
Version: unspecified → Trunk
Created attachment 498602 [details]
Testcase from reporter
This works now!
Status: NEW → RESOLVED
Last Resolved: 7 months ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.