Testing for overdispersion in logistic regression R in Action (Kabacoff, 2011) suggests the following routine to test for overdispersion in a logistic regression:
Fit logistic regression using binomial distribution:
model_binom <- glm(Species=="versicolor" ~ Sepal.Width,
                   family=binomial(), data=iris)

Fit logistic regression using quasibinomial distribution:
model_overdispersed <- glm(Species=="versicolor" ~ Sepal.Width, 
                           family=quasibinomial(), data=iris)

Use chi-squared to test for overdispersion:
pchisq(summary(model_overdispersed)$dispersion * model_binom$df.residual, 
       model_binom$df.residual, lower = F)
# [1] 0.7949171

Could somebody explain how and why the chi-squared distribution is being used to test for overdispersion here? The p-value is 0.79 - how does this show that overdispersion is not a problem in the binomial distribution model?
 A: The approach described requires unnecessary computations. The test statistic is just
sum(residuals(model_binom, type = "deviance")^2)

This is exactly equal to the Pearson $\chi^2$ test statistic for lack of fit, hence it have chi-squared distribution.
Overdispersion as such doesn't apply to Bernoulli data. Large value of $\chi^2$ could indicate lack of covariates or powers, or interactions terms, or data should be grouped. A p-value of 0.79 indicates the test failed to find any problems.
A: As @oleh says, the chi2 test is basically a general GOF, which will be triggered by overdispersion, but could be triggered also by other problems.
You can test specifically for overdispersion in binomial GLMs with the DHARMa R package (disclaimer: I'm the developer), which compares the dispersion in the data with the dispersion of simulated data from the fitted model.
model_binom <- glm(Species=="versicolor" ~ Sepal.Width,
                   family=binomial(), data=iris)
library(DHARMa)
testDispersion(model_binom)

However, note that the raw 0/1 response in a logistic regression cannot have overdispersion, so this test (as any other dispersion test) will never be positive. Overdispersion tests on a 0/1 response only make sense if you group the residuals. See the comments specific to binomial responses in the DHARMa vignette here.
