Remove page reload detection in tests
Our test runner handles this automatically and fails the test with error
code 1.
https://imgur.com/a/JTOQPtU
Release-Notes: skip
Change-Id: Ida8a8ddb0c42a9b2c138d8235c72af79f4487e66
diff --git a/polygerrit-ui/app/test/common-test-setup-karma.ts b/polygerrit-ui/app/test/common-test-setup-karma.ts
index 492d70a..34ec682 100644
--- a/polygerrit-ui/app/test/common-test-setup-karma.ts
+++ b/polygerrit-ui/app/test/common-test-setup-karma.ts
@@ -12,34 +12,4 @@
let testResolver: typeof testResolverImpl;
}
-let originalOnBeforeUnload: typeof window.onbeforeunload;
-
-suiteSetup(() => {
- // This suiteSetup() method is called only once before all tests
-
- // Can't use window.addEventListener("beforeunload",...) here,
- // the handler is raised too late.
- originalOnBeforeUnload = window.onbeforeunload;
- window.onbeforeunload = function (e: BeforeUnloadEvent) {
- // If a test reloads a page, we can't prevent it.
- // However we can print an error and the stack trace with assert.fail
- try {
- throw new Error();
- } catch (e) {
- console.error('Page reloading attempt detected.');
- if (e instanceof Error) {
- console.error(e.stack?.toString());
- }
- }
- if (originalOnBeforeUnload) {
- originalOnBeforeUnload.call(window, e);
- }
- };
-});
-
-suiteTeardown(() => {
- // This suiteTeardown() method is called only once after all tests
- window.onbeforeunload = originalOnBeforeUnload;
-});
-
window.testResolver = testResolverImpl;