| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 | 8 |
| 9 MSVC_PUSH_WARNING_LEVEL(0); | 9 MSVC_PUSH_WARNING_LEVEL(0); |
| 10 #include "Document.h" | 10 #include "Document.h" |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 } | 565 } |
| 566 | 566 |
| 567 // Test situation of BASE tag in original document when serializing HTML DOM. | 567 // Test situation of BASE tag in original document when serializing HTML DOM. |
| 568 // When serializing, we should comment the BASE tag, append a new BASE tag. | 568 // When serializing, we should comment the BASE tag, append a new BASE tag. |
| 569 // rewrite all the savable URLs to relative local path, and change other URLs | 569 // rewrite all the savable URLs to relative local path, and change other URLs |
| 570 // to absolute URLs. | 570 // to absolute URLs. |
| 571 TEST_F(DomSerializerTests, SerialzeHTMLDOMWithBaseTag) { | 571 TEST_F(DomSerializerTests, SerialzeHTMLDOMWithBaseTag) { |
| 572 // There are total 2 available base tags in this test file. | 572 // There are total 2 available base tags in this test file. |
| 573 const int kTotalBaseTagCountInTestFile = 2; | 573 const int kTotalBaseTagCountInTestFile = 2; |
| 574 | 574 |
| 575 FilePath page_file_path = FilePath::FromWStringHack(data_dir_).Append( | 575 FilePath page_file_path = FilePath::FromWStringHack(data_dir_).AppendASCII( |
| 576 FILE_PATH_LITERAL("dom_serializer")); | 576 "dom_serializer"); |
| 577 file_util::EnsureEndsWithSeparator(&page_file_path); | 577 file_util::EnsureEndsWithSeparator(&page_file_path); |
| 578 | 578 |
| 579 // Get page dir URL which is base URL of this file. | 579 // Get page dir URL which is base URL of this file. |
| 580 GURL path_dir_url = net::FilePathToFileURL(page_file_path.ToWStringHack()); | 580 GURL path_dir_url = net::FilePathToFileURL(page_file_path.ToWStringHack()); |
| 581 // Get file path. | 581 // Get file path. |
| 582 page_file_path = | 582 page_file_path = |
| 583 page_file_path.Append(FILE_PATH_LITERAL("html_doc_has_base_tag.htm")); | 583 page_file_path.AppendASCII("html_doc_has_base_tag.htm"); |
| 584 // Get file URL. | 584 // Get file URL. |
| 585 GURL file_url = net::FilePathToFileURL(page_file_path.ToWStringHack()); | 585 GURL file_url = net::FilePathToFileURL(page_file_path.ToWStringHack()); |
| 586 ASSERT_TRUE(file_url.SchemeIsFile()); | 586 ASSERT_TRUE(file_url.SchemeIsFile()); |
| 587 std::wstring page_url = ASCIIToWide(file_url.spec()); | 587 std::wstring page_url = ASCIIToWide(file_url.spec()); |
| 588 // Load the test file. | 588 // Load the test file. |
| 589 LoadPageFromURL(page_url); | 589 LoadPageFromURL(page_url); |
| 590 // Since for this test, we assume there is no savable sub-resource links for | 590 // Since for this test, we assume there is no savable sub-resource links for |
| 591 // this test file, also all links are relative URLs in this test file, so we | 591 // this test file, also all links are relative URLs in this test file, so we |
| 592 // need to check those relative URLs and make sure document has BASE tag. | 592 // need to check those relative URLs and make sure document has BASE tag. |
| 593 WebFrameImpl* web_frame = | 593 WebFrameImpl* web_frame = |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 } | 675 } |
| 676 // We have one more added BASE tag which is generated by JavaScript. | 676 // We have one more added BASE tag which is generated by JavaScript. |
| 677 ASSERT_EQ(new_base_tag_count, original_base_tag_count + 1); | 677 ASSERT_EQ(new_base_tag_count, original_base_tag_count + 1); |
| 678 // Make sure in new document, the base URL is equal with the |path_dir_url|. | 678 // Make sure in new document, the base URL is equal with the |path_dir_url|. |
| 679 GURL new_base_url( | 679 GURL new_base_url( |
| 680 WideToUTF8(webkit_glue::StringToStdWString(doc->baseURL()))); | 680 WideToUTF8(webkit_glue::StringToStdWString(doc->baseURL()))); |
| 681 ASSERT_EQ(new_base_url, path_dir_url); | 681 ASSERT_EQ(new_base_url, path_dir_url); |
| 682 } | 682 } |
| 683 | 683 |
| 684 } // namespace | 684 } // namespace |
| OLD | NEW |