Skip to content

Commit

Permalink
Fix FF test
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-fix committed Nov 27, 2019
1 parent b028a83 commit 86e41b7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/vaadin-context-menu.html
Expand Up @@ -412,6 +412,9 @@

this._oldListenOn.style.webkitTouchCallout = '';
this._oldListenOn.style.webkitUserSelect = '';
this._oldListenOn.style.MozUserSelect = '';
this._oldListenOn.style.msUserSelect = '';
this._oldListenOn.style.userSelect = '';

this._oldListenOn = null;
this._oldOpenOn = null;
Expand All @@ -428,7 +431,10 @@
_setListenOnUserSelect(value) {
// note: these styles don't seem to work in Firefox on iOS.
this.listenOn.style.webkitTouchCallout = value;
this.listenOn.style.webkitUserSelect = value;
this.listenOn.style.webkitUserSelect = value; // Chrome, Safari
this.listenOn.style.MozUserSelect = value; // Firefox
this.listenOn.style.msUserSelect = value; // IE 10+
this.listenOn.style.userSelect = value;
}

_closeOnChanged(closeOn, oldCloseOn) {
Expand Down
16 changes: 13 additions & 3 deletions test/overlay.html
Expand Up @@ -109,11 +109,18 @@
it('should set `user-select` to `none` on opening', done => {
listenOnce(overlay, 'vaadin-overlay-open', () => {
expect(menu.opened).to.eql(true);
expect(getComputedStyle(menu).userSelect).to.equal('none');

const userSelect = getComputedStyle(menu).webkitUserSelect ||
getComputedStyle(menu).MozUserSelect ||
getComputedStyle(menu).msUserSelect ||
getComputedStyle(menu).userSelect;

expect(userSelect).to.equal('none');
done();
});

expect(getComputedStyle(menu).userSelect).to.not.equal('none');
['webkitUserSelect', 'MozUserSelect', 'msUserSelect', 'userSelect'].forEach(prop =>
expect(getComputedStyle(menu)[prop]).not.to.equal('none'));
contextmenu();
});

Expand All @@ -124,7 +131,10 @@
newTarget.textContent = 'New target';
menu.listenOn.parentElement.appendChild(newTarget);
menu.listenOn = newTarget;
expect(getComputedStyle(menu).userSelect).not.to.equal('none');

['webkitUserSelect', 'MozUserSelect', 'msUserSelect', 'userSelect'].forEach(prop =>
expect(getComputedStyle(menu)[prop]).not.to.equal('none'));

done();
});

Expand Down

0 comments on commit 86e41b7

Please sign in to comment.