From 6a0c96034683b34e632ef576b73be85695d439a3 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Thu, 14 Jun 2018 04:36:38 +0200 Subject: Remove usage of synchronous ajax requests (#12546) * Do not use sync ajax requests * adds deprecation comments * convert some methods to be fully async * adds minimum waittime after page load in ui tests * improve wait times --- CHANGELOG.md | 1 + plugins/Annotations/javascripts/annotations.js | 10 +- plugins/CoreHome/javascripts/corehome.js | 2 +- plugins/CoreHome/javascripts/dataTable.js | 4 +- .../CoreHome/javascripts/dataTable_rowactions.js | 2 +- plugins/CoreHome/javascripts/popover.js | 2 +- plugins/DBStats/templates/index.twig | 2 +- plugins/Dashboard/javascripts/dashboard.js | 13 +- plugins/Dashboard/javascripts/dashboardObject.js | 6 +- plugins/Dashboard/javascripts/dashboardWidget.js | 137 +++++++++++---------- plugins/Dashboard/javascripts/widgetMenu.js | 113 +++++++++-------- plugins/Dashboard/templates/embeddedIndex.twig | 3 +- plugins/Live/javascripts/SegmentedVisitorLog.js | 2 +- plugins/Live/javascripts/live.js | 2 +- plugins/Live/templates/index.twig | 2 +- plugins/Morpheus/javascripts/ajaxHelper.js | 3 + plugins/Overlay/javascripts/Piwik_Overlay.js | 2 +- plugins/SEO/javascripts/rank.js | 2 +- plugins/SegmentEditor/javascripts/Segmentation.js | 2 +- plugins/Transitions/javascripts/transitions.js | 4 +- .../widget-preview/widget-preview.directive.js | 53 ++++---- tests/UI/specs/UIIntegration_spec.js | 15 ++- .../screenshot-testing/support/page-renderer.js | 2 + 23 files changed, 199 insertions(+), 185 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2df4ae011a..f6f2aabe7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ The Product Changelog at **[matomo.org/changelog](https://matomo.org/changelog)* ### Breaking Changes `piwik` font is deprecated and will be removed in Matomo 4.0. Please use new `matomo` font instead +Sending synchronous requests using ajaxHelper is now deprecated. All requests will be send async as of Matomo 4.0 ### New APIs * A new JavaScript tracker method `resetUserId` has been added to allow clearing user and visitor id. diff --git a/plugins/Annotations/javascripts/annotations.js b/plugins/Annotations/javascripts/annotations.js index b6d08e9856..0556b6027f 100755 --- a/plugins/Annotations/javascripts/annotations.js +++ b/plugins/Annotations/javascripts/annotations.js @@ -28,7 +28,7 @@ ajaxRequest.addParams(ajaxParams, 'get'); ajaxRequest.setCallback(callback); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); }, // calls Annotations.addAnnotation @@ -49,7 +49,7 @@ ajaxRequest.withTokenInUrl(); ajaxRequest.setCallback(callback); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); }, // calls Annotations.saveAnnotation @@ -72,7 +72,7 @@ ajaxRequest.withTokenInUrl(); ajaxRequest.setCallback(callback); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); }, // calls Annotations.deleteAnnotation @@ -92,7 +92,7 @@ ajaxRequest.withTokenInUrl(); ajaxRequest.setCallback(callback); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); }, // calls Annotations.getEvolutionIcons @@ -114,7 +114,7 @@ ajaxRequest.addParams(ajaxParams, 'get'); ajaxRequest.setFormat('html'); ajaxRequest.setCallback(callback); - ajaxRequest.send(false); + ajaxRequest.send(); } }; diff --git a/plugins/CoreHome/javascripts/corehome.js b/plugins/CoreHome/javascripts/corehome.js index b50296bfaa..c84c80959e 100755 --- a/plugins/CoreHome/javascripts/corehome.js +++ b/plugins/CoreHome/javascripts/corehome.js @@ -58,7 +58,7 @@ }); }); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); return false; }); diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js index ccc6bf00a1..a5f3906a0b 100644 --- a/plugins/CoreHome/javascripts/dataTable.js +++ b/plugins/CoreHome/javascripts/dataTable.js @@ -275,7 +275,7 @@ $.extend(DataTable.prototype, UIControl.prototype, { }); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); }, // Function called when the AJAX request is successful @@ -1361,7 +1361,7 @@ $.extend(DataTable.prototype, UIControl.prototype, { }, 'post'); ajaxRequest.setCallback(function () {}); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); } }, diff --git a/plugins/CoreHome/javascripts/dataTable_rowactions.js b/plugins/CoreHome/javascripts/dataTable_rowactions.js index d357a5e594..b937979cdf 100644 --- a/plugins/CoreHome/javascripts/dataTable_rowactions.js +++ b/plugins/CoreHome/javascripts/dataTable_rowactions.js @@ -426,5 +426,5 @@ DataTable_RowActions_RowEvolution.prototype.showRowEvolution = function (apiMeth ajaxRequest.addParams(requestParams, 'get'); ajaxRequest.setCallback(callback); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); }; diff --git a/plugins/CoreHome/javascripts/popover.js b/plugins/CoreHome/javascripts/popover.js index 5bf316991c..61308b22cf 100644 --- a/plugins/CoreHome/javascripts/popover.js +++ b/plugins/CoreHome/javascripts/popover.js @@ -295,7 +295,7 @@ var Piwik_Popover = (function () { ajaxRequest.addParams(piwikHelper.getArrayFromQueryString(url), 'get'); ajaxRequest.setCallback(callback); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); } }; })(); diff --git a/plugins/DBStats/templates/index.twig b/plugins/DBStats/templates/index.twig index a3f9e80897..fde84f2bfa 100755 --- a/plugins/DBStats/templates/index.twig +++ b/plugins/DBStats/templates/index.twig @@ -89,7 +89,7 @@ piwikHelper.compileAngularComponents(self); }); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); }); }); })(jQuery); diff --git a/plugins/Dashboard/javascripts/dashboard.js b/plugins/Dashboard/javascripts/dashboard.js index 22e07e38e0..86faf58b52 100644 --- a/plugins/Dashboard/javascripts/dashboard.js +++ b/plugins/Dashboard/javascripts/dashboard.js @@ -37,7 +37,7 @@ function createDashboard() { }); } ); - ajaxRequest.send(true); + ajaxRequest.send(); }}); } @@ -120,7 +120,7 @@ function copyDashboardToUser() { }); } ); - ajaxRequest.send(true); + ajaxRequest.send(); piwikHelper.modalConfirm(makeSelectorLastId('copyDashboardToUserConfirm'), { yes: function () { @@ -145,7 +145,7 @@ function copyDashboardToUser() { } ); ajaxRequest.withTokenInUrl(); - ajaxRequest.send(true); + ajaxRequest.send(); } }); } @@ -199,10 +199,11 @@ function copyDashboardToUser() { return self.isWidgetAvailable(widgetUniqueId); }, onSelect: function (widgetUniqueId) { - var widget = widgetsHelper.getWidgetObjectFromUniqueId(widgetUniqueId); - self.$element.removeClass('expanded'); + widgetsHelper.getWidgetObjectFromUniqueId(widgetUniqueId, function(widget){ + self.$element.removeClass('expanded'); + self.widgetSelected(widget); + }); - self.widgetSelected(widget); }, resetOnSelect: true }); diff --git a/plugins/Dashboard/javascripts/dashboardObject.js b/plugins/Dashboard/javascripts/dashboardObject.js index 6af7a1ec05..c72f53a8c9 100644 --- a/plugins/Dashboard/javascripts/dashboardObject.js +++ b/plugins/Dashboard/javascripts/dashboardObject.js @@ -182,7 +182,7 @@ ); ajaxRequest.setLoadingElement(); ajaxRequest.setFormat('html'); - ajaxRequest.send(true); + ajaxRequest.send(); }, rebuildMenu: rebuildMenu, @@ -211,7 +211,7 @@ ); ajaxRequest.withTokenInUrl(); ajaxRequest.setFormat('html'); - ajaxRequest.send(true); + ajaxRequest.send(); }, /** @@ -647,7 +647,7 @@ ajaxRequest.withTokenInUrl(); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); } } diff --git a/plugins/Dashboard/javascripts/dashboardWidget.js b/plugins/Dashboard/javascripts/dashboardWidget.js index ce88cf1c8f..6756b1d291 100755 --- a/plugins/Dashboard/javascripts/dashboardWidget.js +++ b/plugins/Dashboard/javascripts/dashboardWidget.js @@ -204,81 +204,83 @@ */ _createDashboardWidget: function (uniqueId) { - var widgetName = widgetsHelper.getWidgetNameFromUniqueId(uniqueId); - if (!widgetName) { - widgetName = _pk_translate('Dashboard_WidgetNotFound'); - } + var self = this; - var title = this.options.title === null ? $('').text(widgetName) : this.options.title; - var emptyWidgetContent = require('piwik/UI/Dashboard').WidgetFactory.make(uniqueId, title); - this.element.html(emptyWidgetContent); + widgetsHelper.getWidgetNameFromUniqueId(uniqueId, function(widgetName) { + if (!widgetName) { + widgetName = _pk_translate('Dashboard_WidgetNotFound'); + } - var widgetElement = $('[id="' + uniqueId + '"]', this.element); - var self = this; - widgetElement - .on('mouseenter.dashboardWidget', function () { - if (!self.isMaximised) { - $(this).addClass('widgetHover'); - $('.widgetTop', this).addClass('widgetTopHover'); - } - }) - .on('mouseleave.dashboardWidget', function () { - if (!self.isMaximised) { - $(this).removeClass('widgetHover'); - $('.widgetTop', this).removeClass('widgetTopHover'); - } - }); - - if (this.options.isHidden) { - $('.widgetContent', widgetElement).toggleClass('hidden').closest('.widget').toggleClass('hiddenContent'); - } + var title = self.options.title === null ? $('').text(widgetName) : self.options.title; + var emptyWidgetContent = require('piwik/UI/Dashboard').WidgetFactory.make(uniqueId, title); + self.element.html(emptyWidgetContent); - $('.button#close', widgetElement) - .on('click.dashboardWidget', function (ev) { - piwikHelper.modalConfirm('#confirm', {yes: function () { - if (self.options.onRemove) { - self.options.onRemove(self.element); + var widgetElement = $('[id="' + uniqueId + '"]', self.element); + widgetElement + .on('mouseenter.dashboardWidget', function () { + if (!self.isMaximised) { + $(this).addClass('widgetHover'); + $('.widgetTop', this).addClass('widgetTopHover'); + } + }) + .on('mouseleave.dashboardWidget', function () { + if (!self.isMaximised) { + $(this).removeClass('widgetHover'); + $('.widgetTop', this).removeClass('widgetTopHover'); + } + }); + + if (self.options.isHidden) { + $('.widgetContent', widgetElement).toggleClass('hidden').closest('.widget').toggleClass('hiddenContent'); + } + + $('.button#close', widgetElement) + .on('click.dashboardWidget', function (ev) { + piwikHelper.modalConfirm('#confirm', {yes: function () { + if (self.options.onRemove) { + self.options.onRemove(self.element); + } else { + self.element.remove(); + self.options.onChange(); + } + }}); + }); + + $('.button#maximise', widgetElement) + .on('click.dashboardWidget', function (ev) { + if (self.options.onMaximise) { + self.options.onMaximise(self.element); } else { - self.element.remove(); - self.options.onChange(); + if ($('.widgetContent', $(this).parents('.widget')).hasClass('hidden')) { + self.showContent(); + } else { + self.maximise(); + } } - }}); - }); - - $('.button#maximise', widgetElement) - .on('click.dashboardWidget', function (ev) { - if (self.options.onMaximise) { - self.options.onMaximise(self.element); - } else { - if ($('.widgetContent', $(this).parents('.widget')).hasClass('hidden')) { - self.showContent(); + }); + + $('.button#minimise', widgetElement) + .on('click.dashboardWidget', function (ev) { + if (self.options.onMinimise) { + self.options.onMinimise(self.element); } else { - self.maximise(); + if (!self.isMaximised) { + self.hideContent(); + } else { + self.element.dialog("close"); + } } - } - }); - - $('.button#minimise', widgetElement) - .on('click.dashboardWidget', function (ev) { - if (self.options.onMinimise) { - self.options.onMinimise(self.element); - } else { - if (!self.isMaximised) { - self.hideContent(); + }); + + $('.button#refresh', widgetElement) + .on('click.dashboardWidget', function (ev) { + if (self.options.onRefresh) { + self.options.onRefresh(self.element); } else { - self.element.dialog("close"); + self.reload(false, true); } - } - }); - - $('.button#refresh', widgetElement) - .on('click.dashboardWidget', function (ev) { - if (self.options.onRefresh) { - self.options.onRefresh(self.element); - } else { - self.reload(false, true); - } - }); + }); + }); }, /** @@ -350,8 +352,7 @@ */ detachWidget: function () { this.element.before('
'); - var placeholder = $('[id="' + self.uniqueId + '-placeholder"]') - + var placeholder = $('[id="' + self.uniqueId + '-placeholder"]'); $('#' + this.uniqueId + '-placeholder').height(this.element.height()); $('#' + this.uniqueId + '-placeholder').width(this.element.width() - 16); diff --git a/plugins/Dashboard/javascripts/widgetMenu.js b/plugins/Dashboard/javascripts/widgetMenu.js index 55eef4ab09..465e8001f5 100644 --- a/plugins/Dashboard/javascripts/widgetMenu.js +++ b/plugins/Dashboard/javascripts/widgetMenu.js @@ -89,47 +89,50 @@ widgetsHelper.getAvailableWidgets = function (callback) { } $('#loadingError').show(); }); - ajaxRequest.send(true); + ajaxRequest.send(); + return; } if (callback) { callback(widgetsHelper.availableWidgets); } - - return widgetsHelper.availableWidgets; }; /** - * Returns the complete widget object by its unique id + * Determines the complete widget object by its unique id and sends it to callback method * * @param {string} uniqueId - * @return {object} widget object + * @param {function} callback */ -widgetsHelper.getWidgetObjectFromUniqueId = function (uniqueId) { - var widgets = widgetsHelper.getAvailableWidgets(); - for (var widgetCategory in widgets) { - var widgetInCategory = widgets[widgetCategory]; - for (var i in widgetInCategory) { - if (widgetInCategory[i]["uniqueId"] == uniqueId) { - return widgetInCategory[i]; +widgetsHelper.getWidgetObjectFromUniqueId = function (uniqueId, callback) { + widgetsHelper.getAvailableWidgets(function(widgets){ + for (var widgetCategory in widgets) { + var widgetInCategory = widgets[widgetCategory]; + for (var i in widgetInCategory) { + if (widgetInCategory[i]["uniqueId"] == uniqueId) { + callback(widgetInCategory[i]); + return; + } } } - } - return false; + callback(false); + }); }; /** - * Returns the name of a widget by its unique id + * Determines the name of a widget by its unique id and sends it to the callback * * @param {string} uniqueId unique id of the widget + * @param {function} callback * @return {string} */ -widgetsHelper.getWidgetNameFromUniqueId = function (uniqueId) { - var widget = this.getWidgetObjectFromUniqueId(uniqueId); - if (widget == false) { - return false; - } - return widget["name"]; +widgetsHelper.getWidgetNameFromUniqueId = function (uniqueId, callback) { + this.getWidgetObjectFromUniqueId(uniqueId, function(widget) { + if (widget == false) { + callback(false); + } + callback(widget["name"]); + }); }; /** @@ -155,7 +158,7 @@ widgetsHelper.loadWidgetAjax = function (widgetUniqueId, widgetParameters, onWid ajaxRequest.setErrorCallback(onWidgetErrorCallback); } ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); return ajaxRequest; }; @@ -389,6 +392,7 @@ widgetsHelper.loadWidgetAjax = function (widgetUniqueId, widgetParameters, onWid * Show widget with the given uniqueId in preview * * @param {string} widgetUniqueId unique id of widget to display + * @param widgetPreview * @return {void} */ function showPreview(widgetUniqueId, widgetPreview) { @@ -399,39 +403,40 @@ widgetsHelper.loadWidgetAjax = function (widgetUniqueId, widgetParameters, onWid var previewElement = createPreviewElement(widgetPreview); - var widget = widgetsHelper.getWidgetObjectFromUniqueId(widgetUniqueId); - var widgetParameters = widget['parameters']; - - var emptyWidgetHtml = require('piwik/UI/Dashboard').WidgetFactory.make( - widgetUniqueId, - $('
') - .attr('title', _pk_translate("Dashboard_AddPreviewedWidget")) - .text(_pk_translate('Dashboard_WidgetPreview')) - ); - previewElement.html(emptyWidgetHtml); - - var onWidgetLoadedCallback = function (response) { - var widgetElement = $(document.getElementById(widgetUniqueId)); - // document.getElementById needed for widgets with uniqueid like widgetOpens+Contact+Form - $('.widgetContent', widgetElement).html($(response)); - $('.widgetContent', widgetElement).trigger('widget:create'); - settings.onPreviewLoaded(widgetUniqueId, widgetElement); - $('.' + settings.widgetpreviewClass + ' .widgetTop', widgetPreview).on('click', function () { - settings.onSelect(widgetUniqueId); - $(widgetPreview).closest('.dashboard-manager').removeClass('expanded'); - if (settings.resetOnSelect) { - resetWidgetPreview(widgetPreview); - } - return false; - }); - }; - - // abort previous sent request - if (widgetPreview.widgetAjaxRequest) { - widgetPreview.widgetAjaxRequest.abort(); - } + widgetsHelper.getWidgetObjectFromUniqueId(widgetUniqueId, function(widget) { + var widgetParameters = widget['parameters']; + + var emptyWidgetHtml = require('piwik/UI/Dashboard').WidgetFactory.make( + widgetUniqueId, + $('
') + .attr('title', _pk_translate("Dashboard_AddPreviewedWidget")) + .text(_pk_translate('Dashboard_WidgetPreview')) + ); + previewElement.html(emptyWidgetHtml); + + var onWidgetLoadedCallback = function (response) { + var widgetElement = $(document.getElementById(widgetUniqueId)); + // document.getElementById needed for widgets with uniqueid like widgetOpens+Contact+Form + $('.widgetContent', widgetElement).html($(response)); + $('.widgetContent', widgetElement).trigger('widget:create'); + settings.onPreviewLoaded(widgetUniqueId, widgetElement); + $('.' + settings.widgetpreviewClass + ' .widgetTop', widgetPreview).on('click', function () { + settings.onSelect(widgetUniqueId); + $(widgetPreview).closest('.dashboard-manager').removeClass('expanded'); + if (settings.resetOnSelect) { + resetWidgetPreview(widgetPreview); + } + return false; + }); + }; + + // abort previous sent request + if (widgetPreview.widgetAjaxRequest) { + widgetPreview.widgetAjaxRequest.abort(); + } - widgetPreview.widgetAjaxRequest = widgetsHelper.loadWidgetAjax(widgetUniqueId, widgetParameters, onWidgetLoadedCallback); + widgetPreview.widgetAjaxRequest = widgetsHelper.loadWidgetAjax(widgetUniqueId, widgetParameters, onWidgetLoadedCallback); + }); } /** diff --git a/plugins/Dashboard/templates/embeddedIndex.twig b/plugins/Dashboard/templates/embeddedIndex.twig index 92fc263a63..30afedc709 100644 --- a/plugins/Dashboard/templates/embeddedIndex.twig +++ b/plugins/Dashboard/templates/embeddedIndex.twig @@ -64,7 +64,8 @@
-
+
diff --git a/plugins/Live/javascripts/SegmentedVisitorLog.js b/plugins/Live/javascripts/SegmentedVisitorLog.js index 4f80e3ddc7..6cc61ffdaa 100644 --- a/plugins/Live/javascripts/SegmentedVisitorLog.js +++ b/plugins/Live/javascripts/SegmentedVisitorLog.js @@ -131,7 +131,7 @@ var SegmentedVisitorLog = function() { ajaxRequest.addParams(requestParams, 'get'); ajaxRequest.setCallback(callback); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); } return { diff --git a/plugins/Live/javascripts/live.js b/plugins/Live/javascripts/live.js index 15076b1f66..83c27081d7 100644 --- a/plugins/Live/javascripts/live.js +++ b/plugins/Live/javascripts/live.js @@ -94,7 +94,7 @@ } } }); - ajaxRequest.send(false); + ajaxRequest.send(); }, /** diff --git a/plugins/Live/templates/index.twig b/plugins/Live/templates/index.twig index 5112c85d10..a908f77434 100644 --- a/plugins/Live/templates/index.twig +++ b/plugins/Live/templates/index.twig @@ -19,7 +19,7 @@ ajaxRequest.setCallback(function (r) { $("#visitsTotal").html(r); }); - ajaxRequest.send(false); + ajaxRequest.send(); }, maxRows: 10, fadeInSpeed: 600, diff --git a/plugins/Morpheus/javascripts/ajaxHelper.js b/plugins/Morpheus/javascripts/ajaxHelper.js index e93c7a82e7..5360a35326 100644 --- a/plugins/Morpheus/javascripts/ajaxHelper.js +++ b/plugins/Morpheus/javascripts/ajaxHelper.js @@ -357,6 +357,9 @@ function ajaxHelper() { /** * Send the request + * + * Note: Sending synchronous requests will be removed in Matomo 4 + * * @param {Boolean} [sync] indicates if the request should be synchronous (defaults to false) * @return {void} */ diff --git a/plugins/Overlay/javascripts/Piwik_Overlay.js b/plugins/Overlay/javascripts/Piwik_Overlay.js index 2b18578147..e0be6ce5c9 100644 --- a/plugins/Overlay/javascripts/Piwik_Overlay.js +++ b/plugins/Overlay/javascripts/Piwik_Overlay.js @@ -87,7 +87,7 @@ var Piwik_Overlay = (function () { $errorNotLoading.show(); }); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); } /** Adjust the dimensions of the iframe */ diff --git a/plugins/SEO/javascripts/rank.js b/plugins/SEO/javascripts/rank.js index 1b5cdb91d2..ef92aa8c3b 100644 --- a/plugins/SEO/javascripts/rank.js +++ b/plugins/SEO/javascripts/rank.js @@ -20,7 +20,7 @@ $(document).ready(function () { } ); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); } // click on Rank button diff --git a/plugins/SegmentEditor/javascripts/Segmentation.js b/plugins/SegmentEditor/javascripts/Segmentation.js index fb52e12548..df5cf288d1 100644 --- a/plugins/SegmentEditor/javascripts/Segmentation.js +++ b/plugins/SegmentEditor/javascripts/Segmentation.js @@ -671,7 +671,7 @@ Segmentation = (function($) { ajaxHandler.setCallback(function (response) { self.updateMethod(params); }); - ajaxHandler.send(true); + ajaxHandler.send(); } else { self.updateMethod(params); } diff --git a/plugins/Transitions/javascripts/transitions.js b/plugins/Transitions/javascripts/transitions.js index 1bb6b1043b..8e6a03ad79 100644 --- a/plugins/Transitions/javascripts/transitions.js +++ b/plugins/Transitions/javascripts/transitions.js @@ -1471,7 +1471,7 @@ Piwik_Transitions_Ajax.prototype.callTransitionsController = function (action, c }, 'get'); ajaxRequest.setCallback(callback); ajaxRequest.setFormat('html'); - ajaxRequest.send(false); + ajaxRequest.send(); }; Piwik_Transitions_Ajax.prototype.callApi = function (method, params, callback) { @@ -1529,7 +1529,7 @@ Piwik_Transitions_Ajax.prototype.callApi = function (method, params, callback) { } } ); - ajaxRequest.send(false); + ajaxRequest.send(); }; // -------------------------------------- diff --git a/plugins/Widgetize/angularjs/widget-preview/widget-preview.directive.js b/plugins/Widgetize/angularjs/widget-preview/widget-preview.directive.js index 6694b15fae..eb9961548b 100644 --- a/plugins/Widgetize/angularjs/widget-preview/widget-preview.directive.js +++ b/plugins/Widgetize/angularjs/widget-preview/widget-preview.directive.js @@ -52,37 +52,38 @@ }; this.callbackAddExportButtonsUnderWidget = function (widgetUniqueId, loadedWidgetElement) { - var widget = widgetsHelper.getWidgetObjectFromUniqueId(widgetUniqueId); - var widgetParameters = widget['parameters']; + widgetsHelper.getWidgetObjectFromUniqueId(widgetUniqueId, function(widget) { + var widgetParameters = widget['parameters']; - var exportButtonsElement = $(''); + var exportButtonsElement = $(''); - var urlIframe = getEmbedUrl(widgetParameters, "iframe"); - // We first build the HTML code that will load the widget in an IFRAME - var widgetIframeHtml = '
' + - '' + - '
'; + var urlIframe = getEmbedUrl(widgetParameters, "iframe"); + // We first build the HTML code that will load the widget in an IFRAME + var widgetIframeHtml = '
' + + '' + + '
'; - // Add the input field containing the widget in an Iframe - $(exportButtonsElement).append( - '
' + - '' + - '
' + - self.getInputFormWithHtml('iframeEmbed', widgetIframeHtml) + - '
' + - '
' + - '
' + - '' - + '
' - ); + // Add the input field containing the widget in an Iframe + $(exportButtonsElement).append( + '
' + + '' + + '
' + + self.getInputFormWithHtml('iframeEmbed', widgetIframeHtml) + + '
' + + '
' + + '
' + + '' + + '
' + ); - // Finally we append the content to the parent widget DIV - $(loadedWidgetElement) - .parent() - .append(exportButtonsElement); + // Finally we append the content to the parent widget DIV + $(loadedWidgetElement) + .parent() + .append(exportButtonsElement); - piwik.helper.compileAngularComponents(exportButtonsElement); + piwik.helper.compileAngularComponents(exportButtonsElement); + }); } }, compile: function (element, attrs) { diff --git a/tests/UI/specs/UIIntegration_spec.js b/tests/UI/specs/UIIntegration_spec.js index 94dec399ce..4321882870 100644 --- a/tests/UI/specs/UIIntegration_spec.js +++ b/tests/UI/specs/UIIntegration_spec.js @@ -162,7 +162,7 @@ describe("UIIntegrationTest", function () { // TODO: Rename to Piwik? page.mouseMove('circle'); page.evaluate(function(){ $('.ui-tooltip:visible .rel-time').data('actiontime', Math.floor(new Date((new Date()).getTime()-(4*3600*24000))/1000)); - }); + }, 100); }, done); }); @@ -178,22 +178,22 @@ describe("UIIntegrationTest", function () { // TODO: Rename to Piwik? expect.screenshot('actions_pages_tooltip_help').to.be.captureSelector('.pageWrap', function (page) { page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=General_Pages"); page.mouseMove('[piwik-enriched-headline]'); - page.click(".helpIcon"); + page.click('.helpIcon'); page.evaluate(function () { $('.helpDate:visible').hide(); - }); + }, 100); }, done); }); it('should load the actions > entry pages page correctly', function (done) { expect.screenshot('actions_entry_pages').to.be.captureSelector('.pageWrap', function (page) { - page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=Actions_SubmenuPagesEntry"); + page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=Actions_SubmenuPagesEntry", 2000); }, done); }); it('should load the actions > exit pages page correctly', function (done) { expect.screenshot('actions_exit_pages').to.be.captureSelector('.pageWrap', function (page) { - page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=Actions_SubmenuPagesExit"); + page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=Actions_SubmenuPagesExit", 2000); }, done); }); @@ -211,7 +211,7 @@ describe("UIIntegrationTest", function () { // TODO: Rename to Piwik? it('should load the actions > outlinks page correctly', function (done) { expect.screenshot('actions_outlinks').to.be.captureSelector('.pageWrap', function (page) { - page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=General_Outlinks"); + page.load("?" + urlBase + "#?" + generalParams + "&category=General_Actions&subcategory=General_Outlinks", 1500); }, done); }); @@ -305,8 +305,7 @@ describe("UIIntegrationTest", function () { // TODO: Rename to Piwik? it('should load the goals > management page correctly', function (done) { expect.screenshot('goals_manage').to.be.captureSelector('#content,.top_bar_sites_selector,.entityContainer', function (page) { - page.load("?" + generalParams + "&module=Goals&action=manage"); - page.wait(200); + page.load("?" + generalParams + "&module=Goals&action=manage", 2000); }, done); }); diff --git a/tests/lib/screenshot-testing/support/page-renderer.js b/tests/lib/screenshot-testing/support/page-renderer.js index 4800106c96..6627134db1 100644 --- a/tests/lib/screenshot-testing/support/page-renderer.js +++ b/tests/lib/screenshot-testing/support/page-renderer.js @@ -108,10 +108,12 @@ PageRenderer.prototype.selectMainFrame = function (waitTime) { }; PageRenderer.prototype.reload = function (waitTime) { + waitTime = waitTime ? waitTime : 1000; this.queuedEvents.push([this._reload, waitTime]); }; PageRenderer.prototype.load = function (url, waitTime) { + waitTime = waitTime ? waitTime : 1000; this.queuedEvents.push([this._load, waitTime, url]); }; -- cgit v1.2.3