Let $X_1, \ldots, X_{n_X}$ and $Y_1, \ldots, Y_{n_Y}$ be $n_x$ and $n_Y$ iid observations from two independent Bernoulli populations with probabilities of success $p_X$ and $p_Y$. Define the statistics $T_X = \sum_{i=1}^{n_X}X_i$ and $T_Y = \sum_{i=1}^{n_Y}Y_i$. I am testing the hypothesis:
$$ H_0 : p_X = p_Y \ \ \ \text{and} \ \ \ H_1 : p_X \neq p_Y $$
Consider the test statistic:
$$ T = \dfrac{\hat{p}_X-\hat{p}_Y}{\sqrt{\hat{p}(1-\hat{p})\left(\frac{1}{n_X}+\frac{1}{n_Y}\right)}} $$
where $\hat{p}_X = \frac{T_X}{n_X}$ and $\hat{p}_Y = \frac{T_Y}{n_Y}$, and $\hat{p} = \frac{T_X+T_Y}{n_X+n_Y}$.
I would like to derive the asymptotic distribution of $T$ under $H_0$ as both $n_X$ and $n_Y$ go to infinity that is that under the null: $$ T = \dfrac{\hat{p}_X-\hat{p}_Y}{\sqrt{\hat{p}(1-\hat{p})\left(\frac{1}{n_X}+\frac{1}{n_Y}\right)}} \to_D N(0,1) $$
Now this question has been asked before see: How to derive the asymptotic distribution of the test statistic of a large sample test for equality of two binomial populations?
However the answer given there is wrong because it gives a justification based on the continuous mapping theorem. The continuous mapping theorem says that for random variables $X_n$ and $X$ such that $X_n$ converges in distribution to $X$ and if $g$ is a continuous function, then $g(X_n)$ converges in distribution to $g(X)$. However $g$ cannot be a function of $n$.
The function $\varphi$ used in the answer is itself dependent on $n_X$ and $n_Y$ and so the continuous mapping theorem doesn't apply.
In which case how do you find the asymptotic distribution?