Bug 1522994 - Resolves crash when using Touch Bar inputs out-of-context. r=mikedeboer
authorHarry Twyford <harry.a.twyford@gmail.com>
Sun, 27 Jan 2019 22:06:38 +0000
changeset 515591 747303cab27a597bbfdffd2c1db157f5d65c4f0f
parent 515590 06e3993985b77e62c9b6ee1f9dba87da407eb6d1
child 515592 3c9634352cd66e1debc3beeedd53130d16474db2
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1522994
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1522994 - Resolves crash when using Touch Bar inputs out-of-context. r=mikedeboer Differential Revision: https://phabricator.services.mozilla.com/D17695
browser/components/touchbar/MacTouchBar.js
--- a/browser/components/touchbar/MacTouchBar.js
+++ b/browser/components/touchbar/MacTouchBar.js
@@ -227,26 +227,31 @@ class TouchBarHelper {
     // Remove unimplemented/mispelled inputs.
     prefArray = prefArray.filter(input =>
       Object.keys(kBuiltInInputs).includes(input));
     this._storedLayout = prefArray;
     return this._storedLayout;
   }
 
   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") {
       inputName = kBuiltInInputs[inputName].context();
     }
 
-    let inputData = kBuiltInInputs[inputName];
-
-    if (!inputData) {
+    if (!inputName || !kBuiltInInputs.hasOwnProperty(inputName)) {
       return null;
     }
 
+    let inputData = kBuiltInInputs[inputName];
+
     let item = new TouchBarInput(inputData);
 
     // Async l10n fills in the localized input labels after the initial load.
     this._l10n.formatValue(item.key).then((result) => {
       item.title = result;
       kBuiltInInputs[inputName].localTitle = result; // Cache result.
       // Checking this.window since this callback can fire after all windows are closed.
       if (this.window) {