1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Merge pull request #10019 from Snuffleupagus/eventBusDispatchToDOM

Add general support for re-dispatching events, on `EventBus` instances, to the DOM
This commit is contained in:
Tim van der Meij 2018-09-01 19:11:23 +02:00 committed by GitHub
commit f2f2e05bb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 113 additions and 22 deletions

View file

@ -262,6 +262,45 @@ describe('ui_utils', function() {
eventBus.dispatch('test');
expect(count).toEqual(2);
});
it('should not, by default, re-dispatch to DOM', function(done) {
if (isNodeJS()) {
pending('Document in not supported in Node.js.');
}
const eventBus = new EventBus();
let count = 0;
eventBus.on('test', function() {
count++;
});
document.addEventListener('test', function() {
count++;
});
eventBus.dispatch('test');
Promise.resolve().then(() => {
expect(count).toEqual(1);
done();
});
});
it('should re-dispatch to DOM', function(done) {
if (isNodeJS()) {
pending('Document in not supported in Node.js.');
}
const eventBus = new EventBus({ dispatchToDOM: true, });
let count = 0;
eventBus.on('test', function() {
count++;
});
document.addEventListener('test', function() {
count++;
});
eventBus.dispatch('test');
Promise.resolve().then(() => {
expect(count).toEqual(2);
done();
});
});
});
describe('isValidRotation', function() {