36
36
#endif
37
37
38
38
const char kTestHost [] = " a.test.com" ;
39
- const char kTestAmpPage [] = " /test " ;
39
+ const char kTestAmpPage [] = " /test_amp_page " ;
40
40
const char kTestRedirectingAmpPage1 [] = " /redirecting_amp_page_1" ;
41
41
const char kTestRedirectingAmpPage2 [] = " /redirecting_amp_page_2" ;
42
- const char kTestSimpleNonAmpPage [] = " /simple " ;
43
- const char kTestCanonicalPage [] = " /simple_canonical " ;
42
+ const char kTestSimpleNonAmpPage [] = " /simple_page " ;
43
+ const char kTestCanonicalPage [] = " /simple_canonical_page " ;
44
44
const char kTestAmpBody [] =
45
45
R"(
46
46
<html amp>
@@ -171,9 +171,15 @@ std::unique_ptr<net::test_server::HttpResponse> HandleServerRedirect(
171
171
net::HttpStatusCode code,
172
172
const std::string& source,
173
173
const std::string& dest,
174
+ const std::string& body,
174
175
const net::test_server::HttpRequest& request) {
175
176
GURL request_url = request.GetURL ();
176
177
178
+ if (request.headers .find (" X-Brave-De-AMP" ) != request.headers .end ()) {
179
+ // This should never happen, abort test
180
+ return nullptr ;
181
+ }
182
+
177
183
if (request_url.path () == source) {
178
184
auto http_response =
179
185
std::make_unique<net::test_server::BasicHttpResponse>();
@@ -185,7 +191,7 @@ std::unique_ptr<net::test_server::HttpResponse> HandleServerRedirect(
185
191
dest.c_str ()));
186
192
return http_response;
187
193
} else {
188
- return nullptr ;
194
+ return BuildHttpResponseForAmpPage (body, source, request) ;
189
195
}
190
196
}
191
197
@@ -233,18 +239,16 @@ IN_PROC_BROWSER_TEST_F(DeAmpBrowserTest, AmpPagesPointingAtEachOther) {
233
239
234
240
IN_PROC_BROWSER_TEST_F (DeAmpBrowserTest, CanonicalRedirectsToAmp) {
235
241
TogglePref (true );
236
- https_server_->RegisterRequestHandler (
237
- base::BindRepeating (HandleRequest, kTestCanonicalPage , kTestAmpBody ));
238
242
https_server_->RegisterRequestHandler (base::BindRepeating (
239
243
HandleServerRedirect, net::HttpStatusCode::HTTP_PERMANENT_REDIRECT,
240
- kTestCanonicalPage , kTestAmpPage ));
244
+ kTestCanonicalPage , kTestAmpPage , kTestAmpBody ));
241
245
ASSERT_TRUE (https_server_->Start ());
242
246
243
247
const GURL amp_url = https_server_->GetURL (kTestHost , kTestAmpPage );
244
248
const GURL canonical_url =
245
249
https_server_->GetURL (kTestHost , kTestCanonicalPage );
246
250
247
- NavigateToURLAndWaitForRedirects (amp_url, canonical_url );
251
+ NavigateToURLAndWaitForRedirects (amp_url, amp_url );
248
252
}
249
253
250
254
IN_PROC_BROWSER_TEST_F (DeAmpBrowserTest, NonHttpScheme) {
0 commit comments