Chromium Code Reviews| Index: content/renderer/dom_serializer_browsertest.cc |
| diff --git a/content/renderer/dom_serializer_browsertest.cc b/content/renderer/dom_serializer_browsertest.cc |
| index f0aa764e511c4f845ec590fc6db08b64ebf9eca2..1b8df68086cd03b5febfab6b5cae1daede88f802 100644 |
| --- a/content/renderer/dom_serializer_browsertest.cc |
| +++ b/content/renderer/dom_serializer_browsertest.cc |
| @@ -110,11 +110,12 @@ class DomSerializerTests : public ContentBrowserTest, |
| return GetRenderView()->GetMainRenderFrame()->GetWebFrame(); |
| } |
| - WebFrame* FindSubFrameByURL(const GURL& url) { |
| + WebLocalFrame* FindSubFrameByURL(const GURL& url) { |
| for (WebFrame* frame = GetWebView()->MainFrame(); frame; |
| frame = frame->TraverseNext()) { |
| - if (GURL(frame->GetDocument().Url()) == url) |
| - return frame; |
| + DCHECK(frame->IsWebLocalFrame()); |
|
Łukasz Anforowicz
2017/06/15 20:15:59
Seems okay to do in a test.
|
| + if (GURL(frame->ToWebLocalFrame()->GetDocument().Url()) == url) |
| + return frame->ToWebLocalFrame(); |
| } |
| return nullptr; |
| } |
| @@ -178,7 +179,7 @@ class DomSerializerTests : public ContentBrowserTest, |
| void SerializeHTMLDOMWithDocTypeOnRenderer(const GURL& file_url) { |
| // Make sure original contents have document type. |
| - WebFrame* web_frame = FindSubFrameByURL(file_url); |
| + WebLocalFrame* web_frame = FindSubFrameByURL(file_url); |
| ASSERT_TRUE(web_frame != NULL); |
| WebDocument doc = web_frame->GetDocument(); |
| ASSERT_TRUE(HasDocType(doc)); |
| @@ -196,7 +197,7 @@ class DomSerializerTests : public ContentBrowserTest, |
| void SerializeHTMLDOMWithoutDocTypeOnRenderer(const GURL& file_url) { |
| // Make sure original contents do not have document type. |
| - WebFrame* web_frame = FindSubFrameByURL(file_url); |
| + WebLocalFrame* web_frame = FindSubFrameByURL(file_url); |
| ASSERT_TRUE(web_frame != NULL); |
| WebDocument doc = web_frame->GetDocument(); |
| ASSERT_TRUE(!HasDocType(doc)); |
| @@ -242,7 +243,7 @@ class DomSerializerTests : public ContentBrowserTest, |
| void SerializeHTMLDOMWithNoMetaCharsetInOriginalDocOnRenderer( |
| const GURL& file_url) { |
| // Make sure there is no META charset declaration in original document. |
| - WebFrame* web_frame = FindSubFrameByURL(file_url); |
| + WebLocalFrame* web_frame = FindSubFrameByURL(file_url); |
| ASSERT_TRUE(web_frame != NULL); |
| WebDocument doc = web_frame->GetDocument(); |
| ASSERT_TRUE(doc.IsHTMLDocument()); |
| @@ -291,7 +292,7 @@ class DomSerializerTests : public ContentBrowserTest, |
| const GURL& file_url) { |
| // Make sure there are multiple META charset declarations in original |
| // document. |
| - WebFrame* web_frame = FindSubFrameByURL(file_url); |
| + WebLocalFrame* web_frame = FindSubFrameByURL(file_url); |
| ASSERT_TRUE(web_frame != NULL); |
| WebDocument doc = web_frame->GetDocument(); |
| ASSERT_TRUE(doc.IsHTMLDocument()); |
| @@ -307,7 +308,7 @@ class DomSerializerTests : public ContentBrowserTest, |
| ++charset_declaration_count; |
| } |
| // The original doc has more than META tags which have charset declaration. |
| - ASSERT_TRUE(charset_declaration_count > 1); |
| + ASSERT_GT(charset_declaration_count, 1); |
| // Do serialization. |
| SerializeDomForURL(file_url); |
| @@ -355,7 +356,7 @@ class DomSerializerTests : public ContentBrowserTest, |
| LoadContents(original_contents, file_url, WebString()); |
| // Get BODY's text content in DOM. |
| - WebFrame* web_frame = FindSubFrameByURL(file_url); |
| + WebLocalFrame* web_frame = FindSubFrameByURL(file_url); |
| ASSERT_TRUE(web_frame != NULL); |
| WebDocument doc = web_frame->GetDocument(); |
| ASSERT_TRUE(doc.IsHTMLDocument()); |
| @@ -363,7 +364,7 @@ class DomSerializerTests : public ContentBrowserTest, |
| ASSERT_TRUE(!body_ele.IsNull()); |
| WebNode text_node = body_ele.FirstChild(); |
| ASSERT_TRUE(text_node.IsTextNode()); |
| - ASSERT_TRUE(std::string(text_node.NodeValue().Utf8()) == "&<>\"\'"); |
| + ASSERT_EQ(text_node.NodeValue().Utf8(), "&<>\"\'"); |
| // Do serialization. |
| SerializeDomForURL(file_url); |
| // Compare the serialized contents with original contents. |
| @@ -407,14 +408,14 @@ class DomSerializerTests : public ContentBrowserTest, |
| // Load the test contents. |
| LoadContents(original_contents, file_url, WebString()); |
| // Get value of BODY's title attribute in DOM. |
| - WebFrame* web_frame = FindSubFrameByURL(file_url); |
| + WebLocalFrame* web_frame = FindSubFrameByURL(file_url); |
| ASSERT_TRUE(web_frame != NULL); |
| WebDocument doc = web_frame->GetDocument(); |
| ASSERT_TRUE(doc.IsHTMLDocument()); |
| WebElement body_ele = doc.Body(); |
| ASSERT_TRUE(!body_ele.IsNull()); |
| WebString value = body_ele.GetAttribute("title"); |
| - ASSERT_TRUE(std::string(value.Utf8()) == "&<>\"\'"); |
| + ASSERT_EQ(value.Utf8(), "&<>\"\'"); |
| // Do serialization. |
| SerializeDomForURL(file_url); |
| // Compare the serialized contents with original contents. |
| @@ -441,7 +442,7 @@ class DomSerializerTests : public ContentBrowserTest, |
| void SerializeHTMLDOMWithNonStandardEntitiesOnRenderer(const GURL& file_url) { |
| // Get value of BODY's title attribute in DOM. |
| - WebFrame* web_frame = FindSubFrameByURL(file_url); |
| + WebLocalFrame* web_frame = FindSubFrameByURL(file_url); |
| WebDocument doc = web_frame->GetDocument(); |
| ASSERT_TRUE(doc.IsHTMLDocument()); |
| WebElement body_element = doc.Body(); |
| @@ -473,7 +474,7 @@ class DomSerializerTests : public ContentBrowserTest, |
| // Since for this test, we assume there is no savable sub-resource links for |
| // this test file, also all links are relative URLs in this test file, so we |
| // need to check those relative URLs and make sure document has BASE tag. |
| - WebFrame* web_frame = FindSubFrameByURL(file_url); |
| + WebLocalFrame* web_frame = FindSubFrameByURL(file_url); |
| ASSERT_TRUE(web_frame != NULL); |
| WebDocument doc = web_frame->GetDocument(); |
| ASSERT_TRUE(doc.IsHTMLDocument()); |
| @@ -564,7 +565,7 @@ class DomSerializerTests : public ContentBrowserTest, |
| LoadContents(empty_head_contents, file_url, WebString()); |
| // Make sure the head tag is empty. |
| - WebFrame* web_frame = GetMainFrame(); |
| + WebLocalFrame* web_frame = GetMainFrame(); |
| ASSERT_TRUE(web_frame != NULL); |
| WebDocument doc = web_frame->GetDocument(); |
| ASSERT_TRUE(doc.IsHTMLDocument()); |
| @@ -604,7 +605,7 @@ class DomSerializerTests : public ContentBrowserTest, |
| void SubResourceForElementsInNonHTMLNamespaceOnRenderer( |
| const GURL& file_url) { |
| - WebFrame* web_frame = FindSubFrameByURL(file_url); |
| + WebLocalFrame* web_frame = FindSubFrameByURL(file_url); |
| ASSERT_TRUE(web_frame != NULL); |
| WebDocument doc = web_frame->GetDocument(); |
| WebNode lastNodeInBody = doc.Body().LastChild(); |