Commit 53762c31 authored by Solly Ross's avatar Solly Ross

Fixed Cursor URI Support Detection

There was a bug in cursor URI support detection due to the way
set_defaults now works -- the code was checking for `null`, whereas
when not set, options default to `undefined` unless otherwise
specified.  The code now checks for either `null` or `undefined`.
Tests have been added to ensure that this works properly.
parent cfc02e5e
...@@ -89,12 +89,12 @@ var Display; ...@@ -89,12 +89,12 @@ var Display;
var curSave = this._target.style.cursor; var curSave = this._target.style.cursor;
Display.changeCursor(this._target, curDat, curDat, 2, 2, 8, 8); Display.changeCursor(this._target, curDat, curDat, 2, 2, 8, 8);
if (this._target.style.cursor) { if (this._target.style.cursor) {
if (this._cursor_uri === null) { if (this._cursor_uri === null || this._cursor_uri === undefined) {
this._cursor_uri = true; this._cursor_uri = true;
} }
Util.Info("Data URI scheme cursor supported"); Util.Info("Data URI scheme cursor supported");
} else { } else {
if (this._cursor_uri === null) { if (this._cursor_uri === null || this._cursor_uri === undefined) {
this._cursor_uri = false; this._cursor_uri = false;
} }
Util.Warn("Data URI scheme cursor not supported"); Util.Warn("Data URI scheme cursor not supported");
......
...@@ -26,6 +26,40 @@ describe('Display/Canvas Helper', function () { ...@@ -26,6 +26,40 @@ describe('Display/Canvas Helper', function () {
return canvas; 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 () { describe('viewport handling', function () {
var display; var display;
beforeEach(function () { beforeEach(function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment