mirror of
				https://github.com/mozilla/gecko-dev.git
				synced 2025-11-04 02:09:05 +02:00 
			
		
		
		
	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,15 +89,21 @@ class PrefsFeed {
 | 
			
		|||
   */
 | 
			
		||||
  onPocketExperimentUpdated(event, reason) {
 | 
			
		||||
    const value = lazy.NimbusFeatures.pocketNewtab.getAllVariables() || {};
 | 
			
		||||
    this.store.dispatch(
 | 
			
		||||
      ac.BroadcastToContent({
 | 
			
		||||
        type: at.PREF_CHANGED,
 | 
			
		||||
        data: {
 | 
			
		||||
          name: "pocketConfig",
 | 
			
		||||
          value,
 | 
			
		||||
        },
 | 
			
		||||
      })
 | 
			
		||||
    );
 | 
			
		||||
    // Loaded experiments are set up inside init()
 | 
			
		||||
    if (
 | 
			
		||||
      reason !== "feature-experiment-loaded" &&
 | 
			
		||||
      reason !== "feature-rollout-loaded"
 | 
			
		||||
    ) {
 | 
			
		||||
      this.store.dispatch(
 | 
			
		||||
        ac.BroadcastToContent({
 | 
			
		||||
          type: at.PREF_CHANGED,
 | 
			
		||||
          data: {
 | 
			
		||||
            name: "pocketConfig",
 | 
			
		||||
            value,
 | 
			
		||||
          },
 | 
			
		||||
        })
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  init() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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", () => {
 | 
			
		||||
    sandbox.stub(global.NimbusFeatures.newtab, "getAllVariables").returns({
 | 
			
		||||
      prefsButtonIcon: "icon-new",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue