mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Backed out changeset 039d90d5ec6b (bug 1704005
) for failures on test_hide_gamepad_info.html. CLOSED TREE
This commit is contained in:
parent
511356a7c1
commit
cdd2783d2a
@ -1491,6 +1491,27 @@ void Navigator::GetGamepads(nsTArray<RefPtr<Gamepad>>& aGamepads,
|
||||
NS_ENSURE_TRUE_VOID(mWindow->GetDocShell());
|
||||
nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow);
|
||||
|
||||
// As we are moving this API to secure contexts, we are going to temporarily
|
||||
// show a console warning to developers.
|
||||
if (!mGamepadSecureContextWarningShown && !win->IsSecureContext()) {
|
||||
mGamepadSecureContextWarningShown = true;
|
||||
auto msg =
|
||||
u"The Gamepad API will only be available in "
|
||||
"secure contexts (e.g., https). Please see "
|
||||
"https://hacks.mozilla.org/2020/07/securing-gamepad-api/ for more "
|
||||
"info."_ns;
|
||||
nsContentUtils::ReportToConsoleNonLocalized(
|
||||
msg, nsIScriptError::warningFlag, "DOM"_ns, win->GetExtantDoc());
|
||||
}
|
||||
|
||||
#ifdef EARLY_BETA_OR_EARLIER
|
||||
if (!win->IsSecureContext()) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
// We will move this into Beta in Firefox 82
|
||||
if (!FeaturePolicyUtils::IsFeatureAllowed(win->GetExtantDoc(),
|
||||
u"gamepad"_ns)) {
|
||||
aRv.ThrowSecurityError(
|
||||
@ -1498,6 +1519,7 @@ void Navigator::GetGamepads(nsTArray<RefPtr<Gamepad>>& aGamepads,
|
||||
"getGamepads() from this context.");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
win->SetHasGamepadEventListener(true);
|
||||
win->GetGamepads(aGamepads);
|
||||
|
@ -285,6 +285,8 @@ class Navigator final : public nsISupports, public nsWrapperCache {
|
||||
RefPtr<AddonManager> mAddonManager;
|
||||
RefPtr<webgpu::Instance> mWebGpu;
|
||||
RefPtr<Promise> mSharePromise; // Web Share API related
|
||||
// Gamepad moving to secure contexts
|
||||
bool mGamepadSecureContextWarningShown = false;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -35,7 +35,6 @@ static FeatureMap sSupportedFeatures[] = {
|
||||
{"display-capture", FeaturePolicyUtils::FeaturePolicyValue::eSelf},
|
||||
{"fullscreen", FeaturePolicyUtils::FeaturePolicyValue::eSelf},
|
||||
{"web-share", FeaturePolicyUtils::FeaturePolicyValue::eSelf},
|
||||
{"gamepad", FeaturePolicyUtils::FeaturePolicyValue::eSelf},
|
||||
};
|
||||
|
||||
/*
|
||||
@ -49,6 +48,7 @@ static FeatureMap sExperimentalFeatures[] = {
|
||||
// policy.
|
||||
{"autoplay", FeaturePolicyUtils::FeaturePolicyValue::eAll},
|
||||
{"encrypted-media", FeaturePolicyUtils::FeaturePolicyValue::eAll},
|
||||
{"gamepad", FeaturePolicyUtils::FeaturePolicyValue::eSelf},
|
||||
{"midi", FeaturePolicyUtils::FeaturePolicyValue::eSelf},
|
||||
{"payment", FeaturePolicyUtils::FeaturePolicyValue::eAll},
|
||||
{"document-domain", FeaturePolicyUtils::FeaturePolicyValue::eAll},
|
||||
|
@ -14,7 +14,6 @@ let supportedFeatures = [
|
||||
"camera",
|
||||
"encrypted-media",
|
||||
"fullscreen",
|
||||
"gamepad",
|
||||
"geolocation",
|
||||
"microphone",
|
||||
"midi",
|
||||
|
@ -21,3 +21,6 @@ support-files = test_gamepad_hidden_frame_iframe.html
|
||||
support-files = test_gamepad_multitouch_crossorigin_iframe.html
|
||||
[test_navigator_gamepads.html]
|
||||
support-files = test_navigator_gamepads_iframe.html
|
||||
[test_gamepad_insecure.html]
|
||||
support-files = test_gamepad_iframe_insecure.html
|
||||
scheme = http
|
||||
|
@ -0,0 +1,40 @@
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test gamepad</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" src="mock_gamepad.js"></script>
|
||||
<script class="testbody" type="text/javascript">
|
||||
const { is, ok, SimpleTest, SpecialPowers } = window.parent;
|
||||
|
||||
window.addEventListener("gamepadconnected", () => {
|
||||
ok(false, "gamepadconnected event must not fire");
|
||||
});
|
||||
|
||||
window.addEventListener("gamepaddisconnected", () => {
|
||||
ok(false, "gamepaddisconnected event must not fire");
|
||||
});
|
||||
|
||||
|
||||
runGamepadTest(async ()=> {
|
||||
// Add a gamepad - normally would cause "gamepadconnected" to fire
|
||||
const index = await GamepadService.addGamepad("test gamepad", // id
|
||||
GamepadService.standardMapping,
|
||||
GamepadService.noHand,
|
||||
4,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
is(navigator.getGamepads().length, 0, "Expected 0 gamepads in insecure context");
|
||||
await GamepadService.removeGamepad(index);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
20
dom/tests/mochitest/gamepad/test_gamepad_insecure.html
Normal file
20
dom/tests/mochitest/gamepad/test_gamepad_insecure.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test gamepad</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" src="mock_gamepad.js"></script>
|
||||
<script class="testbody" type="text/javascript">
|
||||
// This test loads in an iframe, to ensure that the navigator instance is
|
||||
// loaded with the correct value of the preference.
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
setGamepadPreferenceAndCreateIframe("test_gamepad_iframe_insecure.html");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -405,21 +405,21 @@ var interfaceNamesInGlobalScope = [
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "GainNode", insecureContext: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "Gamepad", insecureContext: false },
|
||||
{ name: "Gamepad", insecureContext: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "GamepadAxisMoveEvent", insecureContext: false },
|
||||
{ name: "GamepadAxisMoveEvent", insecureContext: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "GamepadButtonEvent", insecureContext: false },
|
||||
{ name: "GamepadButtonEvent", insecureContext: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "GamepadButton", insecureContext: false },
|
||||
{ name: "GamepadButton", insecureContext: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "GamepadEvent", insecureContext: false },
|
||||
{ name: "GamepadEvent", insecureContext: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "GamepadHapticActuator", insecureContext: false },
|
||||
{ name: "GamepadHapticActuator", insecureContext: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "GamepadLightIndicator", insecureContext: false, disabled: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "GamepadPose", insecureContext: false },
|
||||
{ name: "GamepadPose", insecureContext: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "GamepadTouch", insecureContext: false, disabled: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
@ -10,8 +10,7 @@
|
||||
*/
|
||||
|
||||
[Pref="dom.gamepad.enabled",
|
||||
Exposed=Window,
|
||||
SecureContext]
|
||||
Exposed=Window]
|
||||
interface GamepadButton {
|
||||
readonly attribute boolean pressed;
|
||||
readonly attribute boolean touched;
|
||||
@ -35,8 +34,7 @@ enum GamepadMappingType {
|
||||
};
|
||||
|
||||
[Pref="dom.gamepad.enabled",
|
||||
Exposed=Window,
|
||||
SecureContext]
|
||||
Exposed=Window]
|
||||
interface Gamepad {
|
||||
/**
|
||||
* An identifier, unique per type of device.
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
[Pref="dom.gamepad.non_standard_events.enabled",
|
||||
Exposed=Window, SecureContext]
|
||||
Exposed=Window]
|
||||
interface GamepadAxisMoveEvent : GamepadEvent
|
||||
{
|
||||
constructor(DOMString type,
|
||||
|
@ -5,8 +5,7 @@
|
||||
*/
|
||||
|
||||
[Pref="dom.gamepad.non_standard_events.enabled",
|
||||
Exposed=Window,
|
||||
SecureContext]
|
||||
Exposed=Window]
|
||||
interface GamepadButtonEvent : GamepadEvent
|
||||
{
|
||||
constructor(DOMString type,
|
||||
|
@ -8,8 +8,7 @@
|
||||
*/
|
||||
|
||||
[Pref="dom.gamepad.enabled",
|
||||
Exposed=Window,
|
||||
SecureContext]
|
||||
Exposed=Window]
|
||||
interface GamepadEvent : Event
|
||||
{
|
||||
constructor(DOMString type, optional GamepadEventInit eventInitDict = {});
|
||||
|
@ -13,8 +13,7 @@ enum GamepadHapticActuatorType {
|
||||
|
||||
[Pref="dom.gamepad.extensions.enabled",
|
||||
HeaderFile="mozilla/dom/GamepadHapticActuator.h",
|
||||
Exposed=Window,
|
||||
SecureContext]
|
||||
Exposed=Window]
|
||||
interface GamepadHapticActuator
|
||||
{
|
||||
readonly attribute GamepadHapticActuatorType type;
|
||||
|
@ -8,8 +8,7 @@
|
||||
*/
|
||||
|
||||
[Pref="dom.gamepad.extensions.enabled",
|
||||
Exposed=Window,
|
||||
SecureContext]
|
||||
Exposed=Window]
|
||||
interface GamepadPose
|
||||
{
|
||||
readonly attribute boolean hasOrientation;
|
||||
|
@ -200,7 +200,7 @@ partial interface Navigator {
|
||||
|
||||
// https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension
|
||||
partial interface Navigator {
|
||||
[Throws, Pref="dom.gamepad.enabled", SecureContext]
|
||||
[Throws, Pref="dom.gamepad.enabled"]
|
||||
sequence<Gamepad?> getGamepads();
|
||||
};
|
||||
partial interface Navigator {
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gamepad-default-feature-policy.https.sub.html]
|
||||
[Feature-Policy allow="gamepad" disallows cross-origin by default.]
|
||||
expected: PASS
|
||||
expected: FAIL
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
[gamepad-secure-context.html]
|
||||
[Gamepad API is not exposed in insecure contexts]
|
||||
expected: FAIL
|
||||
|
@ -1,4 +1,4 @@
|
||||
[idlharness-extensions.https.window.html]
|
||||
[idlharness-extensions.window.html]
|
||||
[GamepadTouch interface: existence and properties of interface object]
|
||||
expected: FAIL
|
||||
|
Loading…
Reference in New Issue
Block a user