Disable visibility behaviors when testing

It results in surprise behaviors.
This commit is contained in:
Michael Lange 2018-05-12 20:00:34 -07:00
parent 3f781743e4
commit 536c013928
2 changed files with 16 additions and 6 deletions

View File

@ -1,3 +1,4 @@
import Ember from 'ember';
import Mixin from '@ember/object/mixin';
import { assert } from '@ember/debug';
@ -7,11 +8,15 @@ export default Mixin.create({
},
setupDocumentVisibility: function() {
this.set('_visibilityHandler', this.get('visibilityHandler').bind(this));
document.addEventListener('visibilitychange', this.get('_visibilityHandler'));
if (!Ember.testing) {
this.set('_visibilityHandler', this.get('visibilityHandler').bind(this));
document.addEventListener('visibilitychange', this.get('_visibilityHandler'));
}
}.on('init'),
removeDocumentVisibility: function() {
document.removeEventListener('visibilitychange', this.get('_visibilityHandler'));
if (!Ember.testing) {
document.removeEventListener('visibilitychange', this.get('_visibilityHandler'));
}
}.on('willDestroy'),
});

View File

@ -1,3 +1,4 @@
import Ember from 'ember';
import Mixin from '@ember/object/mixin';
import { assert } from '@ember/debug';
@ -7,11 +8,15 @@ export default Mixin.create({
},
setupDocumentVisibility: function() {
this.set('_visibilityHandler', this.get('visibilityHandler').bind(this));
document.addEventListener('visibilitychange', this.get('_visibilityHandler'));
if (!Ember.testing) {
this.set('_visibilityHandler', this.get('visibilityHandler').bind(this));
document.addEventListener('visibilitychange', this.get('_visibilityHandler'));
}
}.on('activate'),
removeDocumentVisibility: function() {
document.removeEventListener('visibilitychange', this.get('_visibilityHandler'));
if (!Ember.testing) {
document.removeEventListener('visibilitychange', this.get('_visibilityHandler'));
}
}.on('deactivate'),
});