Skip to content

Commit 06dbed9

Browse files
OrKoNDevtools-frontend LUCI CQ
authored andcommitted
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>
1 parent 74ba745 commit 06dbed9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

test/e2e_non_hosted/conductor/mocha-interface-helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ export function makeInstrumentedTestFunction(fn: Mocha.AsyncFunc, label: string,
8787
debugger; // If you're paused here while debugging, stepping into the next line will step into your test.
8888
}
8989
const testResult =
90-
await (state === undefined ? fn.call(this) : (fn as E2E.TestAsyncCallbackWithState).call(this, state.state));
90+
await (state === undefined ? fn.call(this) :
91+
(fn as unknown as E2E.TestAsyncCallbackWithState).call(undefined, state.state));
9192
dumpCollectedErrors();
9293
return testResult;
9394
})();

test/e2e_non_hosted/types.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ declare global {
5353
browser: BrowserWrapper;
5454
}
5555

56-
export type TestAsyncCallbackWithState = (this: Mocha.Context, state: State) => PromiseLike<unknown>;
56+
// We do not allow test functions to affect mocha context.
57+
export type TestAsyncCallbackWithState = (this: undefined, state: State) => PromiseLike<unknown>;
5758
}
5859
}

0 commit comments

Comments
 (0)