| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/pickle.h" | 11 #include "base/pickle.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/test/histogram_tester.h" | 13 #include "base/test/histogram_tester.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 17 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 18 #include "chrome/browser/safe_browsing/ui_manager.h" | 18 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 20 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 21 #include "components/history/core/browser/history_backend.h" | 21 #include "components/history/core/browser/history_backend.h" |
| 22 #include "components/history/core/browser/history_service.h" | 22 #include "components/history/core/browser/history_service.h" |
| 23 #include "components/safe_browsing/browser/threat_details.h" | 23 #include "components/safe_browsing/browser/threat_details.h" |
| 24 #include "components/safe_browsing/browser/threat_details_history.h" | 24 #include "components/safe_browsing/browser/threat_details_history.h" |
| 25 #include "components/safe_browsing/common/safebrowsing_messages.h" | 25 #include "components/safe_browsing/common/safebrowsing_messages.h" |
| 26 #include "components/safe_browsing/csd.pb.h" | 26 #include "components/safe_browsing/csd.pb.h" |
| 27 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
| 28 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 29 #include "content/public/test/test_renderer_host.h" |
| 29 #include "content/public/test/web_contents_tester.h" | 30 #include "content/public/test/web_contents_tester.h" |
| 30 #include "net/base/io_buffer.h" | 31 #include "net/base/io_buffer.h" |
| 31 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
| 32 #include "net/base/test_completion_callback.h" | 33 #include "net/base/test_completion_callback.h" |
| 33 #include "net/disk_cache/disk_cache.h" | 34 #include "net/disk_cache/disk_cache.h" |
| 34 #include "net/http/http_cache.h" | 35 #include "net/http/http_cache.h" |
| 35 #include "net/http/http_response_headers.h" | 36 #include "net/http/http_response_headers.h" |
| 36 #include "net/http/http_response_info.h" | 37 #include "net/http/http_response_info.h" |
| 37 #include "net/http/http_util.h" | 38 #include "net/http/http_util.h" |
| 38 #include "net/url_request/url_request_context.h" | 39 #include "net/url_request/url_request_context.h" |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 } | 540 } |
| 540 | 541 |
| 541 // Tests creating a threat report when receiving data from multiple renderers. | 542 // Tests creating a threat report when receiving data from multiple renderers. |
| 542 // We use three layers in this test: | 543 // We use three layers in this test: |
| 543 // kDOMParentURL | 544 // kDOMParentURL |
| 544 // \- <div id=outer> | 545 // \- <div id=outer> |
| 545 // \- <iframe src=kDOMChildURL foo=bar> | 546 // \- <iframe src=kDOMChildURL foo=bar> |
| 546 // \- <div id=inner bar=baz/> - div and script are at the same level. | 547 // \- <div id=inner bar=baz/> - div and script are at the same level. |
| 547 // \- <script src=kDOMChildURL2> | 548 // \- <script src=kDOMChildURL2> |
| 548 TEST_F(ThreatDetailsTest, ThreatDOMDetails_MultipleFrames) { | 549 TEST_F(ThreatDetailsTest, ThreatDOMDetails_MultipleFrames) { |
| 550 // Create a child renderer inside the main frame to house the inner iframe. |
| 551 // Perform the navigation first in order to manipulate the frame tree. |
| 552 content::WebContentsTester::For(web_contents()) |
| 553 ->NavigateAndCommit(GURL(kLandingURL)); |
| 554 content::RenderFrameHost* child_rfh = |
| 555 content::RenderFrameHostTester::For(main_rfh())->AppendChild("subframe"); |
| 556 |
| 549 // Define two sets of DOM nodes - one for an outer page containing an iframe, | 557 // Define two sets of DOM nodes - one for an outer page containing an iframe, |
| 550 // and then another for the inner page containing the contents of that iframe. | 558 // and then another for the inner page containing the contents of that iframe. |
| 551 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> outer_params; | 559 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> outer_params; |
| 552 SafeBrowsingHostMsg_ThreatDOMDetails_Node outer_child_div; | 560 SafeBrowsingHostMsg_ThreatDOMDetails_Node outer_child_div; |
| 553 outer_child_div.node_id = 1; | 561 outer_child_div.node_id = 1; |
| 554 outer_child_div.child_node_ids.push_back(2); | 562 outer_child_div.child_node_ids.push_back(2); |
| 555 outer_child_div.tag_name = "div"; | 563 outer_child_div.tag_name = "div"; |
| 556 outer_child_div.parent = GURL(kDOMParentURL); | 564 outer_child_div.parent = GURL(kDOMParentURL); |
| 557 outer_child_div.attributes.push_back(std::make_pair("id", "outer")); | 565 outer_child_div.attributes.push_back(std::make_pair("id", "outer")); |
| 558 outer_params.push_back(outer_child_div); | 566 outer_params.push_back(outer_child_div); |
| 559 | 567 |
| 560 SafeBrowsingHostMsg_ThreatDOMDetails_Node outer_child_iframe; | 568 SafeBrowsingHostMsg_ThreatDOMDetails_Node outer_child_iframe; |
| 561 outer_child_iframe.node_id = 2; | 569 outer_child_iframe.node_id = 2; |
| 562 outer_child_iframe.parent_node_id = 1; | 570 outer_child_iframe.parent_node_id = 1; |
| 563 outer_child_iframe.url = GURL(kDOMChildURL); | 571 outer_child_iframe.url = GURL(kDOMChildURL); |
| 564 outer_child_iframe.tag_name = "iframe"; | 572 outer_child_iframe.tag_name = "iframe"; |
| 565 outer_child_iframe.parent = GURL(kDOMParentURL); | 573 outer_child_iframe.parent = GURL(kDOMParentURL); |
| 566 outer_child_iframe.attributes.push_back(std::make_pair("src", kDOMChildURL)); | 574 outer_child_iframe.attributes.push_back(std::make_pair("src", kDOMChildURL)); |
| 567 outer_child_iframe.attributes.push_back(std::make_pair("foo", "bar")); | 575 outer_child_iframe.attributes.push_back(std::make_pair("foo", "bar")); |
| 576 outer_child_iframe.child_frame_routing_id = child_rfh->GetRoutingID(); |
| 568 outer_params.push_back(outer_child_iframe); | 577 outer_params.push_back(outer_child_iframe); |
| 569 | 578 |
| 570 SafeBrowsingHostMsg_ThreatDOMDetails_Node outer_summary_node; | 579 SafeBrowsingHostMsg_ThreatDOMDetails_Node outer_summary_node; |
| 571 outer_summary_node.url = GURL(kDOMParentURL); | 580 outer_summary_node.url = GURL(kDOMParentURL); |
| 572 outer_summary_node.children.push_back(GURL(kDOMChildURL)); | 581 outer_summary_node.children.push_back(GURL(kDOMChildURL)); |
| 573 outer_params.push_back(outer_summary_node); | 582 outer_params.push_back(outer_summary_node); |
| 574 | 583 |
| 575 // Now define some more nodes for the body of the iframe. | 584 // Now define some more nodes for the body of the iframe. |
| 576 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> inner_params; | 585 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> inner_params; |
| 577 SafeBrowsingHostMsg_ThreatDOMDetails_Node inner_child_div; | 586 SafeBrowsingHostMsg_ThreatDOMDetails_Node inner_child_div; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 elem_dom_inner_div->add_attribute()->set_name("bar"); | 668 elem_dom_inner_div->add_attribute()->set_name("bar"); |
| 660 elem_dom_inner_div->mutable_attribute(1)->set_value("baz"); | 669 elem_dom_inner_div->mutable_attribute(1)->set_value("baz"); |
| 661 | 670 |
| 662 HTMLElement* elem_dom_inner_script = expected.add_dom(); | 671 HTMLElement* elem_dom_inner_script = expected.add_dom(); |
| 663 elem_dom_inner_script->set_id(3); | 672 elem_dom_inner_script->set_id(3); |
| 664 elem_dom_inner_script->set_tag("SCRIPT"); | 673 elem_dom_inner_script->set_tag("SCRIPT"); |
| 665 elem_dom_inner_script->set_resource_id(res_dom_child2->id()); | 674 elem_dom_inner_script->set_resource_id(res_dom_child2->id()); |
| 666 elem_dom_inner_script->add_attribute()->set_name("src"); | 675 elem_dom_inner_script->add_attribute()->set_name("src"); |
| 667 elem_dom_inner_script->mutable_attribute(0)->set_value(kDOMChildUrl2); | 676 elem_dom_inner_script->mutable_attribute(0)->set_value(kDOMChildUrl2); |
| 668 | 677 |
| 669 content::WebContentsTester::For(web_contents()) | |
| 670 ->NavigateAndCommit(GURL(kLandingURL)); | |
| 671 | |
| 672 UnsafeResource resource; | 678 UnsafeResource resource; |
| 673 InitResource(&resource, SB_THREAT_TYPE_URL_UNWANTED, | 679 InitResource(&resource, SB_THREAT_TYPE_URL_UNWANTED, |
| 674 true /* is_subresource */, GURL(kThreatURL)); | 680 true /* is_subresource */, GURL(kThreatURL)); |
| 675 | 681 |
| 676 // Send both sets of nodes, from different render frames. | 682 // Send both sets of nodes, from different render frames. |
| 677 { | 683 { |
| 678 scoped_refptr<ThreatDetailsWrap> report = new ThreatDetailsWrap( | 684 scoped_refptr<ThreatDetailsWrap> report = new ThreatDetailsWrap( |
| 679 ui_manager_.get(), web_contents(), resource, NULL, history_service()); | 685 ui_manager_.get(), web_contents(), resource, NULL, history_service()); |
| 680 | 686 |
| 681 // We call AddDOMDetails directly so we can specify different render frame | 687 // Send both sets of nodes from different render frames. |
| 682 // IDs. | 688 report->OnReceivedThreatDOMDetails(main_rfh(), outer_params); |
| 683 report->AddDOMDetails(100, GURL(kDOMParentURL), outer_params); | 689 report->OnReceivedThreatDOMDetails(child_rfh, inner_params); |
| 684 report->AddDOMDetails(200, GURL(kDOMChildURL), inner_params); | 690 |
| 685 std::string serialized = WaitForSerializedReport( | 691 std::string serialized = WaitForSerializedReport( |
| 686 report.get(), false /* did_proceed*/, 0 /* num_visit */); | 692 report.get(), false /* did_proceed*/, 0 /* num_visit */); |
| 687 ClientSafeBrowsingReportRequest actual; | 693 ClientSafeBrowsingReportRequest actual; |
| 688 actual.ParseFromString(serialized); | 694 actual.ParseFromString(serialized); |
| 689 VerifyResults(actual, expected); | 695 VerifyResults(actual, expected); |
| 690 } | 696 } |
| 691 | 697 |
| 692 // Try again but with the messages coming in a different order. The IDs change | 698 // Try again but with the messages coming in a different order. The IDs change |
| 693 // slightly, but everything else remains the same. | 699 // slightly, but everything else remains the same. |
| 694 { | 700 { |
| 695 // Adjust the expected IDs: the inner params come first, so InnerScript and | 701 // Adjust the expected IDs: the inner params come first, so InnerScript |
| 696 // appear before DomParent | 702 // and InnerDiv appear before DomParent |
| 697 res_dom_child2->set_id(2); | 703 res_dom_child2->set_id(2); |
| 698 res_dom_child2->set_parent_id(3); | 704 res_dom_child2->set_parent_id(3); |
| 699 res_dom_child->set_id(3); | 705 res_dom_child->set_id(3); |
| 700 res_dom_child->set_parent_id(4); | 706 res_dom_child->set_parent_id(4); |
| 701 res_dom_child->clear_child_ids(); | 707 res_dom_child->clear_child_ids(); |
| 702 res_dom_child->add_child_ids(2); | 708 res_dom_child->add_child_ids(2); |
| 703 res_dom_parent->set_id(4); | 709 res_dom_parent->set_id(4); |
| 704 res_dom_parent->clear_child_ids(); | 710 res_dom_parent->clear_child_ids(); |
| 705 res_dom_parent->add_child_ids(3); | 711 res_dom_parent->add_child_ids(3); |
| 706 | 712 |
| 707 // Also adjust the elements - they change order since InnerDiv and | 713 // Also adjust the elements - they change order since InnerDiv and |
| 708 // InnerScript come in first. | 714 // InnerScript come in first. |
| 709 elem_dom_inner_div->set_id(0); | 715 elem_dom_inner_div->set_id(0); |
| 710 elem_dom_inner_script->set_id(1); | 716 elem_dom_inner_script->set_id(1); |
| 711 elem_dom_inner_script->set_resource_id(res_dom_child2->id()); | 717 elem_dom_inner_script->set_resource_id(res_dom_child2->id()); |
| 712 | 718 |
| 713 elem_dom_outer_div->set_id(2); | 719 elem_dom_outer_div->set_id(2); |
| 714 elem_dom_outer_div->clear_child_ids(); | 720 elem_dom_outer_div->clear_child_ids(); |
| 715 elem_dom_outer_div->add_child_ids(3); | 721 elem_dom_outer_div->add_child_ids(3); |
| 716 elem_dom_outer_iframe->set_id(3); | 722 elem_dom_outer_iframe->set_id(3); |
| 717 elem_dom_outer_iframe->set_resource_id(res_dom_child->id()); | 723 elem_dom_outer_iframe->set_resource_id(res_dom_child->id()); |
| 718 elem_dom_outer_iframe->clear_child_ids(); | 724 elem_dom_outer_iframe->clear_child_ids(); |
| 719 elem_dom_outer_iframe->add_child_ids(0); | 725 elem_dom_outer_iframe->add_child_ids(0); |
| 720 elem_dom_outer_iframe->add_child_ids(1); | 726 elem_dom_outer_iframe->add_child_ids(1); |
| 721 | 727 |
| 722 scoped_refptr<ThreatDetailsWrap> report = new ThreatDetailsWrap( | 728 scoped_refptr<ThreatDetailsWrap> report = new ThreatDetailsWrap( |
| 723 ui_manager_.get(), web_contents(), resource, NULL, history_service()); | 729 ui_manager_.get(), web_contents(), resource, NULL, history_service()); |
| 724 | 730 |
| 725 // We call AddDOMDetails directly so we can specify different render frame | 731 // Send both sets of nodes from different render frames. |
| 726 // IDs. | 732 report->OnReceivedThreatDOMDetails(child_rfh, inner_params); |
| 727 report->AddDOMDetails(200, GURL(kDOMChildURL), inner_params); | 733 report->OnReceivedThreatDOMDetails(main_rfh(), outer_params); |
| 728 report->AddDOMDetails(100, GURL(kDOMParentURL), outer_params); | 734 |
| 729 std::string serialized = WaitForSerializedReport( | 735 std::string serialized = WaitForSerializedReport( |
| 730 report.get(), false /* did_proceed*/, 0 /* num_visit */); | 736 report.get(), false /* did_proceed*/, 0 /* num_visit */); |
| 731 ClientSafeBrowsingReportRequest actual; | 737 ClientSafeBrowsingReportRequest actual; |
| 732 actual.ParseFromString(serialized); | 738 actual.ParseFromString(serialized); |
| 733 VerifyResults(actual, expected); | 739 VerifyResults(actual, expected); |
| 734 } | 740 } |
| 735 } | 741 } |
| 736 | 742 |
| 737 // Tests an ambiguous DOM, meaning that an inner render frame has URL that can | 743 // Tests an ambiguous DOM, meaning that an inner render frame can not be mapped |
| 738 // not be mapped to an iframe element in the parent frame with that same URL. | 744 // to an iframe element in the parent frame, which is a failure to lookup the |
| 739 // Typically this happens when the iframe tag has a data URL. | 745 // frames in the frame tree and should not happen. |
| 740 // We use three layers in this test: | 746 // We use three layers in this test: |
| 741 // kDOMParentURL | 747 // kDOMParentURL |
| 742 // \- <iframe src=kDataURL> | 748 // \- <frame src=kDataURL> |
| 743 // \- <script src=kDOMChildURL2> | 749 // \- <script src=kDOMChildURL2> |
| 744 TEST_F(ThreatDetailsTest, ThreatDOMDetails_AmbiguousDOM) { | 750 TEST_F(ThreatDetailsTest, ThreatDOMDetails_AmbiguousDOM) { |
| 745 const char kAmbiguousDomMetric[] = "SafeBrowsing.ThreatReport.DomIsAmbiguous"; | 751 const char kAmbiguousDomMetric[] = "SafeBrowsing.ThreatReport.DomIsAmbiguous"; |
| 746 | 752 |
| 747 // Define two sets of DOM nodes - one for an outer page containing an iframe, | 753 // Create a child renderer inside the main frame to house the inner iframe. |
| 748 // and then another for the inner page containing the contents of that iframe. | 754 // Perform the navigation first in order to manipulate the frame tree. |
| 755 content::WebContentsTester::For(web_contents()) |
| 756 ->NavigateAndCommit(GURL(kLandingURL)); |
| 757 content::RenderFrameHost* child_rfh = |
| 758 content::RenderFrameHostTester::For(main_rfh())->AppendChild("subframe"); |
| 759 |
| 760 // Define two sets of DOM nodes - one for an outer page containing a frame, |
| 761 // and then another for the inner page containing the contents of that frame. |
| 749 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> outer_params; | 762 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> outer_params; |
| 750 SafeBrowsingHostMsg_ThreatDOMDetails_Node outer_child_node; | 763 SafeBrowsingHostMsg_ThreatDOMDetails_Node outer_child_node; |
| 751 outer_child_node.url = GURL(kDataURL); | 764 outer_child_node.url = GURL(kDataURL); |
| 752 outer_child_node.tag_name = "frame"; | 765 outer_child_node.tag_name = "frame"; |
| 753 outer_child_node.parent = GURL(kDOMParentURL); | 766 outer_child_node.parent = GURL(kDOMParentURL); |
| 754 outer_child_node.attributes.push_back(std::make_pair("src", kDataURL)); | 767 outer_child_node.attributes.push_back(std::make_pair("src", kDataURL)); |
| 755 outer_params.push_back(outer_child_node); | 768 outer_params.push_back(outer_child_node); |
| 756 SafeBrowsingHostMsg_ThreatDOMDetails_Node outer_summary_node; | 769 SafeBrowsingHostMsg_ThreatDOMDetails_Node outer_summary_node; |
| 757 outer_summary_node.url = GURL(kDOMParentURL); | 770 outer_summary_node.url = GURL(kDOMParentURL); |
| 758 outer_summary_node.children.push_back(GURL(kDataURL)); | 771 outer_summary_node.children.push_back(GURL(kDataURL)); |
| 772 // Set |child_frame_routing_id| for this node to something non-sensical so |
| 773 // that the child frame lookup fails. |
| 774 outer_summary_node.child_frame_routing_id = -100; |
| 759 outer_params.push_back(outer_summary_node); | 775 outer_params.push_back(outer_summary_node); |
| 760 | 776 |
| 761 // Now define some more nodes for the body of the iframe. The URL of this | 777 // Now define some more nodes for the body of the frame. The URL of this |
| 762 // inner frame is "about:blank". | 778 // inner frame is "about:blank". |
| 763 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> inner_params; | 779 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> inner_params; |
| 764 SafeBrowsingHostMsg_ThreatDOMDetails_Node inner_child_node; | 780 SafeBrowsingHostMsg_ThreatDOMDetails_Node inner_child_node; |
| 765 inner_child_node.url = GURL(kDOMChildUrl2); | 781 inner_child_node.url = GURL(kDOMChildUrl2); |
| 766 inner_child_node.tag_name = "script"; | 782 inner_child_node.tag_name = "script"; |
| 767 inner_child_node.parent = GURL(kBlankURL); | 783 inner_child_node.parent = GURL(kBlankURL); |
| 768 inner_child_node.attributes.push_back(std::make_pair("src", kDOMChildUrl2)); | 784 inner_child_node.attributes.push_back(std::make_pair("src", kDOMChildUrl2)); |
| 769 inner_params.push_back(inner_child_node); | 785 inner_params.push_back(inner_child_node); |
| 770 SafeBrowsingHostMsg_ThreatDOMDetails_Node inner_summary_node; | 786 SafeBrowsingHostMsg_ThreatDOMDetails_Node inner_summary_node; |
| 771 inner_summary_node.url = GURL(kBlankURL); | 787 inner_summary_node.url = GURL(kBlankURL); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 pb_element->add_attribute()->set_name("src"); | 832 pb_element->add_attribute()->set_name("src"); |
| 817 pb_element->mutable_attribute(0)->set_value(kDataURL); | 833 pb_element->mutable_attribute(0)->set_value(kDataURL); |
| 818 | 834 |
| 819 pb_element = expected.add_dom(); | 835 pb_element = expected.add_dom(); |
| 820 pb_element->set_id(1); | 836 pb_element->set_id(1); |
| 821 pb_element->set_tag("SCRIPT"); | 837 pb_element->set_tag("SCRIPT"); |
| 822 pb_element->set_resource_id(4); | 838 pb_element->set_resource_id(4); |
| 823 pb_element->add_attribute()->set_name("src"); | 839 pb_element->add_attribute()->set_name("src"); |
| 824 pb_element->mutable_attribute(0)->set_value(kDOMChildUrl2); | 840 pb_element->mutable_attribute(0)->set_value(kDOMChildUrl2); |
| 825 | 841 |
| 826 content::WebContentsTester::For(web_contents()) | |
| 827 ->NavigateAndCommit(GURL(kLandingURL)); | |
| 828 | |
| 829 UnsafeResource resource; | 842 UnsafeResource resource; |
| 830 InitResource(&resource, SB_THREAT_TYPE_URL_UNWANTED, | 843 InitResource(&resource, SB_THREAT_TYPE_URL_UNWANTED, |
| 831 true /* is_subresource */, GURL(kThreatURL)); | 844 true /* is_subresource */, GURL(kThreatURL)); |
| 832 scoped_refptr<ThreatDetailsWrap> report = new ThreatDetailsWrap( | 845 scoped_refptr<ThreatDetailsWrap> report = new ThreatDetailsWrap( |
| 833 ui_manager_.get(), web_contents(), resource, NULL, history_service()); | 846 ui_manager_.get(), web_contents(), resource, NULL, history_service()); |
| 834 base::HistogramTester histograms; | 847 base::HistogramTester histograms; |
| 835 | 848 |
| 836 // Send both sets of nodes, from different render frames. We call | 849 // Send both sets of nodes from different render frames. |
| 837 // AddDOMDetails directly so we can specify different render frame IDs. | 850 report->OnReceivedThreatDOMDetails(main_rfh(), outer_params); |
| 838 report->AddDOMDetails(100, GURL(kDOMParentURL), outer_params); | 851 report->OnReceivedThreatDOMDetails(child_rfh, inner_params); |
| 839 // The inner frame was using a data URL so its last committed URL is empty. | |
| 840 report->AddDOMDetails(200, GURL(), inner_params); | |
| 841 | 852 |
| 842 std::string serialized = WaitForSerializedReport( | 853 std::string serialized = WaitForSerializedReport( |
| 843 report.get(), false /* did_proceed*/, 0 /* num_visit */); | 854 report.get(), false /* did_proceed*/, 0 /* num_visit */); |
| 844 ClientSafeBrowsingReportRequest actual; | 855 ClientSafeBrowsingReportRequest actual; |
| 845 actual.ParseFromString(serialized); | 856 actual.ParseFromString(serialized); |
| 846 VerifyResults(actual, expected); | 857 VerifyResults(actual, expected); |
| 847 | 858 |
| 848 // This DOM should be ambiguous, expect the UMA metric to be incremented. | 859 // This DOM should be ambiguous, expect the UMA metric to be incremented. |
| 849 histograms.ExpectTotalCount(kAmbiguousDomMetric, 1); | 860 histograms.ExpectTotalCount(kAmbiguousDomMetric, 1); |
| 850 } | 861 } |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 pb_resource->set_parent_id(3); | 1340 pb_resource->set_parent_id(3); |
| 1330 pb_resource->set_url(kSecondRedirectURL); | 1341 pb_resource->set_url(kSecondRedirectURL); |
| 1331 pb_resource = expected.add_resources(); | 1342 pb_resource = expected.add_resources(); |
| 1332 pb_resource->set_id(3); | 1343 pb_resource->set_id(3); |
| 1333 pb_resource->set_url(kFirstRedirectURL); | 1344 pb_resource->set_url(kFirstRedirectURL); |
| 1334 | 1345 |
| 1335 VerifyResults(actual, expected); | 1346 VerifyResults(actual, expected); |
| 1336 } | 1347 } |
| 1337 | 1348 |
| 1338 } // namespace safe_browsing | 1349 } // namespace safe_browsing |
| OLD | NEW |