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
path: root/js
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2013-11-26 00:55:24 +0400
committerThomas Steur <thomas.steur@gmail.com>2013-11-26 00:55:24 +0400
commit06ac8c09501de7a1f1259cd7623dbe9ec5996c49 (patch)
tree0861caeb44843dfea15a2a3bab51810da625cb1c /js
parent8bb8fd48623637365c0a25a6b13e5fef23e740f5 (diff)
refs #4225 sort object to make sure we get the same test results on PhantomJS, Webkit and any other browser
Diffstat (limited to 'js')
-rw-r--r--js/piwik.js36
1 files changed, 33 insertions, 3 deletions
diff --git a/js/piwik.js b/js/piwik.js
index 88a9f19bfb..5aed2d9c8e 100644
--- a/js/piwik.js
+++ b/js/piwik.js
@@ -34,7 +34,7 @@
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
- lastIndex, length, parse, prototype, push, replace, slice, stringify,
+ lastIndex, length, parse, prototype, push, replace, sort, slice, stringify,
test, toJSON, toString, valueOf,
objectToJSON
*/
@@ -1568,6 +1568,33 @@ if (typeof Piwik !== 'object') {
configCookiesDisabled = savedConfigCookiesDisabled;
}
+ function sortObjectByKeys(value) {
+ if (!value || !isObject(value)) {
+ return;
+ }
+
+ // Object.keys(value) is not supported by all browsers, we get the keys manually
+ var keys = [];
+ var key;
+
+ for (key in value) {
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
+ keys.push(key);
+ }
+ }
+
+ var normalized = {};
+ keys.sort();
+ var len = keys.length;
+ var i;
+
+ for (i = 0; i < len; i++) {
+ normalized[keys[i]] = value[keys[i]];
+ }
+
+ return normalized;
+ }
+
/**
* Returns the URL to call piwik.php,
* with the standard parameters (plugins, resolution, url, referrer, etc.).
@@ -1748,8 +1775,11 @@ if (typeof Piwik !== 'object') {
return '';
}
- request += appendCustomVariablesToRequest(customVariablesPage, 'cvar');
- request += appendCustomVariablesToRequest(customVariablesEvent, 'e_cvar');
+ var sortedCustomVarPage = sortObjectByKeys(customVariablesPage);
+ var sortedCustomVarEvent = sortObjectByKeys(customVariablesEvent);
+
+ request += appendCustomVariablesToRequest(sortedCustomVarPage, 'cvar');
+ request += appendCustomVariablesToRequest(sortedCustomVarEvent, 'e_cvar');
// Custom Variables, scope "visit"
if (customVariables) {