Bug 1540206 - Fixing VRController gamepad id null terminator characters. r=kip

Differential Revision: https://phabricator.services.mozilla.com/D25826

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Daosheng Mu 2019-04-02 19:35:46 +00:00
Родитель ce2f2d7371
Коммит f128a608ee
3 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -326,7 +326,7 @@ VRDisplay::VRDisplay(nsPIDOMWindowInner* aWindow, gfx::VRDisplayClient* aClient)
mShutdown(false) {
const gfx::VRDisplayInfo& info = aClient->GetDisplayInfo();
mDisplayId = info.GetDisplayID();
mDisplayName = NS_ConvertASCIItoUTF16(info.GetDisplayName());
mDisplayName = NS_ConvertUTF8toUTF16(info.GetDisplayName());
mCapabilities = new VRDisplayCapabilities(aWindow, info.GetCapabilities());
if (info.GetCapabilities() &
gfx::VRDisplayCapabilityFlags::Cap_StageParameters) {

Просмотреть файл

@ -27,6 +27,7 @@
async_test(function(t) {
window.addEventListener("gamepadbuttondown", function(e) {
assert_equals(e.gamepad.displayId, vrDisplay.displayId, "gamepad.displayId should be equal to vrDisplay.");
assert_equals(e.gamepad.id, "Puppet Gamepad", "gamepad.id must be equal to 'Puppet Gamepad'.");
++controllerCount;
if (controllerCount == 2) {
t.done();
@ -42,6 +43,7 @@
return navigator.getVRDisplays().then((displays) => {
vrDisplay = displays[0];
assert_equals(displays.length, 1, "displays.length must be one after attach.");
assert_equals(vrDisplay.displayName, "Puppet HMD", "display.displayName must be equal to 'Puppet HMD'.");
addController();
addController();
});

Просмотреть файл

@ -159,7 +159,7 @@ void VRDisplayClient::FireGamepadEvents() {
if ((lastState.controllerName[0] == '\0' || !existing) &&
(state.numButtons > 0 || state.numAxes > 0)) {
dom::GamepadAdded info(
NS_ConvertUTF8toUTF16(state.controllerName, kVRControllerNameMaxLen),
NS_ConvertUTF8toUTF16(state.controllerName),
dom::GamepadMappingType::_empty, state.hand, mDisplayInfo.mDisplayID,
state.numButtons, state.numAxes, state.numHaptics);
dom::GamepadChangeEventBody body(info);