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 Mixin from '@ember/object/mixin';
|
||||||
import { assert } from '@ember/debug';
|
import { assert } from '@ember/debug';
|
||||||
|
|
||||||
|
@ -7,11 +8,15 @@ export default Mixin.create({
|
||||||
},
|
},
|
||||||
|
|
||||||
setupDocumentVisibility: function() {
|
setupDocumentVisibility: function() {
|
||||||
|
if (!Ember.testing) {
|
||||||
this.set('_visibilityHandler', this.get('visibilityHandler').bind(this));
|
this.set('_visibilityHandler', this.get('visibilityHandler').bind(this));
|
||||||
document.addEventListener('visibilitychange', this.get('_visibilityHandler'));
|
document.addEventListener('visibilitychange', this.get('_visibilityHandler'));
|
||||||
|
}
|
||||||
}.on('init'),
|
}.on('init'),
|
||||||
|
|
||||||
removeDocumentVisibility: function() {
|
removeDocumentVisibility: function() {
|
||||||
|
if (!Ember.testing) {
|
||||||
document.removeEventListener('visibilitychange', this.get('_visibilityHandler'));
|
document.removeEventListener('visibilitychange', this.get('_visibilityHandler'));
|
||||||
|
}
|
||||||
}.on('willDestroy'),
|
}.on('willDestroy'),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import Ember from 'ember';
|
||||||
import Mixin from '@ember/object/mixin';
|
import Mixin from '@ember/object/mixin';
|
||||||
import { assert } from '@ember/debug';
|
import { assert } from '@ember/debug';
|
||||||
|
|
||||||
|
@ -7,11 +8,15 @@ export default Mixin.create({
|
||||||
},
|
},
|
||||||
|
|
||||||
setupDocumentVisibility: function() {
|
setupDocumentVisibility: function() {
|
||||||
|
if (!Ember.testing) {
|
||||||
this.set('_visibilityHandler', this.get('visibilityHandler').bind(this));
|
this.set('_visibilityHandler', this.get('visibilityHandler').bind(this));
|
||||||
document.addEventListener('visibilitychange', this.get('_visibilityHandler'));
|
document.addEventListener('visibilitychange', this.get('_visibilityHandler'));
|
||||||
|
}
|
||||||
}.on('activate'),
|
}.on('activate'),
|
||||||
|
|
||||||
removeDocumentVisibility: function() {
|
removeDocumentVisibility: function() {
|
||||||
|
if (!Ember.testing) {
|
||||||
document.removeEventListener('visibilitychange', this.get('_visibilityHandler'));
|
document.removeEventListener('visibilitychange', this.get('_visibilityHandler'));
|
||||||
|
}
|
||||||
}.on('deactivate'),
|
}.on('deactivate'),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue