forked from mirrors/gecko-dev
		
	Bug 1822503 - Pocket newtab fixing startup reset from happening during experiment load. r=nanj,mconley,barret
Differential Revision: https://phabricator.services.mozilla.com/D173342
This commit is contained in:
		
							parent
							
								
									34e0e21dc3
								
							
						
					
					
						commit
						add966c63f
					
				
					 2 changed files with 26 additions and 9 deletions
				
			
		|  | @ -89,6 +89,11 @@ class PrefsFeed { | ||||||
|    */ |    */ | ||||||
|   onPocketExperimentUpdated(event, reason) { |   onPocketExperimentUpdated(event, reason) { | ||||||
|     const value = lazy.NimbusFeatures.pocketNewtab.getAllVariables() || {}; |     const value = lazy.NimbusFeatures.pocketNewtab.getAllVariables() || {}; | ||||||
|  |     // Loaded experiments are set up inside init()
 | ||||||
|  |     if ( | ||||||
|  |       reason !== "feature-experiment-loaded" && | ||||||
|  |       reason !== "feature-rollout-loaded" | ||||||
|  |     ) { | ||||||
|       this.store.dispatch( |       this.store.dispatch( | ||||||
|         ac.BroadcastToContent({ |         ac.BroadcastToContent({ | ||||||
|           type: at.PREF_CHANGED, |           type: at.PREF_CHANGED, | ||||||
|  | @ -99,6 +104,7 @@ class PrefsFeed { | ||||||
|         }) |         }) | ||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   init() { |   init() { | ||||||
|     this._prefs.observeBranch(this); |     this._prefs.observeBranch(this); | ||||||
|  |  | ||||||
|  | @ -177,6 +177,17 @@ describe("PrefsFeed", () => { | ||||||
|       }) |       }) | ||||||
|     ); |     ); | ||||||
|   }); |   }); | ||||||
|  |   it("should not send a PREF_CHANGED actions when onPocketExperimentUpdated is called during startup", () => { | ||||||
|  |     sandbox | ||||||
|  |       .stub(global.NimbusFeatures.pocketNewtab, "getAllVariables") | ||||||
|  |       .returns({ | ||||||
|  |         prefsButtonIcon: "icon-new", | ||||||
|  |       }); | ||||||
|  |     feed.onPocketExperimentUpdated({}, "feature-experiment-loaded"); | ||||||
|  |     assert.notCalled(feed.store.dispatch); | ||||||
|  |     feed.onPocketExperimentUpdated({}, "feature-rollout-loaded"); | ||||||
|  |     assert.notCalled(feed.store.dispatch); | ||||||
|  |   }); | ||||||
|   it("should send a PREF_CHANGED actions when onExperimentUpdated is called", () => { |   it("should send a PREF_CHANGED actions when onExperimentUpdated is called", () => { | ||||||
|     sandbox.stub(global.NimbusFeatures.newtab, "getAllVariables").returns({ |     sandbox.stub(global.NimbusFeatures.newtab, "getAllVariables").returns({ | ||||||
|       prefsButtonIcon: "icon-new", |       prefsButtonIcon: "icon-new", | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 scottdowne
						scottdowne