diff options
Diffstat (limited to 'tests/javascript')
-rw-r--r-- | tests/javascript/index.php | 21 | ||||
-rw-r--r-- | tests/javascript/piwiktest.js | 3 |
2 files changed, 22 insertions, 2 deletions
diff --git a/tests/javascript/index.php b/tests/javascript/index.php index 60d7f11558..02e083e258 100644 --- a/tests/javascript/index.php +++ b/tests/javascript/index.php @@ -2829,7 +2829,7 @@ function PiwikTest() { }); test("Overlay URL Normalizer", function() { - expect(11); + expect(23); var test = function(testCases) { for (var i = 0; i < testCases.length; i++) { @@ -2894,6 +2894,25 @@ function PiwikTest() { 'example3.com/' ] ]); + + + var tracker = Piwik.getTracker(); + + // test getPiwikUrlForOverlay + var getPiwikUrlForOverlay = tracker.hook.test._getPiwikUrlForOverlay; + + equal( typeof getPiwikUrlForOverlay, 'function', 'getPiwikUrlForOverlay' ); + equal( getPiwikUrlForOverlay('http://www.example.com/js/tracker.php?version=232323'), 'http://www.example.com/', 'with query and js folder' ); + equal( getPiwikUrlForOverlay('http://www.example.com/tracker.php?version=232323'), 'http://www.example.com/', 'with query and no js folder' ); + equal( getPiwikUrlForOverlay('http://www.example.com/js/tracker.php'), 'http://www.example.com/', 'no query, custom tracker and js folder' ); + equal( getPiwikUrlForOverlay('http://www.example.com/tracker.php'), 'http://www.example.com/', 'no query, custom tracker and no js folder' ); + equal( getPiwikUrlForOverlay('http://www.example.com/js/piwik.php'), 'http://www.example.com/', 'with piwik.php and no js folder' ); + equal( getPiwikUrlForOverlay('http://www.example.com/piwik.php'), 'http://www.example.com/', 'with piwik.php and no js folder' ); + equal( getPiwikUrlForOverlay('http://www.example.com/master/js/piwik.php'), 'http://www.example.com/master/', 'installed in custom folder and js folder' ); + equal( getPiwikUrlForOverlay('http://www.example.com/master/piwik.php'), 'http://www.example.com/master/', 'installed in custom folder and no js folder' ); + equal( getPiwikUrlForOverlay('/piwik.php'), '/', 'only piwik.php with leading slash' ); + equal( getPiwikUrlForOverlay('piwik.php'), '', 'only piwik.php' ); + equal( getPiwikUrlForOverlay('/piwik.php?version=1234'), '/', 'only piwik.php with leading slash with query' ); }); <?php diff --git a/tests/javascript/piwiktest.js b/tests/javascript/piwiktest.js index 67157c6d96..ff5525c47d 100644 --- a/tests/javascript/piwiktest.js +++ b/tests/javascript/piwiktest.js @@ -44,7 +44,8 @@ Piwik.addPlugin('testPlugin', { '_purify : purify,' + '_resolveRelativeReference : resolveRelativeReference,' + '_addEventListener : addEventListener,' + - '_prefixPropertyName : prefixPropertyName' + + '_prefixPropertyName : prefixPropertyName,' + + '_getPiwikUrlForOverlay : getPiwikUrlForOverlay' + '}' ); }, |