From 6009d4ae877ca72a3eb638917ecc1ed857df71ec Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 5 Apr 2013 12:32:19 +0300 Subject: [PATCH] move phantomjs check for touch into Leaflet to allow standalone mocha-phantomjs usage on the browser reporter --- spec/karma.conf.js | 1 - spec/karma.js | 7 ------- spec/suites/map/MapSpec.js | 3 +++ src/core/Browser.js | 5 ++++- 4 files changed, 7 insertions(+), 9 deletions(-) delete mode 100644 spec/karma.js diff --git a/spec/karma.conf.js b/spec/karma.conf.js index 816938bf..5c296e6c 100644 --- a/spec/karma.conf.js +++ b/spec/karma.conf.js @@ -13,7 +13,6 @@ files = [].concat([ "../node_modules/mocha/mocha.js", MOCHA_ADAPTER, "before.js", - "karma.js", "sinon.js", "expect.js" ], libSources, [ diff --git a/spec/karma.js b/spec/karma.js deleted file mode 100644 index 0283d4e1..00000000 --- a/spec/karma.js +++ /dev/null @@ -1,7 +0,0 @@ -// PhantomJS has `'ontouchstart' in document.documentElement`, but -// doesn't actually support touch. So force touch not to be used. -// -// http://code.google.com/p/phantomjs/issues/detail?id=375 -// https://github.com/ariya/phantomjs/pull/408 -// https://github.com/Leaflet/Leaflet/pull/1434#issuecomment-13843151 -window.L_NO_TOUCH = true; diff --git a/spec/suites/map/MapSpec.js b/spec/suites/map/MapSpec.js index 6172da77..f4f53247 100644 --- a/spec/suites/map/MapSpec.js +++ b/spec/suites/map/MapSpec.js @@ -35,13 +35,16 @@ describe("Map", function () { var container = document.createElement('div'), map = new L.Map(container).setView([0, 0], 1), spy = sinon.spy(); + map.on('click dblclick mousedown mouseup mousemove', spy); map.remove(); + happen.click(container); happen.dblclick(container); happen.mousedown(container); happen.mouseup(container); happen.mousemove(container); + expect(spy.called).to.not.be.ok(); }); }); diff --git a/src/core/Browser.js b/src/core/Browser.js index 32a0e35c..1239ba7b 100644 --- a/src/core/Browser.js +++ b/src/core/Browser.js @@ -32,7 +32,10 @@ any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d) && !phantomjs; - var touch = !window.L_NO_TOUCH && (function () { + // PhantomJS has 'ontouchstart' in document.documentElement, but doesn't actually support touch. + // https://github.com/Leaflet/Leaflet/pull/1434#issuecomment-13843151 + + var touch = !window.L_NO_TOUCH && !phantomjs && (function () { var startName = 'ontouchstart';