1

I am currently testing a polymer element and need to wait for a variable to be set in my element. After searching how to instruct Javascript to wait for the variable to be set, I came up with the following code:

var behavior;

setup(function(){
  behavior = fixture("behavior");
});


test('Behavior loads resources', function(done) {
  var waitForI18n = function() {
      if(behavior.isI18nLoaded){
        clearInterval(interval);
        expect(behavior.getKey("test")).to.be.equal("test" + behavior.language.toUpperCase());
        done();
      }
  };
  var interval = setInterval(waitForI18n, 50);
});

This works in Chrome but other browsers just freeze and eventually crash: IE11, Edge, Firefox. I was able to get a "Too much recursion" error in firefox, but not much else.

Am I doing anything wrong? Any ideas? I've tried with a recursive setTimeout, but the behavior was the same: Chrome works, but not other browsers.

mauro1855
  • 116
  • 1
  • 7

0 Answers0