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

Side by Side Diff: content/renderer/dom_serializer_browsertest.cc

Issue 2928033002: Move GetDocument method from WebFrame to WebLocalFrame. (Closed)
Patch Set: Split a DCHECK in two as suggested by boliu@. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 104
105 WebView* GetWebView() { 105 WebView* GetWebView() {
106 return GetRenderView()->GetWebView(); 106 return GetRenderView()->GetWebView();
107 } 107 }
108 108
109 WebLocalFrame* GetMainFrame() { 109 WebLocalFrame* GetMainFrame() {
110 return GetRenderView()->GetMainRenderFrame()->GetWebFrame(); 110 return GetRenderView()->GetMainRenderFrame()->GetWebFrame();
111 } 111 }
112 112
113 WebFrame* FindSubFrameByURL(const GURL& url) { 113 WebLocalFrame* FindSubFrameByURL(const GURL& url) {
114 for (WebFrame* frame = GetWebView()->MainFrame(); frame; 114 for (WebFrame* frame = GetWebView()->MainFrame(); frame;
115 frame = frame->TraverseNext()) { 115 frame = frame->TraverseNext()) {
116 if (GURL(frame->GetDocument().Url()) == url) 116 DCHECK(frame->IsWebLocalFrame());
117 return frame; 117 if (GURL(frame->ToWebLocalFrame()->GetDocument().Url()) == url)
118 return frame->ToWebLocalFrame();
118 } 119 }
119 return nullptr; 120 return nullptr;
120 } 121 }
121 122
122 // Load web page according to input content and relative URLs within 123 // Load web page according to input content and relative URLs within
123 // the document. 124 // the document.
124 void LoadContents(const std::string& contents, 125 void LoadContents(const std::string& contents,
125 const GURL& base_url, 126 const GURL& base_url,
126 const WebString encoding_info) { 127 const WebString encoding_info) {
127 FrameLoadWaiter waiter(GetRenderView()->GetMainRenderFrame()); 128 FrameLoadWaiter waiter(GetRenderView()->GetMainRenderFrame());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 WebString file_path = WebString::FromUTF8("c:\\dummy.htm"); 172 WebString file_path = WebString::FromUTF8("c:\\dummy.htm");
172 SingleLinkRewritingDelegate delegate(frame_url, file_path); 173 SingleLinkRewritingDelegate delegate(frame_url, file_path);
173 // Start serializing DOM. 174 // Start serializing DOM.
174 bool result = WebFrameSerializer::Serialize(web_frame->ToWebLocalFrame(), 175 bool result = WebFrameSerializer::Serialize(web_frame->ToWebLocalFrame(),
175 this, &delegate); 176 this, &delegate);
176 ASSERT_TRUE(result); 177 ASSERT_TRUE(result);
177 } 178 }
178 179
179 void SerializeHTMLDOMWithDocTypeOnRenderer(const GURL& file_url) { 180 void SerializeHTMLDOMWithDocTypeOnRenderer(const GURL& file_url) {
180 // Make sure original contents have document type. 181 // Make sure original contents have document type.
181 WebFrame* web_frame = FindSubFrameByURL(file_url); 182 WebLocalFrame* web_frame = FindSubFrameByURL(file_url);
182 ASSERT_TRUE(web_frame != NULL); 183 ASSERT_TRUE(web_frame != NULL);
183 WebDocument doc = web_frame->GetDocument(); 184 WebDocument doc = web_frame->GetDocument();
184 ASSERT_TRUE(HasDocType(doc)); 185 ASSERT_TRUE(HasDocType(doc));
185 // Do serialization. 186 // Do serialization.
186 SerializeDomForURL(file_url); 187 SerializeDomForURL(file_url);
187 // Load the serialized contents. 188 // Load the serialized contents.
188 ASSERT_TRUE(serialization_reported_end_of_data_); 189 ASSERT_TRUE(serialization_reported_end_of_data_);
189 LoadContents(serialized_contents_, file_url, 190 LoadContents(serialized_contents_, file_url,
190 web_frame->GetDocument().Encoding()); 191 web_frame->GetDocument().Encoding());
191 // Make sure serialized contents still have document type. 192 // Make sure serialized contents still have document type.
192 web_frame = GetMainFrame(); 193 web_frame = GetMainFrame();
193 doc = web_frame->GetDocument(); 194 doc = web_frame->GetDocument();
194 ASSERT_TRUE(HasDocType(doc)); 195 ASSERT_TRUE(HasDocType(doc));
195 } 196 }
196 197
197 void SerializeHTMLDOMWithoutDocTypeOnRenderer(const GURL& file_url) { 198 void SerializeHTMLDOMWithoutDocTypeOnRenderer(const GURL& file_url) {
198 // Make sure original contents do not have document type. 199 // Make sure original contents do not have document type.
199 WebFrame* web_frame = FindSubFrameByURL(file_url); 200 WebLocalFrame* web_frame = FindSubFrameByURL(file_url);
200 ASSERT_TRUE(web_frame != NULL); 201 ASSERT_TRUE(web_frame != NULL);
201 WebDocument doc = web_frame->GetDocument(); 202 WebDocument doc = web_frame->GetDocument();
202 ASSERT_TRUE(!HasDocType(doc)); 203 ASSERT_TRUE(!HasDocType(doc));
203 // Do serialization. 204 // Do serialization.
204 SerializeDomForURL(file_url); 205 SerializeDomForURL(file_url);
205 // Load the serialized contents. 206 // Load the serialized contents.
206 ASSERT_TRUE(serialization_reported_end_of_data_); 207 ASSERT_TRUE(serialization_reported_end_of_data_);
207 LoadContents(serialized_contents_, file_url, 208 LoadContents(serialized_contents_, file_url,
208 web_frame->GetDocument().Encoding()); 209 web_frame->GetDocument().Encoding());
209 // Make sure serialized contents do not have document type. 210 // Make sure serialized contents do not have document type.
(...skipping 25 matching lines...) Expand all
235 SerializeDomForURL(file_url); 236 SerializeDomForURL(file_url);
236 // Make sure the serialized contents have MOTW ; 237 // Make sure the serialized contents have MOTW ;
237 ASSERT_TRUE(serialization_reported_end_of_data_); 238 ASSERT_TRUE(serialization_reported_end_of_data_);
238 ASSERT_FALSE(std::string::npos == 239 ASSERT_FALSE(std::string::npos ==
239 serialized_contents_.find(motw_declaration)); 240 serialized_contents_.find(motw_declaration));
240 } 241 }
241 242
242 void SerializeHTMLDOMWithNoMetaCharsetInOriginalDocOnRenderer( 243 void SerializeHTMLDOMWithNoMetaCharsetInOriginalDocOnRenderer(
243 const GURL& file_url) { 244 const GURL& file_url) {
244 // Make sure there is no META charset declaration in original document. 245 // Make sure there is no META charset declaration in original document.
245 WebFrame* web_frame = FindSubFrameByURL(file_url); 246 WebLocalFrame* web_frame = FindSubFrameByURL(file_url);
246 ASSERT_TRUE(web_frame != NULL); 247 ASSERT_TRUE(web_frame != NULL);
247 WebDocument doc = web_frame->GetDocument(); 248 WebDocument doc = web_frame->GetDocument();
248 ASSERT_TRUE(doc.IsHTMLDocument()); 249 ASSERT_TRUE(doc.IsHTMLDocument());
249 WebElement head_element = doc.Head(); 250 WebElement head_element = doc.Head();
250 ASSERT_TRUE(!head_element.IsNull()); 251 ASSERT_TRUE(!head_element.IsNull());
251 // Go through all children of HEAD element. 252 // Go through all children of HEAD element.
252 WebElementCollection meta_elements = 253 WebElementCollection meta_elements =
253 head_element.GetElementsByHTMLTagName("meta"); 254 head_element.GetElementsByHTMLTagName("meta");
254 for (WebElement element = meta_elements.FirstItem(); !element.IsNull(); 255 for (WebElement element = meta_elements.FirstItem(); !element.IsNull();
255 element = meta_elements.NextItem()) { 256 element = meta_elements.NextItem()) {
(...skipping 28 matching lines...) Expand all
284 if (element == meta_element) 285 if (element == meta_element)
285 continue; 286 continue;
286 ASSERT_TRUE(element.To<WebMetaElement>().ComputeEncoding().IsEmpty()); 287 ASSERT_TRUE(element.To<WebMetaElement>().ComputeEncoding().IsEmpty());
287 } 288 }
288 } 289 }
289 290
290 void SerializeHTMLDOMWithMultipleMetaCharsetInOriginalDocOnRenderer( 291 void SerializeHTMLDOMWithMultipleMetaCharsetInOriginalDocOnRenderer(
291 const GURL& file_url) { 292 const GURL& file_url) {
292 // Make sure there are multiple META charset declarations in original 293 // Make sure there are multiple META charset declarations in original
293 // document. 294 // document.
294 WebFrame* web_frame = FindSubFrameByURL(file_url); 295 WebLocalFrame* web_frame = FindSubFrameByURL(file_url);
295 ASSERT_TRUE(web_frame != NULL); 296 ASSERT_TRUE(web_frame != NULL);
296 WebDocument doc = web_frame->GetDocument(); 297 WebDocument doc = web_frame->GetDocument();
297 ASSERT_TRUE(doc.IsHTMLDocument()); 298 ASSERT_TRUE(doc.IsHTMLDocument());
298 WebElement head_element = doc.Head(); 299 WebElement head_element = doc.Head();
299 ASSERT_TRUE(!head_element.IsNull()); 300 ASSERT_TRUE(!head_element.IsNull());
300 // Go through all children of HEAD element. 301 // Go through all children of HEAD element.
301 int charset_declaration_count = 0; 302 int charset_declaration_count = 0;
302 WebElementCollection meta_elements = 303 WebElementCollection meta_elements =
303 head_element.GetElementsByHTMLTagName("meta"); 304 head_element.GetElementsByHTMLTagName("meta");
304 for (WebElement element = meta_elements.FirstItem(); !element.IsNull(); 305 for (WebElement element = meta_elements.FirstItem(); !element.IsNull();
305 element = meta_elements.NextItem()) { 306 element = meta_elements.NextItem()) {
306 if (!element.To<WebMetaElement>().ComputeEncoding().IsEmpty()) 307 if (!element.To<WebMetaElement>().ComputeEncoding().IsEmpty())
307 ++charset_declaration_count; 308 ++charset_declaration_count;
308 } 309 }
309 // The original doc has more than META tags which have charset declaration. 310 // The original doc has more than META tags which have charset declaration.
310 ASSERT_TRUE(charset_declaration_count > 1); 311 ASSERT_GT(charset_declaration_count, 1);
311 312
312 // Do serialization. 313 // Do serialization.
313 SerializeDomForURL(file_url); 314 SerializeDomForURL(file_url);
314 315
315 // Load the serialized contents. 316 // Load the serialized contents.
316 ASSERT_TRUE(serialization_reported_end_of_data_); 317 ASSERT_TRUE(serialization_reported_end_of_data_);
317 LoadContents(serialized_contents_, file_url, 318 LoadContents(serialized_contents_, file_url,
318 web_frame->GetDocument().Encoding()); 319 web_frame->GetDocument().Encoding());
319 // Make sure only first child of HEAD element is META which has charset 320 // Make sure only first child of HEAD element is META which has charset
320 // declaration in serialized contents. 321 // declaration in serialized contents.
(...skipping 27 matching lines...) Expand all
348 // actions. The test content is in constant:original_contents. 349 // actions. The test content is in constant:original_contents.
349 GURL file_url = net::FilePathToFileURL(page_file_path); 350 GURL file_url = net::FilePathToFileURL(page_file_path);
350 ASSERT_TRUE(file_url.SchemeIsFile()); 351 ASSERT_TRUE(file_url.SchemeIsFile());
351 // Test contents. 352 // Test contents.
352 static const char* const original_contents = 353 static const char* const original_contents =
353 "<html><body>&amp;&lt;&gt;\"\'</body></html>"; 354 "<html><body>&amp;&lt;&gt;\"\'</body></html>";
354 // Load the test contents. 355 // Load the test contents.
355 LoadContents(original_contents, file_url, WebString()); 356 LoadContents(original_contents, file_url, WebString());
356 357
357 // Get BODY's text content in DOM. 358 // Get BODY's text content in DOM.
358 WebFrame* web_frame = FindSubFrameByURL(file_url); 359 WebLocalFrame* web_frame = FindSubFrameByURL(file_url);
359 ASSERT_TRUE(web_frame != NULL); 360 ASSERT_TRUE(web_frame != NULL);
360 WebDocument doc = web_frame->GetDocument(); 361 WebDocument doc = web_frame->GetDocument();
361 ASSERT_TRUE(doc.IsHTMLDocument()); 362 ASSERT_TRUE(doc.IsHTMLDocument());
362 WebElement body_ele = doc.Body(); 363 WebElement body_ele = doc.Body();
363 ASSERT_TRUE(!body_ele.IsNull()); 364 ASSERT_TRUE(!body_ele.IsNull());
364 WebNode text_node = body_ele.FirstChild(); 365 WebNode text_node = body_ele.FirstChild();
365 ASSERT_TRUE(text_node.IsTextNode()); 366 ASSERT_TRUE(text_node.IsTextNode());
366 ASSERT_TRUE(std::string(text_node.NodeValue().Utf8()) == "&<>\"\'"); 367 ASSERT_EQ(text_node.NodeValue().Utf8(), "&<>\"\'");
367 // Do serialization. 368 // Do serialization.
368 SerializeDomForURL(file_url); 369 SerializeDomForURL(file_url);
369 // Compare the serialized contents with original contents. 370 // Compare the serialized contents with original contents.
370 ASSERT_TRUE(serialization_reported_end_of_data_); 371 ASSERT_TRUE(serialization_reported_end_of_data_);
371 // Compare the serialized contents with original contents to make sure 372 // Compare the serialized contents with original contents to make sure
372 // they are same. 373 // they are same.
373 // Because we add MOTW when serializing DOM, so before comparison, we also 374 // Because we add MOTW when serializing DOM, so before comparison, we also
374 // need to add MOTW to original_contents. 375 // need to add MOTW to original_contents.
375 std::string original_str = 376 std::string original_str =
376 WebFrameSerializer::GenerateMarkOfTheWebDeclaration(file_url).Utf8(); 377 WebFrameSerializer::GenerateMarkOfTheWebDeclaration(file_url).Utf8();
(...skipping 23 matching lines...) Expand all
400 // Get file URL. The URL is dummy URL to identify the following loading 401 // Get file URL. The URL is dummy URL to identify the following loading
401 // actions. The test content is in constant:original_contents. 402 // actions. The test content is in constant:original_contents.
402 GURL file_url = net::FilePathToFileURL(page_file_path); 403 GURL file_url = net::FilePathToFileURL(page_file_path);
403 ASSERT_TRUE(file_url.SchemeIsFile()); 404 ASSERT_TRUE(file_url.SchemeIsFile());
404 // Test contents. 405 // Test contents.
405 static const char* const original_contents = 406 static const char* const original_contents =
406 "<html><body title=\"&amp;&lt;&gt;&quot;&#39;\"></body></html>"; 407 "<html><body title=\"&amp;&lt;&gt;&quot;&#39;\"></body></html>";
407 // Load the test contents. 408 // Load the test contents.
408 LoadContents(original_contents, file_url, WebString()); 409 LoadContents(original_contents, file_url, WebString());
409 // Get value of BODY's title attribute in DOM. 410 // Get value of BODY's title attribute in DOM.
410 WebFrame* web_frame = FindSubFrameByURL(file_url); 411 WebLocalFrame* web_frame = FindSubFrameByURL(file_url);
411 ASSERT_TRUE(web_frame != NULL); 412 ASSERT_TRUE(web_frame != NULL);
412 WebDocument doc = web_frame->GetDocument(); 413 WebDocument doc = web_frame->GetDocument();
413 ASSERT_TRUE(doc.IsHTMLDocument()); 414 ASSERT_TRUE(doc.IsHTMLDocument());
414 WebElement body_ele = doc.Body(); 415 WebElement body_ele = doc.Body();
415 ASSERT_TRUE(!body_ele.IsNull()); 416 ASSERT_TRUE(!body_ele.IsNull());
416 WebString value = body_ele.GetAttribute("title"); 417 WebString value = body_ele.GetAttribute("title");
417 ASSERT_TRUE(std::string(value.Utf8()) == "&<>\"\'"); 418 ASSERT_EQ(value.Utf8(), "&<>\"\'");
418 // Do serialization. 419 // Do serialization.
419 SerializeDomForURL(file_url); 420 SerializeDomForURL(file_url);
420 // Compare the serialized contents with original contents. 421 // Compare the serialized contents with original contents.
421 ASSERT_TRUE(serialization_reported_end_of_data_); 422 ASSERT_TRUE(serialization_reported_end_of_data_);
422 // Compare the serialized contents with original contents to make sure 423 // Compare the serialized contents with original contents to make sure
423 // they are same. 424 // they are same.
424 std::string original_str = 425 std::string original_str =
425 WebFrameSerializer::GenerateMarkOfTheWebDeclaration(file_url).Utf8(); 426 WebFrameSerializer::GenerateMarkOfTheWebDeclaration(file_url).Utf8();
426 original_str += original_contents; 427 original_str += original_contents;
427 if (!doc.IsNull()) { 428 if (!doc.IsNull()) {
428 WebString encoding = web_frame->GetDocument().Encoding(); 429 WebString encoding = web_frame->GetDocument().Encoding();
429 std::string htmlTag("<html>"); 430 std::string htmlTag("<html>");
430 std::string::size_type pos = original_str.find(htmlTag); 431 std::string::size_type pos = original_str.find(htmlTag);
431 ASSERT_NE(std::string::npos, pos); 432 ASSERT_NE(std::string::npos, pos);
432 pos += htmlTag.length(); 433 pos += htmlTag.length();
433 std::string head_part("<head>"); 434 std::string head_part("<head>");
434 head_part += 435 head_part +=
435 WebFrameSerializer::GenerateMetaCharsetDeclaration(encoding).Utf8(); 436 WebFrameSerializer::GenerateMetaCharsetDeclaration(encoding).Utf8();
436 head_part += "</head>"; 437 head_part += "</head>";
437 original_str.insert(pos, head_part); 438 original_str.insert(pos, head_part);
438 } 439 }
439 ASSERT_EQ(original_str, serialized_contents_); 440 ASSERT_EQ(original_str, serialized_contents_);
440 } 441 }
441 442
442 void SerializeHTMLDOMWithNonStandardEntitiesOnRenderer(const GURL& file_url) { 443 void SerializeHTMLDOMWithNonStandardEntitiesOnRenderer(const GURL& file_url) {
443 // Get value of BODY's title attribute in DOM. 444 // Get value of BODY's title attribute in DOM.
444 WebFrame* web_frame = FindSubFrameByURL(file_url); 445 WebLocalFrame* web_frame = FindSubFrameByURL(file_url);
445 WebDocument doc = web_frame->GetDocument(); 446 WebDocument doc = web_frame->GetDocument();
446 ASSERT_TRUE(doc.IsHTMLDocument()); 447 ASSERT_TRUE(doc.IsHTMLDocument());
447 WebElement body_element = doc.Body(); 448 WebElement body_element = doc.Body();
448 // Unescaped string for "&percnt;&nsup;&sup1;&apos;". 449 // Unescaped string for "&percnt;&nsup;&sup1;&apos;".
449 static const wchar_t parsed_value[] = { 450 static const wchar_t parsed_value[] = {
450 '%', 0x2285, 0x00b9, '\'', 0 451 '%', 0x2285, 0x00b9, '\'', 0
451 }; 452 };
452 WebString value = body_element.GetAttribute("title"); 453 WebString value = body_element.GetAttribute("title");
453 WebString content = doc.ContentAsTextForTesting(); 454 WebString content = doc.ContentAsTextForTesting();
454 ASSERT_TRUE(base::UTF16ToWide(value.Utf16()) == parsed_value); 455 ASSERT_TRUE(base::UTF16ToWide(value.Utf16()) == parsed_value);
(...skipping 11 matching lines...) Expand all
466 } 467 }
467 468
468 void SerializeHTMLDOMWithBaseTagOnRenderer(const GURL& file_url, 469 void SerializeHTMLDOMWithBaseTagOnRenderer(const GURL& file_url,
469 const GURL& path_dir_url) { 470 const GURL& path_dir_url) {
470 // There are total 2 available base tags in this test file. 471 // There are total 2 available base tags in this test file.
471 const int kTotalBaseTagCountInTestFile = 2; 472 const int kTotalBaseTagCountInTestFile = 2;
472 473
473 // Since for this test, we assume there is no savable sub-resource links for 474 // Since for this test, we assume there is no savable sub-resource links for
474 // this test file, also all links are relative URLs in this test file, so we 475 // this test file, also all links are relative URLs in this test file, so we
475 // need to check those relative URLs and make sure document has BASE tag. 476 // need to check those relative URLs and make sure document has BASE tag.
476 WebFrame* web_frame = FindSubFrameByURL(file_url); 477 WebLocalFrame* web_frame = FindSubFrameByURL(file_url);
477 ASSERT_TRUE(web_frame != NULL); 478 ASSERT_TRUE(web_frame != NULL);
478 WebDocument doc = web_frame->GetDocument(); 479 WebDocument doc = web_frame->GetDocument();
479 ASSERT_TRUE(doc.IsHTMLDocument()); 480 ASSERT_TRUE(doc.IsHTMLDocument());
480 // Go through all descent nodes. 481 // Go through all descent nodes.
481 WebElementCollection all = doc.All(); 482 WebElementCollection all = doc.All();
482 int original_base_tag_count = 0; 483 int original_base_tag_count = 0;
483 for (WebElement element = all.FirstItem(); !element.IsNull(); 484 for (WebElement element = all.FirstItem(); !element.IsNull();
484 element = all.NextItem()) { 485 element = all.NextItem()) {
485 if (element.HasHTMLTagName("base")) { 486 if (element.HasHTMLTagName("base")) {
486 original_base_tag_count++; 487 original_base_tag_count++;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 "dom_serializer", "empty_head.htm"); 558 "dom_serializer", "empty_head.htm");
558 GURL file_url = net::FilePathToFileURL(page_file_path); 559 GURL file_url = net::FilePathToFileURL(page_file_path);
559 ASSERT_TRUE(file_url.SchemeIsFile()); 560 ASSERT_TRUE(file_url.SchemeIsFile());
560 561
561 // Load the test html content. 562 // Load the test html content.
562 static const char* const empty_head_contents = 563 static const char* const empty_head_contents =
563 "<html><head></head><body>hello world</body></html>"; 564 "<html><head></head><body>hello world</body></html>";
564 LoadContents(empty_head_contents, file_url, WebString()); 565 LoadContents(empty_head_contents, file_url, WebString());
565 566
566 // Make sure the head tag is empty. 567 // Make sure the head tag is empty.
567 WebFrame* web_frame = GetMainFrame(); 568 WebLocalFrame* web_frame = GetMainFrame();
568 ASSERT_TRUE(web_frame != NULL); 569 ASSERT_TRUE(web_frame != NULL);
569 WebDocument doc = web_frame->GetDocument(); 570 WebDocument doc = web_frame->GetDocument();
570 ASSERT_TRUE(doc.IsHTMLDocument()); 571 ASSERT_TRUE(doc.IsHTMLDocument());
571 WebElement head_element = doc.Head(); 572 WebElement head_element = doc.Head();
572 ASSERT_TRUE(!head_element.IsNull()); 573 ASSERT_TRUE(!head_element.IsNull());
573 ASSERT_TRUE(head_element.FirstChild().IsNull()); 574 ASSERT_TRUE(head_element.FirstChild().IsNull());
574 575
575 // Do serialization. 576 // Do serialization.
576 SerializeDomForURL(file_url); 577 SerializeDomForURL(file_url);
577 ASSERT_TRUE(serialization_reported_end_of_data_); 578 ASSERT_TRUE(serialization_reported_end_of_data_);
(...skipping 19 matching lines...) Expand all
597 // "hello world" 598 // "hello world"
598 WebElement body_element = doc.Body(); 599 WebElement body_element = doc.Body();
599 ASSERT_TRUE(!body_element.IsNull()); 600 ASSERT_TRUE(!body_element.IsNull());
600 WebNode text_node = body_element.FirstChild(); 601 WebNode text_node = body_element.FirstChild();
601 ASSERT_TRUE(text_node.IsTextNode()); 602 ASSERT_TRUE(text_node.IsTextNode());
602 ASSERT_EQ("hello world", text_node.NodeValue()); 603 ASSERT_EQ("hello world", text_node.NodeValue());
603 } 604 }
604 605
605 void SubResourceForElementsInNonHTMLNamespaceOnRenderer( 606 void SubResourceForElementsInNonHTMLNamespaceOnRenderer(
606 const GURL& file_url) { 607 const GURL& file_url) {
607 WebFrame* web_frame = FindSubFrameByURL(file_url); 608 WebLocalFrame* web_frame = FindSubFrameByURL(file_url);
608 ASSERT_TRUE(web_frame != NULL); 609 ASSERT_TRUE(web_frame != NULL);
609 WebDocument doc = web_frame->GetDocument(); 610 WebDocument doc = web_frame->GetDocument();
610 WebNode lastNodeInBody = doc.Body().LastChild(); 611 WebNode lastNodeInBody = doc.Body().LastChild();
611 ASSERT_TRUE(lastNodeInBody.IsElementNode()); 612 ASSERT_TRUE(lastNodeInBody.IsElementNode());
612 WebString uri = 613 WebString uri =
613 GetSubResourceLinkFromElement(lastNodeInBody.To<WebElement>()); 614 GetSubResourceLinkFromElement(lastNodeInBody.To<WebElement>());
614 EXPECT_TRUE(uri.IsNull()); 615 EXPECT_TRUE(uri.IsNull());
615 } 616 }
616 617
617 private: 618 private:
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 NavigateToURL(shell(), file_url); 850 NavigateToURL(shell(), file_url);
850 851
851 PostTaskToInProcessRendererAndWait( 852 PostTaskToInProcessRendererAndWait(
852 base::Bind( 853 base::Bind(
853 &DomSerializerTests:: 854 &DomSerializerTests::
854 SubResourceForElementsInNonHTMLNamespaceOnRenderer, 855 SubResourceForElementsInNonHTMLNamespaceOnRenderer,
855 base::Unretained(this), file_url)); 856 base::Unretained(this), file_url));
856 } 857 }
857 858
858 } // namespace content 859 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.cc ('k') | content/renderer/fetchers/associated_resource_fetcher_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698