Use a utility function for reloading the window
This means we can intercept and send a stack trace to console.info.
Change-Id: Ia50503e5c058c351e6372dd19ff8568ca4aa0a31
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts
index 9ad0b05f..f36df84 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts
@@ -55,6 +55,7 @@
} from '../../../utils/attention-set-util';
import {CustomKeyboardEvent} from '../../../types/events';
import {fireEvent} from '../../../utils/event-util';
+import {windowLocationReload} from '../../../utils/dom-util';
const NUMBER_FIXED_COLUMNS = 3;
const CLOSED_STATUS = ['MERGED', 'ABANDONED'];
@@ -478,7 +479,7 @@
}
_reloadWindow() {
- window.location.reload();
+ windowLocationReload();
}
_toggleChangeStar(e: CustomKeyboardEvent) {
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
index 4a92869..fe68cdc 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
@@ -55,7 +55,10 @@
} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
import {GrEditConstants} from '../../edit/gr-edit-constants';
import {pluralize} from '../../../utils/string-util';
-import {getComputedStyleValue} from '../../../utils/dom-util';
+import {
+ getComputedStyleValue,
+ windowLocationReload,
+} from '../../../utils/dom-util';
import {GerritNav} from '../../core/gr-navigation/gr-navigation';
import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
import {getPluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader';
@@ -896,7 +899,7 @@
}
_reloadWindow() {
- window.location.reload();
+ windowLocationReload();
}
_handleCommitMessageCancel() {
diff --git a/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager.ts b/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager.ts
index 264034c..a3a648e 100644
--- a/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager.ts
+++ b/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager.ts
@@ -38,6 +38,7 @@
ServerErrorEvent,
ShowAlertEvent,
} from '../../../types/events';
+import {windowLocationReload} from '../../../utils/dom-util';
const HIDE_ALERT_TIMEOUT_MS = 5000;
const CHECK_SIGN_IN_INTERVAL_MS = 60 * 1000;
@@ -446,7 +447,7 @@
}
_reloadPage() {
- window.location.reload();
+ windowLocationReload();
}
_createLoginPopup() {
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
index 8a23004..3a76112 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
@@ -67,6 +67,7 @@
import {GerritView, updateState} from '../../../services/router/router-model';
import {firePageError} from '../../../utils/event-util';
import {addQuotesWhen} from '../../../utils/string-util';
+import {windowLocationReload} from '../../../utils/dom-util';
const RoutePattern = {
ROOT: '/',
@@ -1725,7 +1726,7 @@
* by the catchall _handleDefaultRoute handler.
*/
_handlePassThroughRoute() {
- location.reload();
+ windowLocationReload();
}
/**
@@ -1762,7 +1763,7 @@
_handleDocumentationRedirectRoute(data: PageContextWithQueryMap) {
if (data.params[1]) {
- location.reload();
+ windowLocationReload();
} else {
// Redirect /Documentation to /Documentation/index.html
this._redirect('/Documentation/index.html');
diff --git a/polygerrit-ui/app/elements/gr-app-element.ts b/polygerrit-ui/app/elements/gr-app-element.ts
index 72e24f7..cdc9f98 100644
--- a/polygerrit-ui/app/elements/gr-app-element.ts
+++ b/polygerrit-ui/app/elements/gr-app-element.ts
@@ -79,6 +79,7 @@
import {ViewState} from '../types/types';
import {EventType} from '../utils/event-util';
import {GerritView} from '../services/router/router-model';
+import {windowLocationReload} from '../utils/dom-util';
interface ErrorInfo {
text: string;
@@ -241,7 +242,7 @@
// Ideally individual views should handle this event and respond with a soft
// reload. This is a catch-all for all views that cannot or have not
// implemented that.
- this.addEventListener('reload', () => window.location.reload());
+ this.addEventListener('reload', () => windowLocationReload());
}
/** @override */
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-action-context.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-action-context.ts
index 2149fe4..d4a2bd6 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-action-context.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-action-context.ts
@@ -19,6 +19,7 @@
import {ShowAlertEventDetail} from '../../../types/events';
import {PluginApi} from '../../plugins/gr-plugin-types';
import {UIActionInfo} from './gr-change-actions-js-api';
+import {windowLocationReload} from '../../../utils/dom-util';
interface GrPopupInterface {
close(): void;
@@ -57,7 +58,7 @@
}
refresh() {
- window.location.reload();
+ windowLocationReload();
}
textfield(): HTMLElement {
diff --git a/polygerrit-ui/app/utils/dom-util.ts b/polygerrit-ui/app/utils/dom-util.ts
index c9a7d6b..2023da0 100644
--- a/polygerrit-ui/app/utils/dom-util.ts
+++ b/polygerrit-ui/app/utils/dom-util.ts
@@ -153,6 +153,12 @@
return [...results];
}
+export function windowLocationReload() {
+ const e = new Error();
+ console.info(`Calling window.location.realod(): ${e.stack}`);
+ window.location.reload();
+}
+
/**
* Retrieves the dom path of the current event.
*