Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Side by Side Diff: components/dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc

Issue 2921143002: Reverse accidental enabling of 'use strict' in closure compiler (Closed)
Patch Set: add todo Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/closure_compiler/closure_args.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h " 5 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h "
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 DistillerPageWebContents::CreateNewWebContents(url); 175 DistillerPageWebContents::CreateNewWebContents(url);
176 } 176 }
177 177
178 bool new_web_contents_created() { return new_web_contents_created_; } 178 bool new_web_contents_created() { return new_web_contents_created_; }
179 179
180 private: 180 private:
181 bool expect_new_web_contents_; 181 bool expect_new_web_contents_;
182 bool new_web_contents_created_; 182 bool new_web_contents_created_;
183 }; 183 };
184 184
185 // Consistently failing for no obvious reason on Android. 185 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, BasicDistillationWorks) {
186 // See: crbug.com/728960.
187 #if defined(OS_ANDROID)
188 #define MAYBE_BasicDistillationWorks DISABLED_BasicDistillationWorks
189 #else
190 #define MAYBE_BasicDistillationWorks BasicDistillationWorks
191 #endif
192 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
193 MAYBE_BasicDistillationWorks) {
194 DistillerPageWebContents distiller_page( 186 DistillerPageWebContents distiller_page(
195 shell()->web_contents()->GetBrowserContext(), 187 shell()->web_contents()->GetBrowserContext(),
196 shell()->web_contents()->GetContainerBounds().size(), 188 shell()->web_contents()->GetContainerBounds().size(),
197 std::unique_ptr<SourcePageHandleWebContents>()); 189 std::unique_ptr<SourcePageHandleWebContents>());
198 distiller_page_ = &distiller_page; 190 distiller_page_ = &distiller_page;
199 191
200 base::RunLoop run_loop; 192 base::RunLoop run_loop;
201 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); 193 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath);
202 run_loop.Run(); 194 run_loop.Run();
203 195
204 EXPECT_EQ("Test Page Title", distiller_result_->title()); 196 EXPECT_EQ("Test Page Title", distiller_result_->title());
205 EXPECT_THAT(distiller_result_->distilled_content().html(), 197 EXPECT_THAT(distiller_result_->distilled_content().html(),
206 HasSubstr("Lorem ipsum")); 198 HasSubstr("Lorem ipsum"));
207 EXPECT_THAT(distiller_result_->distilled_content().html(), 199 EXPECT_THAT(distiller_result_->distilled_content().html(),
208 Not(HasSubstr("questionable content"))); 200 Not(HasSubstr("questionable content")));
209 EXPECT_EQ("", distiller_result_->pagination_info().next_page()); 201 EXPECT_EQ("", distiller_result_->pagination_info().next_page());
210 EXPECT_EQ("", distiller_result_->pagination_info().prev_page()); 202 EXPECT_EQ("", distiller_result_->pagination_info().prev_page());
211 } 203 }
212 204
213 // Consistently failing for no obvious reason on Android. 205 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeLinks) {
214 // See: crbug.com/728960.
215 #if defined(OS_ANDROID)
216 #define MAYBE_HandlesRelativeLinks DISABLED_HandlesRelativeLinks
217 #else
218 #define MAYBE_HandlesRelativeLinks HandlesRelativeLinks
219 #endif
220 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
221 MAYBE_HandlesRelativeLinks) {
222 DistillerPageWebContents distiller_page( 206 DistillerPageWebContents distiller_page(
223 shell()->web_contents()->GetBrowserContext(), 207 shell()->web_contents()->GetBrowserContext(),
224 shell()->web_contents()->GetContainerBounds().size(), 208 shell()->web_contents()->GetContainerBounds().size(),
225 std::unique_ptr<SourcePageHandleWebContents>()); 209 std::unique_ptr<SourcePageHandleWebContents>());
226 distiller_page_ = &distiller_page; 210 distiller_page_ = &distiller_page;
227 211
228 base::RunLoop run_loop; 212 base::RunLoop run_loop;
229 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); 213 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath);
230 run_loop.Run(); 214 run_loop.Run();
231 215
232 // A relative link should've been updated. 216 // A relative link should've been updated.
233 EXPECT_THAT(distiller_result_->distilled_content().html(), 217 EXPECT_THAT(distiller_result_->distilled_content().html(),
234 ContainsRegex("href=\"http://127.0.0.1:.*/relativelink.html\"")); 218 ContainsRegex("href=\"http://127.0.0.1:.*/relativelink.html\""));
235 EXPECT_THAT(distiller_result_->distilled_content().html(), 219 EXPECT_THAT(distiller_result_->distilled_content().html(),
236 HasSubstr("href=\"http://www.google.com/absolutelink.html\"")); 220 HasSubstr("href=\"http://www.google.com/absolutelink.html\""));
237 } 221 }
238 222
239 // Consistently failing for no obvious reason on Android. 223 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeImages) {
240 // See: crbug.com/728960.
241 #if defined(OS_ANDROID)
242 #define MAYBE_HandlesRelativeImages DISABLED_HandlesRelativeImages
243 #else
244 #define MAYBE_HandlesRelativeImages HandlesRelativeImages
245 #endif
246 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
247 MAYBE_HandlesRelativeImages) {
248 DistillerPageWebContents distiller_page( 224 DistillerPageWebContents distiller_page(
249 shell()->web_contents()->GetBrowserContext(), 225 shell()->web_contents()->GetBrowserContext(),
250 shell()->web_contents()->GetContainerBounds().size(), 226 shell()->web_contents()->GetContainerBounds().size(),
251 std::unique_ptr<SourcePageHandleWebContents>()); 227 std::unique_ptr<SourcePageHandleWebContents>());
252 distiller_page_ = &distiller_page; 228 distiller_page_ = &distiller_page;
253 229
254 base::RunLoop run_loop; 230 base::RunLoop run_loop;
255 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); 231 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath);
256 run_loop.Run(); 232 run_loop.Run();
257 233
258 // A relative link should've been updated. 234 // A relative link should've been updated.
259 EXPECT_THAT(distiller_result_->distilled_content().html(), 235 EXPECT_THAT(distiller_result_->distilled_content().html(),
260 ContainsRegex("src=\"http://127.0.0.1:.*/relativeimage.png\"")); 236 ContainsRegex("src=\"http://127.0.0.1:.*/relativeimage.png\""));
261 EXPECT_THAT(distiller_result_->distilled_content().html(), 237 EXPECT_THAT(distiller_result_->distilled_content().html(),
262 HasSubstr("src=\"http://www.google.com/absoluteimage.png\"")); 238 HasSubstr("src=\"http://www.google.com/absoluteimage.png\""));
263 } 239 }
264 240
265 // Consistently failing for no obvious reason on Android. 241 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeVideos) {
266 // See: crbug.com/728960.
267 #if defined(OS_ANDROID)
268 #define MAYBE_HandlesRelativeVideos DISABLED_HandlesRelativeVideos
269 #else
270 #define MAYBE_HandlesRelativeVideos HandlesRelativeVideos
271 #endif
272 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
273 MAYBE_HandlesRelativeVideos) {
274 DistillerPageWebContents distiller_page( 242 DistillerPageWebContents distiller_page(
275 shell()->web_contents()->GetBrowserContext(), 243 shell()->web_contents()->GetBrowserContext(),
276 shell()->web_contents()->GetContainerBounds().size(), 244 shell()->web_contents()->GetContainerBounds().size(),
277 std::unique_ptr<SourcePageHandleWebContents>()); 245 std::unique_ptr<SourcePageHandleWebContents>());
278 distiller_page_ = &distiller_page; 246 distiller_page_ = &distiller_page;
279 247
280 base::RunLoop run_loop; 248 base::RunLoop run_loop;
281 DistillPage(run_loop.QuitClosure(), kVideoArticlePath); 249 DistillPage(run_loop.QuitClosure(), kVideoArticlePath);
282 run_loop.Run(); 250 run_loop.Run();
283 251
284 // A relative source/track should've been updated. 252 // A relative source/track should've been updated.
285 EXPECT_THAT(distiller_result_->distilled_content().html(), 253 EXPECT_THAT(distiller_result_->distilled_content().html(),
286 ContainsRegex("src=\"http://127.0.0.1:.*/relative_video.webm\"")); 254 ContainsRegex("src=\"http://127.0.0.1:.*/relative_video.webm\""));
287 EXPECT_THAT( 255 EXPECT_THAT(
288 distiller_result_->distilled_content().html(), 256 distiller_result_->distilled_content().html(),
289 ContainsRegex("src=\"http://127.0.0.1:.*/relative_track_en.vtt\"")); 257 ContainsRegex("src=\"http://127.0.0.1:.*/relative_track_en.vtt\""));
290 EXPECT_THAT(distiller_result_->distilled_content().html(), 258 EXPECT_THAT(distiller_result_->distilled_content().html(),
291 HasSubstr("src=\"http://www.google.com/absolute_video.ogg\"")); 259 HasSubstr("src=\"http://www.google.com/absolute_video.ogg\""));
292 EXPECT_THAT(distiller_result_->distilled_content().html(), 260 EXPECT_THAT(distiller_result_->distilled_content().html(),
293 HasSubstr("src=\"http://www.google.com/absolute_track_fr.vtt\"")); 261 HasSubstr("src=\"http://www.google.com/absolute_track_fr.vtt\""));
294 } 262 }
295 263
296 // Consistently failing for no obvious reason on Android. 264 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, VisibilityDetection) {
297 // See: crbug.com/728960.
298 #if defined(OS_ANDROID)
299 #define MAYBE_VisibilityDetection DISABLED_VisibilityDetection
300 #else
301 #define MAYBE_VisibilityDetection VisibilityDetection
302 #endif
303 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
304 MAYBE_VisibilityDetection) {
305 DistillerPageWebContents distiller_page( 265 DistillerPageWebContents distiller_page(
306 shell()->web_contents()->GetBrowserContext(), 266 shell()->web_contents()->GetBrowserContext(),
307 shell()->web_contents()->GetContainerBounds().size(), 267 shell()->web_contents()->GetContainerBounds().size(),
308 std::unique_ptr<SourcePageHandleWebContents>()); 268 std::unique_ptr<SourcePageHandleWebContents>());
309 distiller_page_ = &distiller_page; 269 distiller_page_ = &distiller_page;
310 270
311 // visble_style.html and invisible_style.html only differ by the visibility 271 // visble_style.html and invisible_style.html only differ by the visibility
312 // internal stylesheet. 272 // internal stylesheet.
313 273
314 { 274 {
315 base::RunLoop run_loop; 275 base::RunLoop run_loop;
316 DistillPage(run_loop.QuitClosure(), "/visible_style.html"); 276 DistillPage(run_loop.QuitClosure(), "/visible_style.html");
317 run_loop.Run(); 277 run_loop.Run();
318 EXPECT_THAT(distiller_result_->distilled_content().html(), 278 EXPECT_THAT(distiller_result_->distilled_content().html(),
319 HasSubstr("Lorem ipsum")); 279 HasSubstr("Lorem ipsum"));
320 } 280 }
321 281
322 { 282 {
323 base::RunLoop run_loop; 283 base::RunLoop run_loop;
324 DistillPage(run_loop.QuitClosure(), "/invisible_style.html"); 284 DistillPage(run_loop.QuitClosure(), "/invisible_style.html");
325 run_loop.Run(); 285 run_loop.Run();
326 EXPECT_THAT(distiller_result_->distilled_content().html(), 286 EXPECT_THAT(distiller_result_->distilled_content().html(),
327 Not(HasSubstr("Lorem ipsum"))); 287 Not(HasSubstr("Lorem ipsum")));
328 } 288 }
329 } 289 }
330 290
331 // Consistently failing for no obvious reason on Android.
332 // See: crbug.com/728960.
333 #if defined(OS_ANDROID)
334 #define MAYBE_UsingCurrentWebContentsWrongUrl \
335 DISABLED_UsingCurrentWebContentsWrongUrl
336 #else
337 #define MAYBE_UsingCurrentWebContentsWrongUrl UsingCurrentWebContentsWrongUrl
338 #endif
339 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, 291 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
340 MAYBE_UsingCurrentWebContentsWrongUrl) { 292 UsingCurrentWebContentsWrongUrl) {
341 std::string url("/bogus"); 293 std::string url("/bogus");
342 bool expect_new_web_contents = true; 294 bool expect_new_web_contents = true;
343 bool setup_main_frame_observer = true; 295 bool setup_main_frame_observer = true;
344 bool wait_for_document_loaded = true; 296 bool wait_for_document_loaded = true;
345 RunUseCurrentWebContentsTest(url, 297 RunUseCurrentWebContentsTest(url,
346 expect_new_web_contents, 298 expect_new_web_contents,
347 setup_main_frame_observer, 299 setup_main_frame_observer,
348 wait_for_document_loaded); 300 wait_for_document_loaded);
349 } 301 }
350 302
351 // Consistently failing for no obvious reason on Android.
352 // See: crbug.com/728960.
353 #if defined(OS_ANDROID)
354 #define MAYBE_UsingCurrentWebContentsNoMainFrameObserver \
355 DISABLED_UsingCurrentWebContentsNoMainFrameObserver
356 #else
357 #define MAYBE_UsingCurrentWebContentsNoMainFrameObserver \
358 UsingCurrentWebContentsNoMainFrameObserver
359 #endif
360 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, 303 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
361 MAYBE_UsingCurrentWebContentsNoMainFrameObserver) { 304 UsingCurrentWebContentsNoMainFrameObserver) {
362 std::string url(kSimpleArticlePath); 305 std::string url(kSimpleArticlePath);
363 bool expect_new_web_contents = true; 306 bool expect_new_web_contents = true;
364 bool setup_main_frame_observer = false; 307 bool setup_main_frame_observer = false;
365 bool wait_for_document_loaded = true; 308 bool wait_for_document_loaded = true;
366 RunUseCurrentWebContentsTest(url, 309 RunUseCurrentWebContentsTest(url,
367 expect_new_web_contents, 310 expect_new_web_contents,
368 setup_main_frame_observer, 311 setup_main_frame_observer,
369 wait_for_document_loaded); 312 wait_for_document_loaded);
370 } 313 }
371 314
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 // It can not crash the loop when returning the result. 409 // It can not crash the loop when returning the result.
467 delete distiller_page_; 410 delete distiller_page_;
468 411
469 // Make sure the test ends when it does not crash. 412 // Make sure the test ends when it does not crash.
470 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 413 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
471 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(2)); 414 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(2));
472 415
473 run_loop.Run(); 416 run_loop.Run();
474 } 417 }
475 418
476 // Consistently failing for no obvious reason on Android. 419 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, MarkupInfo) {
477 // See: crbug.com/728960.
478 #if defined(OS_ANDROID)
479 #define MAYBE_MarkupInfo DISABLED_MarkupInfo
480 #else
481 #define MAYBE_MarkupInfo MarkupInfo
482 #endif
483 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, MAYBE_MarkupInfo) {
484 DistillerPageWebContents distiller_page( 420 DistillerPageWebContents distiller_page(
485 shell()->web_contents()->GetBrowserContext(), 421 shell()->web_contents()->GetBrowserContext(),
486 shell()->web_contents()->GetContainerBounds().size(), 422 shell()->web_contents()->GetContainerBounds().size(),
487 std::unique_ptr<SourcePageHandleWebContents>()); 423 std::unique_ptr<SourcePageHandleWebContents>());
488 distiller_page_ = &distiller_page; 424 distiller_page_ = &distiller_page;
489 425
490 base::RunLoop run_loop; 426 base::RunLoop run_loop;
491 DistillPage(run_loop.QuitClosure(), "/markup_article.html"); 427 DistillPage(run_loop.QuitClosure(), "/markup_article.html");
492 run_loop.Run(); 428 run_loop.Run();
493 429
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 ASSERT_TRUE(js_result_); 518 ASSERT_TRUE(js_result_);
583 ASSERT_TRUE(js_result_->GetAsDictionary(&dict)); 519 ASSERT_TRUE(js_result_->GetAsDictionary(&dict));
584 520
585 ASSERT_TRUE(dict->HasKey("success")); 521 ASSERT_TRUE(dict->HasKey("success"));
586 bool success; 522 bool success;
587 ASSERT_TRUE(dict->GetBoolean("success", &success)); 523 ASSERT_TRUE(dict->GetBoolean("success", &success));
588 EXPECT_TRUE(success); 524 EXPECT_TRUE(success);
589 } 525 }
590 526
591 } // namespace dom_distiller 527 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « no previous file | third_party/closure_compiler/closure_args.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698