Verifying that the tab exists in TabbedEditorcontainer tab map before consuming it.
Root cause:
To set the error icon code passes tab_id to the setTabIcon function on this._tabbedPane but never verified that the tab_id exists in the tab Map structure and then proceed to modify its property which causes an error.
e.g
https://imgur.com/a/4Nb0Chu
In the attached image code wants to consume tab: "tab_43" but it does not exist in the current map of tabs
then it tries to modify the properties of an undefined object triggering the error:
Uncaught (in promise) TypeError: Cannot read property '_setIcon' of undefined
at TabbedPane.setTabIcon (TabbedPane.js:formatted)
at Sources.TabbedEditorContainer._addLoadErrorIcon (sources_module.js:formatted)
at eval (sources_module.js:formatted)
Fix:
Verify that the tab_id exists on the map before modifying the object.
Change-Id: I51b704597d0b1b68eee2e099d747d97339e9f59d
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1904287
Reviewed-by: Robert Paveza <Rob.Paveza@microsoft.com>
Reviewed-by: Mandy Chen <mandy.chen@microsoft.com>
Commit-Queue: Vidal Diazleal <vidorteg@microsoft.com>
diff --git a/front_end/sources/TabbedEditorContainer.js b/front_end/sources/TabbedEditorContainer.js
index 4e00fb5..2985ce7 100644
--- a/front_end/sources/TabbedEditorContainer.js
+++ b/front_end/sources/TabbedEditorContainer.js
@@ -509,7 +509,9 @@
_addLoadErrorIcon(tabId) {
const icon = UI.Icon.create('smallicon-error');
icon.title = ls`Unable to load this content.`;
- this._tabbedPane.setTabIcon(tabId, icon);
+ if (this._tabbedPane.tabView(tabId)) {
+ this._tabbedPane.setTabIcon(tabId, icon);
+ }
}
/**