window-name-after-cross-origin-main-frame-navigation.sub.html expects window.name cleared in a popup that has an opener, which HTML keeps

Open Beginner friendly
#65,239 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
html, javascript
Domain
testing, web-dev

Research direction

Start with html/browsers/browsing-the-web/history-traversal/window-name-after-cross-origin-main-frame-navigation.sub.html and its helper support/window-name-navigation.sub.html, then compare them with the aux-frame sibling test, which expects the name kept. Confirm the failure by running the main-frame test with the WPT runner. Done means the test either expects the name to be kept (shouldhavename=true) or is removed as a duplicate, and it passes or is cleanly dropped in the browsers the issue lists.

Written by the indexing model from the issue text.

Description

Test: html/browsers/browsing-the-web/history-traversal/window-name-after-cross-origin-main-frame-navigation.sub.html at 2358bd4835.

What it does. It opens a popup with an opener (line 11), and the test expects the popup's name to be empty after it navigates itself cross-origin:

window.popupWin = window.open('support/window-name-after-cross-origin-main-frame-navigation-popup.sub.html', '_blank');

The popup navigates to support/window-name-navigation.sub.html with shouldhavename=false, which sets window.name = "test" (line 8) and navigates to the www1 host (line 9). There support/window-name-test.sub.html posts window.name == "" to window.opener (lines 4-5), and the test asserts it is true (line 19).

Why it cannot pass. HTML clears the target name on a cross-origin navigation only for a browsing context that is not an auxiliary browsing context with an opener. Finalize a cross-document navigation, step 4:

If all of the following are true:

  • navigable's parent is null;
  • historyEntry's document's browsing context is not an auxiliary browsing context whose opener browsing context is non-null; and
  • historyEntry's document's origin is not same origin with navigable's active document's origin,

then set historyEntry's document state's navigable target name to the empty string.

The popup here is auxiliary and its opener is non-null (the test needs the opener: the result is posted to window.opener), so the name stays "test". The sibling test window-name-after-cross-origin-aux-frame-navigation.sub.html runs the same navigation in a popup with an opener, expects the name kept (shouldhavename=true), and passes in Chrome, Firefox and Safari. The no-opener case is covered by unset_context_name.html, which opens its window with "noopener".

Results at 2358bd4835 (wpt.fyi):

Suggested fix. The test duplicates the aux-frame test with the opposite expectation. Remove it, or make it expect the name kept (shouldhavename=true), as the aux-frame test does. If the intent is a top-level browsing context with no opener, that case needs a noopener window and a reporting path other than window.opener, as unset_context_name.html already has.

Dominant language
HTML
Stars
6.3k
Forks
4.1k
Avg merge
17h 53m
Merged PRs (30d)
840

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from web-platform-tests/wpt

All issues in web-platform-tests/wpt

Similar issues

More Testing & QA issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.