OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 }; | 443 }; |
444 | 444 |
445 TEST_P(ParameterizedWebFrameTest, RequestExecuteScript) { | 445 TEST_P(ParameterizedWebFrameTest, RequestExecuteScript) { |
446 RegisterMockedHttpURLLoad("foo.html"); | 446 RegisterMockedHttpURLLoad("foo.html"); |
447 | 447 |
448 FrameTestHelpers::WebViewHelper web_view_helper; | 448 FrameTestHelpers::WebViewHelper web_view_helper; |
449 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); | 449 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); |
450 | 450 |
451 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 451 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
452 ScriptExecutionCallbackHelper callback_helper( | 452 ScriptExecutionCallbackHelper callback_helper( |
453 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext()); | 453 web_view_helper.LocalMainFrame()->MainWorldScriptContext()); |
454 web_view_helper.WebView() | 454 web_view_helper.WebView() |
455 ->MainFrameImpl() | 455 ->MainFrameImpl() |
456 ->RequestExecuteScriptAndReturnValue( | 456 ->RequestExecuteScriptAndReturnValue( |
457 WebScriptSource(WebString("'hello';")), false, &callback_helper); | 457 WebScriptSource(WebString("'hello';")), false, &callback_helper); |
458 RunPendingTasks(); | 458 RunPendingTasks(); |
459 EXPECT_TRUE(callback_helper.DidComplete()); | 459 EXPECT_TRUE(callback_helper.DidComplete()); |
460 EXPECT_EQ("hello", callback_helper.StringValue()); | 460 EXPECT_EQ("hello", callback_helper.StringValue()); |
461 } | 461 } |
462 | 462 |
463 TEST_P(ParameterizedWebFrameTest, SuspendedRequestExecuteScript) { | 463 TEST_P(ParameterizedWebFrameTest, SuspendedRequestExecuteScript) { |
464 RegisterMockedHttpURLLoad("foo.html"); | 464 RegisterMockedHttpURLLoad("foo.html"); |
465 RegisterMockedHttpURLLoad("bar.html"); | 465 RegisterMockedHttpURLLoad("bar.html"); |
466 | 466 |
467 FrameTestHelpers::WebViewHelper web_view_helper; | 467 FrameTestHelpers::WebViewHelper web_view_helper; |
468 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); | 468 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); |
469 | 469 |
470 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 470 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
471 ScriptExecutionCallbackHelper callback_helper( | 471 ScriptExecutionCallbackHelper callback_helper( |
472 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext()); | 472 web_view_helper.LocalMainFrame()->MainWorldScriptContext()); |
473 | 473 |
474 // Suspend scheduled tasks so the script doesn't run. | 474 // Suspend scheduled tasks so the script doesn't run. |
475 web_view_helper.WebView() | 475 web_view_helper.WebView() |
476 ->MainFrameImpl() | 476 ->MainFrameImpl() |
477 ->GetFrame() | 477 ->GetFrame() |
478 ->GetDocument() | 478 ->GetDocument() |
479 ->SuspendScheduledTasks(); | 479 ->SuspendScheduledTasks(); |
480 web_view_helper.WebView() | 480 web_view_helper.WebView() |
481 ->MainFrameImpl() | 481 ->MainFrameImpl() |
482 ->RequestExecuteScriptAndReturnValue( | 482 ->RequestExecuteScriptAndReturnValue( |
(...skipping 14 matching lines...) Expand all Loading... |
497 | 497 |
498 FrameTestHelpers::WebViewHelper web_view_helper; | 498 FrameTestHelpers::WebViewHelper web_view_helper; |
499 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); | 499 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); |
500 | 500 |
501 auto callback = [](const v8::FunctionCallbackInfo<v8::Value>& info) { | 501 auto callback = [](const v8::FunctionCallbackInfo<v8::Value>& info) { |
502 info.GetReturnValue().Set(V8String(info.GetIsolate(), "hello")); | 502 info.GetReturnValue().Set(V8String(info.GetIsolate(), "hello")); |
503 }; | 503 }; |
504 | 504 |
505 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 505 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
506 v8::Local<v8::Context> context = | 506 v8::Local<v8::Context> context = |
507 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext(); | 507 web_view_helper.LocalMainFrame()->MainWorldScriptContext(); |
508 ScriptExecutionCallbackHelper callback_helper(context); | 508 ScriptExecutionCallbackHelper callback_helper(context); |
509 v8::Local<v8::Function> function = | 509 v8::Local<v8::Function> function = |
510 v8::Function::New(context, callback).ToLocalChecked(); | 510 v8::Function::New(context, callback).ToLocalChecked(); |
511 web_view_helper.WebView() | 511 web_view_helper.WebView() |
512 ->MainFrame() | 512 ->MainFrame() |
513 ->ToWebLocalFrame() | 513 ->ToWebLocalFrame() |
514 ->RequestExecuteV8Function(context, function, | 514 ->RequestExecuteV8Function(context, function, |
515 v8::Undefined(context->GetIsolate()), 0, | 515 v8::Undefined(context->GetIsolate()), 0, |
516 nullptr, &callback_helper); | 516 nullptr, &callback_helper); |
517 RunPendingTasks(); | 517 RunPendingTasks(); |
518 EXPECT_TRUE(callback_helper.DidComplete()); | 518 EXPECT_TRUE(callback_helper.DidComplete()); |
519 EXPECT_EQ("hello", callback_helper.StringValue()); | 519 EXPECT_EQ("hello", callback_helper.StringValue()); |
520 } | 520 } |
521 | 521 |
522 TEST_P(ParameterizedWebFrameTest, RequestExecuteV8FunctionWhileSuspended) { | 522 TEST_P(ParameterizedWebFrameTest, RequestExecuteV8FunctionWhileSuspended) { |
523 RegisterMockedHttpURLLoad("foo.html"); | 523 RegisterMockedHttpURLLoad("foo.html"); |
524 | 524 |
525 FrameTestHelpers::WebViewHelper web_view_helper; | 525 FrameTestHelpers::WebViewHelper web_view_helper; |
526 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); | 526 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); |
527 | 527 |
528 auto callback = [](const v8::FunctionCallbackInfo<v8::Value>& info) { | 528 auto callback = [](const v8::FunctionCallbackInfo<v8::Value>& info) { |
529 info.GetReturnValue().Set(V8String(info.GetIsolate(), "hello")); | 529 info.GetReturnValue().Set(V8String(info.GetIsolate(), "hello")); |
530 }; | 530 }; |
531 | 531 |
532 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 532 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
533 v8::Local<v8::Context> context = | 533 v8::Local<v8::Context> context = |
534 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext(); | 534 web_view_helper.LocalMainFrame()->MainWorldScriptContext(); |
535 | 535 |
536 // Suspend scheduled tasks so the script doesn't run. | 536 // Suspend scheduled tasks so the script doesn't run. |
537 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 537 WebLocalFrameBase* main_frame = web_view_helper.LocalMainFrame(); |
538 main_frame->GetFrame()->GetDocument()->SuspendScheduledTasks(); | 538 main_frame->GetFrame()->GetDocument()->SuspendScheduledTasks(); |
539 | 539 |
540 ScriptExecutionCallbackHelper callback_helper(context); | 540 ScriptExecutionCallbackHelper callback_helper(context); |
541 v8::Local<v8::Function> function = | 541 v8::Local<v8::Function> function = |
542 v8::Function::New(context, callback).ToLocalChecked(); | 542 v8::Function::New(context, callback).ToLocalChecked(); |
543 main_frame->RequestExecuteV8Function(context, function, | 543 main_frame->RequestExecuteV8Function(context, function, |
544 v8::Undefined(context->GetIsolate()), 0, | 544 v8::Undefined(context->GetIsolate()), 0, |
545 nullptr, &callback_helper); | 545 nullptr, &callback_helper); |
546 RunPendingTasks(); | 546 RunPendingTasks(); |
547 EXPECT_FALSE(callback_helper.DidComplete()); | 547 EXPECT_FALSE(callback_helper.DidComplete()); |
(...skipping 10 matching lines...) Expand all Loading... |
558 | 558 |
559 FrameTestHelpers::WebViewHelper web_view_helper; | 559 FrameTestHelpers::WebViewHelper web_view_helper; |
560 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); | 560 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); |
561 | 561 |
562 auto callback = [](const v8::FunctionCallbackInfo<v8::Value>& info) { | 562 auto callback = [](const v8::FunctionCallbackInfo<v8::Value>& info) { |
563 info.GetReturnValue().Set(v8::Boolean::New( | 563 info.GetReturnValue().Set(v8::Boolean::New( |
564 info.GetIsolate(), UserGestureIndicator::ProcessingUserGesture())); | 564 info.GetIsolate(), UserGestureIndicator::ProcessingUserGesture())); |
565 }; | 565 }; |
566 | 566 |
567 // Suspend scheduled tasks so the script doesn't run. | 567 // Suspend scheduled tasks so the script doesn't run. |
568 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 568 WebLocalFrameBase* main_frame = web_view_helper.LocalMainFrame(); |
569 Document* document = main_frame->GetFrame()->GetDocument(); | 569 Document* document = main_frame->GetFrame()->GetDocument(); |
570 document->SuspendScheduledTasks(); | 570 document->SuspendScheduledTasks(); |
571 | 571 |
572 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 572 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
573 v8::Local<v8::Context> context = | 573 v8::Local<v8::Context> context = |
574 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext(); | 574 web_view_helper.LocalMainFrame()->MainWorldScriptContext(); |
575 | 575 |
576 std::unique_ptr<UserGestureIndicator> indicator = | 576 std::unique_ptr<UserGestureIndicator> indicator = |
577 WTF::WrapUnique(new UserGestureIndicator( | 577 WTF::WrapUnique(new UserGestureIndicator( |
578 UserGestureToken::Create(document, UserGestureToken::kNewGesture))); | 578 UserGestureToken::Create(document, UserGestureToken::kNewGesture))); |
579 ScriptExecutionCallbackHelper callback_helper(context); | 579 ScriptExecutionCallbackHelper callback_helper(context); |
580 v8::Local<v8::Function> function = | 580 v8::Local<v8::Function> function = |
581 v8::Function::New(context, callback).ToLocalChecked(); | 581 v8::Function::New(context, callback).ToLocalChecked(); |
582 main_frame->RequestExecuteV8Function( | 582 main_frame->RequestExecuteV8Function( |
583 main_frame->MainWorldScriptContext(), function, | 583 main_frame->MainWorldScriptContext(), function, |
584 v8::Undefined(context->GetIsolate()), 0, nullptr, &callback_helper); | 584 v8::Undefined(context->GetIsolate()), 0, nullptr, &callback_helper); |
585 | 585 |
586 RunPendingTasks(); | 586 RunPendingTasks(); |
587 EXPECT_FALSE(callback_helper.DidComplete()); | 587 EXPECT_FALSE(callback_helper.DidComplete()); |
588 | 588 |
589 main_frame->GetFrame()->GetDocument()->ResumeScheduledTasks(); | 589 main_frame->GetFrame()->GetDocument()->ResumeScheduledTasks(); |
590 RunPendingTasks(); | 590 RunPendingTasks(); |
591 EXPECT_TRUE(callback_helper.DidComplete()); | 591 EXPECT_TRUE(callback_helper.DidComplete()); |
592 EXPECT_EQ(true, callback_helper.BoolValue()); | 592 EXPECT_EQ(true, callback_helper.BoolValue()); |
593 } | 593 } |
594 | 594 |
595 TEST_P(ParameterizedWebFrameTest, IframeScriptRemovesSelf) { | 595 TEST_P(ParameterizedWebFrameTest, IframeScriptRemovesSelf) { |
596 RegisterMockedHttpURLLoad("single_iframe.html"); | 596 RegisterMockedHttpURLLoad("single_iframe.html"); |
597 RegisterMockedHttpURLLoad("visible_iframe.html"); | 597 RegisterMockedHttpURLLoad("visible_iframe.html"); |
598 | 598 |
599 FrameTestHelpers::WebViewHelper web_view_helper; | 599 FrameTestHelpers::WebViewHelper web_view_helper; |
600 web_view_helper.InitializeAndLoad(base_url_ + "single_iframe.html"); | 600 web_view_helper.InitializeAndLoad(base_url_ + "single_iframe.html"); |
601 | 601 |
602 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 602 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
603 ScriptExecutionCallbackHelper callback_helper( | 603 ScriptExecutionCallbackHelper callback_helper( |
604 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext()); | 604 web_view_helper.LocalMainFrame()->MainWorldScriptContext()); |
605 web_view_helper.WebView() | 605 web_view_helper.WebView() |
606 ->MainFrame() | 606 ->MainFrame() |
607 ->FirstChild() | 607 ->FirstChild() |
608 ->ToWebLocalFrame() | 608 ->ToWebLocalFrame() |
609 ->RequestExecuteScriptAndReturnValue( | 609 ->RequestExecuteScriptAndReturnValue( |
610 WebScriptSource(WebString( | 610 WebScriptSource(WebString( |
611 "var iframe = " | 611 "var iframe = " |
612 "window.top.document.getElementsByTagName('iframe')[0]; " | 612 "window.top.document.getElementsByTagName('iframe')[0]; " |
613 "window.top.document.body.removeChild(iframe); 'hello';")), | 613 "window.top.document.body.removeChild(iframe); 'hello';")), |
614 false, &callback_helper); | 614 false, &callback_helper); |
615 RunPendingTasks(); | 615 RunPendingTasks(); |
616 EXPECT_TRUE(callback_helper.DidComplete()); | 616 EXPECT_TRUE(callback_helper.DidComplete()); |
617 EXPECT_EQ(String(), callback_helper.StringValue()); | 617 EXPECT_EQ(String(), callback_helper.StringValue()); |
618 } | 618 } |
619 | 619 |
620 TEST_P(ParameterizedWebFrameTest, FormWithNullFrame) { | 620 TEST_P(ParameterizedWebFrameTest, FormWithNullFrame) { |
621 RegisterMockedHttpURLLoad("form.html"); | 621 RegisterMockedHttpURLLoad("form.html"); |
622 | 622 |
623 FrameTestHelpers::WebViewHelper web_view_helper; | 623 FrameTestHelpers::WebViewHelper web_view_helper; |
624 web_view_helper.InitializeAndLoad(base_url_ + "form.html"); | 624 web_view_helper.InitializeAndLoad(base_url_ + "form.html"); |
625 | 625 |
626 WebVector<WebFormElement> forms; | 626 WebVector<WebFormElement> forms; |
627 web_view_helper.WebView()->MainFrameImpl()->GetDocument().Forms(forms); | 627 web_view_helper.LocalMainFrame()->GetDocument().Forms(forms); |
628 web_view_helper.Reset(); | 628 web_view_helper.Reset(); |
629 | 629 |
630 EXPECT_EQ(forms.size(), 1U); | 630 EXPECT_EQ(forms.size(), 1U); |
631 | 631 |
632 // This test passes if this doesn't crash. | 632 // This test passes if this doesn't crash. |
633 WebSearchableFormData searchable_data_form(forms[0]); | 633 WebSearchableFormData searchable_data_form(forms[0]); |
634 } | 634 } |
635 | 635 |
636 TEST_P(ParameterizedWebFrameTest, ChromePageJavascript) { | 636 TEST_P(ParameterizedWebFrameTest, ChromePageJavascript) { |
637 RegisterMockedChromeURLLoad("history.html"); | 637 RegisterMockedChromeURLLoad("history.html"); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 | 1005 |
1006 TEST_P(ParameterizedWebFrameTest, DispatchMessageEventWithOriginCheck) { | 1006 TEST_P(ParameterizedWebFrameTest, DispatchMessageEventWithOriginCheck) { |
1007 RegisterMockedHttpURLLoad("postmessage_test.html"); | 1007 RegisterMockedHttpURLLoad("postmessage_test.html"); |
1008 | 1008 |
1009 FrameTestHelpers::WebViewHelper web_view_helper; | 1009 FrameTestHelpers::WebViewHelper web_view_helper; |
1010 web_view_helper.InitializeAndLoad(base_url_ + "postmessage_test.html"); | 1010 web_view_helper.InitializeAndLoad(base_url_ + "postmessage_test.html"); |
1011 | 1011 |
1012 // Send a message with the correct origin. | 1012 // Send a message with the correct origin. |
1013 WebSecurityOrigin correct_origin( | 1013 WebSecurityOrigin correct_origin( |
1014 WebSecurityOrigin::Create(ToKURL(base_url_))); | 1014 WebSecurityOrigin::Create(ToKURL(base_url_))); |
1015 WebDocument document = | 1015 WebDocument document = web_view_helper.LocalMainFrame()->GetDocument(); |
1016 web_view_helper.WebView()->MainFrameImpl()->GetDocument(); | |
1017 WebSerializedScriptValue data(WebSerializedScriptValue::CreateInvalid()); | 1016 WebSerializedScriptValue data(WebSerializedScriptValue::CreateInvalid()); |
1018 WebDOMMessageEvent message(data, "http://origin.com"); | 1017 WebDOMMessageEvent message(data, "http://origin.com"); |
1019 web_view_helper.WebView() | 1018 web_view_helper.WebView() |
1020 ->MainFrameImpl() | 1019 ->MainFrameImpl() |
1021 ->DispatchMessageEventWithOriginCheck(correct_origin, message); | 1020 ->DispatchMessageEventWithOriginCheck(correct_origin, message); |
1022 | 1021 |
1023 // Send another message with incorrect origin. | 1022 // Send another message with incorrect origin. |
1024 WebSecurityOrigin incorrect_origin( | 1023 WebSecurityOrigin incorrect_origin( |
1025 WebSecurityOrigin::Create(ToKURL(chrome_url_))); | 1024 WebSecurityOrigin::Create(ToKURL(chrome_url_))); |
1026 web_view_helper.WebView() | 1025 web_view_helper.WebView() |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 int viewport_width = 640; | 1173 int viewport_width = 640; |
1175 int viewport_height = 480; | 1174 int viewport_height = 480; |
1176 | 1175 |
1177 FrameTestHelpers::WebViewHelper web_view_helper; | 1176 FrameTestHelpers::WebViewHelper web_view_helper; |
1178 web_view_helper.InitializeAndLoad(base_url_ + "iframe_reload.html", nullptr, | 1177 web_view_helper.InitializeAndLoad(base_url_ + "iframe_reload.html", nullptr, |
1179 &client, nullptr, ConfigureAndroid); | 1178 &client, nullptr, ConfigureAndroid); |
1180 | 1179 |
1181 LocalFrame* main_frame = | 1180 LocalFrame* main_frame = |
1182 ToLocalFrame(web_view_helper.WebView()->GetPage()->MainFrame()); | 1181 ToLocalFrame(web_view_helper.WebView()->GetPage()->MainFrame()); |
1183 Document* document = main_frame->GetDocument(); | 1182 Document* document = main_frame->GetDocument(); |
1184 LocalFrameView* frame_view = | 1183 LocalFrameView* frame_view = web_view_helper.LocalMainFrame()->GetFrameView(); |
1185 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
1186 document->GetSettings()->SetTextAutosizingEnabled(true); | 1184 document->GetSettings()->SetTextAutosizingEnabled(true); |
1187 EXPECT_TRUE(document->GetSettings()->TextAutosizingEnabled()); | 1185 EXPECT_TRUE(document->GetSettings()->TextAutosizingEnabled()); |
1188 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); | 1186 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); |
1189 | 1187 |
1190 for (Frame* frame = main_frame; frame; frame = frame->Tree().TraverseNext()) { | 1188 for (Frame* frame = main_frame; frame; frame = frame->Tree().TraverseNext()) { |
1191 if (!frame->IsLocalFrame()) | 1189 if (!frame->IsLocalFrame()) |
1192 continue; | 1190 continue; |
1193 EXPECT_TRUE( | 1191 EXPECT_TRUE( |
1194 SetTextAutosizingMultiplier(ToLocalFrame(frame)->GetDocument(), 2)); | 1192 SetTextAutosizingMultiplier(ToLocalFrame(frame)->GetDocument(), 2)); |
1195 for (LayoutItem layout_item = | 1193 for (LayoutItem layout_item = |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 int viewport_width = 640; | 1759 int viewport_width = 640; |
1762 int viewport_height = 480; | 1760 int viewport_height = 480; |
1763 | 1761 |
1764 FrameTestHelpers::WebViewHelper web_view_helper; | 1762 FrameTestHelpers::WebViewHelper web_view_helper; |
1765 | 1763 |
1766 web_view_helper.InitializeAndLoad(base_url_ + "0-by-0.html", nullptr, &client, | 1764 web_view_helper.InitializeAndLoad(base_url_ + "0-by-0.html", nullptr, &client, |
1767 nullptr, ConfigureAndroid); | 1765 nullptr, ConfigureAndroid); |
1768 web_view_helper.WebView()->GetSettings()->SetForceZeroLayoutHeight(true); | 1766 web_view_helper.WebView()->GetSettings()->SetForceZeroLayoutHeight(true); |
1769 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); | 1767 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); |
1770 | 1768 |
1771 LocalFrame* frame = web_view_helper.WebView()->MainFrameImpl()->GetFrame(); | 1769 LocalFrame* frame = web_view_helper.LocalMainFrame()->GetFrame(); |
1772 Document* document = frame->GetDocument(); | 1770 Document* document = frame->GetDocument(); |
1773 EXPECT_EQ(viewport_height, document->documentElement()->clientHeight()); | 1771 EXPECT_EQ(viewport_height, document->documentElement()->clientHeight()); |
1774 EXPECT_EQ(viewport_width, document->documentElement()->clientWidth()); | 1772 EXPECT_EQ(viewport_width, document->documentElement()->clientWidth()); |
1775 } | 1773 } |
1776 | 1774 |
1777 TEST_P(ParameterizedWebFrameTest, | 1775 TEST_P(ParameterizedWebFrameTest, |
1778 SetForceZeroLayoutHeightWorksWithWrapContentMode) { | 1776 SetForceZeroLayoutHeightWorksWithWrapContentMode) { |
1779 RegisterMockedHttpURLLoad("0-by-0.html"); | 1777 RegisterMockedHttpURLLoad("0-by-0.html"); |
1780 | 1778 |
1781 FixedLayoutTestWebViewClient client; | 1779 FixedLayoutTestWebViewClient client; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1837 ->GetLayoutSize() | 1835 ->GetLayoutSize() |
1838 .Width()); | 1836 .Width()); |
1839 EXPECT_EQ(0, web_view_helper.WebView() | 1837 EXPECT_EQ(0, web_view_helper.WebView() |
1840 ->MainFrameImpl() | 1838 ->MainFrameImpl() |
1841 ->GetFrameView() | 1839 ->GetFrameView() |
1842 ->GetLayoutSize() | 1840 ->GetLayoutSize() |
1843 .Height()); | 1841 .Height()); |
1844 EXPECT_EQ(viewport_width, scroll_container->Size().Width()); | 1842 EXPECT_EQ(viewport_width, scroll_container->Size().Width()); |
1845 EXPECT_EQ(viewport_height, scroll_container->Size().Height()); | 1843 EXPECT_EQ(viewport_height, scroll_container->Size().Height()); |
1846 | 1844 |
1847 LocalFrame* frame = web_view_helper.WebView()->MainFrameImpl()->GetFrame(); | 1845 LocalFrame* frame = web_view_helper.LocalMainFrame()->GetFrame(); |
1848 VisualViewport& visual_viewport = frame->GetPage()->GetVisualViewport(); | 1846 VisualViewport& visual_viewport = frame->GetPage()->GetVisualViewport(); |
1849 EXPECT_EQ(viewport_height, visual_viewport.ContainerLayer()->Size().Height()); | 1847 EXPECT_EQ(viewport_height, visual_viewport.ContainerLayer()->Size().Height()); |
1850 EXPECT_TRUE( | 1848 EXPECT_TRUE( |
1851 visual_viewport.ContainerLayer()->PlatformLayer()->MasksToBounds()); | 1849 visual_viewport.ContainerLayer()->PlatformLayer()->MasksToBounds()); |
1852 EXPECT_FALSE(scroll_container->PlatformLayer()->MasksToBounds()); | 1850 EXPECT_FALSE(scroll_container->PlatformLayer()->MasksToBounds()); |
1853 } | 1851 } |
1854 | 1852 |
1855 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeight) { | 1853 TEST_P(ParameterizedWebFrameTest, SetForceZeroLayoutHeight) { |
1856 RegisterMockedHttpURLLoad("200-by-300.html"); | 1854 RegisterMockedHttpURLLoad("200-by-300.html"); |
1857 | 1855 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1961 // set view height to zero so that if the height of the view is not | 1959 // set view height to zero so that if the height of the view is not |
1962 // successfully updated during later resizes touch events will fail | 1960 // successfully updated during later resizes touch events will fail |
1963 // (as in not hit content included in the view) | 1961 // (as in not hit content included in the view) |
1964 web_view_helper.Resize(WebSize(viewport_width, 0)); | 1962 web_view_helper.Resize(WebSize(viewport_width, 0)); |
1965 | 1963 |
1966 web_view_helper.WebView()->GetSettings()->SetForceZeroLayoutHeight(true); | 1964 web_view_helper.WebView()->GetSettings()->SetForceZeroLayoutHeight(true); |
1967 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); | 1965 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); |
1968 | 1966 |
1969 IntPoint hit_point = IntPoint(30, 30); // button size is 100x100 | 1967 IntPoint hit_point = IntPoint(30, 30); // button size is 100x100 |
1970 | 1968 |
1971 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 1969 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
1972 Document* document = frame->GetFrame()->GetDocument(); | 1970 Document* document = frame->GetFrame()->GetDocument(); |
1973 Element* element = document->getElementById("tap_button"); | 1971 Element* element = document->getElementById("tap_button"); |
1974 | 1972 |
1975 ASSERT_NE(nullptr, element); | 1973 ASSERT_NE(nullptr, element); |
1976 EXPECT_EQ(String("oldValue"), element->innerText()); | 1974 EXPECT_EQ(String("oldValue"), element->innerText()); |
1977 | 1975 |
1978 WebGestureEvent gesture_event(WebInputEvent::kGestureTap, | 1976 WebGestureEvent gesture_event(WebInputEvent::kGestureTap, |
1979 WebInputEvent::kNoModifiers, | 1977 WebInputEvent::kNoModifiers, |
1980 WebInputEvent::kTimeStampForTesting); | 1978 WebInputEvent::kTimeStampForTesting); |
1981 gesture_event.SetFrameScale(1); | 1979 gesture_event.SetFrameScale(1); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2280 client.screen_info_.device_scale_factor = 1; | 2278 client.screen_info_.device_scale_factor = 1; |
2281 int viewport_width = 640; | 2279 int viewport_width = 640; |
2282 int viewport_height = 480; | 2280 int viewport_height = 480; |
2283 | 2281 |
2284 FrameTestHelpers::WebViewHelper web_view_helper; | 2282 FrameTestHelpers::WebViewHelper web_view_helper; |
2285 web_view_helper.Initialize(nullptr, &client); | 2283 web_view_helper.Initialize(nullptr, &client); |
2286 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), | 2284 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), |
2287 base_url_ + "body-overflow-hidden.html"); | 2285 base_url_ + "body-overflow-hidden.html"); |
2288 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); | 2286 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); |
2289 | 2287 |
2290 LocalFrameView* view = | 2288 LocalFrameView* view = web_view_helper.LocalMainFrame()->GetFrameView(); |
2291 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
2292 EXPECT_FALSE(view->UserInputScrollable(kVerticalScrollbar)); | 2289 EXPECT_FALSE(view->UserInputScrollable(kVerticalScrollbar)); |
2293 EXPECT_FALSE(view->UserInputScrollable(kHorizontalScrollbar)); | 2290 EXPECT_FALSE(view->UserInputScrollable(kHorizontalScrollbar)); |
2294 } | 2291 } |
2295 | 2292 |
2296 TEST_P(ParameterizedWebFrameTest, | 2293 TEST_P(ParameterizedWebFrameTest, |
2297 OverflowHiddenDisablesScrollingWithSetCanHaveScrollbars) { | 2294 OverflowHiddenDisablesScrollingWithSetCanHaveScrollbars) { |
2298 RegisterMockedHttpURLLoad("body-overflow-hidden-short.html"); | 2295 RegisterMockedHttpURLLoad("body-overflow-hidden-short.html"); |
2299 | 2296 |
2300 FixedLayoutTestWebViewClient client; | 2297 FixedLayoutTestWebViewClient client; |
2301 client.screen_info_.device_scale_factor = 1; | 2298 client.screen_info_.device_scale_factor = 1; |
2302 int viewport_width = 640; | 2299 int viewport_width = 640; |
2303 int viewport_height = 480; | 2300 int viewport_height = 480; |
2304 | 2301 |
2305 FrameTestHelpers::WebViewHelper web_view_helper; | 2302 FrameTestHelpers::WebViewHelper web_view_helper; |
2306 web_view_helper.Initialize(nullptr, &client); | 2303 web_view_helper.Initialize(nullptr, &client); |
2307 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), | 2304 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), |
2308 base_url_ + "body-overflow-hidden-short.html"); | 2305 base_url_ + "body-overflow-hidden-short.html"); |
2309 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); | 2306 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); |
2310 | 2307 |
2311 LocalFrameView* view = | 2308 LocalFrameView* view = web_view_helper.LocalMainFrame()->GetFrameView(); |
2312 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
2313 EXPECT_FALSE(view->UserInputScrollable(kVerticalScrollbar)); | 2309 EXPECT_FALSE(view->UserInputScrollable(kVerticalScrollbar)); |
2314 EXPECT_FALSE(view->UserInputScrollable(kHorizontalScrollbar)); | 2310 EXPECT_FALSE(view->UserInputScrollable(kHorizontalScrollbar)); |
2315 | 2311 |
2316 web_view_helper.WebView()->MainFrameImpl()->SetCanHaveScrollbars(true); | 2312 web_view_helper.LocalMainFrame()->SetCanHaveScrollbars(true); |
2317 EXPECT_FALSE(view->UserInputScrollable(kVerticalScrollbar)); | 2313 EXPECT_FALSE(view->UserInputScrollable(kVerticalScrollbar)); |
2318 EXPECT_FALSE(view->UserInputScrollable(kHorizontalScrollbar)); | 2314 EXPECT_FALSE(view->UserInputScrollable(kHorizontalScrollbar)); |
2319 } | 2315 } |
2320 | 2316 |
2321 TEST_F(WebFrameTest, IgnoreOverflowHiddenQuirk) { | 2317 TEST_F(WebFrameTest, IgnoreOverflowHiddenQuirk) { |
2322 RegisterMockedHttpURLLoad("body-overflow-hidden.html"); | 2318 RegisterMockedHttpURLLoad("body-overflow-hidden.html"); |
2323 | 2319 |
2324 FixedLayoutTestWebViewClient client; | 2320 FixedLayoutTestWebViewClient client; |
2325 client.screen_info_.device_scale_factor = 1; | 2321 client.screen_info_.device_scale_factor = 1; |
2326 int viewport_width = 640; | 2322 int viewport_width = 640; |
2327 int viewport_height = 480; | 2323 int viewport_height = 480; |
2328 | 2324 |
2329 FrameTestHelpers::WebViewHelper web_view_helper; | 2325 FrameTestHelpers::WebViewHelper web_view_helper; |
2330 web_view_helper.Initialize(nullptr, &client); | 2326 web_view_helper.Initialize(nullptr, &client); |
2331 web_view_helper.WebView() | 2327 web_view_helper.WebView() |
2332 ->GetSettings() | 2328 ->GetSettings() |
2333 ->SetIgnoreMainFrameOverflowHiddenQuirk(true); | 2329 ->SetIgnoreMainFrameOverflowHiddenQuirk(true); |
2334 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), | 2330 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), |
2335 base_url_ + "body-overflow-hidden.html"); | 2331 base_url_ + "body-overflow-hidden.html"); |
2336 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); | 2332 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); |
2337 | 2333 |
2338 LocalFrameView* view = | 2334 LocalFrameView* view = web_view_helper.LocalMainFrame()->GetFrameView(); |
2339 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
2340 EXPECT_TRUE(view->UserInputScrollable(kVerticalScrollbar)); | 2335 EXPECT_TRUE(view->UserInputScrollable(kVerticalScrollbar)); |
2341 } | 2336 } |
2342 | 2337 |
2343 TEST_P(ParameterizedWebFrameTest, NonZeroValuesNoQuirk) { | 2338 TEST_P(ParameterizedWebFrameTest, NonZeroValuesNoQuirk) { |
2344 RegisterMockedHttpURLLoad("viewport-nonzero-values.html"); | 2339 RegisterMockedHttpURLLoad("viewport-nonzero-values.html"); |
2345 | 2340 |
2346 FixedLayoutTestWebViewClient client; | 2341 FixedLayoutTestWebViewClient client; |
2347 client.screen_info_.device_scale_factor = 1; | 2342 client.screen_info_.device_scale_factor = 1; |
2348 int viewport_width = 640; | 2343 int viewport_width = 640; |
2349 int viewport_height = 480; | 2344 int viewport_height = 480; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2387 // Small viewport to ensure there are always scrollbars. | 2382 // Small viewport to ensure there are always scrollbars. |
2388 int viewport_width = 64; | 2383 int viewport_width = 64; |
2389 int viewport_height = 48; | 2384 int viewport_height = 48; |
2390 | 2385 |
2391 FrameTestHelpers::WebViewHelper web_view_helper; | 2386 FrameTestHelpers::WebViewHelper web_view_helper; |
2392 web_view_helper.InitializeAndLoad(base_url_ + "fixed_layout.html", nullptr, | 2387 web_view_helper.InitializeAndLoad(base_url_ + "fixed_layout.html", nullptr, |
2393 &client, nullptr, ConfigureAndroid); | 2388 &client, nullptr, ConfigureAndroid); |
2394 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); | 2389 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); |
2395 | 2390 |
2396 int prev_layout_count = | 2391 int prev_layout_count = |
2397 web_view_helper.WebView()->MainFrameImpl()->GetFrameView()->LayoutCount(); | 2392 web_view_helper.LocalMainFrame()->GetFrameView()->LayoutCount(); |
2398 web_view_helper.WebView()->SetPageScaleFactor(3); | 2393 web_view_helper.WebView()->SetPageScaleFactor(3); |
2399 EXPECT_FALSE(web_view_helper.WebView() | 2394 EXPECT_FALSE(web_view_helper.WebView() |
2400 ->MainFrameImpl() | 2395 ->MainFrameImpl() |
2401 ->GetFrameView() | 2396 ->GetFrameView() |
2402 ->NeedsLayout()); | 2397 ->NeedsLayout()); |
2403 EXPECT_EQ(prev_layout_count, web_view_helper.WebView() | 2398 EXPECT_EQ(prev_layout_count, web_view_helper.WebView() |
2404 ->MainFrameImpl() | 2399 ->MainFrameImpl() |
2405 ->GetFrameView() | 2400 ->GetFrameView() |
2406 ->LayoutCount()); | 2401 ->LayoutCount()); |
2407 } | 2402 } |
2408 | 2403 |
2409 TEST_P(ParameterizedWebFrameTest, | 2404 TEST_P(ParameterizedWebFrameTest, |
2410 setPageScaleFactorWithOverlayScrollbarsDoesNotLayout) { | 2405 setPageScaleFactorWithOverlayScrollbarsDoesNotLayout) { |
2411 RegisterMockedHttpURLLoad("fixed_layout.html"); | 2406 RegisterMockedHttpURLLoad("fixed_layout.html"); |
2412 | 2407 |
2413 FixedLayoutTestWebViewClient client; | 2408 FixedLayoutTestWebViewClient client; |
2414 client.screen_info_.device_scale_factor = 1; | 2409 client.screen_info_.device_scale_factor = 1; |
2415 int viewport_width = 640; | 2410 int viewport_width = 640; |
2416 int viewport_height = 480; | 2411 int viewport_height = 480; |
2417 | 2412 |
2418 FrameTestHelpers::WebViewHelper web_view_helper; | 2413 FrameTestHelpers::WebViewHelper web_view_helper; |
2419 web_view_helper.InitializeAndLoad(base_url_ + "fixed_layout.html", nullptr, | 2414 web_view_helper.InitializeAndLoad(base_url_ + "fixed_layout.html", nullptr, |
2420 &client, nullptr, ConfigureAndroid); | 2415 &client, nullptr, ConfigureAndroid); |
2421 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); | 2416 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); |
2422 | 2417 |
2423 int prev_layout_count = | 2418 int prev_layout_count = |
2424 web_view_helper.WebView()->MainFrameImpl()->GetFrameView()->LayoutCount(); | 2419 web_view_helper.LocalMainFrame()->GetFrameView()->LayoutCount(); |
2425 web_view_helper.WebView()->SetPageScaleFactor(30); | 2420 web_view_helper.WebView()->SetPageScaleFactor(30); |
2426 EXPECT_FALSE(web_view_helper.WebView() | 2421 EXPECT_FALSE(web_view_helper.WebView() |
2427 ->MainFrameImpl() | 2422 ->MainFrameImpl() |
2428 ->GetFrameView() | 2423 ->GetFrameView() |
2429 ->NeedsLayout()); | 2424 ->NeedsLayout()); |
2430 EXPECT_EQ(prev_layout_count, web_view_helper.WebView() | 2425 EXPECT_EQ(prev_layout_count, web_view_helper.WebView() |
2431 ->MainFrameImpl() | 2426 ->MainFrameImpl() |
2432 ->GetFrameView() | 2427 ->GetFrameView() |
2433 ->LayoutCount()); | 2428 ->LayoutCount()); |
2434 } | 2429 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2487 client.screen_info_.device_scale_factor = 1; | 2482 client.screen_info_.device_scale_factor = 1; |
2488 // Small viewport to ensure there are always scrollbars. | 2483 // Small viewport to ensure there are always scrollbars. |
2489 int viewport_width = 64; | 2484 int viewport_width = 64; |
2490 int viewport_height = 48; | 2485 int viewport_height = 48; |
2491 | 2486 |
2492 FrameTestHelpers::WebViewHelper web_view_helper; | 2487 FrameTestHelpers::WebViewHelper web_view_helper; |
2493 web_view_helper.InitializeAndLoad(base_url_ + "large-div.html", nullptr, | 2488 web_view_helper.InitializeAndLoad(base_url_ + "large-div.html", nullptr, |
2494 &client, nullptr, ConfigureAndroid); | 2489 &client, nullptr, ConfigureAndroid); |
2495 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); | 2490 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); |
2496 | 2491 |
2497 LocalFrameView* view = | 2492 LocalFrameView* view = web_view_helper.LocalMainFrame()->GetFrameView(); |
2498 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
2499 int viewport_width_minus_scrollbar = viewport_width; | 2493 int viewport_width_minus_scrollbar = viewport_width; |
2500 int viewport_height_minus_scrollbar = viewport_height; | 2494 int viewport_height_minus_scrollbar = viewport_height; |
2501 | 2495 |
2502 if (view->VerticalScrollbar() && | 2496 if (view->VerticalScrollbar() && |
2503 !view->VerticalScrollbar()->IsOverlayScrollbar()) | 2497 !view->VerticalScrollbar()->IsOverlayScrollbar()) |
2504 viewport_width_minus_scrollbar -= 15; | 2498 viewport_width_minus_scrollbar -= 15; |
2505 | 2499 |
2506 if (view->HorizontalScrollbar() && | 2500 if (view->HorizontalScrollbar() && |
2507 !view->HorizontalScrollbar()->IsOverlayScrollbar()) | 2501 !view->HorizontalScrollbar()->IsOverlayScrollbar()) |
2508 viewport_height_minus_scrollbar -= 15; | 2502 viewport_height_minus_scrollbar -= 15; |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2955 RegisterMockedHttpURLLoad("viewport-and-media.html"); | 2949 RegisterMockedHttpURLLoad("viewport-and-media.html"); |
2956 | 2950 |
2957 FixedLayoutTestWebViewClient client; | 2951 FixedLayoutTestWebViewClient client; |
2958 FrameTestHelpers::WebViewHelper web_view_helper; | 2952 FrameTestHelpers::WebViewHelper web_view_helper; |
2959 web_view_helper.Initialize(nullptr, &client, nullptr, ConfigureAndroid); | 2953 web_view_helper.Initialize(nullptr, &client, nullptr, ConfigureAndroid); |
2960 web_view_helper.Resize(WebSize(640, 480)); | 2954 web_view_helper.Resize(WebSize(640, 480)); |
2961 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), | 2955 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), |
2962 base_url_ + "viewport-and-media.html"); | 2956 base_url_ + "viewport-and-media.html"); |
2963 | 2957 |
2964 Document* document = | 2958 Document* document = |
2965 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->GetDocument(); | 2959 web_view_helper.LocalMainFrame()->GetFrame()->GetDocument(); |
2966 EXPECT_EQ(2000, web_view_helper.WebView() | 2960 EXPECT_EQ(2000, web_view_helper.WebView() |
2967 ->MainFrameImpl() | 2961 ->MainFrameImpl() |
2968 ->GetFrameView() | 2962 ->GetFrameView() |
2969 ->GetLayoutSize() | 2963 ->GetLayoutSize() |
2970 .Width()); | 2964 .Width()); |
2971 | 2965 |
2972 // The styleForElementCount() should match the number of elements for a single | 2966 // The styleForElementCount() should match the number of elements for a single |
2973 // pass of computed styles construction for the document. | 2967 // pass of computed styles construction for the document. |
2974 EXPECT_EQ(10u, document->GetStyleEngine().StyleForElementCount()); | 2968 EXPECT_EQ(10u, document->GetStyleEngine().StyleForElementCount()); |
2975 EXPECT_EQ(Color(0, 128, 0), | 2969 EXPECT_EQ(Color(0, 128, 0), |
2976 document->body()->GetComputedStyle()->VisitedDependentColor( | 2970 document->body()->GetComputedStyle()->VisitedDependentColor( |
2977 CSSPropertyColor)); | 2971 CSSPropertyColor)); |
2978 } | 2972 } |
2979 | 2973 |
2980 TEST_P(ParameterizedWebFrameTest, AtViewportWithViewportLengths) { | 2974 TEST_P(ParameterizedWebFrameTest, AtViewportWithViewportLengths) { |
2981 RegisterMockedHttpURLLoad("viewport-lengths.html"); | 2975 RegisterMockedHttpURLLoad("viewport-lengths.html"); |
2982 | 2976 |
2983 FixedLayoutTestWebViewClient client; | 2977 FixedLayoutTestWebViewClient client; |
2984 FrameTestHelpers::WebViewHelper web_view_helper; | 2978 FrameTestHelpers::WebViewHelper web_view_helper; |
2985 web_view_helper.Initialize(nullptr, &client, nullptr, ConfigureAndroid); | 2979 web_view_helper.Initialize(nullptr, &client, nullptr, ConfigureAndroid); |
2986 web_view_helper.Resize(WebSize(800, 600)); | 2980 web_view_helper.Resize(WebSize(800, 600)); |
2987 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), | 2981 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), |
2988 base_url_ + "viewport-lengths.html"); | 2982 base_url_ + "viewport-lengths.html"); |
2989 | 2983 |
2990 LocalFrameView* view = | 2984 LocalFrameView* view = web_view_helper.LocalMainFrame()->GetFrameView(); |
2991 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
2992 EXPECT_EQ(400, view->GetLayoutSize().Width()); | 2985 EXPECT_EQ(400, view->GetLayoutSize().Width()); |
2993 EXPECT_EQ(300, view->GetLayoutSize().Height()); | 2986 EXPECT_EQ(300, view->GetLayoutSize().Height()); |
2994 | 2987 |
2995 web_view_helper.Resize(WebSize(1000, 400)); | 2988 web_view_helper.Resize(WebSize(1000, 400)); |
2996 | 2989 |
2997 EXPECT_EQ(500, view->GetLayoutSize().Width()); | 2990 EXPECT_EQ(500, view->GetLayoutSize().Width()); |
2998 EXPECT_EQ(200, view->GetLayoutSize().Height()); | 2991 EXPECT_EQ(200, view->GetLayoutSize().Height()); |
2999 } | 2992 } |
3000 | 2993 |
3001 class WebFrameResizeTest : public ParameterizedWebFrameTest { | 2994 class WebFrameResizeTest : public ParameterizedWebFrameTest { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3136 FixedLayoutTestWebViewClient client; | 3129 FixedLayoutTestWebViewClient client; |
3137 client.screen_info_.device_scale_factor = 1; | 3130 client.screen_info_.device_scale_factor = 1; |
3138 int viewport_width = 640; | 3131 int viewport_width = 640; |
3139 int viewport_height = 480; | 3132 int viewport_height = 480; |
3140 | 3133 |
3141 FrameTestHelpers::WebViewHelper web_view_helper; | 3134 FrameTestHelpers::WebViewHelper web_view_helper; |
3142 web_view_helper.InitializeAndLoad(base_url_ + "fixed_layout.html", nullptr, | 3135 web_view_helper.InitializeAndLoad(base_url_ + "fixed_layout.html", nullptr, |
3143 &client, nullptr, ConfigureAndroid); | 3136 &client, nullptr, ConfigureAndroid); |
3144 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); | 3137 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); |
3145 | 3138 |
3146 LocalFrameView* view = | 3139 LocalFrameView* view = web_view_helper.LocalMainFrame()->GetFrameView(); |
3147 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
3148 EXPECT_EQ(view->ScrollSize(kHorizontalScrollbar), | 3140 EXPECT_EQ(view->ScrollSize(kHorizontalScrollbar), |
3149 view->ContentsSize().Width() - view->VisibleContentRect().Width()); | 3141 view->ContentsSize().Width() - view->VisibleContentRect().Width()); |
3150 EXPECT_EQ( | 3142 EXPECT_EQ( |
3151 view->ScrollSize(kVerticalScrollbar), | 3143 view->ScrollSize(kVerticalScrollbar), |
3152 view->ContentsSize().Height() - view->VisibleContentRect().Height()); | 3144 view->ContentsSize().Height() - view->VisibleContentRect().Height()); |
3153 | 3145 |
3154 web_view_helper.WebView()->SetPageScaleFactor(10); | 3146 web_view_helper.WebView()->SetPageScaleFactor(10); |
3155 | 3147 |
3156 EXPECT_EQ(view->ScrollSize(kHorizontalScrollbar), | 3148 EXPECT_EQ(view->ScrollSize(kHorizontalScrollbar), |
3157 view->ContentsSize().Width() - view->VisibleContentRect().Width()); | 3149 view->ContentsSize().Width() - view->VisibleContentRect().Width()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3207 fake_compositing_web_view_client = | 3199 fake_compositing_web_view_client = |
3208 WTF::MakeUnique<FakeCompositingWebViewClient>(); | 3200 WTF::MakeUnique<FakeCompositingWebViewClient>(); |
3209 FrameTestHelpers::WebViewHelper web_view_helper; | 3201 FrameTestHelpers::WebViewHelper web_view_helper; |
3210 web_view_helper.Initialize(nullptr, fake_compositing_web_view_client.get(), | 3202 web_view_helper.Initialize(nullptr, fake_compositing_web_view_client.get(), |
3211 nullptr, &ConfigureCompositingWebView); | 3203 nullptr, &ConfigureCompositingWebView); |
3212 | 3204 |
3213 web_view_helper.Resize(WebSize(view_width, view_height)); | 3205 web_view_helper.Resize(WebSize(view_width, view_height)); |
3214 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), | 3206 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), |
3215 base_url_ + "large-div.html"); | 3207 base_url_ + "large-div.html"); |
3216 | 3208 |
3217 LocalFrameView* view = | 3209 LocalFrameView* view = web_view_helper.LocalMainFrame()->GetFrameView(); |
3218 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
3219 EXPECT_TRUE( | 3210 EXPECT_TRUE( |
3220 view->GetLayoutViewItem().Compositor()->LayerForHorizontalScrollbar()); | 3211 view->GetLayoutViewItem().Compositor()->LayerForHorizontalScrollbar()); |
3221 EXPECT_TRUE( | 3212 EXPECT_TRUE( |
3222 view->GetLayoutViewItem().Compositor()->LayerForVerticalScrollbar()); | 3213 view->GetLayoutViewItem().Compositor()->LayerForVerticalScrollbar()); |
3223 | 3214 |
3224 web_view_helper.Resize(WebSize(view_width * 10, view_height * 10)); | 3215 web_view_helper.Resize(WebSize(view_width * 10, view_height * 10)); |
3225 EXPECT_FALSE( | 3216 EXPECT_FALSE( |
3226 view->GetLayoutViewItem().Compositor()->LayerForHorizontalScrollbar()); | 3217 view->GetLayoutViewItem().Compositor()->LayerForHorizontalScrollbar()); |
3227 EXPECT_FALSE( | 3218 EXPECT_FALSE( |
3228 view->GetLayoutViewItem().Compositor()->LayerForVerticalScrollbar()); | 3219 view->GetLayoutViewItem().Compositor()->LayerForVerticalScrollbar()); |
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4153 EXPECT_EQ(2ul, ix); | 4144 EXPECT_EQ(2ul, ix); |
4154 } | 4145 } |
4155 | 4146 |
4156 TEST_P(ParameterizedWebFrameTest, FirstRectForCharacterRangeWithPinchZoom) { | 4147 TEST_P(ParameterizedWebFrameTest, FirstRectForCharacterRangeWithPinchZoom) { |
4157 RegisterMockedHttpURLLoad("textbox.html"); | 4148 RegisterMockedHttpURLLoad("textbox.html"); |
4158 | 4149 |
4159 FrameTestHelpers::WebViewHelper web_view_helper; | 4150 FrameTestHelpers::WebViewHelper web_view_helper; |
4160 web_view_helper.InitializeAndLoad(base_url_ + "textbox.html"); | 4151 web_view_helper.InitializeAndLoad(base_url_ + "textbox.html"); |
4161 web_view_helper.Resize(WebSize(640, 480)); | 4152 web_view_helper.Resize(WebSize(640, 480)); |
4162 | 4153 |
4163 WebLocalFrame* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 4154 WebLocalFrame* main_frame = web_view_helper.LocalMainFrame(); |
4164 main_frame->ExecuteScript(WebScriptSource("selectRange();")); | 4155 main_frame->ExecuteScript(WebScriptSource("selectRange();")); |
4165 | 4156 |
4166 WebRect old_rect; | 4157 WebRect old_rect; |
4167 main_frame->FirstRectForCharacterRange(0, 5, old_rect); | 4158 main_frame->FirstRectForCharacterRange(0, 5, old_rect); |
4168 | 4159 |
4169 WebFloatPoint visual_offset(100, 130); | 4160 WebFloatPoint visual_offset(100, 130); |
4170 float scale = 2; | 4161 float scale = 2; |
4171 web_view_helper.WebView()->SetPageScaleFactor(scale); | 4162 web_view_helper.WebView()->SetPageScaleFactor(scale); |
4172 web_view_helper.WebView()->SetVisualViewportOffset(visual_offset); | 4163 web_view_helper.WebView()->SetVisualViewportOffset(visual_offset); |
4173 | 4164 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4274 RegisterMockedHttpURLLoad("fixed_layout.html"); | 4265 RegisterMockedHttpURLLoad("fixed_layout.html"); |
4275 | 4266 |
4276 FrameTestHelpers::WebViewHelper web_view_helper; | 4267 FrameTestHelpers::WebViewHelper web_view_helper; |
4277 web_view_helper.Initialize(); | 4268 web_view_helper.Initialize(); |
4278 WebURLRequest request(ToKURL(base_url_ + "fixed_layout.html")); | 4269 WebURLRequest request(ToKURL(base_url_ + "fixed_layout.html")); |
4279 web_view_helper.WebView()->MainFrameImpl()->LoadRequest(request); | 4270 web_view_helper.WebView()->MainFrameImpl()->LoadRequest(request); |
4280 // start reload before first request is delivered. | 4271 // start reload before first request is delivered. |
4281 FrameTestHelpers::ReloadFrameBypassingCache( | 4272 FrameTestHelpers::ReloadFrameBypassingCache( |
4282 web_view_helper.WebView()->MainFrameImpl()); | 4273 web_view_helper.WebView()->MainFrameImpl()); |
4283 | 4274 |
4284 WebDataSource* data_source = | 4275 WebDataSource* data_source = web_view_helper.LocalMainFrame()->DataSource(); |
4285 web_view_helper.WebView()->MainFrameImpl()->DataSource(); | |
4286 ASSERT_TRUE(data_source); | 4276 ASSERT_TRUE(data_source); |
4287 EXPECT_EQ(ToKURL(base_url_ + "fixed_layout.html"), | 4277 EXPECT_EQ(ToKURL(base_url_ + "fixed_layout.html"), |
4288 KURL(data_source->GetRequest().Url())); | 4278 KURL(data_source->GetRequest().Url())); |
4289 } | 4279 } |
4290 | 4280 |
4291 TEST_P(ParameterizedWebFrameTest, AppendRedirects) { | 4281 TEST_P(ParameterizedWebFrameTest, AppendRedirects) { |
4292 const std::string first_url = "about:blank"; | 4282 const std::string first_url = "about:blank"; |
4293 const std::string second_url = "http://internal.test"; | 4283 const std::string second_url = "http://internal.test"; |
4294 | 4284 |
4295 FrameTestHelpers::WebViewHelper web_view_helper; | 4285 FrameTestHelpers::WebViewHelper web_view_helper; |
4296 web_view_helper.InitializeAndLoad(first_url); | 4286 web_view_helper.InitializeAndLoad(first_url); |
4297 | 4287 |
4298 WebDataSource* data_source = | 4288 WebDataSource* data_source = web_view_helper.LocalMainFrame()->DataSource(); |
4299 web_view_helper.WebView()->MainFrameImpl()->DataSource(); | |
4300 ASSERT_TRUE(data_source); | 4289 ASSERT_TRUE(data_source); |
4301 data_source->AppendRedirect(ToKURL(second_url)); | 4290 data_source->AppendRedirect(ToKURL(second_url)); |
4302 | 4291 |
4303 WebVector<WebURL> redirects; | 4292 WebVector<WebURL> redirects; |
4304 data_source->RedirectChain(redirects); | 4293 data_source->RedirectChain(redirects); |
4305 ASSERT_EQ(2U, redirects.size()); | 4294 ASSERT_EQ(2U, redirects.size()); |
4306 EXPECT_EQ(ToKURL(first_url), KURL(redirects[0])); | 4295 EXPECT_EQ(ToKURL(first_url), KURL(redirects[0])); |
4307 EXPECT_EQ(ToKURL(second_url), KURL(redirects[1])); | 4296 EXPECT_EQ(ToKURL(second_url), KURL(redirects[1])); |
4308 } | 4297 } |
4309 | 4298 |
4310 TEST_P(ParameterizedWebFrameTest, IframeRedirect) { | 4299 TEST_P(ParameterizedWebFrameTest, IframeRedirect) { |
4311 RegisterMockedHttpURLLoad("iframe_redirect.html"); | 4300 RegisterMockedHttpURLLoad("iframe_redirect.html"); |
4312 RegisterMockedHttpURLLoad("visible_iframe.html"); | 4301 RegisterMockedHttpURLLoad("visible_iframe.html"); |
4313 | 4302 |
4314 FrameTestHelpers::WebViewHelper web_view_helper; | 4303 FrameTestHelpers::WebViewHelper web_view_helper; |
4315 web_view_helper.InitializeAndLoad(base_url_ + "iframe_redirect.html"); | 4304 web_view_helper.InitializeAndLoad(base_url_ + "iframe_redirect.html"); |
4316 // Pump pending requests one more time. The test page loads script that | 4305 // Pump pending requests one more time. The test page loads script that |
4317 // navigates. | 4306 // navigates. |
4318 FrameTestHelpers::PumpPendingRequestsForFrameToLoad( | 4307 FrameTestHelpers::PumpPendingRequestsForFrameToLoad( |
4319 web_view_helper.WebView()->MainFrame()); | 4308 web_view_helper.WebView()->MainFrame()); |
4320 | 4309 |
4321 WebFrame* iframe = | 4310 WebFrame* iframe = web_view_helper.LocalMainFrame()->FindFrameByName( |
4322 web_view_helper.WebView()->MainFrameImpl()->FindFrameByName( | 4311 WebString::FromUTF8("ifr")); |
4323 WebString::FromUTF8("ifr")); | |
4324 ASSERT_TRUE(iframe && iframe->IsWebLocalFrame()); | 4312 ASSERT_TRUE(iframe && iframe->IsWebLocalFrame()); |
4325 WebDataSource* iframe_data_source = iframe->ToWebLocalFrame()->DataSource(); | 4313 WebDataSource* iframe_data_source = iframe->ToWebLocalFrame()->DataSource(); |
4326 ASSERT_TRUE(iframe_data_source); | 4314 ASSERT_TRUE(iframe_data_source); |
4327 WebVector<WebURL> redirects; | 4315 WebVector<WebURL> redirects; |
4328 iframe_data_source->RedirectChain(redirects); | 4316 iframe_data_source->RedirectChain(redirects); |
4329 ASSERT_EQ(2U, redirects.size()); | 4317 ASSERT_EQ(2U, redirects.size()); |
4330 EXPECT_EQ(ToKURL("about:blank"), KURL(redirects[0])); | 4318 EXPECT_EQ(ToKURL("about:blank"), KURL(redirects[0])); |
4331 EXPECT_EQ(ToKURL("http://internal.test/visible_iframe.html"), | 4319 EXPECT_EQ(ToKURL("http://internal.test/visible_iframe.html"), |
4332 KURL(redirects[1])); | 4320 KURL(redirects[1])); |
4333 } | 4321 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4481 Vector<std::unique_ptr<ContextLifetimeTestWebFrameClient::Notification>> | 4469 Vector<std::unique_ptr<ContextLifetimeTestWebFrameClient::Notification>> |
4482 create_notifications; | 4470 create_notifications; |
4483 Vector<std::unique_ptr<ContextLifetimeTestWebFrameClient::Notification>> | 4471 Vector<std::unique_ptr<ContextLifetimeTestWebFrameClient::Notification>> |
4484 release_notifications; | 4472 release_notifications; |
4485 ContextLifetimeTestWebFrameClient web_frame_client(create_notifications, | 4473 ContextLifetimeTestWebFrameClient web_frame_client(create_notifications, |
4486 release_notifications); | 4474 release_notifications); |
4487 FrameTestHelpers::WebViewHelper web_view_helper; | 4475 FrameTestHelpers::WebViewHelper web_view_helper; |
4488 web_view_helper.InitializeAndLoad( | 4476 web_view_helper.InitializeAndLoad( |
4489 base_url_ + "context_notifications_test.html", &web_frame_client); | 4477 base_url_ + "context_notifications_test.html", &web_frame_client); |
4490 | 4478 |
4491 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 4479 WebLocalFrameBase* main_frame = web_view_helper.LocalMainFrame(); |
4492 WebFrame* child_frame = main_frame->FirstChild(); | 4480 WebFrame* child_frame = main_frame->FirstChild(); |
4493 | 4481 |
4494 ASSERT_EQ(2u, create_notifications.size()); | 4482 ASSERT_EQ(2u, create_notifications.size()); |
4495 EXPECT_EQ(0u, release_notifications.size()); | 4483 EXPECT_EQ(0u, release_notifications.size()); |
4496 | 4484 |
4497 auto& first_create_notification = create_notifications[0]; | 4485 auto& first_create_notification = create_notifications[0]; |
4498 auto& second_create_notification = create_notifications[1]; | 4486 auto& second_create_notification = create_notifications[1]; |
4499 | 4487 |
4500 EXPECT_EQ(main_frame, first_create_notification->frame); | 4488 EXPECT_EQ(main_frame, first_create_notification->frame); |
4501 EXPECT_EQ(main_frame->MainWorldScriptContext(), | 4489 EXPECT_EQ(main_frame->MainWorldScriptContext(), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4545 | 4533 |
4546 // The two release notifications we got should be exactly the same as the | 4534 // The two release notifications we got should be exactly the same as the |
4547 // first two create notifications. | 4535 // first two create notifications. |
4548 for (size_t i = 0; i < release_notifications.size(); ++i) { | 4536 for (size_t i = 0; i < release_notifications.size(); ++i) { |
4549 EXPECT_TRUE(release_notifications[i]->Equals( | 4537 EXPECT_TRUE(release_notifications[i]->Equals( |
4550 create_notifications[create_notifications.size() - 3 - i].get())); | 4538 create_notifications[create_notifications.size() - 3 - i].get())); |
4551 } | 4539 } |
4552 | 4540 |
4553 // The last two create notifications should be for the current frames and | 4541 // The last two create notifications should be for the current frames and |
4554 // context. | 4542 // context. |
4555 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 4543 WebLocalFrameBase* main_frame = web_view_helper.LocalMainFrame(); |
4556 WebFrame* child_frame = main_frame->FirstChild(); | 4544 WebFrame* child_frame = main_frame->FirstChild(); |
4557 auto& first_refresh_notification = create_notifications[2]; | 4545 auto& first_refresh_notification = create_notifications[2]; |
4558 auto& second_refresh_notification = create_notifications[3]; | 4546 auto& second_refresh_notification = create_notifications[3]; |
4559 | 4547 |
4560 EXPECT_EQ(main_frame, first_refresh_notification->frame); | 4548 EXPECT_EQ(main_frame, first_refresh_notification->frame); |
4561 EXPECT_EQ(main_frame->MainWorldScriptContext(), | 4549 EXPECT_EQ(main_frame->MainWorldScriptContext(), |
4562 first_refresh_notification->context); | 4550 first_refresh_notification->context); |
4563 EXPECT_EQ(0, first_refresh_notification->world_id); | 4551 EXPECT_EQ(0, first_refresh_notification->world_id); |
4564 | 4552 |
4565 EXPECT_EQ(child_frame, second_refresh_notification->frame); | 4553 EXPECT_EQ(child_frame, second_refresh_notification->frame); |
(...skipping 18 matching lines...) Expand all Loading... |
4584 FrameTestHelpers::WebViewHelper web_view_helper; | 4572 FrameTestHelpers::WebViewHelper web_view_helper; |
4585 web_view_helper.InitializeAndLoad( | 4573 web_view_helper.InitializeAndLoad( |
4586 base_url_ + "context_notifications_test.html", &web_frame_client); | 4574 base_url_ + "context_notifications_test.html", &web_frame_client); |
4587 | 4575 |
4588 // Add an isolated world. | 4576 // Add an isolated world. |
4589 web_frame_client.Reset(); | 4577 web_frame_client.Reset(); |
4590 | 4578 |
4591 int isolated_world_id = 42; | 4579 int isolated_world_id = 42; |
4592 WebScriptSource script_source("hi!"); | 4580 WebScriptSource script_source("hi!"); |
4593 int num_sources = 1; | 4581 int num_sources = 1; |
4594 web_view_helper.WebView()->MainFrameImpl()->ExecuteScriptInIsolatedWorld( | 4582 web_view_helper.LocalMainFrame()->ExecuteScriptInIsolatedWorld( |
4595 isolated_world_id, &script_source, num_sources); | 4583 isolated_world_id, &script_source, num_sources); |
4596 | 4584 |
4597 // We should now have a new create notification. | 4585 // We should now have a new create notification. |
4598 ASSERT_EQ(1u, create_notifications.size()); | 4586 ASSERT_EQ(1u, create_notifications.size()); |
4599 auto& notification = create_notifications[0]; | 4587 auto& notification = create_notifications[0]; |
4600 ASSERT_EQ(isolated_world_id, notification->world_id); | 4588 ASSERT_EQ(isolated_world_id, notification->world_id); |
4601 ASSERT_EQ(web_view_helper.WebView()->MainFrame(), notification->frame); | 4589 ASSERT_EQ(web_view_helper.WebView()->MainFrame(), notification->frame); |
4602 | 4590 |
4603 // We don't have an API to enumarate isolated worlds for a frame, but we can | 4591 // We don't have an API to enumarate isolated worlds for a frame, but we can |
4604 // at least assert that the context we got is *not* the main world's context. | 4592 // at least assert that the context we got is *not* the main world's context. |
4605 ASSERT_NE( | 4593 ASSERT_NE(web_view_helper.LocalMainFrame()->MainWorldScriptContext(), |
4606 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext(), | 4594 v8::Local<v8::Context>::New(isolate, notification->context)); |
4607 v8::Local<v8::Context>::New(isolate, notification->context)); | |
4608 | 4595 |
4609 web_view_helper.Reset(); | 4596 web_view_helper.Reset(); |
4610 | 4597 |
4611 // We should have gotten three release notifications (one for each of the | 4598 // We should have gotten three release notifications (one for each of the |
4612 // frames, plus one for the isolated context). | 4599 // frames, plus one for the isolated context). |
4613 ASSERT_EQ(3u, release_notifications.size()); | 4600 ASSERT_EQ(3u, release_notifications.size()); |
4614 | 4601 |
4615 // And one of them should be exactly the same as the create notification for | 4602 // And one of them should be exactly the same as the create notification for |
4616 // the isolated context. | 4603 // the isolated context. |
4617 int match_count = 0; | 4604 int match_count = 0; |
4618 for (size_t i = 0; i < release_notifications.size(); ++i) { | 4605 for (size_t i = 0; i < release_notifications.size(); ++i) { |
4619 if (release_notifications[i]->Equals(create_notifications[0].get())) | 4606 if (release_notifications[i]->Equals(create_notifications[0].get())) |
4620 ++match_count; | 4607 ++match_count; |
4621 } | 4608 } |
4622 EXPECT_EQ(1, match_count); | 4609 EXPECT_EQ(1, match_count); |
4623 } | 4610 } |
4624 | 4611 |
4625 TEST_P(ParameterizedWebFrameTest, FindInPage) { | 4612 TEST_P(ParameterizedWebFrameTest, FindInPage) { |
4626 RegisterMockedHttpURLLoad("find.html"); | 4613 RegisterMockedHttpURLLoad("find.html"); |
4627 FrameTestHelpers::WebViewHelper web_view_helper; | 4614 FrameTestHelpers::WebViewHelper web_view_helper; |
4628 web_view_helper.InitializeAndLoad(base_url_ + "find.html"); | 4615 web_view_helper.InitializeAndLoad(base_url_ + "find.html"); |
4629 ASSERT_TRUE(web_view_helper.WebView()->MainFrameImpl()); | 4616 ASSERT_TRUE(web_view_helper.LocalMainFrame()); |
4630 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 4617 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
4631 const int kFindIdentifier = 12345; | 4618 const int kFindIdentifier = 12345; |
4632 WebFindOptions options; | 4619 WebFindOptions options; |
4633 | 4620 |
4634 // Find in a <div> element. | 4621 // Find in a <div> element. |
4635 EXPECT_TRUE(frame->Find(kFindIdentifier, WebString::FromUTF8("bar1"), options, | 4622 EXPECT_TRUE(frame->Find(kFindIdentifier, WebString::FromUTF8("bar1"), options, |
4636 false)); | 4623 false)); |
4637 frame->StopFinding(WebLocalFrame::kStopFindActionKeepSelection); | 4624 frame->StopFinding(WebLocalFrame::kStopFindActionKeepSelection); |
4638 WebRange range = frame->SelectionRange(); | 4625 WebRange range = frame->SelectionRange(); |
4639 EXPECT_EQ(5, range.StartOffset()); | 4626 EXPECT_EQ(5, range.StartOffset()); |
4640 EXPECT_EQ(9, range.EndOffset()); | 4627 EXPECT_EQ(9, range.EndOffset()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4688 range = frame->SelectionRange(); | 4675 range = frame->SelectionRange(); |
4689 ASSERT_TRUE(range.IsNull()); | 4676 ASSERT_TRUE(range.IsNull()); |
4690 } | 4677 } |
4691 | 4678 |
4692 TEST_P(ParameterizedWebFrameTest, GetContentAsPlainText) { | 4679 TEST_P(ParameterizedWebFrameTest, GetContentAsPlainText) { |
4693 FrameTestHelpers::WebViewHelper web_view_helper; | 4680 FrameTestHelpers::WebViewHelper web_view_helper; |
4694 web_view_helper.InitializeAndLoad("about:blank"); | 4681 web_view_helper.InitializeAndLoad("about:blank"); |
4695 // We set the size because it impacts line wrapping, which changes the | 4682 // We set the size because it impacts line wrapping, which changes the |
4696 // resulting text value. | 4683 // resulting text value. |
4697 web_view_helper.Resize(WebSize(640, 480)); | 4684 web_view_helper.Resize(WebSize(640, 480)); |
4698 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 4685 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
4699 | 4686 |
4700 // Generate a simple test case. | 4687 // Generate a simple test case. |
4701 const char kSimpleSource[] = "<div>Foo bar</div><div></div>baz"; | 4688 const char kSimpleSource[] = "<div>Foo bar</div><div></div>baz"; |
4702 KURL test_url = ToKURL("about:blank"); | 4689 KURL test_url = ToKURL("about:blank"); |
4703 FrameTestHelpers::LoadHTMLString(frame, kSimpleSource, test_url); | 4690 FrameTestHelpers::LoadHTMLString(frame, kSimpleSource, test_url); |
4704 | 4691 |
4705 // Make sure it comes out OK. | 4692 // Make sure it comes out OK. |
4706 const std::string expected("Foo bar\nbaz"); | 4693 const std::string expected("Foo bar\nbaz"); |
4707 WebString text = WebFrameContentDumper::DumpWebViewAsText( | 4694 WebString text = WebFrameContentDumper::DumpWebViewAsText( |
4708 web_view_helper.WebView(), std::numeric_limits<size_t>::max()); | 4695 web_view_helper.WebView(), std::numeric_limits<size_t>::max()); |
(...skipping 21 matching lines...) Expand all Loading... |
4730 // Get the frame text where the subframe separator falls on the boundary of | 4717 // Get the frame text where the subframe separator falls on the boundary of |
4731 // what we'll take. There used to be a crash in this case. | 4718 // what we'll take. There used to be a crash in this case. |
4732 text = | 4719 text = |
4733 WebFrameContentDumper::DumpWebViewAsText(web_view_helper.WebView(), 12); | 4720 WebFrameContentDumper::DumpWebViewAsText(web_view_helper.WebView(), 12); |
4734 EXPECT_EQ("Hello world", text.Utf8()); | 4721 EXPECT_EQ("Hello world", text.Utf8()); |
4735 } | 4722 } |
4736 | 4723 |
4737 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage) { | 4724 TEST_P(ParameterizedWebFrameTest, GetFullHtmlOfPage) { |
4738 FrameTestHelpers::WebViewHelper web_view_helper; | 4725 FrameTestHelpers::WebViewHelper web_view_helper; |
4739 web_view_helper.InitializeAndLoad("about:blank"); | 4726 web_view_helper.InitializeAndLoad("about:blank"); |
4740 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 4727 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
4741 | 4728 |
4742 // Generate a simple test case. | 4729 // Generate a simple test case. |
4743 const char kSimpleSource[] = "<p>Hello</p><p>World</p>"; | 4730 const char kSimpleSource[] = "<p>Hello</p><p>World</p>"; |
4744 KURL test_url = ToKURL("about:blank"); | 4731 KURL test_url = ToKURL("about:blank"); |
4745 FrameTestHelpers::LoadHTMLString(frame, kSimpleSource, test_url); | 4732 FrameTestHelpers::LoadHTMLString(frame, kSimpleSource, test_url); |
4746 | 4733 |
4747 WebString text = WebFrameContentDumper::DumpWebViewAsText( | 4734 WebString text = WebFrameContentDumper::DumpWebViewAsText( |
4748 web_view_helper.WebView(), std::numeric_limits<size_t>::max()); | 4735 web_view_helper.WebView(), std::numeric_limits<size_t>::max()); |
4749 EXPECT_EQ("Hello\n\nWorld", text.Utf8()); | 4736 EXPECT_EQ("Hello\n\nWorld", text.Utf8()); |
4750 | 4737 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4830 | 4817 |
4831 // Note that the 'result 19' in the <select> element is not expected to | 4818 // Note that the 'result 19' in the <select> element is not expected to |
4832 // produce a match. Also, results 00 and 01 are in a different frame that is | 4819 // produce a match. Also, results 00 and 01 are in a different frame that is |
4833 // not included in this test. | 4820 // not included in this test. |
4834 const char kFindString[] = "result"; | 4821 const char kFindString[] = "result"; |
4835 const int kFindIdentifier = 12345; | 4822 const int kFindIdentifier = 12345; |
4836 const int kNumResults = 17; | 4823 const int kNumResults = 17; |
4837 | 4824 |
4838 WebFindOptions options; | 4825 WebFindOptions options; |
4839 WebString search_text = WebString::FromUTF8(kFindString); | 4826 WebString search_text = WebString::FromUTF8(kFindString); |
4840 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 4827 WebLocalFrameBase* main_frame = web_view_helper.LocalMainFrame(); |
4841 EXPECT_TRUE(main_frame->Find(kFindIdentifier, search_text, options, false)); | 4828 EXPECT_TRUE(main_frame->Find(kFindIdentifier, search_text, options, false)); |
4842 | 4829 |
4843 main_frame->EnsureTextFinder().ResetMatchCount(); | 4830 main_frame->EnsureTextFinder().ResetMatchCount(); |
4844 | 4831 |
4845 for (WebLocalFrameBase* frame = main_frame; frame; | 4832 for (WebLocalFrameBase* frame = main_frame; frame; |
4846 frame = static_cast<WebLocalFrameBase*>(frame->TraverseNext())) { | 4833 frame = static_cast<WebLocalFrameBase*>(frame->TraverseNext())) { |
4847 frame->EnsureTextFinder().StartScopingStringMatches(kFindIdentifier, | 4834 frame->EnsureTextFinder().StartScopingStringMatches(kFindIdentifier, |
4848 search_text, options); | 4835 search_text, options); |
4849 } | 4836 } |
4850 | 4837 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4896 &client); | 4883 &client); |
4897 web_view_helper.WebView()->Resize(WebSize(640, 480)); | 4884 web_view_helper.WebView()->Resize(WebSize(640, 480)); |
4898 RunPendingTasks(); | 4885 RunPendingTasks(); |
4899 | 4886 |
4900 const char* kFindString = "a"; | 4887 const char* kFindString = "a"; |
4901 const int kFindIdentifier = 7777; | 4888 const int kFindIdentifier = 7777; |
4902 const int kActiveIndex = 1; | 4889 const int kActiveIndex = 1; |
4903 | 4890 |
4904 WebFindOptions options; | 4891 WebFindOptions options; |
4905 WebString search_text = WebString::FromUTF8(kFindString); | 4892 WebString search_text = WebString::FromUTF8(kFindString); |
4906 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 4893 WebLocalFrameBase* main_frame = web_view_helper.LocalMainFrame(); |
4907 EXPECT_TRUE(main_frame->Find(kFindIdentifier, search_text, options, false)); | 4894 EXPECT_TRUE(main_frame->Find(kFindIdentifier, search_text, options, false)); |
4908 main_frame->EnsureTextFinder().ResetMatchCount(); | 4895 main_frame->EnsureTextFinder().ResetMatchCount(); |
4909 | 4896 |
4910 for (WebLocalFrameBase* frame = main_frame; frame; | 4897 for (WebLocalFrameBase* frame = main_frame; frame; |
4911 frame = static_cast<WebLocalFrameBase*>(frame->TraverseNext())) { | 4898 frame = static_cast<WebLocalFrameBase*>(frame->TraverseNext())) { |
4912 frame->EnsureTextFinder().StartScopingStringMatches(kFindIdentifier, | 4899 frame->EnsureTextFinder().StartScopingStringMatches(kFindIdentifier, |
4913 search_text, options); | 4900 search_text, options); |
4914 } | 4901 } |
4915 | 4902 |
4916 RunPendingTasks(); | 4903 RunPendingTasks(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4953 FrameTestHelpers::WebViewHelper web_view_helper; | 4940 FrameTestHelpers::WebViewHelper web_view_helper; |
4954 web_view_helper.InitializeAndLoad(base_url_ + "find_in_page.html", &client); | 4941 web_view_helper.InitializeAndLoad(base_url_ + "find_in_page.html", &client); |
4955 web_view_helper.Resize(WebSize(640, 480)); | 4942 web_view_helper.Resize(WebSize(640, 480)); |
4956 RunPendingTasks(); | 4943 RunPendingTasks(); |
4957 | 4944 |
4958 const char kFindString[] = "result"; | 4945 const char kFindString[] = "result"; |
4959 const int kFindIdentifier = 12345; | 4946 const int kFindIdentifier = 12345; |
4960 | 4947 |
4961 WebFindOptions options; | 4948 WebFindOptions options; |
4962 WebString search_text = WebString::FromUTF8(kFindString); | 4949 WebString search_text = WebString::FromUTF8(kFindString); |
4963 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 4950 WebLocalFrameBase* main_frame = web_view_helper.LocalMainFrame(); |
4964 WebLocalFrameBase* second_frame = | 4951 WebLocalFrameBase* second_frame = |
4965 ToWebLocalFrameBase(main_frame->TraverseNext()); | 4952 ToWebLocalFrameBase(main_frame->TraverseNext()); |
4966 | 4953 |
4967 // Detach the frame before finding. | 4954 // Detach the frame before finding. |
4968 RemoveElementById(main_frame, "frame"); | 4955 RemoveElementById(main_frame, "frame"); |
4969 | 4956 |
4970 EXPECT_TRUE(main_frame->Find(kFindIdentifier, search_text, options, false)); | 4957 EXPECT_TRUE(main_frame->Find(kFindIdentifier, search_text, options, false)); |
4971 EXPECT_FALSE( | 4958 EXPECT_FALSE( |
4972 second_frame->Find(kFindIdentifier, search_text, options, false)); | 4959 second_frame->Find(kFindIdentifier, search_text, options, false)); |
4973 | 4960 |
(...skipping 20 matching lines...) Expand all Loading... |
4994 FrameTestHelpers::WebViewHelper web_view_helper; | 4981 FrameTestHelpers::WebViewHelper web_view_helper; |
4995 web_view_helper.InitializeAndLoad(base_url_ + "find_in_page.html", &client); | 4982 web_view_helper.InitializeAndLoad(base_url_ + "find_in_page.html", &client); |
4996 web_view_helper.Resize(WebSize(640, 480)); | 4983 web_view_helper.Resize(WebSize(640, 480)); |
4997 RunPendingTasks(); | 4984 RunPendingTasks(); |
4998 | 4985 |
4999 const char kFindString[] = "result"; | 4986 const char kFindString[] = "result"; |
5000 const int kFindIdentifier = 12345; | 4987 const int kFindIdentifier = 12345; |
5001 | 4988 |
5002 WebFindOptions options; | 4989 WebFindOptions options; |
5003 WebString search_text = WebString::FromUTF8(kFindString); | 4990 WebString search_text = WebString::FromUTF8(kFindString); |
5004 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 4991 WebLocalFrameBase* main_frame = web_view_helper.LocalMainFrame(); |
5005 | 4992 |
5006 for (WebFrame* frame = main_frame; frame; frame = frame->TraverseNext()) | 4993 for (WebFrame* frame = main_frame; frame; frame = frame->TraverseNext()) |
5007 EXPECT_TRUE(frame->ToWebLocalFrame()->Find(kFindIdentifier, search_text, | 4994 EXPECT_TRUE(frame->ToWebLocalFrame()->Find(kFindIdentifier, search_text, |
5008 options, false)); | 4995 options, false)); |
5009 | 4996 |
5010 RunPendingTasks(); | 4997 RunPendingTasks(); |
5011 EXPECT_FALSE(client.FindResultsAreReady()); | 4998 EXPECT_FALSE(client.FindResultsAreReady()); |
5012 | 4999 |
5013 // Detach the frame between finding and scoping. | 5000 // Detach the frame between finding and scoping. |
5014 RemoveElementById(main_frame, "frame"); | 5001 RemoveElementById(main_frame, "frame"); |
(...skipping 18 matching lines...) Expand all Loading... |
5033 FrameTestHelpers::WebViewHelper web_view_helper; | 5020 FrameTestHelpers::WebViewHelper web_view_helper; |
5034 web_view_helper.InitializeAndLoad(base_url_ + "find_in_page.html", &client); | 5021 web_view_helper.InitializeAndLoad(base_url_ + "find_in_page.html", &client); |
5035 web_view_helper.Resize(WebSize(640, 480)); | 5022 web_view_helper.Resize(WebSize(640, 480)); |
5036 RunPendingTasks(); | 5023 RunPendingTasks(); |
5037 | 5024 |
5038 const char kFindString[] = "result"; | 5025 const char kFindString[] = "result"; |
5039 const int kFindIdentifier = 12345; | 5026 const int kFindIdentifier = 12345; |
5040 | 5027 |
5041 WebFindOptions options; | 5028 WebFindOptions options; |
5042 WebString search_text = WebString::FromUTF8(kFindString); | 5029 WebString search_text = WebString::FromUTF8(kFindString); |
5043 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 5030 WebLocalFrameBase* main_frame = web_view_helper.LocalMainFrame(); |
5044 | 5031 |
5045 for (WebFrame* frame = main_frame; frame; frame = frame->TraverseNext()) | 5032 for (WebFrame* frame = main_frame; frame; frame = frame->TraverseNext()) |
5046 EXPECT_TRUE(frame->ToWebLocalFrame()->Find(kFindIdentifier, search_text, | 5033 EXPECT_TRUE(frame->ToWebLocalFrame()->Find(kFindIdentifier, search_text, |
5047 options, false)); | 5034 options, false)); |
5048 | 5035 |
5049 RunPendingTasks(); | 5036 RunPendingTasks(); |
5050 EXPECT_FALSE(client.FindResultsAreReady()); | 5037 EXPECT_FALSE(client.FindResultsAreReady()); |
5051 | 5038 |
5052 main_frame->EnsureTextFinder().ResetMatchCount(); | 5039 main_frame->EnsureTextFinder().ResetMatchCount(); |
5053 | 5040 |
(...skipping 19 matching lines...) Expand all Loading... |
5073 web_view_helper.InitializeAndLoad(base_url_ + "find_in_generated_frame.html", | 5060 web_view_helper.InitializeAndLoad(base_url_ + "find_in_generated_frame.html", |
5074 &client); | 5061 &client); |
5075 web_view_helper.Resize(WebSize(640, 480)); | 5062 web_view_helper.Resize(WebSize(640, 480)); |
5076 RunPendingTasks(); | 5063 RunPendingTasks(); |
5077 | 5064 |
5078 const char kFindString[] = "result"; | 5065 const char kFindString[] = "result"; |
5079 const int kFindIdentifier = 12345; | 5066 const int kFindIdentifier = 12345; |
5080 | 5067 |
5081 WebFindOptions options; | 5068 WebFindOptions options; |
5082 WebString search_text = WebString::FromUTF8(kFindString); | 5069 WebString search_text = WebString::FromUTF8(kFindString); |
5083 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 5070 WebLocalFrameBase* main_frame = web_view_helper.LocalMainFrame(); |
5084 | 5071 |
5085 // Check that child frame exists. | 5072 // Check that child frame exists. |
5086 EXPECT_TRUE(!!main_frame->TraverseNext()); | 5073 EXPECT_TRUE(!!main_frame->TraverseNext()); |
5087 | 5074 |
5088 for (WebFrame* frame = main_frame; frame; frame = frame->TraverseNext()) | 5075 for (WebFrame* frame = main_frame; frame; frame = frame->TraverseNext()) |
5089 EXPECT_FALSE(frame->ToWebLocalFrame()->Find(kFindIdentifier, search_text, | 5076 EXPECT_FALSE(frame->ToWebLocalFrame()->Find(kFindIdentifier, search_text, |
5090 options, false)); | 5077 options, false)); |
5091 | 5078 |
5092 RunPendingTasks(); | 5079 RunPendingTasks(); |
5093 EXPECT_FALSE(client.FindResultsAreReady()); | 5080 EXPECT_FALSE(client.FindResultsAreReady()); |
5094 | 5081 |
5095 main_frame->EnsureTextFinder().ResetMatchCount(); | 5082 main_frame->EnsureTextFinder().ResetMatchCount(); |
5096 } | 5083 } |
5097 | 5084 |
5098 TEST_P(ParameterizedWebFrameTest, SetTickmarks) { | 5085 TEST_P(ParameterizedWebFrameTest, SetTickmarks) { |
5099 RegisterMockedHttpURLLoad("find.html"); | 5086 RegisterMockedHttpURLLoad("find.html"); |
5100 | 5087 |
5101 FindUpdateWebFrameClient client; | 5088 FindUpdateWebFrameClient client; |
5102 FrameTestHelpers::WebViewHelper web_view_helper; | 5089 FrameTestHelpers::WebViewHelper web_view_helper; |
5103 web_view_helper.InitializeAndLoad(base_url_ + "find.html", &client); | 5090 web_view_helper.InitializeAndLoad(base_url_ + "find.html", &client); |
5104 web_view_helper.Resize(WebSize(640, 480)); | 5091 web_view_helper.Resize(WebSize(640, 480)); |
5105 RunPendingTasks(); | 5092 RunPendingTasks(); |
5106 | 5093 |
5107 const char kFindString[] = "foo"; | 5094 const char kFindString[] = "foo"; |
5108 const int kFindIdentifier = 12345; | 5095 const int kFindIdentifier = 12345; |
5109 | 5096 |
5110 WebFindOptions options; | 5097 WebFindOptions options; |
5111 WebString search_text = WebString::FromUTF8(kFindString); | 5098 WebString search_text = WebString::FromUTF8(kFindString); |
5112 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 5099 WebLocalFrameBase* main_frame = web_view_helper.LocalMainFrame(); |
5113 EXPECT_TRUE(main_frame->Find(kFindIdentifier, search_text, options, false)); | 5100 EXPECT_TRUE(main_frame->Find(kFindIdentifier, search_text, options, false)); |
5114 | 5101 |
5115 main_frame->EnsureTextFinder().ResetMatchCount(); | 5102 main_frame->EnsureTextFinder().ResetMatchCount(); |
5116 main_frame->EnsureTextFinder().StartScopingStringMatches( | 5103 main_frame->EnsureTextFinder().StartScopingStringMatches( |
5117 kFindIdentifier, search_text, options); | 5104 kFindIdentifier, search_text, options); |
5118 | 5105 |
5119 RunPendingTasks(); | 5106 RunPendingTasks(); |
5120 EXPECT_TRUE(client.FindResultsAreReady()); | 5107 EXPECT_TRUE(client.FindResultsAreReady()); |
5121 | 5108 |
5122 // Get the tickmarks for the original find request. | 5109 // Get the tickmarks for the original find request. |
5123 LocalFrameView* frame_view = | 5110 LocalFrameView* frame_view = web_view_helper.LocalMainFrame()->GetFrameView(); |
5124 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
5125 Scrollbar* scrollbar = frame_view->CreateScrollbar(kHorizontalScrollbar); | 5111 Scrollbar* scrollbar = frame_view->CreateScrollbar(kHorizontalScrollbar); |
5126 Vector<IntRect> original_tickmarks; | 5112 Vector<IntRect> original_tickmarks; |
5127 scrollbar->GetTickmarks(original_tickmarks); | 5113 scrollbar->GetTickmarks(original_tickmarks); |
5128 EXPECT_EQ(4u, original_tickmarks.size()); | 5114 EXPECT_EQ(4u, original_tickmarks.size()); |
5129 | 5115 |
5130 // Override the tickmarks. | 5116 // Override the tickmarks. |
5131 Vector<IntRect> overriding_tickmarks_expected; | 5117 Vector<IntRect> overriding_tickmarks_expected; |
5132 overriding_tickmarks_expected.push_back(IntRect(0, 0, 100, 100)); | 5118 overriding_tickmarks_expected.push_back(IntRect(0, 0, 100, 100)); |
5133 overriding_tickmarks_expected.push_back(IntRect(0, 20, 100, 100)); | 5119 overriding_tickmarks_expected.push_back(IntRect(0, 20, 100, 100)); |
5134 overriding_tickmarks_expected.push_back(IntRect(0, 30, 100, 100)); | 5120 overriding_tickmarks_expected.push_back(IntRect(0, 30, 100, 100)); |
(...skipping 16 matching lines...) Expand all Loading... |
5151 | 5137 |
5152 TEST_P(ParameterizedWebFrameTest, FindInPageJavaScriptUpdatesDOM) { | 5138 TEST_P(ParameterizedWebFrameTest, FindInPageJavaScriptUpdatesDOM) { |
5153 RegisterMockedHttpURLLoad("find.html"); | 5139 RegisterMockedHttpURLLoad("find.html"); |
5154 | 5140 |
5155 FindUpdateWebFrameClient client; | 5141 FindUpdateWebFrameClient client; |
5156 FrameTestHelpers::WebViewHelper web_view_helper; | 5142 FrameTestHelpers::WebViewHelper web_view_helper; |
5157 web_view_helper.InitializeAndLoad(base_url_ + "find.html", &client); | 5143 web_view_helper.InitializeAndLoad(base_url_ + "find.html", &client); |
5158 web_view_helper.Resize(WebSize(640, 480)); | 5144 web_view_helper.Resize(WebSize(640, 480)); |
5159 RunPendingTasks(); | 5145 RunPendingTasks(); |
5160 | 5146 |
5161 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 5147 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
5162 const int kFindIdentifier = 12345; | 5148 const int kFindIdentifier = 12345; |
5163 static const char* kFindString = "foo"; | 5149 static const char* kFindString = "foo"; |
5164 WebString search_text = WebString::FromUTF8(kFindString); | 5150 WebString search_text = WebString::FromUTF8(kFindString); |
5165 WebFindOptions options; | 5151 WebFindOptions options; |
5166 bool active_now; | 5152 bool active_now; |
5167 | 5153 |
5168 frame->EnsureTextFinder().ResetMatchCount(); | 5154 frame->EnsureTextFinder().ResetMatchCount(); |
5169 frame->EnsureTextFinder().StartScopingStringMatches(kFindIdentifier, | 5155 frame->EnsureTextFinder().StartScopingStringMatches(kFindIdentifier, |
5170 search_text, options); | 5156 search_text, options); |
5171 RunPendingTasks(); | 5157 RunPendingTasks(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5224 // We have 2 occurrences of the pattern in our text. | 5210 // We have 2 occurrences of the pattern in our text. |
5225 const char* html = | 5211 const char* html = |
5226 "foo bar foo bar foo abc bar foo bar foo bar foo bar foo bar foo bar foo " | 5212 "foo bar foo bar foo abc bar foo bar foo bar foo bar foo bar foo bar foo " |
5227 "bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo " | 5213 "bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo " |
5228 "bar foo bar foo abc bar <div id='new_text'></div>"; | 5214 "bar foo bar foo abc bar <div id='new_text'></div>"; |
5229 | 5215 |
5230 FindUpdateWebFrameClient client; | 5216 FindUpdateWebFrameClient client; |
5231 FrameTestHelpers::WebViewHelper web_view_helper; | 5217 FrameTestHelpers::WebViewHelper web_view_helper; |
5232 web_view_helper.Initialize(&client); | 5218 web_view_helper.Initialize(&client); |
5233 | 5219 |
5234 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 5220 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
5235 FrameTestHelpers::LoadHTMLString(frame, html, | 5221 FrameTestHelpers::LoadHTMLString(frame, html, |
5236 URLTestHelpers::ToKURL(base_url_)); | 5222 URLTestHelpers::ToKURL(base_url_)); |
5237 web_view_helper.Resize(WebSize(640, 480)); | 5223 web_view_helper.Resize(WebSize(640, 480)); |
5238 web_view_helper.WebView()->SetFocus(true); | 5224 web_view_helper.WebView()->SetFocus(true); |
5239 RunPendingTasks(); | 5225 RunPendingTasks(); |
5240 | 5226 |
5241 const int kFindIdentifier = 12345; | 5227 const int kFindIdentifier = 12345; |
5242 WebFindOptions options; | 5228 WebFindOptions options; |
5243 | 5229 |
5244 // The first search that will start the scoping process. | 5230 // The first search that will start the scoping process. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5280 EXPECT_EQ(3, client.Count()); | 5266 EXPECT_EQ(3, client.Count()); |
5281 EXPECT_EQ(3, client.ActiveIndex()); | 5267 EXPECT_EQ(3, client.ActiveIndex()); |
5282 } | 5268 } |
5283 | 5269 |
5284 TEST_P(ParameterizedWebFrameTest, | 5270 TEST_P(ParameterizedWebFrameTest, |
5285 FindInPageStopFindActionKeepSelectionInAnotherDocument) { | 5271 FindInPageStopFindActionKeepSelectionInAnotherDocument) { |
5286 RegisterMockedHttpURLLoad("find.html"); | 5272 RegisterMockedHttpURLLoad("find.html"); |
5287 RegisterMockedHttpURLLoad("hello_world.html"); | 5273 RegisterMockedHttpURLLoad("hello_world.html"); |
5288 FrameTestHelpers::WebViewHelper web_view_helper; | 5274 FrameTestHelpers::WebViewHelper web_view_helper; |
5289 web_view_helper.InitializeAndLoad(base_url_ + "find.html"); | 5275 web_view_helper.InitializeAndLoad(base_url_ + "find.html"); |
5290 ASSERT_TRUE(web_view_helper.WebView()->MainFrameImpl()); | 5276 ASSERT_TRUE(web_view_helper.LocalMainFrame()); |
5291 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 5277 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
5292 const int kFindIdentifier = 12345; | 5278 const int kFindIdentifier = 12345; |
5293 WebFindOptions options; | 5279 WebFindOptions options; |
5294 | 5280 |
5295 // Set active match | 5281 // Set active match |
5296 ASSERT_TRUE( | 5282 ASSERT_TRUE( |
5297 frame->Find(kFindIdentifier, WebString::FromUTF8("foo"), options, false)); | 5283 frame->Find(kFindIdentifier, WebString::FromUTF8("foo"), options, false)); |
5298 // Move to another page. | 5284 // Move to another page. |
5299 FrameTestHelpers::LoadFrame(frame, base_url_ + "hello_world.html"); | 5285 FrameTestHelpers::LoadFrame(frame, base_url_ + "hello_world.html"); |
5300 | 5286 |
5301 // Stop Find-In-Page. |TextFinder::active_match_| still hold a |Range| in | 5287 // Stop Find-In-Page. |TextFinder::active_match_| still hold a |Range| in |
(...skipping 27 matching lines...) Expand all Loading... |
5329 WebLocalFrame* frame; | 5315 WebLocalFrame* frame; |
5330 WebRect start_web_rect; | 5316 WebRect start_web_rect; |
5331 WebRect end_web_rect; | 5317 WebRect end_web_rect; |
5332 | 5318 |
5333 RegisterMockedHttpURLLoad("select_range_basic.html"); | 5319 RegisterMockedHttpURLLoad("select_range_basic.html"); |
5334 RegisterMockedHttpURLLoad("select_range_scroll.html"); | 5320 RegisterMockedHttpURLLoad("select_range_scroll.html"); |
5335 | 5321 |
5336 FrameTestHelpers::WebViewHelper web_view_helper; | 5322 FrameTestHelpers::WebViewHelper web_view_helper; |
5337 InitializeTextSelectionWebView(base_url_ + "select_range_basic.html", | 5323 InitializeTextSelectionWebView(base_url_ + "select_range_basic.html", |
5338 &web_view_helper); | 5324 &web_view_helper); |
5339 frame = web_view_helper.WebView()->MainFrameImpl(); | 5325 frame = web_view_helper.LocalMainFrame(); |
5340 EXPECT_EQ("Some test text for testing.", SelectionAsString(frame)); | 5326 EXPECT_EQ("Some test text for testing.", SelectionAsString(frame)); |
5341 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5327 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5342 frame->ExecuteCommand(WebString::FromUTF8("Unselect")); | 5328 frame->ExecuteCommand(WebString::FromUTF8("Unselect")); |
5343 EXPECT_EQ("", SelectionAsString(frame)); | 5329 EXPECT_EQ("", SelectionAsString(frame)); |
5344 frame->SelectRange(TopLeft(start_web_rect), | 5330 frame->SelectRange(TopLeft(start_web_rect), |
5345 BottomRightMinusOne(end_web_rect)); | 5331 BottomRightMinusOne(end_web_rect)); |
5346 // On some devices, the above bottomRightMinusOne() causes the ending '.' not | 5332 // On some devices, the above bottomRightMinusOne() causes the ending '.' not |
5347 // selected. | 5333 // selected. |
5348 std::string selection_string = SelectionAsString(frame); | 5334 std::string selection_string = SelectionAsString(frame); |
5349 EXPECT_TRUE(selection_string == "Some test text for testing." || | 5335 EXPECT_TRUE(selection_string == "Some test text for testing." || |
5350 selection_string == "Some test text for testing"); | 5336 selection_string == "Some test text for testing"); |
5351 | 5337 |
5352 InitializeTextSelectionWebView(base_url_ + "select_range_scroll.html", | 5338 InitializeTextSelectionWebView(base_url_ + "select_range_scroll.html", |
5353 &web_view_helper); | 5339 &web_view_helper); |
5354 frame = web_view_helper.WebView()->MainFrameImpl(); | 5340 frame = web_view_helper.LocalMainFrame(); |
5355 EXPECT_EQ("Some offscreen test text for testing.", SelectionAsString(frame)); | 5341 EXPECT_EQ("Some offscreen test text for testing.", SelectionAsString(frame)); |
5356 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5342 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5357 frame->ExecuteCommand(WebString::FromUTF8("Unselect")); | 5343 frame->ExecuteCommand(WebString::FromUTF8("Unselect")); |
5358 EXPECT_EQ("", SelectionAsString(frame)); | 5344 EXPECT_EQ("", SelectionAsString(frame)); |
5359 frame->SelectRange(TopLeft(start_web_rect), | 5345 frame->SelectRange(TopLeft(start_web_rect), |
5360 BottomRightMinusOne(end_web_rect)); | 5346 BottomRightMinusOne(end_web_rect)); |
5361 // On some devices, the above bottomRightMinusOne() causes the ending '.' not | 5347 // On some devices, the above bottomRightMinusOne() causes the ending '.' not |
5362 // selected. | 5348 // selected. |
5363 selection_string = SelectionAsString(frame); | 5349 selection_string = SelectionAsString(frame); |
5364 EXPECT_TRUE(selection_string == "Some offscreen test text for testing." || | 5350 EXPECT_TRUE(selection_string == "Some offscreen test text for testing." || |
5365 selection_string == "Some offscreen test text for testing"); | 5351 selection_string == "Some offscreen test text for testing"); |
5366 } | 5352 } |
5367 | 5353 |
5368 TEST_P(ParameterizedWebFrameTest, SelectRangeDefaultHandleVisibility) { | 5354 TEST_P(ParameterizedWebFrameTest, SelectRangeDefaultHandleVisibility) { |
5369 RegisterMockedHttpURLLoad("select_range_basic.html"); | 5355 RegisterMockedHttpURLLoad("select_range_basic.html"); |
5370 | 5356 |
5371 FrameTestHelpers::WebViewHelper web_view_helper; | 5357 FrameTestHelpers::WebViewHelper web_view_helper; |
5372 InitializeTextSelectionWebView(base_url_ + "select_range_basic.html", | 5358 InitializeTextSelectionWebView(base_url_ + "select_range_basic.html", |
5373 &web_view_helper); | 5359 &web_view_helper); |
5374 | 5360 |
5375 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 5361 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
5376 frame->SelectRange(WebRange(0, 5)); | 5362 frame->SelectRange(WebRange(0, 5)); |
5377 EXPECT_FALSE(frame->SelectionRange().IsNull()); | 5363 EXPECT_FALSE(frame->SelectionRange().IsNull()); |
5378 | 5364 |
5379 EXPECT_FALSE(frame->GetFrame()->Selection().IsHandleVisible()) | 5365 EXPECT_FALSE(frame->GetFrame()->Selection().IsHandleVisible()) |
5380 << "By default selection handles should not be visible"; | 5366 << "By default selection handles should not be visible"; |
5381 } | 5367 } |
5382 | 5368 |
5383 TEST_P(ParameterizedWebFrameTest, SelectRangeHideHandle) { | 5369 TEST_P(ParameterizedWebFrameTest, SelectRangeHideHandle) { |
5384 RegisterMockedHttpURLLoad("select_range_basic.html"); | 5370 RegisterMockedHttpURLLoad("select_range_basic.html"); |
5385 | 5371 |
5386 FrameTestHelpers::WebViewHelper web_view_helper; | 5372 FrameTestHelpers::WebViewHelper web_view_helper; |
5387 InitializeTextSelectionWebView(base_url_ + "select_range_basic.html", | 5373 InitializeTextSelectionWebView(base_url_ + "select_range_basic.html", |
5388 &web_view_helper); | 5374 &web_view_helper); |
5389 | 5375 |
5390 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 5376 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
5391 frame->SelectRange(WebRange(0, 5), WebLocalFrame::kHideSelectionHandle); | 5377 frame->SelectRange(WebRange(0, 5), WebLocalFrame::kHideSelectionHandle); |
5392 | 5378 |
5393 EXPECT_FALSE(frame->GetFrame()->Selection().IsHandleVisible()) | 5379 EXPECT_FALSE(frame->GetFrame()->Selection().IsHandleVisible()) |
5394 << "Selection handle should not be visible with kHideSelectionHandle"; | 5380 << "Selection handle should not be visible with kHideSelectionHandle"; |
5395 } | 5381 } |
5396 | 5382 |
5397 TEST_P(ParameterizedWebFrameTest, SelectRangeShowHandle) { | 5383 TEST_P(ParameterizedWebFrameTest, SelectRangeShowHandle) { |
5398 RegisterMockedHttpURLLoad("select_range_basic.html"); | 5384 RegisterMockedHttpURLLoad("select_range_basic.html"); |
5399 | 5385 |
5400 FrameTestHelpers::WebViewHelper web_view_helper; | 5386 FrameTestHelpers::WebViewHelper web_view_helper; |
5401 InitializeTextSelectionWebView(base_url_ + "select_range_basic.html", | 5387 InitializeTextSelectionWebView(base_url_ + "select_range_basic.html", |
5402 &web_view_helper); | 5388 &web_view_helper); |
5403 | 5389 |
5404 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 5390 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
5405 frame->SelectRange(WebRange(0, 5), WebLocalFrame::kShowSelectionHandle); | 5391 frame->SelectRange(WebRange(0, 5), WebLocalFrame::kShowSelectionHandle); |
5406 | 5392 |
5407 EXPECT_TRUE(frame->GetFrame()->Selection().IsHandleVisible()) | 5393 EXPECT_TRUE(frame->GetFrame()->Selection().IsHandleVisible()) |
5408 << "Selection handle should be visible with kShowSelectionHandle"; | 5394 << "Selection handle should be visible with kShowSelectionHandle"; |
5409 } | 5395 } |
5410 | 5396 |
5411 TEST_P(ParameterizedWebFrameTest, SelectRangePreserveHandleVisibility) { | 5397 TEST_P(ParameterizedWebFrameTest, SelectRangePreserveHandleVisibility) { |
5412 RegisterMockedHttpURLLoad("select_range_basic.html"); | 5398 RegisterMockedHttpURLLoad("select_range_basic.html"); |
5413 | 5399 |
5414 FrameTestHelpers::WebViewHelper web_view_helper; | 5400 FrameTestHelpers::WebViewHelper web_view_helper; |
5415 InitializeTextSelectionWebView(base_url_ + "select_range_basic.html", | 5401 InitializeTextSelectionWebView(base_url_ + "select_range_basic.html", |
5416 &web_view_helper); | 5402 &web_view_helper); |
5417 | 5403 |
5418 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 5404 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
5419 frame->SelectRange(WebRange(0, 5), WebLocalFrame::kHideSelectionHandle); | 5405 frame->SelectRange(WebRange(0, 5), WebLocalFrame::kHideSelectionHandle); |
5420 frame->SelectRange(WebRange(0, 6), WebLocalFrame::kPreserveHandleVisibility); | 5406 frame->SelectRange(WebRange(0, 6), WebLocalFrame::kPreserveHandleVisibility); |
5421 | 5407 |
5422 EXPECT_FALSE(frame->GetFrame()->Selection().IsHandleVisible()) | 5408 EXPECT_FALSE(frame->GetFrame()->Selection().IsHandleVisible()) |
5423 << "kPreserveHandleVisibility should keep handles invisible"; | 5409 << "kPreserveHandleVisibility should keep handles invisible"; |
5424 | 5410 |
5425 frame->SelectRange(WebRange(0, 5), WebLocalFrame::kShowSelectionHandle); | 5411 frame->SelectRange(WebRange(0, 5), WebLocalFrame::kShowSelectionHandle); |
5426 frame->SelectRange(WebRange(0, 6), WebLocalFrame::kPreserveHandleVisibility); | 5412 frame->SelectRange(WebRange(0, 6), WebLocalFrame::kPreserveHandleVisibility); |
5427 | 5413 |
5428 EXPECT_TRUE(frame->GetFrame()->Selection().IsHandleVisible()) | 5414 EXPECT_TRUE(frame->GetFrame()->Selection().IsHandleVisible()) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5461 WebRect end_web_rect; | 5447 WebRect end_web_rect; |
5462 | 5448 |
5463 RegisterMockedHttpURLLoad("select_range_div_editable.html"); | 5449 RegisterMockedHttpURLLoad("select_range_div_editable.html"); |
5464 | 5450 |
5465 // Select the middle of an editable element, then try to extend the selection | 5451 // Select the middle of an editable element, then try to extend the selection |
5466 // to the top of the document. The selection range should be clipped to the | 5452 // to the top of the document. The selection range should be clipped to the |
5467 // bounds of the editable element. | 5453 // bounds of the editable element. |
5468 FrameTestHelpers::WebViewHelper web_view_helper; | 5454 FrameTestHelpers::WebViewHelper web_view_helper; |
5469 InitializeTextSelectionWebView(base_url_ + "select_range_div_editable.html", | 5455 InitializeTextSelectionWebView(base_url_ + "select_range_div_editable.html", |
5470 &web_view_helper); | 5456 &web_view_helper); |
5471 frame = web_view_helper.WebView()->MainFrameImpl(); | 5457 frame = web_view_helper.LocalMainFrame(); |
5472 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); | 5458 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); |
5473 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5459 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5474 | 5460 |
5475 frame->SelectRange(BottomRightMinusOne(end_web_rect), WebPoint(0, 0)); | 5461 frame->SelectRange(BottomRightMinusOne(end_web_rect), WebPoint(0, 0)); |
5476 EXPECT_EQ("16-char header. This text is initially selected.", | 5462 EXPECT_EQ("16-char header. This text is initially selected.", |
5477 SelectionAsString(frame)); | 5463 SelectionAsString(frame)); |
5478 | 5464 |
5479 // As above, but extending the selection to the bottom of the document. | 5465 // As above, but extending the selection to the bottom of the document. |
5480 InitializeTextSelectionWebView(base_url_ + "select_range_div_editable.html", | 5466 InitializeTextSelectionWebView(base_url_ + "select_range_div_editable.html", |
5481 &web_view_helper); | 5467 &web_view_helper); |
5482 frame = web_view_helper.WebView()->MainFrameImpl(); | 5468 frame = web_view_helper.LocalMainFrame(); |
5483 | 5469 |
5484 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5470 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5485 frame->SelectRange(TopLeft(start_web_rect), | 5471 frame->SelectRange(TopLeft(start_web_rect), |
5486 BottomRightMinusOne(end_web_rect)); | 5472 BottomRightMinusOne(end_web_rect)); |
5487 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); | 5473 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); |
5488 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5474 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5489 | 5475 |
5490 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5476 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5491 frame->SelectRange(TopLeft(start_web_rect), WebPoint(640, 480)); | 5477 frame->SelectRange(TopLeft(start_web_rect), WebPoint(640, 480)); |
5492 EXPECT_EQ("This text is initially selected. 16-char footer.", | 5478 EXPECT_EQ("This text is initially selected. 16-char footer.", |
5493 SelectionAsString(frame)); | 5479 SelectionAsString(frame)); |
5494 } | 5480 } |
5495 | 5481 |
5496 // positionForPoint returns the wrong values for contenteditable spans. See | 5482 // positionForPoint returns the wrong values for contenteditable spans. See |
5497 // http://crbug.com/238334. | 5483 // http://crbug.com/238334. |
5498 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable) { | 5484 TEST_P(ParameterizedWebFrameTest, DISABLED_SelectRangeSpanContentEditable) { |
5499 WebLocalFrame* frame; | 5485 WebLocalFrame* frame; |
5500 WebRect start_web_rect; | 5486 WebRect start_web_rect; |
5501 WebRect end_web_rect; | 5487 WebRect end_web_rect; |
5502 | 5488 |
5503 RegisterMockedHttpURLLoad("select_range_span_editable.html"); | 5489 RegisterMockedHttpURLLoad("select_range_span_editable.html"); |
5504 | 5490 |
5505 // Select the middle of an editable element, then try to extend the selection | 5491 // Select the middle of an editable element, then try to extend the selection |
5506 // to the top of the document. | 5492 // to the top of the document. |
5507 // The selection range should be clipped to the bounds of the editable | 5493 // The selection range should be clipped to the bounds of the editable |
5508 // element. | 5494 // element. |
5509 FrameTestHelpers::WebViewHelper web_view_helper; | 5495 FrameTestHelpers::WebViewHelper web_view_helper; |
5510 InitializeTextSelectionWebView(base_url_ + "select_range_span_editable.html", | 5496 InitializeTextSelectionWebView(base_url_ + "select_range_span_editable.html", |
5511 &web_view_helper); | 5497 &web_view_helper); |
5512 frame = web_view_helper.WebView()->MainFrameImpl(); | 5498 frame = web_view_helper.LocalMainFrame(); |
5513 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); | 5499 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); |
5514 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5500 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5515 | 5501 |
5516 frame->SelectRange(BottomRightMinusOne(end_web_rect), WebPoint(0, 0)); | 5502 frame->SelectRange(BottomRightMinusOne(end_web_rect), WebPoint(0, 0)); |
5517 EXPECT_EQ("16-char header. This text is initially selected.", | 5503 EXPECT_EQ("16-char header. This text is initially selected.", |
5518 SelectionAsString(frame)); | 5504 SelectionAsString(frame)); |
5519 | 5505 |
5520 // As above, but extending the selection to the bottom of the document. | 5506 // As above, but extending the selection to the bottom of the document. |
5521 InitializeTextSelectionWebView(base_url_ + "select_range_span_editable.html", | 5507 InitializeTextSelectionWebView(base_url_ + "select_range_span_editable.html", |
5522 &web_view_helper); | 5508 &web_view_helper); |
5523 frame = web_view_helper.WebView()->MainFrameImpl(); | 5509 frame = web_view_helper.LocalMainFrame(); |
5524 | 5510 |
5525 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5511 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5526 frame->SelectRange(TopLeft(start_web_rect), | 5512 frame->SelectRange(TopLeft(start_web_rect), |
5527 BottomRightMinusOne(end_web_rect)); | 5513 BottomRightMinusOne(end_web_rect)); |
5528 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); | 5514 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); |
5529 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5515 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5530 | 5516 |
5531 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); | 5517 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); |
5532 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5518 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5533 frame->SelectRange(TopLeft(start_web_rect), WebPoint(640, 480)); | 5519 frame->SelectRange(TopLeft(start_web_rect), WebPoint(640, 480)); |
5534 EXPECT_EQ("This text is initially selected. 16-char footer.", | 5520 EXPECT_EQ("This text is initially selected. 16-char footer.", |
5535 SelectionAsString(frame)); | 5521 SelectionAsString(frame)); |
5536 } | 5522 } |
5537 | 5523 |
5538 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionStart) { | 5524 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionStart) { |
5539 RegisterMockedHttpURLLoad("text_selection.html"); | 5525 RegisterMockedHttpURLLoad("text_selection.html"); |
5540 FrameTestHelpers::WebViewHelper web_view_helper; | 5526 FrameTestHelpers::WebViewHelper web_view_helper; |
5541 InitializeTextSelectionWebView(base_url_ + "text_selection.html", | 5527 InitializeTextSelectionWebView(base_url_ + "text_selection.html", |
5542 &web_view_helper); | 5528 &web_view_helper); |
5543 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 5529 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
5544 | 5530 |
5545 // Select second span. We can move the start to include the first span. | 5531 // Select second span. We can move the start to include the first span. |
5546 frame->ExecuteScript(WebScriptSource("selectElement('header_2');")); | 5532 frame->ExecuteScript(WebScriptSource("selectElement('header_2');")); |
5547 EXPECT_EQ("Header 2.", SelectionAsString(frame)); | 5533 EXPECT_EQ("Header 2.", SelectionAsString(frame)); |
5548 frame->SelectRange(BottomRightMinusOne(ElementBounds(frame, "header_2")), | 5534 frame->SelectRange(BottomRightMinusOne(ElementBounds(frame, "header_2")), |
5549 TopLeft(ElementBounds(frame, "header_1"))); | 5535 TopLeft(ElementBounds(frame, "header_1"))); |
5550 EXPECT_EQ("Header 1. Header 2.", SelectionAsString(frame)); | 5536 EXPECT_EQ("Header 1. Header 2.", SelectionAsString(frame)); |
5551 | 5537 |
5552 // We can move the start and end together. | 5538 // We can move the start and end together. |
5553 frame->ExecuteScript(WebScriptSource("selectElement('header_1');")); | 5539 frame->ExecuteScript(WebScriptSource("selectElement('header_1');")); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5589 // positionForPoint returns the wrong values for contenteditable spans. See | 5575 // positionForPoint returns the wrong values for contenteditable spans. See |
5590 // http://crbug.com/238334. | 5576 // http://crbug.com/238334. |
5591 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); | 5577 // EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); |
5592 } | 5578 } |
5593 | 5579 |
5594 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd) { | 5580 TEST_P(ParameterizedWebFrameTest, SelectRangeCanMoveSelectionEnd) { |
5595 RegisterMockedHttpURLLoad("text_selection.html"); | 5581 RegisterMockedHttpURLLoad("text_selection.html"); |
5596 FrameTestHelpers::WebViewHelper web_view_helper; | 5582 FrameTestHelpers::WebViewHelper web_view_helper; |
5597 InitializeTextSelectionWebView(base_url_ + "text_selection.html", | 5583 InitializeTextSelectionWebView(base_url_ + "text_selection.html", |
5598 &web_view_helper); | 5584 &web_view_helper); |
5599 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 5585 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
5600 | 5586 |
5601 // Select first span. We can move the end to include the second span. | 5587 // Select first span. We can move the end to include the second span. |
5602 frame->ExecuteScript(WebScriptSource("selectElement('header_1');")); | 5588 frame->ExecuteScript(WebScriptSource("selectElement('header_1');")); |
5603 EXPECT_EQ("Header 1.", SelectionAsString(frame)); | 5589 EXPECT_EQ("Header 1.", SelectionAsString(frame)); |
5604 frame->SelectRange(TopLeft(ElementBounds(frame, "header_1")), | 5590 frame->SelectRange(TopLeft(ElementBounds(frame, "header_1")), |
5605 BottomRightMinusOne(ElementBounds(frame, "header_2"))); | 5591 BottomRightMinusOne(ElementBounds(frame, "header_2"))); |
5606 EXPECT_EQ("Header 1. Header 2.", SelectionAsString(frame)); | 5592 EXPECT_EQ("Header 1. Header 2.", SelectionAsString(frame)); |
5607 | 5593 |
5608 // We can move the start and end together. | 5594 // We can move the start and end together. |
5609 frame->ExecuteScript(WebScriptSource("selectElement('header_2');")); | 5595 frame->ExecuteScript(WebScriptSource("selectElement('header_2');")); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5650 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtent) { | 5636 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtent) { |
5651 WebLocalFrameBase* frame; | 5637 WebLocalFrameBase* frame; |
5652 WebRect start_web_rect; | 5638 WebRect start_web_rect; |
5653 WebRect end_web_rect; | 5639 WebRect end_web_rect; |
5654 | 5640 |
5655 RegisterMockedHttpURLLoad("move_range_selection_extent.html"); | 5641 RegisterMockedHttpURLLoad("move_range_selection_extent.html"); |
5656 | 5642 |
5657 FrameTestHelpers::WebViewHelper web_view_helper; | 5643 FrameTestHelpers::WebViewHelper web_view_helper; |
5658 InitializeTextSelectionWebView(base_url_ + "move_range_selection_extent.html", | 5644 InitializeTextSelectionWebView(base_url_ + "move_range_selection_extent.html", |
5659 &web_view_helper); | 5645 &web_view_helper); |
5660 frame = web_view_helper.WebView()->MainFrameImpl(); | 5646 frame = web_view_helper.LocalMainFrame(); |
5661 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); | 5647 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); |
5662 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5648 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5663 | 5649 |
5664 frame->MoveRangeSelectionExtent(WebPoint(640, 480)); | 5650 frame->MoveRangeSelectionExtent(WebPoint(640, 480)); |
5665 EXPECT_EQ("This text is initially selected. 16-char footer.", | 5651 EXPECT_EQ("This text is initially selected. 16-char footer.", |
5666 SelectionAsString(frame)); | 5652 SelectionAsString(frame)); |
5667 | 5653 |
5668 frame->MoveRangeSelectionExtent(WebPoint(0, 0)); | 5654 frame->MoveRangeSelectionExtent(WebPoint(0, 0)); |
5669 EXPECT_EQ("16-char header. ", SelectionAsString(frame)); | 5655 EXPECT_EQ("16-char header. ", SelectionAsString(frame)); |
5670 | 5656 |
(...skipping 16 matching lines...) Expand all Loading... |
5687 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtentCannotCollapse) { | 5673 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtentCannotCollapse) { |
5688 WebLocalFrameBase* frame; | 5674 WebLocalFrameBase* frame; |
5689 WebRect start_web_rect; | 5675 WebRect start_web_rect; |
5690 WebRect end_web_rect; | 5676 WebRect end_web_rect; |
5691 | 5677 |
5692 RegisterMockedHttpURLLoad("move_range_selection_extent.html"); | 5678 RegisterMockedHttpURLLoad("move_range_selection_extent.html"); |
5693 | 5679 |
5694 FrameTestHelpers::WebViewHelper web_view_helper; | 5680 FrameTestHelpers::WebViewHelper web_view_helper; |
5695 InitializeTextSelectionWebView(base_url_ + "move_range_selection_extent.html", | 5681 InitializeTextSelectionWebView(base_url_ + "move_range_selection_extent.html", |
5696 &web_view_helper); | 5682 &web_view_helper); |
5697 frame = web_view_helper.WebView()->MainFrameImpl(); | 5683 frame = web_view_helper.LocalMainFrame(); |
5698 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); | 5684 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); |
5699 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5685 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5700 | 5686 |
5701 frame->MoveRangeSelectionExtent(BottomRightMinusOne(start_web_rect)); | 5687 frame->MoveRangeSelectionExtent(BottomRightMinusOne(start_web_rect)); |
5702 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); | 5688 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); |
5703 | 5689 |
5704 // Reset with swapped base and extent. | 5690 // Reset with swapped base and extent. |
5705 frame->SelectRange(TopLeft(end_web_rect), | 5691 frame->SelectRange(TopLeft(end_web_rect), |
5706 BottomRightMinusOne(start_web_rect)); | 5692 BottomRightMinusOne(start_web_rect)); |
5707 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); | 5693 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); |
5708 | 5694 |
5709 frame->MoveRangeSelectionExtent(BottomRightMinusOne(end_web_rect)); | 5695 frame->MoveRangeSelectionExtent(BottomRightMinusOne(end_web_rect)); |
5710 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); | 5696 EXPECT_EQ("This text is initially selected.", SelectionAsString(frame)); |
5711 } | 5697 } |
5712 | 5698 |
5713 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtentScollsInputField) { | 5699 TEST_P(ParameterizedWebFrameTest, MoveRangeSelectionExtentScollsInputField) { |
5714 WebLocalFrameBase* frame; | 5700 WebLocalFrameBase* frame; |
5715 WebRect start_web_rect; | 5701 WebRect start_web_rect; |
5716 WebRect end_web_rect; | 5702 WebRect end_web_rect; |
5717 | 5703 |
5718 RegisterMockedHttpURLLoad("move_range_selection_extent_input_field.html"); | 5704 RegisterMockedHttpURLLoad("move_range_selection_extent_input_field.html"); |
5719 | 5705 |
5720 FrameTestHelpers::WebViewHelper web_view_helper; | 5706 FrameTestHelpers::WebViewHelper web_view_helper; |
5721 InitializeTextSelectionWebView( | 5707 InitializeTextSelectionWebView( |
5722 base_url_ + "move_range_selection_extent_input_field.html", | 5708 base_url_ + "move_range_selection_extent_input_field.html", |
5723 &web_view_helper); | 5709 &web_view_helper); |
5724 frame = web_view_helper.WebView()->MainFrameImpl(); | 5710 frame = web_view_helper.LocalMainFrame(); |
5725 EXPECT_EQ("Length", SelectionAsString(frame)); | 5711 EXPECT_EQ("Length", SelectionAsString(frame)); |
5726 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); | 5712 web_view_helper.WebView()->SelectionBounds(start_web_rect, end_web_rect); |
5727 | 5713 |
5728 EXPECT_EQ(0, frame->GetFrame() | 5714 EXPECT_EQ(0, frame->GetFrame() |
5729 ->Selection() | 5715 ->Selection() |
5730 .ComputeVisibleSelectionInDOMTreeDeprecated() | 5716 .ComputeVisibleSelectionInDOMTreeDeprecated() |
5731 .RootEditableElement() | 5717 .RootEditableElement() |
5732 ->scrollLeft()); | 5718 ->scrollLeft()); |
5733 frame->MoveRangeSelectionExtent( | 5719 frame->MoveRangeSelectionExtent( |
5734 WebPoint(end_web_rect.x + 500, end_web_rect.y)); | 5720 WebPoint(end_web_rect.x + 500, end_web_rect.y)); |
(...skipping 13 matching lines...) Expand all Loading... |
5748 .ComputeOffsetInContainerNode(); | 5734 .ComputeOffsetInContainerNode(); |
5749 } | 5735 } |
5750 | 5736 |
5751 // positionForPoint returns the wrong values for contenteditable spans. See | 5737 // positionForPoint returns the wrong values for contenteditable spans. See |
5752 // http://crbug.com/238334. | 5738 // http://crbug.com/238334. |
5753 TEST_P(ParameterizedWebFrameTest, DISABLED_PositionForPointTest) { | 5739 TEST_P(ParameterizedWebFrameTest, DISABLED_PositionForPointTest) { |
5754 RegisterMockedHttpURLLoad("select_range_span_editable.html"); | 5740 RegisterMockedHttpURLLoad("select_range_span_editable.html"); |
5755 FrameTestHelpers::WebViewHelper web_view_helper; | 5741 FrameTestHelpers::WebViewHelper web_view_helper; |
5756 InitializeTextSelectionWebView(base_url_ + "select_range_span_editable.html", | 5742 InitializeTextSelectionWebView(base_url_ + "select_range_span_editable.html", |
5757 &web_view_helper); | 5743 &web_view_helper); |
5758 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 5744 WebLocalFrameBase* main_frame = web_view_helper.LocalMainFrame(); |
5759 LayoutObject* layout_object = | 5745 LayoutObject* layout_object = |
5760 main_frame->GetFrame() | 5746 main_frame->GetFrame() |
5761 ->Selection() | 5747 ->Selection() |
5762 .ComputeVisibleSelectionInDOMTreeDeprecated() | 5748 .ComputeVisibleSelectionInDOMTreeDeprecated() |
5763 .RootEditableElement() | 5749 .RootEditableElement() |
5764 ->GetLayoutObject(); | 5750 ->GetLayoutObject(); |
5765 EXPECT_EQ(0, ComputeOffset(layout_object, -1, -1)); | 5751 EXPECT_EQ(0, ComputeOffset(layout_object, -1, -1)); |
5766 EXPECT_EQ(64, ComputeOffset(layout_object, 1000, 1000)); | 5752 EXPECT_EQ(64, ComputeOffset(layout_object, 1000, 1000)); |
5767 | 5753 |
5768 RegisterMockedHttpURLLoad("select_range_div_editable.html"); | 5754 RegisterMockedHttpURLLoad("select_range_div_editable.html"); |
5769 InitializeTextSelectionWebView(base_url_ + "select_range_div_editable.html", | 5755 InitializeTextSelectionWebView(base_url_ + "select_range_div_editable.html", |
5770 &web_view_helper); | 5756 &web_view_helper); |
5771 main_frame = web_view_helper.WebView()->MainFrameImpl(); | 5757 main_frame = web_view_helper.LocalMainFrame(); |
5772 layout_object = main_frame->GetFrame() | 5758 layout_object = main_frame->GetFrame() |
5773 ->Selection() | 5759 ->Selection() |
5774 .ComputeVisibleSelectionInDOMTreeDeprecated() | 5760 .ComputeVisibleSelectionInDOMTreeDeprecated() |
5775 .RootEditableElement() | 5761 .RootEditableElement() |
5776 ->GetLayoutObject(); | 5762 ->GetLayoutObject(); |
5777 EXPECT_EQ(0, ComputeOffset(layout_object, -1, -1)); | 5763 EXPECT_EQ(0, ComputeOffset(layout_object, -1, -1)); |
5778 EXPECT_EQ(64, ComputeOffset(layout_object, 1000, 1000)); | 5764 EXPECT_EQ(64, ComputeOffset(layout_object, 1000, 1000)); |
5779 } | 5765 } |
5780 | 5766 |
5781 #if !OS(MACOSX) && !OS(LINUX) | 5767 #if !OS(MACOSX) && !OS(LINUX) |
5782 TEST_P(ParameterizedWebFrameTest, | 5768 TEST_P(ParameterizedWebFrameTest, |
5783 SelectRangeStaysHorizontallyAlignedWhenMoved) { | 5769 SelectRangeStaysHorizontallyAlignedWhenMoved) { |
5784 RegisterMockedHttpURLLoad("move_caret.html"); | 5770 RegisterMockedHttpURLLoad("move_caret.html"); |
5785 | 5771 |
5786 FrameTestHelpers::WebViewHelper web_view_helper; | 5772 FrameTestHelpers::WebViewHelper web_view_helper; |
5787 InitializeTextSelectionWebView(base_url_ + "move_caret.html", | 5773 InitializeTextSelectionWebView(base_url_ + "move_caret.html", |
5788 &web_view_helper); | 5774 &web_view_helper); |
5789 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 5775 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
5790 | 5776 |
5791 WebRect initial_start_rect; | 5777 WebRect initial_start_rect; |
5792 WebRect initial_end_rect; | 5778 WebRect initial_end_rect; |
5793 WebRect start_rect; | 5779 WebRect start_rect; |
5794 WebRect end_rect; | 5780 WebRect end_rect; |
5795 | 5781 |
5796 frame->ExecuteScript(WebScriptSource("selectRange();")); | 5782 frame->ExecuteScript(WebScriptSource("selectRange();")); |
5797 web_view_helper.WebView()->SelectionBounds(initial_start_rect, | 5783 web_view_helper.WebView()->SelectionBounds(initial_start_rect, |
5798 initial_end_rect); | 5784 initial_end_rect); |
5799 WebPoint moved_start(TopLeft(initial_start_rect)); | 5785 WebPoint moved_start(TopLeft(initial_start_rect)); |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6550 | 6536 |
6551 private: | 6537 private: |
6552 int number_of_times_checked_; | 6538 int number_of_times_checked_; |
6553 }; | 6539 }; |
6554 | 6540 |
6555 TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) { | 6541 TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) { |
6556 RegisterMockedHttpURLLoad("spell.html"); | 6542 RegisterMockedHttpURLLoad("spell.html"); |
6557 FrameTestHelpers::WebViewHelper web_view_helper; | 6543 FrameTestHelpers::WebViewHelper web_view_helper; |
6558 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); | 6544 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); |
6559 | 6545 |
6560 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 6546 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
6561 TextCheckClient textcheck; | 6547 TextCheckClient textcheck; |
6562 frame->SetTextCheckClient(&textcheck); | 6548 frame->SetTextCheckClient(&textcheck); |
6563 | 6549 |
6564 Document* document = frame->GetFrame()->GetDocument(); | 6550 Document* document = frame->GetFrame()->GetDocument(); |
6565 Element* element = document->getElementById("data"); | 6551 Element* element = document->getElementById("data"); |
6566 | 6552 |
6567 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( | 6553 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( |
6568 WebSettings::kEditingBehaviorWin); | 6554 WebSettings::kEditingBehaviorWin); |
6569 | 6555 |
6570 element->focus(); | 6556 element->focus(); |
(...skipping 26 matching lines...) Expand all Loading... |
6597 WebFrameContentDumper::DumpWebViewAsText( | 6583 WebFrameContentDumper::DumpWebViewAsText( |
6598 web_view_helper.WebView(), std::numeric_limits<size_t>::max()) | 6584 web_view_helper.WebView(), std::numeric_limits<size_t>::max()) |
6599 .Utf8()); | 6585 .Utf8()); |
6600 } | 6586 } |
6601 | 6587 |
6602 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { | 6588 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { |
6603 RegisterMockedHttpURLLoad("spell.html"); | 6589 RegisterMockedHttpURLLoad("spell.html"); |
6604 FrameTestHelpers::WebViewHelper web_view_helper; | 6590 FrameTestHelpers::WebViewHelper web_view_helper; |
6605 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); | 6591 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); |
6606 | 6592 |
6607 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 6593 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
6608 TextCheckClient textcheck; | 6594 TextCheckClient textcheck; |
6609 frame->SetTextCheckClient(&textcheck); | 6595 frame->SetTextCheckClient(&textcheck); |
6610 | 6596 |
6611 Document* document = frame->GetFrame()->GetDocument(); | 6597 Document* document = frame->GetFrame()->GetDocument(); |
6612 Element* element = document->getElementById("data"); | 6598 Element* element = document->getElementById("data"); |
6613 | 6599 |
6614 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( | 6600 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( |
6615 WebSettings::kEditingBehaviorWin); | 6601 WebSettings::kEditingBehaviorWin); |
6616 | 6602 |
6617 element->focus(); | 6603 element->focus(); |
(...skipping 30 matching lines...) Expand all Loading... |
6648 for (size_t i = 0; i < document_markers.size(); ++i) | 6634 for (size_t i = 0; i < document_markers.size(); ++i) |
6649 result.push_back(document_markers[i]->StartOffset()); | 6635 result.push_back(document_markers[i]->StartOffset()); |
6650 offsets->Assign(result); | 6636 offsets->Assign(result); |
6651 } | 6637 } |
6652 | 6638 |
6653 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) { | 6639 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) { |
6654 RegisterMockedHttpURLLoad("spell.html"); | 6640 RegisterMockedHttpURLLoad("spell.html"); |
6655 FrameTestHelpers::WebViewHelper web_view_helper; | 6641 FrameTestHelpers::WebViewHelper web_view_helper; |
6656 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); | 6642 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); |
6657 | 6643 |
6658 WebLocalFrameBase* web_frame = web_view_helper.WebView()->MainFrameImpl(); | 6644 WebLocalFrameBase* web_frame = web_view_helper.LocalMainFrame(); |
6659 TextCheckClient textcheck; | 6645 TextCheckClient textcheck; |
6660 web_frame->SetTextCheckClient(&textcheck); | 6646 web_frame->SetTextCheckClient(&textcheck); |
6661 | 6647 |
6662 LocalFrame* frame = web_frame->GetFrame(); | 6648 LocalFrame* frame = web_frame->GetFrame(); |
6663 Document* document = frame->GetDocument(); | 6649 Document* document = frame->GetDocument(); |
6664 Element* element = document->getElementById("data"); | 6650 Element* element = document->getElementById("data"); |
6665 | 6651 |
6666 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( | 6652 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( |
6667 WebSettings::kEditingBehaviorWin); | 6653 WebSettings::kEditingBehaviorWin); |
6668 | 6654 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6727 } | 6713 } |
6728 | 6714 |
6729 WebTextCheckingCompletion* completion_; | 6715 WebTextCheckingCompletion* completion_; |
6730 }; | 6716 }; |
6731 | 6717 |
6732 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) { | 6718 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) { |
6733 RegisterMockedHttpURLLoad("spell.html"); | 6719 RegisterMockedHttpURLLoad("spell.html"); |
6734 FrameTestHelpers::WebViewHelper web_view_helper; | 6720 FrameTestHelpers::WebViewHelper web_view_helper; |
6735 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); | 6721 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); |
6736 | 6722 |
6737 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 6723 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
6738 StubbornTextCheckClient textcheck; | 6724 StubbornTextCheckClient textcheck; |
6739 frame->SetTextCheckClient(&textcheck); | 6725 frame->SetTextCheckClient(&textcheck); |
6740 | 6726 |
6741 Document* document = frame->GetFrame()->GetDocument(); | 6727 Document* document = frame->GetFrame()->GetDocument(); |
6742 Element* element = document->getElementById("data"); | 6728 Element* element = document->getElementById("data"); |
6743 | 6729 |
6744 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( | 6730 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( |
6745 WebSettings::kEditingBehaviorWin); | 6731 WebSettings::kEditingBehaviorWin); |
6746 | 6732 |
6747 element->focus(); | 6733 element->focus(); |
(...skipping 21 matching lines...) Expand all Loading... |
6769 // write-after-free when there's no spellcheck client set. | 6755 // write-after-free when there's no spellcheck client set. |
6770 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) { | 6756 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) { |
6771 // The relevant code paths are obsolete with idle time spell checker. | 6757 // The relevant code paths are obsolete with idle time spell checker. |
6772 if (RuntimeEnabledFeatures::IdleTimeSpellCheckingEnabled()) | 6758 if (RuntimeEnabledFeatures::IdleTimeSpellCheckingEnabled()) |
6773 return; | 6759 return; |
6774 | 6760 |
6775 RegisterMockedHttpURLLoad("spell.html"); | 6761 RegisterMockedHttpURLLoad("spell.html"); |
6776 FrameTestHelpers::WebViewHelper web_view_helper; | 6762 FrameTestHelpers::WebViewHelper web_view_helper; |
6777 web_view_helper.InitializeAndLoad(base_url_ + "spell.html"); | 6763 web_view_helper.InitializeAndLoad(base_url_ + "spell.html"); |
6778 | 6764 |
6779 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 6765 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
6780 frame->SetTextCheckClient(0); | 6766 frame->SetTextCheckClient(0); |
6781 | 6767 |
6782 Document* document = frame->GetFrame()->GetDocument(); | 6768 Document* document = frame->GetFrame()->GetDocument(); |
6783 Element* element = document->getElementById("data"); | 6769 Element* element = document->getElementById("data"); |
6784 | 6770 |
6785 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( | 6771 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( |
6786 WebSettings::kEditingBehaviorWin); | 6772 WebSettings::kEditingBehaviorWin); |
6787 | 6773 |
6788 element->focus(); | 6774 element->focus(); |
6789 frame->GetFrame()->GetEditor().ReplaceSelectionWithText( | 6775 frame->GetFrame()->GetEditor().ReplaceSelectionWithText( |
6790 "A", false, false, InputEvent::InputType::kInsertReplacementText); | 6776 "A", false, false, InputEvent::InputType::kInsertReplacementText); |
6791 frame->GetFrame()->GetSpellChecker().CancelCheck(); | 6777 frame->GetFrame()->GetSpellChecker().CancelCheck(); |
6792 } | 6778 } |
6793 | 6779 |
6794 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) { | 6780 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) { |
6795 RegisterMockedHttpURLLoad("spell.html"); | 6781 RegisterMockedHttpURLLoad("spell.html"); |
6796 FrameTestHelpers::WebViewHelper web_view_helper; | 6782 FrameTestHelpers::WebViewHelper web_view_helper; |
6797 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); | 6783 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); |
6798 | 6784 |
6799 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 6785 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
6800 StubbornTextCheckClient textcheck; | 6786 StubbornTextCheckClient textcheck; |
6801 frame->SetTextCheckClient(&textcheck); | 6787 frame->SetTextCheckClient(&textcheck); |
6802 | 6788 |
6803 Document* document = frame->GetFrame()->GetDocument(); | 6789 Document* document = frame->GetFrame()->GetDocument(); |
6804 Element* element = document->getElementById("data"); | 6790 Element* element = document->getElementById("data"); |
6805 | 6791 |
6806 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( | 6792 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( |
6807 WebSettings::kEditingBehaviorWin); | 6793 WebSettings::kEditingBehaviorWin); |
6808 | 6794 |
6809 element->focus(); | 6795 element->focus(); |
(...skipping 17 matching lines...) Expand all Loading... |
6827 | 6813 |
6828 textcheck.KickNoResults(); | 6814 textcheck.KickNoResults(); |
6829 EXPECT_EQ(0U, document->Markers().Markers().size()); | 6815 EXPECT_EQ(0U, document->Markers().Markers().size()); |
6830 } | 6816 } |
6831 | 6817 |
6832 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) { | 6818 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) { |
6833 RegisterMockedHttpURLLoad("spell.html"); | 6819 RegisterMockedHttpURLLoad("spell.html"); |
6834 FrameTestHelpers::WebViewHelper web_view_helper; | 6820 FrameTestHelpers::WebViewHelper web_view_helper; |
6835 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); | 6821 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); |
6836 | 6822 |
6837 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 6823 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
6838 StubbornTextCheckClient textcheck; | 6824 StubbornTextCheckClient textcheck; |
6839 frame->SetTextCheckClient(&textcheck); | 6825 frame->SetTextCheckClient(&textcheck); |
6840 | 6826 |
6841 Document* document = frame->GetFrame()->GetDocument(); | 6827 Document* document = frame->GetFrame()->GetDocument(); |
6842 Element* element = document->getElementById("data"); | 6828 Element* element = document->getElementById("data"); |
6843 | 6829 |
6844 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( | 6830 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( |
6845 WebSettings::kEditingBehaviorWin); | 6831 WebSettings::kEditingBehaviorWin); |
6846 | 6832 |
6847 element->focus(); | 6833 element->focus(); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7074 TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) { | 7060 TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) { |
7075 RegisterMockedHttpURLLoad("long_scroll.html"); | 7061 RegisterMockedHttpURLLoad("long_scroll.html"); |
7076 TestScrolledFrameClient client; | 7062 TestScrolledFrameClient client; |
7077 | 7063 |
7078 // Make sure we initialize to minimum scale, even if the window size | 7064 // Make sure we initialize to minimum scale, even if the window size |
7079 // only becomes available after the load begins. | 7065 // only becomes available after the load begins. |
7080 FrameTestHelpers::WebViewHelper web_view_helper; | 7066 FrameTestHelpers::WebViewHelper web_view_helper; |
7081 web_view_helper.InitializeAndLoad(base_url_ + "long_scroll.html", &client); | 7067 web_view_helper.InitializeAndLoad(base_url_ + "long_scroll.html", &client); |
7082 web_view_helper.Resize(WebSize(1000, 1000)); | 7068 web_view_helper.Resize(WebSize(1000, 1000)); |
7083 | 7069 |
7084 WebLocalFrameBase* frame_impl = web_view_helper.WebView()->MainFrameImpl(); | 7070 WebLocalFrameBase* frame_impl = web_view_helper.LocalMainFrame(); |
7085 DocumentLoader::InitialScrollState& initial_scroll_state = | 7071 DocumentLoader::InitialScrollState& initial_scroll_state = |
7086 frame_impl->GetFrame() | 7072 frame_impl->GetFrame() |
7087 ->Loader() | 7073 ->Loader() |
7088 .GetDocumentLoader() | 7074 .GetDocumentLoader() |
7089 ->GetInitialScrollState(); | 7075 ->GetInitialScrollState(); |
7090 | 7076 |
7091 EXPECT_FALSE(client.WasFrameScrolled()); | 7077 EXPECT_FALSE(client.WasFrameScrolled()); |
7092 EXPECT_FALSE(initial_scroll_state.was_scrolled_by_user); | 7078 EXPECT_FALSE(initial_scroll_state.was_scrolled_by_user); |
7093 | 7079 |
7094 auto* scrollable_area = | 7080 auto* scrollable_area = |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7268 | 7254 |
7269 // decidePolicyForNavigation should be called both for the original request | 7255 // decidePolicyForNavigation should be called both for the original request |
7270 // and the ctrl+click. | 7256 // and the ctrl+click. |
7271 EXPECT_EQ(2, web_frame_client.DecidePolicyCallCount()); | 7257 EXPECT_EQ(2, web_frame_client.DecidePolicyCallCount()); |
7272 } | 7258 } |
7273 | 7259 |
7274 TEST_P(ParameterizedWebFrameTest, BackToReload) { | 7260 TEST_P(ParameterizedWebFrameTest, BackToReload) { |
7275 RegisterMockedHttpURLLoad("fragment_middle_click.html"); | 7261 RegisterMockedHttpURLLoad("fragment_middle_click.html"); |
7276 FrameTestHelpers::WebViewHelper web_view_helper; | 7262 FrameTestHelpers::WebViewHelper web_view_helper; |
7277 web_view_helper.InitializeAndLoad(base_url_ + "fragment_middle_click.html"); | 7263 web_view_helper.InitializeAndLoad(base_url_ + "fragment_middle_click.html"); |
7278 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 7264 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
7279 const FrameLoader& main_frame_loader = | 7265 const FrameLoader& main_frame_loader = |
7280 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->Loader(); | 7266 web_view_helper.LocalMainFrame()->GetFrame()->Loader(); |
7281 Persistent<HistoryItem> first_item = | 7267 Persistent<HistoryItem> first_item = |
7282 main_frame_loader.GetDocumentLoader()->GetHistoryItem(); | 7268 main_frame_loader.GetDocumentLoader()->GetHistoryItem(); |
7283 EXPECT_TRUE(first_item); | 7269 EXPECT_TRUE(first_item); |
7284 | 7270 |
7285 RegisterMockedHttpURLLoad("white-1x1.png"); | 7271 RegisterMockedHttpURLLoad("white-1x1.png"); |
7286 FrameTestHelpers::LoadFrame(frame, base_url_ + "white-1x1.png"); | 7272 FrameTestHelpers::LoadFrame(frame, base_url_ + "white-1x1.png"); |
7287 EXPECT_NE(first_item.Get(), | 7273 EXPECT_NE(first_item.Get(), |
7288 main_frame_loader.GetDocumentLoader()->GetHistoryItem()); | 7274 main_frame_loader.GetDocumentLoader()->GetHistoryItem()); |
7289 | 7275 |
7290 FrameTestHelpers::LoadHistoryItem(frame, WebHistoryItem(first_item.Get()), | 7276 FrameTestHelpers::LoadHistoryItem(frame, WebHistoryItem(first_item.Get()), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7325 EXPECT_EQ(item.UrlString(), main_frame->GetDocument().Url().GetString()); | 7311 EXPECT_EQ(item.UrlString(), main_frame->GetDocument().Url().GetString()); |
7326 EXPECT_EQ(item.UrlString(), WebString(main_frame_loader.GetDocumentLoader() | 7312 EXPECT_EQ(item.UrlString(), WebString(main_frame_loader.GetDocumentLoader() |
7327 ->GetHistoryItem() | 7313 ->GetHistoryItem() |
7328 ->UrlString())); | 7314 ->UrlString())); |
7329 } | 7315 } |
7330 | 7316 |
7331 TEST_P(ParameterizedWebFrameTest, ReloadPost) { | 7317 TEST_P(ParameterizedWebFrameTest, ReloadPost) { |
7332 RegisterMockedHttpURLLoad("reload_post.html"); | 7318 RegisterMockedHttpURLLoad("reload_post.html"); |
7333 FrameTestHelpers::WebViewHelper web_view_helper; | 7319 FrameTestHelpers::WebViewHelper web_view_helper; |
7334 web_view_helper.InitializeAndLoad(base_url_ + "reload_post.html"); | 7320 web_view_helper.InitializeAndLoad(base_url_ + "reload_post.html"); |
7335 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 7321 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
7336 | 7322 |
7337 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), | 7323 FrameTestHelpers::LoadFrame(web_view_helper.WebView()->MainFrameImpl(), |
7338 "javascript:document.forms[0].submit()"); | 7324 "javascript:document.forms[0].submit()"); |
7339 // Pump requests one more time after the javascript URL has executed to | 7325 // Pump requests one more time after the javascript URL has executed to |
7340 // trigger the actual POST load request. | 7326 // trigger the actual POST load request. |
7341 FrameTestHelpers::PumpPendingRequestsForFrameToLoad( | 7327 FrameTestHelpers::PumpPendingRequestsForFrameToLoad( |
7342 web_view_helper.WebView()->MainFrame()); | 7328 web_view_helper.WebView()->MainFrame()); |
7343 EXPECT_EQ(WebString::FromUTF8("POST"), | 7329 EXPECT_EQ(WebString::FromUTF8("POST"), |
7344 frame->DataSource()->GetRequest().HttpMethod()); | 7330 frame->DataSource()->GetRequest().HttpMethod()); |
7345 | 7331 |
7346 FrameTestHelpers::ReloadFrame(frame); | 7332 FrameTestHelpers::ReloadFrame(frame); |
7347 EXPECT_EQ(WebCachePolicy::kValidatingCacheData, | 7333 EXPECT_EQ(WebCachePolicy::kValidatingCacheData, |
7348 frame->DataSource()->GetRequest().GetCachePolicy()); | 7334 frame->DataSource()->GetRequest().GetCachePolicy()); |
7349 EXPECT_EQ(kWebNavigationTypeFormResubmitted, | 7335 EXPECT_EQ(kWebNavigationTypeFormResubmitted, |
7350 frame->DataSource()->GetNavigationType()); | 7336 frame->DataSource()->GetNavigationType()); |
7351 } | 7337 } |
7352 | 7338 |
7353 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) { | 7339 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) { |
7354 RegisterMockedHttpURLLoad("fragment_middle_click.html"); | 7340 RegisterMockedHttpURLLoad("fragment_middle_click.html"); |
7355 FrameTestHelpers::WebViewHelper web_view_helper; | 7341 FrameTestHelpers::WebViewHelper web_view_helper; |
7356 web_view_helper.InitializeAndLoad(base_url_ + "fragment_middle_click.html"); | 7342 web_view_helper.InitializeAndLoad(base_url_ + "fragment_middle_click.html"); |
7357 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 7343 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
7358 const FrameLoader& main_frame_loader = | 7344 const FrameLoader& main_frame_loader = |
7359 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->Loader(); | 7345 web_view_helper.LocalMainFrame()->GetFrame()->Loader(); |
7360 Persistent<HistoryItem> first_item = | 7346 Persistent<HistoryItem> first_item = |
7361 main_frame_loader.GetDocumentLoader()->GetHistoryItem(); | 7347 main_frame_loader.GetDocumentLoader()->GetHistoryItem(); |
7362 EXPECT_TRUE(first_item); | 7348 EXPECT_TRUE(first_item); |
7363 | 7349 |
7364 RegisterMockedHttpURLLoad("white-1x1.png"); | 7350 RegisterMockedHttpURLLoad("white-1x1.png"); |
7365 FrameTestHelpers::LoadFrame(frame, base_url_ + "white-1x1.png"); | 7351 FrameTestHelpers::LoadFrame(frame, base_url_ + "white-1x1.png"); |
7366 EXPECT_NE(first_item.Get(), | 7352 EXPECT_NE(first_item.Get(), |
7367 main_frame_loader.GetDocumentLoader()->GetHistoryItem()); | 7353 main_frame_loader.GetDocumentLoader()->GetHistoryItem()); |
7368 | 7354 |
7369 // Cache policy overrides should take. | 7355 // Cache policy overrides should take. |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7531 base_url_ + "foo_with_image.html"); | 7517 base_url_ + "foo_with_image.html"); |
7532 | 7518 |
7533 // 2 images are requested, and each triggers 2 willSendRequest() calls, | 7519 // 2 images are requested, and each triggers 2 willSendRequest() calls, |
7534 // once for preloading and once for the real request. | 7520 // once for preloading and once for the real request. |
7535 EXPECT_EQ(client.NumOfImageRequests(), 4); | 7521 EXPECT_EQ(client.NumOfImageRequests(), 4); |
7536 } | 7522 } |
7537 | 7523 |
7538 TEST_P(ParameterizedWebFrameTest, WebNodeImageContents) { | 7524 TEST_P(ParameterizedWebFrameTest, WebNodeImageContents) { |
7539 FrameTestHelpers::WebViewHelper web_view_helper; | 7525 FrameTestHelpers::WebViewHelper web_view_helper; |
7540 web_view_helper.InitializeAndLoad("about:blank"); | 7526 web_view_helper.InitializeAndLoad("about:blank"); |
7541 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 7527 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
7542 | 7528 |
7543 static const char kBluePNG[] = | 7529 static const char kBluePNG[] = |
7544 "<img " | 7530 "<img " |
7545 "src=\"data:image/" | 7531 "src=\"data:image/" |
7546 "png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+" | 7532 "png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+" |
7547 "9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90IAAAAAElFTkSuQmCC\">"; | 7533 "9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90IAAAAAElFTkSuQmCC\">"; |
7548 | 7534 |
7549 // Load up the image and test that we can extract the contents. | 7535 // Load up the image and test that we can extract the contents. |
7550 KURL test_url = ToKURL("about:blank"); | 7536 KURL test_url = ToKURL("about:blank"); |
7551 FrameTestHelpers::LoadHTMLString(frame, kBluePNG, test_url); | 7537 FrameTestHelpers::LoadHTMLString(frame, kBluePNG, test_url); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7679 // Tests that the first navigation in an initially blank subframe will result in | 7665 // Tests that the first navigation in an initially blank subframe will result in |
7680 // a history entry being replaced and not a new one being added. | 7666 // a history entry being replaced and not a new one being added. |
7681 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) { | 7667 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) { |
7682 RegisterMockedHttpURLLoad("history.html"); | 7668 RegisterMockedHttpURLLoad("history.html"); |
7683 RegisterMockedHttpURLLoad("find.html"); | 7669 RegisterMockedHttpURLLoad("find.html"); |
7684 | 7670 |
7685 TestHistoryWebFrameClient client; | 7671 TestHistoryWebFrameClient client; |
7686 FrameTestHelpers::WebViewHelper web_view_helper; | 7672 FrameTestHelpers::WebViewHelper web_view_helper; |
7687 web_view_helper.InitializeAndLoad("about:blank", &client); | 7673 web_view_helper.InitializeAndLoad("about:blank", &client); |
7688 | 7674 |
7689 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 7675 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
7690 | 7676 |
7691 frame->ExecuteScript(WebScriptSource(WebString::FromUTF8( | 7677 frame->ExecuteScript(WebScriptSource(WebString::FromUTF8( |
7692 "document.body.appendChild(document.createElement('iframe'))"))); | 7678 "document.body.appendChild(document.createElement('iframe'))"))); |
7693 | 7679 |
7694 WebLocalFrameBase* iframe = ToWebLocalFrameBase(frame->FirstChild()); | 7680 WebLocalFrameBase* iframe = ToWebLocalFrameBase(frame->FirstChild()); |
7695 ASSERT_EQ(&client.ChildClient(), iframe->Client()); | 7681 ASSERT_EQ(&client.ChildClient(), iframe->Client()); |
7696 | 7682 |
7697 std::string url1 = base_url_ + "history.html"; | 7683 std::string url1 = base_url_ + "history.html"; |
7698 FrameTestHelpers::LoadFrame(iframe, url1); | 7684 FrameTestHelpers::LoadFrame(iframe, url1); |
7699 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8()); | 7685 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8()); |
7700 EXPECT_TRUE(client.ChildClient().ReplacesCurrentHistoryItem()); | 7686 EXPECT_TRUE(client.ChildClient().ReplacesCurrentHistoryItem()); |
7701 | 7687 |
7702 std::string url2 = base_url_ + "find.html"; | 7688 std::string url2 = base_url_ + "find.html"; |
7703 FrameTestHelpers::LoadFrame(iframe, url2); | 7689 FrameTestHelpers::LoadFrame(iframe, url2); |
7704 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8()); | 7690 EXPECT_EQ(url2, iframe->GetDocument().Url().GetString().Utf8()); |
7705 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem()); | 7691 EXPECT_FALSE(client.ChildClient().ReplacesCurrentHistoryItem()); |
7706 } | 7692 } |
7707 | 7693 |
7708 // Tests that a navigation in a frame with a non-blank initial URL will create | 7694 // Tests that a navigation in a frame with a non-blank initial URL will create |
7709 // a new history item, unlike the case above. | 7695 // a new history item, unlike the case above. |
7710 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) { | 7696 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) { |
7711 RegisterMockedHttpURLLoad("history.html"); | 7697 RegisterMockedHttpURLLoad("history.html"); |
7712 RegisterMockedHttpURLLoad("find.html"); | 7698 RegisterMockedHttpURLLoad("find.html"); |
7713 | 7699 |
7714 TestHistoryWebFrameClient client; | 7700 TestHistoryWebFrameClient client; |
7715 FrameTestHelpers::WebViewHelper web_view_helper; | 7701 FrameTestHelpers::WebViewHelper web_view_helper; |
7716 web_view_helper.InitializeAndLoad("about:blank", &client); | 7702 web_view_helper.InitializeAndLoad("about:blank", &client); |
7717 | 7703 |
7718 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 7704 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
7719 | 7705 |
7720 std::string url1 = base_url_ + "history.html"; | 7706 std::string url1 = base_url_ + "history.html"; |
7721 FrameTestHelpers::LoadFrame( | 7707 FrameTestHelpers::LoadFrame( |
7722 frame, | 7708 frame, |
7723 "javascript:var f = document.createElement('iframe'); " | 7709 "javascript:var f = document.createElement('iframe'); " |
7724 "f.src = '" + | 7710 "f.src = '" + |
7725 url1 + | 7711 url1 + |
7726 "';" | 7712 "';" |
7727 "document.body.appendChild(f)"); | 7713 "document.body.appendChild(f)"); |
7728 | 7714 |
(...skipping 23 matching lines...) Expand all Loading... |
7752 PaintLayerCompositor* compositor = web_view_helper.WebView()->Compositor(); | 7738 PaintLayerCompositor* compositor = web_view_helper.WebView()->Compositor(); |
7753 ASSERT_TRUE(compositor->ScrollLayer()); | 7739 ASSERT_TRUE(compositor->ScrollLayer()); |
7754 | 7740 |
7755 // Verify that the WebLayer is not scrollable initially. | 7741 // Verify that the WebLayer is not scrollable initially. |
7756 GraphicsLayer* scroll_layer = compositor->ScrollLayer(); | 7742 GraphicsLayer* scroll_layer = compositor->ScrollLayer(); |
7757 WebLayer* web_scroll_layer = scroll_layer->PlatformLayer(); | 7743 WebLayer* web_scroll_layer = scroll_layer->PlatformLayer(); |
7758 ASSERT_FALSE(web_scroll_layer->UserScrollableHorizontal()); | 7744 ASSERT_FALSE(web_scroll_layer->UserScrollableHorizontal()); |
7759 ASSERT_FALSE(web_scroll_layer->UserScrollableVertical()); | 7745 ASSERT_FALSE(web_scroll_layer->UserScrollableVertical()); |
7760 | 7746 |
7761 // Call javascript to make the layer scrollable, and verify it. | 7747 // Call javascript to make the layer scrollable, and verify it. |
7762 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 7748 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
7763 frame->ExecuteScript(WebScriptSource("allowScroll();")); | 7749 frame->ExecuteScript(WebScriptSource("allowScroll();")); |
7764 web_view_helper.WebView()->UpdateAllLifecyclePhases(); | 7750 web_view_helper.WebView()->UpdateAllLifecyclePhases(); |
7765 ASSERT_TRUE(web_scroll_layer->UserScrollableHorizontal()); | 7751 ASSERT_TRUE(web_scroll_layer->UserScrollableHorizontal()); |
7766 ASSERT_TRUE(web_scroll_layer->UserScrollableVertical()); | 7752 ASSERT_TRUE(web_scroll_layer->UserScrollableVertical()); |
7767 } | 7753 } |
7768 | 7754 |
7769 // Test that currentHistoryItem reflects the current page, not the provisional | 7755 // Test that currentHistoryItem reflects the current page, not the provisional |
7770 // load. | 7756 // load. |
7771 TEST_P(ParameterizedWebFrameTest, CurrentHistoryItem) { | 7757 TEST_P(ParameterizedWebFrameTest, CurrentHistoryItem) { |
7772 RegisterMockedHttpURLLoad("fixed_layout.html"); | 7758 RegisterMockedHttpURLLoad("fixed_layout.html"); |
7773 std::string url = base_url_ + "fixed_layout.html"; | 7759 std::string url = base_url_ + "fixed_layout.html"; |
7774 | 7760 |
7775 FrameTestHelpers::WebViewHelper web_view_helper; | 7761 FrameTestHelpers::WebViewHelper web_view_helper; |
7776 web_view_helper.Initialize(); | 7762 web_view_helper.Initialize(); |
7777 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 7763 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); |
7778 const FrameLoader& main_frame_loader = | 7764 const FrameLoader& main_frame_loader = |
7779 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->Loader(); | 7765 web_view_helper.LocalMainFrame()->GetFrame()->Loader(); |
7780 WebURLRequest request(ToKURL(url)); | 7766 WebURLRequest request(ToKURL(url)); |
7781 frame->LoadRequest(request); | 7767 frame->LoadRequest(request); |
7782 | 7768 |
7783 // Before commit, there is no history item. | 7769 // Before commit, there is no history item. |
7784 EXPECT_FALSE(main_frame_loader.GetDocumentLoader()->GetHistoryItem()); | 7770 EXPECT_FALSE(main_frame_loader.GetDocumentLoader()->GetHistoryItem()); |
7785 | 7771 |
7786 FrameTestHelpers::PumpPendingRequestsForFrameToLoad(frame); | 7772 FrameTestHelpers::PumpPendingRequestsForFrameToLoad(frame); |
7787 | 7773 |
7788 // After commit, there is. | 7774 // After commit, there is. |
7789 HistoryItem* item = main_frame_loader.GetDocumentLoader()->GetHistoryItem(); | 7775 HistoryItem* item = main_frame_loader.GetDocumentLoader()->GetHistoryItem(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7852 EXPECT_EQ(500, right_fixed->OffsetLeft() + right_fixed->OffsetWidth()); | 7838 EXPECT_EQ(500, right_fixed->OffsetLeft() + right_fixed->OffsetWidth()); |
7853 EXPECT_EQ(500, left_right_fixed->OffsetWidth()); | 7839 EXPECT_EQ(500, left_right_fixed->OffsetWidth()); |
7854 } | 7840 } |
7855 | 7841 |
7856 TEST_P(ParameterizedWebFrameTest, FrameViewMoveWithSetFrameRect) { | 7842 TEST_P(ParameterizedWebFrameTest, FrameViewMoveWithSetFrameRect) { |
7857 FrameTestHelpers::WebViewHelper web_view_helper; | 7843 FrameTestHelpers::WebViewHelper web_view_helper; |
7858 web_view_helper.InitializeAndLoad("about:blank"); | 7844 web_view_helper.InitializeAndLoad("about:blank"); |
7859 web_view_helper.Resize(WebSize(200, 200)); | 7845 web_view_helper.Resize(WebSize(200, 200)); |
7860 web_view_helper.WebView()->UpdateAllLifecyclePhases(); | 7846 web_view_helper.WebView()->UpdateAllLifecyclePhases(); |
7861 | 7847 |
7862 LocalFrameView* frame_view = | 7848 LocalFrameView* frame_view = web_view_helper.LocalMainFrame()->GetFrameView(); |
7863 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
7864 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frame_view->FrameRect()); | 7849 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frame_view->FrameRect()); |
7865 frame_view->SetFrameRect(IntRect(100, 100, 200, 200)); | 7850 frame_view->SetFrameRect(IntRect(100, 100, 200, 200)); |
7866 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frame_view->FrameRect()); | 7851 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frame_view->FrameRect()); |
7867 } | 7852 } |
7868 | 7853 |
7869 TEST_F(WebFrameTest, FrameViewScrollAccountsForBrowserControls) { | 7854 TEST_F(WebFrameTest, FrameViewScrollAccountsForBrowserControls) { |
7870 FakeCompositingWebViewClient client; | 7855 FakeCompositingWebViewClient client; |
7871 RegisterMockedHttpURLLoad("long_scroll.html"); | 7856 RegisterMockedHttpURLLoad("long_scroll.html"); |
7872 FrameTestHelpers::WebViewHelper web_view_helper; | 7857 FrameTestHelpers::WebViewHelper web_view_helper; |
7873 web_view_helper.InitializeAndLoad(base_url_ + "long_scroll.html", nullptr, | 7858 web_view_helper.InitializeAndLoad(base_url_ + "long_scroll.html", nullptr, |
7874 &client, nullptr, ConfigureAndroid); | 7859 &client, nullptr, ConfigureAndroid); |
7875 | 7860 |
7876 WebViewBase* web_view = web_view_helper.WebView(); | 7861 WebViewBase* web_view = web_view_helper.WebView(); |
7877 LocalFrameView* frame_view = | 7862 LocalFrameView* frame_view = web_view_helper.LocalMainFrame()->GetFrameView(); |
7878 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
7879 | 7863 |
7880 float browser_controls_height = 40; | 7864 float browser_controls_height = 40; |
7881 web_view->ResizeWithBrowserControls(WebSize(100, 100), | 7865 web_view->ResizeWithBrowserControls(WebSize(100, 100), |
7882 browser_controls_height, false); | 7866 browser_controls_height, false); |
7883 web_view->SetPageScaleFactor(2.0f); | 7867 web_view->SetPageScaleFactor(2.0f); |
7884 web_view->UpdateAllLifecyclePhases(); | 7868 web_view->UpdateAllLifecyclePhases(); |
7885 | 7869 |
7886 web_view->MainFrame()->SetScrollOffset(WebSize(0, 2000)); | 7870 web_view->MainFrame()->SetScrollOffset(WebSize(0, 2000)); |
7887 EXPECT_SIZE_EQ(ScrollOffset(0, 1900), frame_view->GetScrollOffset()); | 7871 EXPECT_SIZE_EQ(ScrollOffset(0, 1900), frame_view->GetScrollOffset()); |
7888 | 7872 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7951 web_view_helper.InitializeAndLoad(base_url_ + "rtl-overview-mode.html", | 7935 web_view_helper.InitializeAndLoad(base_url_ + "rtl-overview-mode.html", |
7952 nullptr, &client, nullptr, | 7936 nullptr, &client, nullptr, |
7953 ConfigureAndroid); | 7937 ConfigureAndroid); |
7954 web_view_helper.WebView()->SetInitialPageScaleOverride(-1); | 7938 web_view_helper.WebView()->SetInitialPageScaleOverride(-1); |
7955 web_view_helper.WebView()->GetSettings()->SetWideViewportQuirkEnabled(true); | 7939 web_view_helper.WebView()->GetSettings()->SetWideViewportQuirkEnabled(true); |
7956 web_view_helper.WebView()->GetSettings()->SetLoadWithOverviewMode(true); | 7940 web_view_helper.WebView()->GetSettings()->SetLoadWithOverviewMode(true); |
7957 web_view_helper.WebView()->GetSettings()->SetUseWideViewport(true); | 7941 web_view_helper.WebView()->GetSettings()->SetUseWideViewport(true); |
7958 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); | 7942 web_view_helper.Resize(WebSize(viewport_width, viewport_height)); |
7959 web_view_helper.WebView()->UpdateAllLifecyclePhases(); | 7943 web_view_helper.WebView()->UpdateAllLifecyclePhases(); |
7960 | 7944 |
7961 LocalFrameView* frame_view = | 7945 LocalFrameView* frame_view = web_view_helper.LocalMainFrame()->GetFrameView(); |
7962 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
7963 EXPECT_LT(frame_view->MaximumScrollOffset().Width(), 0); | 7946 EXPECT_LT(frame_view->MaximumScrollOffset().Width(), 0); |
7964 } | 7947 } |
7965 | 7948 |
7966 TEST_P(ParameterizedWebFrameTest, FullscreenLayerSize) { | 7949 TEST_P(ParameterizedWebFrameTest, FullscreenLayerSize) { |
7967 FakeCompositingWebViewClient client; | 7950 FakeCompositingWebViewClient client; |
7968 RegisterMockedHttpURLLoad("fullscreen_div.html"); | 7951 RegisterMockedHttpURLLoad("fullscreen_div.html"); |
7969 FrameTestHelpers::WebViewHelper web_view_helper; | 7952 FrameTestHelpers::WebViewHelper web_view_helper; |
7970 int viewport_width = 640; | 7953 int viewport_width = 640; |
7971 int viewport_height = 480; | 7954 int viewport_height = 480; |
7972 client.screen_info_.rect.width = viewport_width; | 7955 client.screen_info_.rect.width = viewport_width; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8020 UserGestureIndicator gesture(UserGestureToken::Create(document)); | 8003 UserGestureIndicator gesture(UserGestureToken::Create(document)); |
8021 Element* div_fullscreen = document->getElementById("div1"); | 8004 Element* div_fullscreen = document->getElementById("div1"); |
8022 Fullscreen::RequestFullscreen(*div_fullscreen); | 8005 Fullscreen::RequestFullscreen(*div_fullscreen); |
8023 EXPECT_EQ(nullptr, Fullscreen::FullscreenElementFrom(*document)); | 8006 EXPECT_EQ(nullptr, Fullscreen::FullscreenElementFrom(*document)); |
8024 web_view_impl->DidEnterFullscreen(); | 8007 web_view_impl->DidEnterFullscreen(); |
8025 EXPECT_EQ(div_fullscreen, Fullscreen::FullscreenElementFrom(*document)); | 8008 EXPECT_EQ(div_fullscreen, Fullscreen::FullscreenElementFrom(*document)); |
8026 web_view_impl->UpdateAllLifecyclePhases(); | 8009 web_view_impl->UpdateAllLifecyclePhases(); |
8027 EXPECT_EQ(div_fullscreen, Fullscreen::FullscreenElementFrom(*document)); | 8010 EXPECT_EQ(div_fullscreen, Fullscreen::FullscreenElementFrom(*document)); |
8028 | 8011 |
8029 // Verify that the viewports are nonscrollable. | 8012 // Verify that the viewports are nonscrollable. |
8030 LocalFrameView* frame_view = | 8013 LocalFrameView* frame_view = web_view_helper.LocalMainFrame()->GetFrameView(); |
8031 web_view_helper.WebView()->MainFrameImpl()->GetFrameView(); | |
8032 WebLayer* layout_viewport_scroll_layer = | 8014 WebLayer* layout_viewport_scroll_layer = |
8033 web_view_impl->Compositor()->ScrollLayer()->PlatformLayer(); | 8015 web_view_impl->Compositor()->ScrollLayer()->PlatformLayer(); |
8034 WebLayer* visual_viewport_scroll_layer = | 8016 WebLayer* visual_viewport_scroll_layer = |
8035 frame_view->GetPage()->GetVisualViewport().ScrollLayer()->PlatformLayer(); | 8017 frame_view->GetPage()->GetVisualViewport().ScrollLayer()->PlatformLayer(); |
8036 ASSERT_FALSE(layout_viewport_scroll_layer->UserScrollableHorizontal()); | 8018 ASSERT_FALSE(layout_viewport_scroll_layer->UserScrollableHorizontal()); |
8037 ASSERT_FALSE(layout_viewport_scroll_layer->UserScrollableVertical()); | 8019 ASSERT_FALSE(layout_viewport_scroll_layer->UserScrollableVertical()); |
8038 ASSERT_FALSE(visual_viewport_scroll_layer->UserScrollableHorizontal()); | 8020 ASSERT_FALSE(visual_viewport_scroll_layer->UserScrollableHorizontal()); |
8039 ASSERT_FALSE(visual_viewport_scroll_layer->UserScrollableVertical()); | 8021 ASSERT_FALSE(visual_viewport_scroll_layer->UserScrollableVertical()); |
8040 | 8022 |
8041 // Verify that the viewports are scrollable upon exiting fullscreen. | 8023 // Verify that the viewports are scrollable upon exiting fullscreen. |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8395 EXPECT_EQ(100, layout_view_item.LogicalWidth().Floor()); | 8377 EXPECT_EQ(100, layout_view_item.LogicalWidth().Floor()); |
8396 EXPECT_EQ(200, layout_view_item.LogicalHeight().Floor()); | 8378 EXPECT_EQ(200, layout_view_item.LogicalHeight().Floor()); |
8397 EXPECT_FLOAT_EQ(1.0, web_view_impl->PageScaleFactor()); | 8379 EXPECT_FLOAT_EQ(1.0, web_view_impl->PageScaleFactor()); |
8398 EXPECT_FLOAT_EQ(1.0, web_view_impl->MinimumPageScaleFactor()); | 8380 EXPECT_FLOAT_EQ(1.0, web_view_impl->MinimumPageScaleFactor()); |
8399 EXPECT_FLOAT_EQ(1.0, web_view_impl->MaximumPageScaleFactor()); | 8381 EXPECT_FLOAT_EQ(1.0, web_view_impl->MaximumPageScaleFactor()); |
8400 | 8382 |
8401 const char kSource[] = "<meta name=\"viewport\" content=\"width=200\">"; | 8383 const char kSource[] = "<meta name=\"viewport\" content=\"width=200\">"; |
8402 | 8384 |
8403 // Load a new page before exiting fullscreen. | 8385 // Load a new page before exiting fullscreen. |
8404 KURL test_url = ToKURL("about:blank"); | 8386 KURL test_url = ToKURL("about:blank"); |
8405 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 8387 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
8406 FrameTestHelpers::LoadHTMLString(frame, kSource, test_url); | 8388 FrameTestHelpers::LoadHTMLString(frame, kSource, test_url); |
8407 web_view_impl->DidExitFullscreen(); | 8389 web_view_impl->DidExitFullscreen(); |
8408 web_view_impl->UpdateAllLifecyclePhases(); | 8390 web_view_impl->UpdateAllLifecyclePhases(); |
8409 | 8391 |
8410 // Make sure the new page's layout size and scale factor limits aren't | 8392 // Make sure the new page's layout size and scale factor limits aren't |
8411 // overridden. | 8393 // overridden. |
8412 layout_view_item = | 8394 layout_view_item = |
8413 web_view_impl->MainFrameImpl()->GetFrameView()->GetLayoutViewItem(); | 8395 web_view_impl->MainFrameImpl()->GetFrameView()->GetLayoutViewItem(); |
8414 EXPECT_EQ(200, layout_view_item.LogicalWidth().Floor()); | 8396 EXPECT_EQ(200, layout_view_item.LogicalWidth().Floor()); |
8415 EXPECT_EQ(400, layout_view_item.LogicalHeight().Floor()); | 8397 EXPECT_EQ(400, layout_view_item.LogicalHeight().Floor()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8559 return RawResource::FetchSynchronously(fetch_parameters, document->Fetcher()); | 8541 return RawResource::FetchSynchronously(fetch_parameters, document->Fetcher()); |
8560 } | 8542 } |
8561 | 8543 |
8562 TEST_P(ParameterizedWebFrameTest, ManifestFetch) { | 8544 TEST_P(ParameterizedWebFrameTest, ManifestFetch) { |
8563 RegisterMockedHttpURLLoad("foo.html"); | 8545 RegisterMockedHttpURLLoad("foo.html"); |
8564 RegisterMockedHttpURLLoad("link-manifest-fetch.json"); | 8546 RegisterMockedHttpURLLoad("link-manifest-fetch.json"); |
8565 | 8547 |
8566 FrameTestHelpers::WebViewHelper web_view_helper; | 8548 FrameTestHelpers::WebViewHelper web_view_helper; |
8567 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); | 8549 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); |
8568 Document* document = | 8550 Document* document = |
8569 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->GetDocument(); | 8551 web_view_helper.LocalMainFrame()->GetFrame()->GetDocument(); |
8570 | 8552 |
8571 Resource* resource = | 8553 Resource* resource = |
8572 FetchManifest(document, ToKURL(base_url_ + "link-manifest-fetch.json")); | 8554 FetchManifest(document, ToKURL(base_url_ + "link-manifest-fetch.json")); |
8573 | 8555 |
8574 EXPECT_TRUE(resource->IsLoaded()); | 8556 EXPECT_TRUE(resource->IsLoaded()); |
8575 } | 8557 } |
8576 | 8558 |
8577 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchAllow) { | 8559 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchAllow) { |
8578 RegisterMockedURLLoadFromBase(not_base_url_, "link-manifest-fetch.json"); | 8560 RegisterMockedURLLoadFromBase(not_base_url_, "link-manifest-fetch.json"); |
8579 RegisterMockedHttpURLLoadWithCSP("foo.html", "manifest-src *"); | 8561 RegisterMockedHttpURLLoadWithCSP("foo.html", "manifest-src *"); |
8580 | 8562 |
8581 FrameTestHelpers::WebViewHelper web_view_helper; | 8563 FrameTestHelpers::WebViewHelper web_view_helper; |
8582 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); | 8564 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); |
8583 Document* document = | 8565 Document* document = |
8584 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->GetDocument(); | 8566 web_view_helper.LocalMainFrame()->GetFrame()->GetDocument(); |
8585 | 8567 |
8586 Resource* resource = FetchManifest( | 8568 Resource* resource = FetchManifest( |
8587 document, ToKURL(not_base_url_ + "link-manifest-fetch.json")); | 8569 document, ToKURL(not_base_url_ + "link-manifest-fetch.json")); |
8588 | 8570 |
8589 EXPECT_TRUE(resource->IsLoaded()); | 8571 EXPECT_TRUE(resource->IsLoaded()); |
8590 } | 8572 } |
8591 | 8573 |
8592 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelf) { | 8574 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelf) { |
8593 RegisterMockedURLLoadFromBase(not_base_url_, "link-manifest-fetch.json"); | 8575 RegisterMockedURLLoadFromBase(not_base_url_, "link-manifest-fetch.json"); |
8594 RegisterMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'"); | 8576 RegisterMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'"); |
8595 | 8577 |
8596 FrameTestHelpers::WebViewHelper web_view_helper; | 8578 FrameTestHelpers::WebViewHelper web_view_helper; |
8597 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); | 8579 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); |
8598 Document* document = | 8580 Document* document = |
8599 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->GetDocument(); | 8581 web_view_helper.LocalMainFrame()->GetFrame()->GetDocument(); |
8600 | 8582 |
8601 Resource* resource = FetchManifest( | 8583 Resource* resource = FetchManifest( |
8602 document, ToKURL(not_base_url_ + "link-manifest-fetch.json")); | 8584 document, ToKURL(not_base_url_ + "link-manifest-fetch.json")); |
8603 | 8585 |
8604 // Fetching resource wasn't allowed. | 8586 // Fetching resource wasn't allowed. |
8605 ASSERT_TRUE(resource); | 8587 ASSERT_TRUE(resource); |
8606 EXPECT_TRUE(resource->ErrorOccurred()); | 8588 EXPECT_TRUE(resource->ErrorOccurred()); |
8607 EXPECT_TRUE(resource->GetResourceError().IsAccessCheck()); | 8589 EXPECT_TRUE(resource->GetResourceError().IsAccessCheck()); |
8608 } | 8590 } |
8609 | 8591 |
8610 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelfReportOnly) { | 8592 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelfReportOnly) { |
8611 RegisterMockedURLLoadFromBase(not_base_url_, "link-manifest-fetch.json"); | 8593 RegisterMockedURLLoadFromBase(not_base_url_, "link-manifest-fetch.json"); |
8612 RegisterMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'", | 8594 RegisterMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'", |
8613 /* report only */ true); | 8595 /* report only */ true); |
8614 | 8596 |
8615 FrameTestHelpers::WebViewHelper web_view_helper; | 8597 FrameTestHelpers::WebViewHelper web_view_helper; |
8616 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); | 8598 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); |
8617 Document* document = | 8599 Document* document = |
8618 web_view_helper.WebView()->MainFrameImpl()->GetFrame()->GetDocument(); | 8600 web_view_helper.LocalMainFrame()->GetFrame()->GetDocument(); |
8619 | 8601 |
8620 Resource* resource = FetchManifest( | 8602 Resource* resource = FetchManifest( |
8621 document, ToKURL(not_base_url_ + "link-manifest-fetch.json")); | 8603 document, ToKURL(not_base_url_ + "link-manifest-fetch.json")); |
8622 | 8604 |
8623 EXPECT_TRUE(resource->IsLoaded()); | 8605 EXPECT_TRUE(resource->IsLoaded()); |
8624 } | 8606 } |
8625 | 8607 |
8626 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) { | 8608 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) { |
8627 // Check that a reload bypassing cache on a frame will result in the cache | 8609 // Check that a reload bypassing cache on a frame will result in the cache |
8628 // policy of the request being set to ReloadBypassingCache. | 8610 // policy of the request being set to ReloadBypassingCache. |
8629 RegisterMockedHttpURLLoad("foo.html"); | 8611 RegisterMockedHttpURLLoad("foo.html"); |
8630 FrameTestHelpers::WebViewHelper web_view_helper; | 8612 FrameTestHelpers::WebViewHelper web_view_helper; |
8631 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); | 8613 web_view_helper.InitializeAndLoad(base_url_ + "foo.html"); |
8632 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 8614 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
8633 FrameTestHelpers::ReloadFrameBypassingCache(frame); | 8615 FrameTestHelpers::ReloadFrameBypassingCache(frame); |
8634 EXPECT_EQ(WebCachePolicy::kBypassingCache, | 8616 EXPECT_EQ(WebCachePolicy::kBypassingCache, |
8635 frame->DataSource()->GetRequest().GetCachePolicy()); | 8617 frame->DataSource()->GetRequest().GetCachePolicy()); |
8636 } | 8618 } |
8637 | 8619 |
8638 static void NodeImageTestValidation(const IntSize& reference_bitmap_size, | 8620 static void NodeImageTestValidation(const IntSize& reference_bitmap_size, |
8639 DragImage* drag_image) { | 8621 DragImage* drag_image) { |
8640 // Prepare the reference bitmap. | 8622 // Prepare the reference bitmap. |
8641 SkBitmap bitmap; | 8623 SkBitmap bitmap; |
8642 bitmap.allocN32Pixels(reference_bitmap_size.Width(), | 8624 bitmap.allocN32Pixels(reference_bitmap_size.Width(), |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8699 // Crashes on Android: http://crbug.com/403804 | 8681 // Crashes on Android: http://crbug.com/403804 |
8700 #if OS(ANDROID) | 8682 #if OS(ANDROID) |
8701 TEST_P(ParameterizedWebFrameTest, DISABLED_PrintingBasic) | 8683 TEST_P(ParameterizedWebFrameTest, DISABLED_PrintingBasic) |
8702 #else | 8684 #else |
8703 TEST_P(ParameterizedWebFrameTest, PrintingBasic) | 8685 TEST_P(ParameterizedWebFrameTest, PrintingBasic) |
8704 #endif | 8686 #endif |
8705 { | 8687 { |
8706 FrameTestHelpers::WebViewHelper web_view_helper; | 8688 FrameTestHelpers::WebViewHelper web_view_helper; |
8707 web_view_helper.InitializeAndLoad("data:text/html,Hello, world."); | 8689 web_view_helper.InitializeAndLoad("data:text/html,Hello, world."); |
8708 | 8690 |
8709 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); | 8691 WebLocalFrame* frame = web_view_helper.LocalMainFrame(); |
8710 | 8692 |
8711 WebPrintParams print_params; | 8693 WebPrintParams print_params; |
8712 print_params.print_content_area.width = 500; | 8694 print_params.print_content_area.width = 500; |
8713 print_params.print_content_area.height = 500; | 8695 print_params.print_content_area.height = 500; |
8714 | 8696 |
8715 int page_count = frame->PrintBegin(print_params); | 8697 int page_count = frame->PrintBegin(print_params); |
8716 EXPECT_EQ(1, page_count); | 8698 EXPECT_EQ(1, page_count); |
8717 frame->PrintEnd(); | 8699 frame->PrintEnd(); |
8718 } | 8700 } |
8719 | 8701 |
(...skipping 12 matching lines...) Expand all Loading... |
8732 bool did_notify_; | 8714 bool did_notify_; |
8733 }; | 8715 }; |
8734 | 8716 |
8735 TEST_P(ParameterizedWebFrameTest, ThemeColor) { | 8717 TEST_P(ParameterizedWebFrameTest, ThemeColor) { |
8736 RegisterMockedHttpURLLoad("theme_color_test.html"); | 8718 RegisterMockedHttpURLLoad("theme_color_test.html"); |
8737 ThemeColorTestWebFrameClient client; | 8719 ThemeColorTestWebFrameClient client; |
8738 FrameTestHelpers::WebViewHelper web_view_helper; | 8720 FrameTestHelpers::WebViewHelper web_view_helper; |
8739 web_view_helper.InitializeAndLoad(base_url_ + "theme_color_test.html", | 8721 web_view_helper.InitializeAndLoad(base_url_ + "theme_color_test.html", |
8740 &client); | 8722 &client); |
8741 EXPECT_TRUE(client.DidNotify()); | 8723 EXPECT_TRUE(client.DidNotify()); |
8742 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 8724 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
8743 EXPECT_EQ(0xff0000ff, frame->GetDocument().ThemeColor()); | 8725 EXPECT_EQ(0xff0000ff, frame->GetDocument().ThemeColor()); |
8744 // Change color by rgb. | 8726 // Change color by rgb. |
8745 client.Reset(); | 8727 client.Reset(); |
8746 frame->ExecuteScript( | 8728 frame->ExecuteScript( |
8747 WebScriptSource("document.getElementById('tc1').setAttribute('content', " | 8729 WebScriptSource("document.getElementById('tc1').setAttribute('content', " |
8748 "'rgb(0, 0, 0)');")); | 8730 "'rgb(0, 0, 0)');")); |
8749 EXPECT_TRUE(client.DidNotify()); | 8731 EXPECT_TRUE(client.DidNotify()); |
8750 EXPECT_EQ(0xff000000, frame->GetDocument().ThemeColor()); | 8732 EXPECT_EQ(0xff000000, frame->GetDocument().ThemeColor()); |
8751 // Change color by hsl. | 8733 // Change color by hsl. |
8752 client.Reset(); | 8734 client.Reset(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8784 RegisterMockedHttpURLLoad("frame-a-b-c.html"); | 8766 RegisterMockedHttpURLLoad("frame-a-b-c.html"); |
8785 RegisterMockedHttpURLLoad("subframe-a.html"); | 8767 RegisterMockedHttpURLLoad("subframe-a.html"); |
8786 RegisterMockedHttpURLLoad("subframe-b.html"); | 8768 RegisterMockedHttpURLLoad("subframe-b.html"); |
8787 RegisterMockedHttpURLLoad("subframe-c.html"); | 8769 RegisterMockedHttpURLLoad("subframe-c.html"); |
8788 RegisterMockedHttpURLLoad("subframe-hello.html"); | 8770 RegisterMockedHttpURLLoad("subframe-hello.html"); |
8789 | 8771 |
8790 web_view_helper_.InitializeAndLoad(base_url_ + "frame-a-b-c.html"); | 8772 web_view_helper_.InitializeAndLoad(base_url_ + "frame-a-b-c.html"); |
8791 } | 8773 } |
8792 | 8774 |
8793 void Reset() { web_view_helper_.Reset(); } | 8775 void Reset() { web_view_helper_.Reset(); } |
8794 WebLocalFrame* MainFrame() const { | 8776 WebLocalFrame* MainFrame() const { return web_view_helper_.LocalMainFrame(); } |
8795 return web_view_helper_.WebView()->MainFrameImpl(); | |
8796 } | |
8797 WebViewBase* WebView() const { return web_view_helper_.WebView(); } | 8777 WebViewBase* WebView() const { return web_view_helper_.WebView(); } |
8798 | 8778 |
8799 private: | 8779 private: |
8800 FrameTestHelpers::WebViewHelper web_view_helper_; | 8780 FrameTestHelpers::WebViewHelper web_view_helper_; |
8801 }; | 8781 }; |
8802 | 8782 |
8803 TEST_F(WebFrameSwapTest, SwapMainFrame) { | 8783 TEST_F(WebFrameSwapTest, SwapMainFrame) { |
8804 WebRemoteFrame* remote_frame = FrameTestHelpers::CreateRemote(); | 8784 WebRemoteFrame* remote_frame = FrameTestHelpers::CreateRemote(); |
8805 MainFrame()->Swap(remote_frame); | 8785 MainFrame()->Swap(remote_frame); |
8806 | 8786 |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9689 client_.screen_info_.rect = WebRect(0, 0, size.width, size.height); | 9669 client_.screen_info_.rect = WebRect(0, 0, size.width, size.height); |
9690 client_.screen_info_.available_rect = client_.screen_info_.rect; | 9670 client_.screen_info_.available_rect = client_.screen_info_.rect; |
9691 web_view_helper_.Resize(size); | 9671 web_view_helper_.Resize(size); |
9692 EXPECT_EQ(expected_size, DumpSize("test")); | 9672 EXPECT_EQ(expected_size, DumpSize("test")); |
9693 } | 9673 } |
9694 | 9674 |
9695 String DumpSize(const String& id) { | 9675 String DumpSize(const String& id) { |
9696 String code = "dumpSize('" + id + "')"; | 9676 String code = "dumpSize('" + id + "')"; |
9697 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 9677 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
9698 ScriptExecutionCallbackHelper callback_helper( | 9678 ScriptExecutionCallbackHelper callback_helper( |
9699 web_view_helper_.WebView()->MainFrameImpl()->MainWorldScriptContext()); | 9679 web_view_helper_.LocalMainFrame()->MainWorldScriptContext()); |
9700 web_view_helper_.WebView() | 9680 web_view_helper_.WebView() |
9701 ->MainFrameImpl() | 9681 ->MainFrameImpl() |
9702 ->RequestExecuteScriptAndReturnValue(WebScriptSource(WebString(code)), | 9682 ->RequestExecuteScriptAndReturnValue(WebScriptSource(WebString(code)), |
9703 false, &callback_helper); | 9683 false, &callback_helper); |
9704 RunPendingTasks(); | 9684 RunPendingTasks(); |
9705 EXPECT_TRUE(callback_helper.DidComplete()); | 9685 EXPECT_TRUE(callback_helper.DidComplete()); |
9706 return callback_helper.StringValue(); | 9686 return callback_helper.StringValue(); |
9707 } | 9687 } |
9708 | 9688 |
9709 FixedLayoutTestWebViewClient client_; | 9689 FixedLayoutTestWebViewClient client_; |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10325 static void EnableGlobalReuseForUnownedMainFrames(WebSettings* settings) { | 10305 static void EnableGlobalReuseForUnownedMainFrames(WebSettings* settings) { |
10326 settings->SetShouldReuseGlobalForUnownedMainFrame(true); | 10306 settings->SetShouldReuseGlobalForUnownedMainFrame(true); |
10327 } | 10307 } |
10328 | 10308 |
10329 // A main frame with no opener should have a unique security origin. Thus, the | 10309 // A main frame with no opener should have a unique security origin. Thus, the |
10330 // global should never be reused on the initial navigation. | 10310 // global should never be reused on the initial navigation. |
10331 TEST(WebFrameGlobalReuseTest, MainFrameWithNoOpener) { | 10311 TEST(WebFrameGlobalReuseTest, MainFrameWithNoOpener) { |
10332 FrameTestHelpers::WebViewHelper helper; | 10312 FrameTestHelpers::WebViewHelper helper; |
10333 helper.Initialize(); | 10313 helper.Initialize(); |
10334 | 10314 |
10335 WebLocalFrame* main_frame = helper.WebView()->MainFrameImpl(); | 10315 WebLocalFrame* main_frame = helper.LocalMainFrame(); |
10336 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10316 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
10337 main_frame->ExecuteScript(WebScriptSource("hello = 'world';")); | 10317 main_frame->ExecuteScript(WebScriptSource("hello = 'world';")); |
10338 FrameTestHelpers::LoadFrame(main_frame, "data:text/html,new page"); | 10318 FrameTestHelpers::LoadFrame(main_frame, "data:text/html,new page"); |
10339 v8::Local<v8::Value> result = | 10319 v8::Local<v8::Value> result = |
10340 main_frame->ExecuteScriptAndReturnValue(WebScriptSource("hello")); | 10320 main_frame->ExecuteScriptAndReturnValue(WebScriptSource("hello")); |
10341 EXPECT_TRUE(result.IsEmpty()); | 10321 EXPECT_TRUE(result.IsEmpty()); |
10342 } | 10322 } |
10343 | 10323 |
10344 // Child frames should never reuse the global on a cross-origin navigation, even | 10324 // Child frames should never reuse the global on a cross-origin navigation, even |
10345 // if the setting is enabled. It's not safe to since the parent could have | 10325 // if the setting is enabled. It's not safe to since the parent could have |
10346 // injected script before the initial navigation. | 10326 // injected script before the initial navigation. |
10347 TEST(WebFrameGlobalReuseTest, ChildFrame) { | 10327 TEST(WebFrameGlobalReuseTest, ChildFrame) { |
10348 FrameTestHelpers::WebViewHelper helper; | 10328 FrameTestHelpers::WebViewHelper helper; |
10349 helper.Initialize(nullptr, nullptr, nullptr, | 10329 helper.Initialize(nullptr, nullptr, nullptr, |
10350 EnableGlobalReuseForUnownedMainFrames); | 10330 EnableGlobalReuseForUnownedMainFrames); |
10351 | 10331 |
10352 WebLocalFrame* main_frame = helper.WebView()->MainFrameImpl(); | 10332 WebLocalFrame* main_frame = helper.LocalMainFrame(); |
10353 FrameTestHelpers::LoadFrame(main_frame, "data:text/html,<iframe></iframe>"); | 10333 FrameTestHelpers::LoadFrame(main_frame, "data:text/html,<iframe></iframe>"); |
10354 | 10334 |
10355 WebLocalFrame* child_frame = main_frame->FirstChild()->ToWebLocalFrame(); | 10335 WebLocalFrame* child_frame = main_frame->FirstChild()->ToWebLocalFrame(); |
10356 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10336 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
10357 child_frame->ExecuteScript(WebScriptSource("hello = 'world';")); | 10337 child_frame->ExecuteScript(WebScriptSource("hello = 'world';")); |
10358 FrameTestHelpers::LoadFrame(child_frame, "data:text/html,new page"); | 10338 FrameTestHelpers::LoadFrame(child_frame, "data:text/html,new page"); |
10359 v8::Local<v8::Value> result = | 10339 v8::Local<v8::Value> result = |
10360 child_frame->ExecuteScriptAndReturnValue(WebScriptSource("hello")); | 10340 child_frame->ExecuteScriptAndReturnValue(WebScriptSource("hello")); |
10361 EXPECT_TRUE(result.IsEmpty()); | 10341 EXPECT_TRUE(result.IsEmpty()); |
10362 } | 10342 } |
10363 | 10343 |
10364 // A main frame with an opener should never reuse the global on a cross-origin | 10344 // A main frame with an opener should never reuse the global on a cross-origin |
10365 // navigation, even if the setting is enabled. It's not safe to since the opener | 10345 // navigation, even if the setting is enabled. It's not safe to since the opener |
10366 // could have injected script. | 10346 // could have injected script. |
10367 TEST(WebFrameGlobalReuseTest, MainFrameWithOpener) { | 10347 TEST(WebFrameGlobalReuseTest, MainFrameWithOpener) { |
10368 FrameTestHelpers::WebViewHelper opener_helper; | 10348 FrameTestHelpers::WebViewHelper opener_helper; |
10369 opener_helper.Initialize(); | 10349 opener_helper.Initialize(); |
10370 FrameTestHelpers::WebViewHelper helper; | 10350 FrameTestHelpers::WebViewHelper helper; |
10371 helper.InitializeWithOpener(opener_helper.WebView()->MainFrame(), nullptr, | 10351 helper.InitializeWithOpener(opener_helper.WebView()->MainFrame(), nullptr, |
10372 nullptr, nullptr, | 10352 nullptr, nullptr, |
10373 EnableGlobalReuseForUnownedMainFrames); | 10353 EnableGlobalReuseForUnownedMainFrames); |
10374 | 10354 |
10375 WebLocalFrame* main_frame = helper.WebView()->MainFrameImpl(); | 10355 WebLocalFrame* main_frame = helper.LocalMainFrame(); |
10376 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10356 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
10377 main_frame->ExecuteScript(WebScriptSource("hello = 'world';")); | 10357 main_frame->ExecuteScript(WebScriptSource("hello = 'world';")); |
10378 FrameTestHelpers::LoadFrame(main_frame, "data:text/html,new page"); | 10358 FrameTestHelpers::LoadFrame(main_frame, "data:text/html,new page"); |
10379 v8::Local<v8::Value> result = | 10359 v8::Local<v8::Value> result = |
10380 main_frame->ExecuteScriptAndReturnValue(WebScriptSource("hello")); | 10360 main_frame->ExecuteScriptAndReturnValue(WebScriptSource("hello")); |
10381 EXPECT_TRUE(result.IsEmpty()); | 10361 EXPECT_TRUE(result.IsEmpty()); |
10382 } | 10362 } |
10383 | 10363 |
10384 // A main frame that is unrelated to any other frame /can/ reuse the global if | 10364 // A main frame that is unrelated to any other frame /can/ reuse the global if |
10385 // the setting is enabled. In this case, it's impossible for any other frames to | 10365 // the setting is enabled. In this case, it's impossible for any other frames to |
10386 // have touched the global. Only the embedder could have injected script, and | 10366 // have touched the global. Only the embedder could have injected script, and |
10387 // the embedder enabling this setting is a signal that the injected script needs | 10367 // the embedder enabling this setting is a signal that the injected script needs |
10388 // to persist on the first navigation away from the initial empty document. | 10368 // to persist on the first navigation away from the initial empty document. |
10389 TEST(WebFrameGlobalReuseTest, ReuseForMainFrameIfEnabled) { | 10369 TEST(WebFrameGlobalReuseTest, ReuseForMainFrameIfEnabled) { |
10390 FrameTestHelpers::WebViewHelper helper; | 10370 FrameTestHelpers::WebViewHelper helper; |
10391 helper.Initialize(nullptr, nullptr, nullptr, | 10371 helper.Initialize(nullptr, nullptr, nullptr, |
10392 EnableGlobalReuseForUnownedMainFrames); | 10372 EnableGlobalReuseForUnownedMainFrames); |
10393 | 10373 |
10394 WebLocalFrame* main_frame = helper.WebView()->MainFrameImpl(); | 10374 WebLocalFrame* main_frame = helper.LocalMainFrame(); |
10395 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10375 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
10396 main_frame->ExecuteScript(WebScriptSource("hello = 'world';")); | 10376 main_frame->ExecuteScript(WebScriptSource("hello = 'world';")); |
10397 FrameTestHelpers::LoadFrame(main_frame, "data:text/html,new page"); | 10377 FrameTestHelpers::LoadFrame(main_frame, "data:text/html,new page"); |
10398 v8::Local<v8::Value> result = | 10378 v8::Local<v8::Value> result = |
10399 main_frame->ExecuteScriptAndReturnValue(WebScriptSource("hello")); | 10379 main_frame->ExecuteScriptAndReturnValue(WebScriptSource("hello")); |
10400 ASSERT_TRUE(result->IsString()); | 10380 ASSERT_TRUE(result->IsString()); |
10401 EXPECT_EQ("world", | 10381 EXPECT_EQ("world", |
10402 ToCoreString(result->ToString(main_frame->MainWorldScriptContext()) | 10382 ToCoreString(result->ToString(main_frame->MainWorldScriptContext()) |
10403 .ToLocalChecked())); | 10383 .ToLocalChecked())); |
10404 } | 10384 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10575 } | 10555 } |
10576 | 10556 |
10577 TEST_F(WebFrameTest, LoadJavascriptURLInNewFrame) { | 10557 TEST_F(WebFrameTest, LoadJavascriptURLInNewFrame) { |
10578 FrameTestHelpers::WebViewHelper helper; | 10558 FrameTestHelpers::WebViewHelper helper; |
10579 helper.Initialize(); | 10559 helper.Initialize(); |
10580 | 10560 |
10581 std::string redirect_url = base_url_ + "foo.html"; | 10561 std::string redirect_url = base_url_ + "foo.html"; |
10582 URLTestHelpers::RegisterMockedURLLoad(ToKURL(redirect_url), | 10562 URLTestHelpers::RegisterMockedURLLoad(ToKURL(redirect_url), |
10583 testing::WebTestDataPath("foo.html")); | 10563 testing::WebTestDataPath("foo.html")); |
10584 WebURLRequest request(ToKURL("javascript:location='" + redirect_url + "'")); | 10564 WebURLRequest request(ToKURL("javascript:location='" + redirect_url + "'")); |
10585 helper.WebView()->MainFrameImpl()->LoadRequest(request); | 10565 helper.LocalMainFrame()->LoadRequest(request); |
10586 | 10566 |
10587 // Normally, the result of the JS url replaces the existing contents on the | 10567 // Normally, the result of the JS url replaces the existing contents on the |
10588 // Document. However, if the JS triggers a navigation, the contents should | 10568 // Document. However, if the JS triggers a navigation, the contents should |
10589 // not be replaced. | 10569 // not be replaced. |
10590 EXPECT_EQ("", ToLocalFrame(helper.WebView()->GetPage()->MainFrame()) | 10570 EXPECT_EQ("", ToLocalFrame(helper.WebView()->GetPage()->MainFrame()) |
10591 ->GetDocument() | 10571 ->GetDocument() |
10592 ->documentElement() | 10572 ->documentElement() |
10593 ->innerText()); | 10573 ->innerText()); |
10594 } | 10574 } |
10595 | 10575 |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11539 " overflow: scroll;" | 11519 " overflow: scroll;" |
11540 " }" | 11520 " }" |
11541 " div { height:1000px; width: 200px; }" | 11521 " div { height:1000px; width: 200px; }" |
11542 "</style>" | 11522 "</style>" |
11543 "<div id='container'>" | 11523 "<div id='container'>" |
11544 " <div id='space'></div>" | 11524 " <div id='space'></div>" |
11545 "</div>", | 11525 "</div>", |
11546 base_url); | 11526 base_url); |
11547 web_view_impl->UpdateAllLifecyclePhases(); | 11527 web_view_impl->UpdateAllLifecyclePhases(); |
11548 | 11528 |
11549 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 11529 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
11550 Document* document = | 11530 Document* document = |
11551 ToLocalFrame(web_view_impl->GetPage()->MainFrame())->GetDocument(); | 11531 ToLocalFrame(web_view_impl->GetPage()->MainFrame())->GetDocument(); |
11552 Element* container = document->getElementById("container"); | 11532 Element* container = document->getElementById("container"); |
11553 ScrollableArea* scrollable_area = | 11533 ScrollableArea* scrollable_area = |
11554 ToLayoutBox(container->GetLayoutObject())->GetScrollableArea(); | 11534 ToLayoutBox(container->GetLayoutObject())->GetScrollableArea(); |
11555 | 11535 |
11556 EXPECT_FALSE(scrollable_area->ScrollbarsHidden()); | 11536 EXPECT_FALSE(scrollable_area->ScrollbarsHidden()); |
11557 testing::RunDelayedTasks(kMockOverlayFadeOutDelayMs); | 11537 testing::RunDelayedTasks(kMockOverlayFadeOutDelayMs); |
11558 EXPECT_TRUE(scrollable_area->ScrollbarsHidden()); | 11538 EXPECT_TRUE(scrollable_area->ScrollbarsHidden()); |
11559 | 11539 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11787 web_view_helper.Reset(); | 11767 web_view_helper.Reset(); |
11788 } | 11768 } |
11789 | 11769 |
11790 TEST_F(WebFrameTest, ClearClosedOpener) { | 11770 TEST_F(WebFrameTest, ClearClosedOpener) { |
11791 FrameTestHelpers::WebViewHelper opener_helper; | 11771 FrameTestHelpers::WebViewHelper opener_helper; |
11792 opener_helper.Initialize(); | 11772 opener_helper.Initialize(); |
11793 FrameTestHelpers::WebViewHelper helper; | 11773 FrameTestHelpers::WebViewHelper helper; |
11794 helper.InitializeWithOpener(opener_helper.WebView()->MainFrame()); | 11774 helper.InitializeWithOpener(opener_helper.WebView()->MainFrame()); |
11795 | 11775 |
11796 opener_helper.Reset(); | 11776 opener_helper.Reset(); |
11797 EXPECT_EQ(nullptr, helper.WebView()->MainFrameImpl()->Opener()); | 11777 EXPECT_EQ(nullptr, helper.LocalMainFrame()->Opener()); |
11798 } | 11778 } |
11799 | 11779 |
11800 class ShowVirtualKeyboardObserverWidgetClient | 11780 class ShowVirtualKeyboardObserverWidgetClient |
11801 : public FrameTestHelpers::TestWebWidgetClient { | 11781 : public FrameTestHelpers::TestWebWidgetClient { |
11802 public: | 11782 public: |
11803 ShowVirtualKeyboardObserverWidgetClient() | 11783 ShowVirtualKeyboardObserverWidgetClient() |
11804 : did_show_virtual_keyboard_(false) {} | 11784 : did_show_virtual_keyboard_(false) {} |
11805 | 11785 |
11806 void ShowVirtualKeyboardOnElementFocus() override { | 11786 void ShowVirtualKeyboardOnElementFocus() override { |
11807 did_show_virtual_keyboard_ = true; | 11787 did_show_virtual_keyboard_ = true; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11963 | 11943 |
11964 TEST_F(WebFrameTest, FallbackForNonexistentProvisionalNavigation) { | 11944 TEST_F(WebFrameTest, FallbackForNonexistentProvisionalNavigation) { |
11965 RegisterMockedHttpURLLoad("fallback.html"); | 11945 RegisterMockedHttpURLLoad("fallback.html"); |
11966 TestFallbackWebFrameClient main_client; | 11946 TestFallbackWebFrameClient main_client; |
11967 TestFallbackWebFrameClient child_client; | 11947 TestFallbackWebFrameClient child_client; |
11968 main_client.SetChildWebFrameClient(&child_client); | 11948 main_client.SetChildWebFrameClient(&child_client); |
11969 | 11949 |
11970 FrameTestHelpers::WebViewHelper web_view_helper_; | 11950 FrameTestHelpers::WebViewHelper web_view_helper_; |
11971 web_view_helper_.Initialize(&main_client); | 11951 web_view_helper_.Initialize(&main_client); |
11972 | 11952 |
11973 WebLocalFrameBase* main_frame = web_view_helper_.WebView()->MainFrameImpl(); | 11953 WebLocalFrameBase* main_frame = web_view_helper_.LocalMainFrame(); |
11974 WebURLRequest request(ToKURL(base_url_ + "fallback.html")); | 11954 WebURLRequest request(ToKURL(base_url_ + "fallback.html")); |
11975 main_frame->LoadRequest(request); | 11955 main_frame->LoadRequest(request); |
11976 | 11956 |
11977 // Because the child frame will be HandledByClient, the main frame will not | 11957 // Because the child frame will be HandledByClient, the main frame will not |
11978 // finish loading, so FrameTestHelpers::PumpPendingRequestsForFrameToLoad | 11958 // finish loading, so FrameTestHelpers::PumpPendingRequestsForFrameToLoad |
11979 // doesn't work here. | 11959 // doesn't work here. |
11980 Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests(); | 11960 Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests(); |
11981 | 11961 |
11982 // Overwrite the client-handled child frame navigation with about:blank. | 11962 // Overwrite the client-handled child frame navigation with about:blank. |
11983 WebLocalFrame* child = main_frame->FirstChild()->ToWebLocalFrame(); | 11963 WebLocalFrame* child = main_frame->FirstChild()->ToWebLocalFrame(); |
11984 child->LoadRequest(WebURLRequest(BlankURL())); | 11964 child->LoadRequest(WebURLRequest(BlankURL())); |
11985 | 11965 |
11986 // Failing the original child frame navigation and trying to render fallback | 11966 // Failing the original child frame navigation and trying to render fallback |
11987 // content shouldn't crash. It should return NoLoadInProgress. This is so the | 11967 // content shouldn't crash. It should return NoLoadInProgress. This is so the |
11988 // caller won't attempt to replace the correctly empty frame with an error | 11968 // caller won't attempt to replace the correctly empty frame with an error |
11989 // page. | 11969 // page. |
11990 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, | 11970 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, |
11991 child->MaybeRenderFallbackContent(WebURLError())); | 11971 child->MaybeRenderFallbackContent(WebURLError())); |
11992 } | 11972 } |
11993 | 11973 |
11994 TEST_F(WebFrameTest, AltTextOnAboutBlankPage) { | 11974 TEST_F(WebFrameTest, AltTextOnAboutBlankPage) { |
11995 FrameTestHelpers::WebViewHelper web_view_helper; | 11975 FrameTestHelpers::WebViewHelper web_view_helper; |
11996 web_view_helper.InitializeAndLoad("about:blank"); | 11976 web_view_helper.InitializeAndLoad("about:blank"); |
11997 web_view_helper.Resize(WebSize(640, 480)); | 11977 web_view_helper.Resize(WebSize(640, 480)); |
11998 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); | 11978 WebLocalFrameBase* frame = web_view_helper.LocalMainFrame(); |
11999 | 11979 |
12000 const char kSource[] = | 11980 const char kSource[] = |
12001 "<img id='foo' src='foo' alt='foo alt' width='200' height='200'>"; | 11981 "<img id='foo' src='foo' alt='foo alt' width='200' height='200'>"; |
12002 FrameTestHelpers::LoadHTMLString(frame, kSource, ToKURL("about:blank")); | 11982 FrameTestHelpers::LoadHTMLString(frame, kSource, ToKURL("about:blank")); |
12003 web_view_helper.WebView()->UpdateAllLifecyclePhases(); | 11983 web_view_helper.WebView()->UpdateAllLifecyclePhases(); |
12004 RunPendingTasks(); | 11984 RunPendingTasks(); |
12005 | 11985 |
12006 // Check LayoutText with alt text "foo alt" | 11986 // Check LayoutText with alt text "foo alt" |
12007 LayoutObject* layout_object = frame->GetFrame() | 11987 LayoutObject* layout_object = frame->GetFrame() |
12008 ->GetDocument() | 11988 ->GetDocument() |
12009 ->getElementById("foo") | 11989 ->getElementById("foo") |
12010 ->GetLayoutObject() | 11990 ->GetLayoutObject() |
12011 ->SlowFirstChild(); | 11991 ->SlowFirstChild(); |
12012 String text = ""; | 11992 String text = ""; |
12013 for (LayoutObject* obj = layout_object; obj; obj = obj->NextInPreOrder()) { | 11993 for (LayoutObject* obj = layout_object; obj; obj = obj->NextInPreOrder()) { |
12014 if (obj->IsText()) { | 11994 if (obj->IsText()) { |
12015 LayoutText* layout_text = ToLayoutText(obj); | 11995 LayoutText* layout_text = ToLayoutText(obj); |
12016 text = layout_text->GetText(); | 11996 text = layout_text->GetText(); |
12017 break; | 11997 break; |
12018 } | 11998 } |
12019 } | 11999 } |
12020 EXPECT_EQ("foo alt", text.Utf8()); | 12000 EXPECT_EQ("foo alt", text.Utf8()); |
12021 } | 12001 } |
12022 | 12002 |
12023 } // namespace blink | 12003 } // namespace blink |
OLD | NEW |