-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REGRESSION (Safari 16.3): Passing "noopener" as third argument opens …
…tabs into new window https://bugs.webkit.org/show_bug.cgi?id=259093 rdar://112086061 Reviewed by BJ Burg and Chris Dumez. The changes herein bring WebKit up to the HTML specs for window.open(). First, this commit now parses the popup field which is specified in the specs but was missing in our parser. We also start parsing the resizable field which is defined in our API but was never parsed. Finally, we mark all other member fields of optional rather than setting a default value for each of them. Second, this adds the member fields wantsPopup and hasAdditionalFeatures: hasAdditionalFeatures is serialized and sent to the UI Process to indicate that we detected other strings than the ones we normally parse. The field wantsPopup implements the algorithm described here: https://html.spec.whatwg.org/multipage/nav-history-apis.html#apis-for-creating-and-navigating-browsing-contexts-by-name aimed at determining whether we should display a popup or not. Its value is determined in the following way: - features noopener and noreferrer do not count towards the tested feature string. - empty features (two commas in a row), strings made of spaces only do not towards the tested feature string. So spaces and commas don't make the string not empty. - every other words or characters are counted. As such the first test to determine the value of wantsPopup is to check whether any feature is defined or if the string contains additional features, the latter flag is only set if the string contains anything but spaces and commas. This matches the behavior from other browsers and prescribed by the specs. Finally, despite being declared as nullable, the corresponding properties in WKWindowFeatures could never be in fact nil; changing all member fields in WindowFeatures to std::optional allows us to return nil in the corresponding properties when those features are missing. We also add private properties for the corresponding WindowFeatures member fields. These changes ostensibly fixes the issue in question since we needed the ability to check for the absence of the window features. However, to be correct a browser should adopt the new properties as well. * Source/WebCore/loader/FrameLoader.cpp: (WebCore::createWindow): * Source/WebCore/page/Chrome.cpp: (WebCore::Chrome::createWindow): * Source/WebCore/page/LocalDOMWindow.cpp: (WebCore::LocalDOMWindow::createWindow): * Source/WebCore/page/WindowFeatures.cpp: (WebCore::WindowFeatures::wantsPopup const): Implements the specs algorithm to check if we need to get a popup. No features declared besides noopener and noreferrer means we do not want a popup. (WebCore::parseWindowFeatures): Stop setting default values for the window features to avoid indicating that those features were declared in the string. Compute wantsPopup after we are done parsing the string. (WebCore::setWindowFeature): Add a parse step for the popup feature and set the additional features when they are not empty strings or strings made of spaces. (WebCore::parseDialogFeatures): Dialogs are always popups. * Source/WebCore/page/WindowFeatures.h: Make all potential features optional. Add convenience member functions to use instead of using noopener and noreferrer directly. (WebCore::WindowFeatures::wantsNoOpener const): (WebCore::WindowFeatures::wantsNoReferrer const): * Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: Match the declaration above. Serialize the three new fields. * Source/WebKit/UIProcess/API/C/WKPage.cpp: (WKPageSetPageUIClient): Save the new fields in the window feature dictionary for legacy clients. * Source/WebKit/UIProcess/API/Cocoa/WKWindowFeatures.mm: (-[WKWindowFeatures menuBarVisibility]): (-[WKWindowFeatures statusBarVisibility]): (-[WKWindowFeatures toolbarsVisibility]): (-[WKWindowFeatures allowsResizing]): (-[WKWindowFeatures _wantsPopup]): (-[WKWindowFeatures _hasAdditionalFeatures]): (-[WKWindowFeatures _popup]): (-[WKWindowFeatures _locationBarVisibility]): (-[WKWindowFeatures _scrollbarsVisibility]): (-[WKWindowFeatures _fullscreenDisplay]): (-[WKWindowFeatures _dialogDisplay]): * Source/WebKit/UIProcess/API/Cocoa/WKWindowFeaturesPrivate.h: Check if the value is defined and return it as a boolean otherwise return nil. * Source/WebKit/UIProcess/API/glib/WebKitWindowProperties.cpp: Convert optional features into glib API. (webkitWindowPropertiesSetGeometry): (webkitWindowPropertiesSetWantsPopup): * Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm: (WebChromeClient::createWindow): Write the new fields in the window feature dictionary for legacy clients. Only write optional fields if they are not null. * Tools/TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm: (TEST(WebKit, OpenWindowFeatures)): - Reenable the tests checking for the nil case when the string is empty. - Add checks for the new fields in the API. - Add tests for noopener and noreferrer features. - Add test for hasAdditionalFeatures. - Add test for a string containing only separators. Canonical link: https://commits.webkit.org/267354@main
- Loading branch information
1 parent
6cabcd4
commit 301fe8a
Showing
12 changed files
with
317 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.