Bug 1522994 - Resolves crash when using Touch Bar inputs out-of-context. r=mikedeboer

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Harry Twyford 2019-01-27 22:06:38 +00:00
Родитель 5e84c40d52
Коммит a7c263d04d
1 изменённых файлов: 8 добавлений и 3 удалений

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

@ -232,16 +232,21 @@ class TouchBarHelper {
} }
getTouchBarInput(inputName) { getTouchBarInput(inputName) {
// inputName might be undefined if an input's context() returns undefined.
if (!inputName || !kBuiltInInputs.hasOwnProperty(inputName)) {
return null;
}
if (typeof kBuiltInInputs[inputName].context == "function") { if (typeof kBuiltInInputs[inputName].context == "function") {
inputName = kBuiltInInputs[inputName].context(); inputName = kBuiltInInputs[inputName].context();
} }
let inputData = kBuiltInInputs[inputName]; if (!inputName || !kBuiltInInputs.hasOwnProperty(inputName)) {
if (!inputData) {
return null; return null;
} }
let inputData = kBuiltInInputs[inputName];
let item = new TouchBarInput(inputData); let item = new TouchBarInput(inputData);
// Async l10n fills in the localized input labels after the initial load. // Async l10n fills in the localized input labels after the initial load.