File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed
browser/components/tabbrowser Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,18 @@ export default class TabHoverPreviewPanel {
24
24
this . _tab = null ;
25
25
this . _thumbnailElement = null ;
26
26
27
+ // Observe changes to this tab's DOM, and
28
+ // update the preview if the tab title changes
29
+ this . _tabObserver = new this . _win . MutationObserver (
30
+ ( mutationList , _observer ) => {
31
+ for ( const mutation of mutationList ) {
32
+ if ( mutation . attributeName === "label" ) {
33
+ this . _updatePreview ( ) ;
34
+ }
35
+ }
36
+ }
37
+ ) ;
38
+
27
39
this . _setExternalPopupListeners ( ) ;
28
40
29
41
XPCOMUtils . defineLazyPreferenceGetter (
@@ -112,6 +124,9 @@ export default class TabHoverPreviewPanel {
112
124
}
113
125
114
126
this . _tab = tab ;
127
+ this . _tabObserver . observe ( this . _tab , {
128
+ attributes : true ,
129
+ } ) ;
115
130
116
131
// Calling `moveToAnchor` in advance of the call to `openPopup` ensures
117
132
// that race conditions can be avoided in cases where the user hovers
@@ -145,6 +160,7 @@ export default class TabHoverPreviewPanel {
145
160
return ;
146
161
}
147
162
this . _tab = null ;
163
+ this . _tabObserver . disconnect ( ) ;
148
164
this . _thumbnailElement = null ;
149
165
this . _panel . removeEventListener ( "popupshowing" , this ) ;
150
166
this . _win . removeEventListener ( "TabSelect" , this ) ;
Original file line number Diff line number Diff line change 714
714
type : "mouseover" ,
715
715
} ) ;
716
716
} ) ;
717
-
717
+
718
+ /**
719
+ * Verify that if the browser document title (i.e. tab label) changes,
720
+ * the tab preview panel is updated
721
+ */
722
+ add_task ( async function tabContentChangeTests ( ) {
723
+ const previewPanel = document . getElementById ( "tab-preview-panel" ) ;
724
+ const tabUrl =
725
+ "data:text/html,<html><head><title>Original Tab Title</title></head><body>Hello</body></html>" ;
726
+ const tab = await BrowserTestUtils . openNewForegroundTab ( gBrowser , tabUrl ) ;
727
+ await openPreview ( tab ) ;
728
+ Assert . equal (
729
+ previewPanel . querySelector ( ".tab-preview-title" ) . innerText ,
730
+ "Original Tab Title" ,
731
+ "Preview of tab shows original tab title"
732
+ ) ;
733
+ tab . setAttribute ( "label" , "New Tab Title" ) ;
734
+ await BrowserTestUtils . waitForCondition ( ( ) => {
735
+ return (
736
+ previewPanel . querySelector ( ".tab-preview-title" ) . innerText ===
737
+ "New Tab Title"
738
+ ) ;
739
+ } ) ;
740
+ Assert . equal (
741
+ previewPanel . querySelector ( ".tab-preview-title" ) . innerText ,
742
+ "New Tab Title" ,
743
+ "Preview of tab shows new tab title"
744
+ ) ;
745
+ await closePreviews ( ) ;
746
+ BrowserTestUtils . removeTab ( tab ) ;
747
+ } ) ;
You can’t perform that action at this time.
0 commit comments