Disallow mocha context updates within test functions Fixed: 422717761 Change-Id: I72bdec93fa0ba8b272107c5a0bf8a332347f7b40 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6624176 Commit-Queue: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Alex Rudenko <alexrudenko@chromium.org> Auto-Submit: Alex Rudenko <alexrudenko@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
diff --git a/test/e2e_non_hosted/conductor/mocha-interface-helpers.ts b/test/e2e_non_hosted/conductor/mocha-interface-helpers.ts index 28a2215..6f43011 100644 --- a/test/e2e_non_hosted/conductor/mocha-interface-helpers.ts +++ b/test/e2e_non_hosted/conductor/mocha-interface-helpers.ts
@@ -87,7 +87,8 @@ debugger; // If you're paused here while debugging, stepping into the next line will step into your test. } const testResult = - await (state === undefined ? fn.call(this) : (fn as E2E.TestAsyncCallbackWithState).call(this, state.state)); + await (state === undefined ? fn.call(this) : + (fn as unknown as E2E.TestAsyncCallbackWithState).call(undefined, state.state)); dumpCollectedErrors(); return testResult; })();
diff --git a/test/e2e_non_hosted/types.d.ts b/test/e2e_non_hosted/types.d.ts index c1bffae..bfc9ca1b 100644 --- a/test/e2e_non_hosted/types.d.ts +++ b/test/e2e_non_hosted/types.d.ts
@@ -53,6 +53,7 @@ browser: BrowserWrapper; } - export type TestAsyncCallbackWithState = (this: Mocha.Context, state: State) => PromiseLike<unknown>; + // We do not allow test functions to affect mocha context. + export type TestAsyncCallbackWithState = (this: undefined, state: State) => PromiseLike<unknown>; } }