Disable visibility behaviors when testing
It results in surprise behaviors.
This commit is contained in:
parent
3f781743e4
commit
536c013928
|
@ -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'),
|
||||
});
|
||||
|
|
|
@ -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'),
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue