Commit e454a188 authored by Aaron Tagliaboschi's avatar Aaron Tagliaboschi Committed by Commit Bot

Add check to net:TestDelegate to check for response finishing early

If "RunUntilRedirect" or "RunUntilAuthRequired" is run and the request
unexpectedly finishes, TestDelegate will crash for trying to run the
"on_complete_" closure, which would be null, and crashes with a very
unhelpful message. A DCHECK and comment have been added that should make
The issue a little more clear.

Bug: 1000299
Change-Id: I537e8f2abc7754323bdaedcd7ee5d802ea674c9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1782502Reviewed-by: default avatarDavid Benjamin <davidben@chromium.org>
Commit-Queue: Aaron Tagliaboschi <aarontag@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693120}
parent 764d5a66
......@@ -289,6 +289,12 @@ void TestDelegate::OnReadCompleted(URLRequest* request, int bytes_read) {
// It doesn't make sense for the request to have IO pending at this point.
DCHECK_NE(bytes_read, ERR_IO_PENDING);
// If you've reached this, you've either called "RunUntilComplete" or are
// using legacy "QuitCurrent*Deprecated". If this DCHECK fails, that probably
// means you've run "RunUntilRedirect" or "RunUntilAuthRequired" and haven't
// redirected/auth-challenged
DCHECK(on_complete_ || use_legacy_on_complete_);
// If the request was cancelled in a redirect, it should not signal
// OnReadCompleted. Note that |cancel_in_rs_| may be true due to
// https://crbug.com/564848.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment