OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/hash.h" | 6 #include "base/hash.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // the moment. | 242 // the moment. |
243 WebKit::WebMouseWheelEvent wheel_event; | 243 WebKit::WebMouseWheelEvent wheel_event; |
244 wheel_event.type = WebKit::WebInputEvent::MouseWheel; | 244 wheel_event.type = WebKit::WebInputEvent::MouseWheel; |
245 wheel_event.deltaY = -200; | 245 wheel_event.deltaY = -200; |
246 wheel_event.wheelTicksY = -2; | 246 wheel_event.wheelTicksY = -2; |
247 WebContents* web_contents = chrome::GetActiveWebContents(browser()); | 247 WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
248 web_contents->GetRenderViewHost()->ForwardWheelEvent(wheel_event); | 248 web_contents->GetRenderViewHost()->ForwardWheelEvent(wheel_event); |
249 ASSERT_NO_FATAL_FAILURE(WaitForResponse()); | 249 ASSERT_NO_FATAL_FAILURE(WaitForResponse()); |
250 | 250 |
251 int y_offset = 0; | 251 int y_offset = 0; |
252 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractInt( | 252 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
253 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 253 chrome::GetActiveWebContents(browser()), |
254 std::string(), | |
255 "window.domAutomationController.send(plugin.pageYOffset())", | 254 "window.domAutomationController.send(plugin.pageYOffset())", |
256 &y_offset)); | 255 &y_offset)); |
257 ASSERT_GT(y_offset, 0); | 256 ASSERT_GT(y_offset, 0); |
258 } | 257 } |
259 | 258 |
260 #if defined(OS_CHROMEOS) | 259 #if defined(OS_CHROMEOS) |
261 // TODO(sanjeevr): http://crbug.com/79837 | 260 // TODO(sanjeevr): http://crbug.com/79837 |
262 #define MAYBE_FindAndCopy DISABLED_FindAndCopy | 261 #define MAYBE_FindAndCopy DISABLED_FindAndCopy |
263 #else | 262 #else |
264 #define MAYBE_FindAndCopy FindAndCopy | 263 #define MAYBE_FindAndCopy FindAndCopy |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 330 |
332 GURL url = pdf_test_server()->GetURL(base_url + filename); | 331 GURL url = pdf_test_server()->GetURL(base_url + filename); |
333 ui_test_utils::NavigateToURL(browser(), url); | 332 ui_test_utils::NavigateToURL(browser(), url); |
334 | 333 |
335 while (true) { | 334 while (true) { |
336 int last_count = load_stop_notification_count(); | 335 int last_count = load_stop_notification_count(); |
337 // We might get extraneous chrome::LOAD_STOP notifications when | 336 // We might get extraneous chrome::LOAD_STOP notifications when |
338 // doing async loading. This happens when the first loader is cancelled | 337 // doing async loading. This happens when the first loader is cancelled |
339 // and before creating a byte-range request loader. | 338 // and before creating a byte-range request loader. |
340 bool complete = false; | 339 bool complete = false; |
341 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 340 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
342 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 341 chrome::GetActiveWebContents(browser()), |
343 std::string(), | |
344 "window.domAutomationController.send(plugin.documentLoadComplete())", | 342 "window.domAutomationController.send(plugin.documentLoadComplete())", |
345 &complete)); | 343 &complete)); |
346 if (complete) | 344 if (complete) |
347 break; | 345 break; |
348 | 346 |
349 // Check if the LOAD_STOP notification could have come while we run a | 347 // Check if the LOAD_STOP notification could have come while we run a |
350 // nested message loop for the JS call. | 348 // nested message loop for the JS call. |
351 if (last_count != load_stop_notification_count()) | 349 if (last_count != load_stop_notification_count()) |
352 continue; | 350 continue; |
353 content::WaitForLoadStop(chrome::GetActiveWebContents(browser())); | 351 content::WaitForLoadStop(chrome::GetActiveWebContents(browser())); |
354 } | 352 } |
355 } | 353 } |
356 } | 354 } |
357 | 355 |
358 INSTANTIATE_TEST_CASE_P(PDFTestFiles, | 356 INSTANTIATE_TEST_CASE_P(PDFTestFiles, |
359 PDFBrowserTest, | 357 PDFBrowserTest, |
360 testing::Range(0, kLoadingNumberOfParts)); | 358 testing::Range(0, kLoadingNumberOfParts)); |
361 | 359 |
362 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, Action) { | 360 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, Action) { |
363 ASSERT_NO_FATAL_FAILURE(Load()); | 361 ASSERT_NO_FATAL_FAILURE(Load()); |
364 | 362 |
365 ASSERT_TRUE(content::ExecuteJavaScript( | 363 ASSERT_TRUE(content::ExecuteScript( |
366 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 364 chrome::GetActiveWebContents(browser()), |
367 std::string(), | |
368 "document.getElementsByName('plugin')[0].fitToHeight();")); | 365 "document.getElementsByName('plugin')[0].fitToHeight();")); |
369 | 366 |
370 std::string zoom1, zoom2; | 367 std::string zoom1, zoom2; |
371 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( | 368 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
372 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 369 chrome::GetActiveWebContents(browser()), |
373 std::string(), | |
374 "window.domAutomationController.send(" | 370 "window.domAutomationController.send(" |
375 " document.getElementsByName('plugin')[0].getZoomLevel().toString())", | 371 " document.getElementsByName('plugin')[0].getZoomLevel().toString())", |
376 &zoom1)); | 372 &zoom1)); |
377 | 373 |
378 ASSERT_TRUE(content::ExecuteJavaScript( | 374 ASSERT_TRUE(content::ExecuteScript( |
379 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 375 chrome::GetActiveWebContents(browser()), |
380 std::string(), | |
381 "document.getElementsByName('plugin')[0].fitToWidth();")); | 376 "document.getElementsByName('plugin')[0].fitToWidth();")); |
382 | 377 |
383 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( | 378 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
384 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 379 chrome::GetActiveWebContents(browser()), |
385 std::string(), | |
386 "window.domAutomationController.send(" | 380 "window.domAutomationController.send(" |
387 " document.getElementsByName('plugin')[0].getZoomLevel().toString())", | 381 " document.getElementsByName('plugin')[0].getZoomLevel().toString())", |
388 &zoom2)); | 382 &zoom2)); |
389 ASSERT_NE(zoom1, zoom2); | 383 ASSERT_NE(zoom1, zoom2); |
390 } | 384 } |
391 | 385 |
392 // Flaky as per http://crbug.com/74549. | 386 // Flaky as per http://crbug.com/74549. |
393 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, DISABLED_OnLoadAndReload) { | 387 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, DISABLED_OnLoadAndReload) { |
394 ASSERT_TRUE(pdf_test_server()->Start()); | 388 ASSERT_TRUE(pdf_test_server()->Start()); |
395 | 389 |
396 GURL url = pdf_test_server()->GetURL("files/onload_reload.html"); | 390 GURL url = pdf_test_server()->GetURL("files/onload_reload.html"); |
397 ui_test_utils::NavigateToURL(browser(), url); | 391 ui_test_utils::NavigateToURL(browser(), url); |
398 | 392 |
399 content::WindowedNotificationObserver observer( | 393 content::WindowedNotificationObserver observer( |
400 content::NOTIFICATION_LOAD_STOP, | 394 content::NOTIFICATION_LOAD_STOP, |
401 content::Source<NavigationController>( | 395 content::Source<NavigationController>( |
402 &chrome::GetActiveWebContents(browser())->GetController())); | 396 &chrome::GetActiveWebContents(browser())->GetController())); |
403 ASSERT_TRUE(content::ExecuteJavaScript( | 397 ASSERT_TRUE(content::ExecuteScript( |
404 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 398 chrome::GetActiveWebContents(browser()), |
405 std::string(), | |
406 "reloadPDF();")); | 399 "reloadPDF();")); |
407 observer.Wait(); | 400 observer.Wait(); |
408 | 401 |
409 ASSERT_EQ("success", | 402 ASSERT_EQ("success", |
410 chrome::GetActiveWebContents(browser())->GetURL().query()); | 403 chrome::GetActiveWebContents(browser())->GetURL().query()); |
411 } | 404 } |
412 | 405 |
413 } // namespace | 406 } // namespace |
OLD | NEW |