Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-09-13 19:52:46 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-09-13 19:52:46 +0400
commitab443171ce89f5c75cc031f0d3c981cb0d2c3bad (patch)
tree4dcd3c05f1013c5165b3dc6ee2bae4d33de3f6d0 /tests/javascript
parentc94c501f4736d1ce5c10c37cdfb94b1818cfe343 (diff)
refs #4996 fix js error on IE6-IE8 because indexOf is not defined there. also added removed update script again
Diffstat (limited to 'tests/javascript')
-rw-r--r--tests/javascript/index.php54
1 files changed, 50 insertions, 4 deletions
diff --git a/tests/javascript/index.php b/tests/javascript/index.php
index a67f40b526..08cd90cfee 100644
--- a/tests/javascript/index.php
+++ b/tests/javascript/index.php
@@ -99,6 +99,52 @@ function _s(selector) { // select node within content test scope
}
}
+ // Polyfill for IndexOf for IE6-IE8
+ function indexOfArray(theArray, searchElement)
+ {
+ if (theArray && theArray.indexOf) {
+ return theArray.indexOf(searchElement);
+ }
+
+ // 1. Let O be the result of calling ToObject passing
+ // the this value as the argument.
+ if (!isDefined(theArray) || theArray === null) {
+ return -1;
+ }
+
+ if (!theArray.length) {
+ return -1;
+ }
+
+ var len = theArray.length;
+
+ if (len === 0) {
+ return -1;
+ }
+
+ var k = 0;
+
+ // 9. Repeat, while k < len
+ while (k < len) {
+ // a. Let Pk be ToString(k).
+ // This is implicit for LHS operands of the in operator
+ // b. Let kPresent be the result of calling the
+ // HasProperty internal method of O with argument Pk.
+ // This step can be combined with c
+ // c. If kPresent is true, then
+ // i. Let elementK be the result of calling the Get
+ // internal method of O with the argument ToString(k).
+ // ii. Let same be the result of applying the
+ // Strict Equality Comparison Algorithm to
+ // searchElement and elementK.
+ // iii. If same is true, return k.
+ if (theArray[k] === searchElement) {
+ return k;
+ }
+ k++;
+ }
+ return -1;
+ }
function getOrigin()
{
if (window.location.origin) {
@@ -672,7 +718,7 @@ function PiwikTest() {
ok($.isArray(actual), 'htmlCollectionToArray, should convert to array');
ok(actual.length === htmlCollection.length, 'htmlCollectionToArray should have same amount of elements as before');
ok(actual.length > 10, 'htmlCollectionToArray, just make sure there are many a elements found. otherwise test is useless');
- ok(-1 !== actual.indexOf(_e('click1')), 'htmlCollectionToArray, random check to make sure it contains a link');
+ ok(-1 !== indexOfArray(actual, _e('click1')), 'htmlCollectionToArray, random check to make sure it contains a link');
actual = query.isLinkElement();
@@ -708,11 +754,11 @@ function PiwikTest() {
actual = query.find('[href]');
ok(actual.length > 10, "find, should find many elements by attribute");
- ok(-1 !== actual.indexOf(_e('click1')), 'find, random check to make sure it contains a link');
+ ok(-1 !== indexOfArray(actual, _e('click1')), 'find, random check to make sure it contains a link');
actual = query.find('.clicktest');
ok(actual.length === 8, "find, should find many elements by class");
- ok(-1 !== actual.indexOf(_e('click1')), 'find, random check to make sure it contains a link');
+ ok(-1 !== indexOfArray(actual, _e('click1')), 'find, random check to make sure it contains a link');
@@ -749,7 +795,7 @@ function PiwikTest() {
actual = query.findNodesByTagName(document.body, 'a');
ok(actual.length > 10, "findNodesByTagName, find many, even nested ones");
- ok(actual.indexOf(_e('click1')), "findNodesByTagName, just a random test to make sure it actually contains a link");
+ ok(indexOfArray(actual, _e('click1')), "findNodesByTagName, just a random test to make sure it actually contains a link");
});
test("contentFindContentBlock", function() {