whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
7.88k stars 2.58k forks source link

Behavior of Location attribute after closing the window #6899

Open cdumez opened 2 years ago

cdumez commented 2 years ago

I am a bit unclear about what the Location attributes should return after the window is closed.

I thought for example that w.location.href should be "about:blank" after closing the window because of this section of the spec:

For what it's worth, this is WebKit's behavior. I was investigating subtests failures on https://wpt.live/html/cross-origin-opener-policy/resource-popup.https.html and found out that the test is actually relying on w.location.href to be something other than "about:blank" after closing.

I decided to look at Firefox and Chrome and it seems nobody agrees on anything:

  1. Firefox:

    • assign/replace/reload exist and are functions
    • href/protocol/host/hostname/port/pathname/search/hash/origin all return the empty string
    • ancestorOrigins is undefined
  2. Chrome:

    • replace exists and is a function
    • Every other property is undefined
  3. Safari:

    • assign/replace/reload exist and are functions
    • href is "about:blank"
    • origin is "null"
    • pathname is "blank"
    • protocol is "about:"
    • hash/host/hostname/port/search all return the empty string

My understanding was that Safari was matching the HTML specification here but I may have missed something. However, this is causing us to fail WPT tests because no other major browser engine behaves the same way and in particular, none of them have href return "about:blank" after closing.

cdumez commented 2 years ago

cc @domenic

cdumez commented 2 years ago

cc @foolip

domenic commented 2 years ago

In general what happens in closed windows or detached iframes is not very interoperable, so I am not surprised.

I agree Safari matches the spec. And I think of the three behaviors you note it makes the most sense. So I feel like we should just update the test and file bugs on Chrome and Firefox.

/cc @jugglinmike and @zcorpan who worked on that test per https://github.com/web-platform-tests/wpt/commits/master/html/cross-origin-opener-policy/resource-popup.https.html .

cdumez commented 2 years ago

I created a pull request to update the test at https://github.com/web-platform-tests/wpt/pull/29769

mikewest commented 2 years ago

Perhaps @ArthurSonzogni or @antosart can take a look at this from Chromium's perspective?

cdumez commented 2 years ago

FYI, the spec behavior seems to be covered by:

It is indeed passing in Safari but failing in Chrome and Firefox.

zcorpan commented 2 years ago

I agree the Safari/spec behavior makes sense. Thanks for fixing the test @cdumez!