Skip to content

Commit

Permalink
Drop insecure contexts warning from getGamepads()
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=269514
rdar://123039555

Reviewed by Chris Dumez.

Removed console warning about restricting to secure contexts.
Chrome is also removed the warning.
Firefox is removing the restriction.
w3c/gamepad#145 (comment)

Related pull request on the W3C gamepad spec:
w3c/gamepad#194

* LayoutTests/http/tests/misc/gamepads-insecure-expected.txt:
* LayoutTests/http/tests/misc/gamepads-insecure.html:
* Source/WebCore/Modules/gamepad/NavigatorGamepad.cpp:

Canonical link: https://commits.webkit.org/274962@main
  • Loading branch information
marcoscaceres committed Feb 19, 2024
1 parent fd1700a commit 5300e77
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
3 changes: 1 addition & 2 deletions LayoutTests/http/tests/misc/gamepads-insecure-expected.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
CONSOLE MESSAGE: Navigator.getGamepads() will be removed from insecure contexts in a future release
Test that accessing navigator.getGamepads from an insecure context logs a warning
Test that calling navigator.getGamepads no longer generates a console message in insecure contexts
2 changes: 1 addition & 1 deletion LayoutTests/http/tests/misc/gamepads-insecure.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<body>
<p>Test that accessing navigator.getGamepads from an insecure context logs a warning</p>
<p>Test that calling navigator.getGamepads no longer generates a console message in insecure contexts</p>
<script>
if (window.testRunner)
testRunner.dumpAsText();
Expand Down
8 changes: 0 additions & 8 deletions Source/WebCore/Modules/gamepad/NavigatorGamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ ExceptionOr<const Vector<RefPtr<Gamepad>>&> NavigatorGamepad::getGamepads(Naviga
return { emptyGamepads.get() };
}

if (!document->isSecureContext()) {
static std::once_flag onceFlag;
std::call_once(onceFlag, [document] {
document->addConsoleMessage(MessageSource::Security, MessageLevel::Warning, "Navigator.getGamepads() will be removed from insecure contexts in a future release"_s);
});

}

if (!isFeaturePolicyAllowedByDocumentAndAllOwners(FeaturePolicy::Type::Gamepad, *document, LogFeaturePolicyFailure::Yes))
return Exception { ExceptionCode::SecurityError, "Third-party iframes are not allowed to call getGamepads() unless explicitly allowed via Feature-Policy (gamepad)"_s };

Expand Down

0 comments on commit 5300e77

Please sign in to comment.