HTML now defines when a top-level traversable is script-closable, ie whether window.close() works, based on a "is created by web content" flag (whatwg/html#11208, merged in April 2025). A window is script-closable if the flag is set or its session history contains only one entry.
The New Window command is currently specified as creating the new top-level browsing context by running the window open steps. The window open steps set "is created by web content" on the new window. The direct reading of the text suggests that driver-created windows carry the flag and remain script-closable forever, the same behavior as a window.open() popup.
No current implementation does that. I probed Chrome 151 (chromedriver), Firefox 154 (geckodriver) and Safari 26.6.2 (safaridriver). With all three, a window created with New Window and then navigated so its session history is greater than 1 ignores window.close(). All three behave as if the flag is unset. Windows created with window.open(), including noopener, stay closable in all three at any history depth (More info in this comment).
Proposal: Codify the current implemented behavior. Specify that New Window creates the top-level browsing context as if the user had opened a new window, with the "is created by web content" flag unset.
Context: I am working on making the session-history arm of HTML's script-closable checks testable in WPT. The plan is to add test_driver.create_window() backed by New Window.
HTML now defines when a top-level traversable is script-closable, ie whether
window.close()works, based on a "is created by web content" flag (whatwg/html#11208, merged in April 2025). A window is script-closable if the flag is set or its session history contains only one entry.The New Window command is currently specified as creating the new top-level browsing context by running the window open steps. The window open steps set "is created by web content" on the new window. The direct reading of the text suggests that driver-created windows carry the flag and remain script-closable forever, the same behavior as a
window.open()popup.No current implementation does that. I probed Chrome 151 (chromedriver), Firefox 154 (geckodriver) and Safari 26.6.2 (safaridriver). With all three, a window created with New Window and then navigated so its session history is greater than 1 ignores
window.close(). All three behave as if the flag is unset. Windows created withwindow.open(), includingnoopener, stay closable in all three at any history depth (More info in this comment).Proposal: Codify the current implemented behavior. Specify that New Window creates the top-level browsing context as if the user had opened a new window, with the "is created by web content" flag unset.
Context: I am working on making the session-history arm of HTML's script-closable checks testable in WPT. The plan is to add
test_driver.create_window()backed by New Window.