diff --git a/include/display.js b/include/display.js index e8ac63d8..d2876a76 100644 --- a/include/display.js +++ b/include/display.js @@ -89,12 +89,12 @@ var Display; var curSave = this._target.style.cursor; Display.changeCursor(this._target, curDat, curDat, 2, 2, 8, 8); if (this._target.style.cursor) { - if (this._cursor_uri === null) { + if (this._cursor_uri === null || this._cursor_uri === undefined) { this._cursor_uri = true; } Util.Info("Data URI scheme cursor supported"); } else { - if (this._cursor_uri === null) { + if (this._cursor_uri === null || this._cursor_uri === undefined) { this._cursor_uri = false; } Util.Warn("Data URI scheme cursor not supported"); diff --git a/tests/test.display.js b/tests/test.display.js index 832970d5..25adfbea 100644 --- a/tests/test.display.js +++ b/tests/test.display.js @@ -26,6 +26,40 @@ describe('Display/Canvas Helper', function () { return canvas; } + describe('checking for cursor uri support', function () { + beforeEach(function () { + this._old_change_cursor = Display.changeCursor; + }); + + it('should disable cursor URIs if there is no support', function () { + Display.changeCursor = function(target) { + target.style.cursor = undefined; + }; + var display = new Display({ target: document.createElement('canvas'), prefer_js: true, viewport: false }); + expect(display._cursor_uri).to.be.false; + }); + + it('should enable cursor URIs if there is support', function () { + Display.changeCursor = function(target) { + target.style.cursor = 'pointer'; + }; + var display = new Display({ target: document.createElement('canvas'), prefer_js: true, viewport: false }); + expect(display._cursor_uri).to.be.true; + }); + + it('respect the cursor_uri option if there is support', function () { + Display.changeCursor = function(target) { + target.style.cursor = 'pointer'; + }; + var display = new Display({ target: document.createElement('canvas'), prefer_js: true, viewport: false, cursor_uri: false }); + expect(display._cursor_uri).to.be.false; + }); + + afterEach(function () { + Display.changeCursor = this._old_change_cursor; + }); + }); + describe('viewport handling', function () { var display; beforeEach(function () {