Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Fix leak with change listeners in frame
Browse files Browse the repository at this point in the history
Auditors: @bridiver

Fix #8244

Auditors: @bridiver
  • Loading branch information
bbondy committed Apr 12, 2017
1 parent 3efe3a8 commit 657689d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Frame extends ImmutableComponent {
super()
this.onUpdateWheelZoom = debounce(this.onUpdateWheelZoom.bind(this), 20)
this.onFocus = this.onFocus.bind(this)
this.onAppStateChange = this.onAppStateChange.bind(this)
// Maps notification message to its callback
this.notificationCallbacks = {}
// Counter for detecting PDF URL redirect loops
Expand Down Expand Up @@ -296,6 +297,7 @@ class Frame extends ImmutableComponent {
}

componentWillUnmount () {
appStoreRenderer.removeChangeListener(this.onAppStateChange)
this.expireContentSettings(this.origin)
}

Expand Down Expand Up @@ -358,14 +360,15 @@ class Frame extends ImmutableComponent {
this.updateAboutDetails(prevProps)
}

componentDidMount () {
appStoreRenderer.addChangeListener(() => {
if (!this.frame.isEmpty() && this.tab && !this.tab.delete('frame').equals(this.lastTab)) {
windowActions.tabDataChanged(this.frame, this.tab)
}
this.lastTab = this.tab && this.tab.delete('frame')
})
onAppStateChange () {
if (!this.frame.isEmpty() && this.tab && !this.tab.delete('frame').equals(this.lastTab)) {
windowActions.tabDataChanged(this.frame, this.tab)
}
this.lastTab = this.tab && this.tab.delete('frame')
}

componentDidMount () {
appStoreRenderer.addChangeListener(this.onAppStateChange)
if (this.props.isActive) {
windowActions.setActiveFrame(this.frame)
}
Expand Down

0 comments on commit 657689d

Please sign in to comment.