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" |
11 #include "DocumentType.h" | 11 #include "DocumentType.h" |
12 #include "Element.h" | 12 #include "Element.h" |
13 #include "FrameLoader.h" | 13 #include "FrameLoader.h" |
14 #include "FrameView.h" | 14 #include "FrameView.h" |
15 #include "HTMLHeadElement.h" | 15 #include "HTMLHeadElement.h" |
16 #include "HTMLMetaElement.h" | 16 #include "HTMLMetaElement.h" |
17 #include "HTMLNames.h" | 17 #include "HTMLNames.h" |
18 #include "KURL.h" | 18 #include "KURL.h" |
19 #include "markup.h" | 19 #include "markup.h" |
20 #include "SharedBuffer.h" | 20 #include "SharedBuffer.h" |
21 #include "SubstituteData.h" | 21 #include "SubstituteData.h" |
22 MSVC_POP_WARNING(); | 22 MSVC_POP_WARNING(); |
23 #undef LOG | 23 #undef LOG |
24 | 24 |
| 25 #include "base/file_path.h" |
25 #include "base/file_util.h" | 26 #include "base/file_util.h" |
26 #include "base/hash_tables.h" | 27 #include "base/hash_tables.h" |
27 #include "base/string_util.h" | 28 #include "base/string_util.h" |
28 #include "net/base/net_util.h" | 29 #include "net/base/net_util.h" |
29 #include "net/url_request/url_request_context.h" | 30 #include "net/url_request/url_request_context.h" |
30 #include "webkit/glue/dom_operations.h" | 31 #include "webkit/glue/dom_operations.h" |
31 #include "webkit/glue/dom_serializer.h" | 32 #include "webkit/glue/dom_serializer.h" |
32 #include "webkit/glue/dom_serializer_delegate.h" | 33 #include "webkit/glue/dom_serializer_delegate.h" |
33 #include "webkit/glue/webframe.h" | 34 #include "webkit/glue/webframe.h" |
34 #include "webkit/glue/webframe_impl.h" | 35 #include "webkit/glue/webframe_impl.h" |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 ASSERT_EQ(serialized_contents, orginal_contents); | 566 ASSERT_EQ(serialized_contents, orginal_contents); |
566 } | 567 } |
567 | 568 |
568 // Test situation of BASE tag in original document when serializing HTML DOM. | 569 // Test situation of BASE tag in original document when serializing HTML DOM. |
569 // When serializing, we should comment the BASE tag, append a new BASE tag. | 570 // When serializing, we should comment the BASE tag, append a new BASE tag. |
570 // rewrite all the savable URLs to relative local path, and change other URLs | 571 // rewrite all the savable URLs to relative local path, and change other URLs |
571 // to absolute URLs. | 572 // to absolute URLs. |
572 TEST_F(DomSerializerTests, SerialzeHTMLDOMWithBaseTag) { | 573 TEST_F(DomSerializerTests, SerialzeHTMLDOMWithBaseTag) { |
573 // There are total 2 available base tags in this test file. | 574 // There are total 2 available base tags in this test file. |
574 const int kTotalBaseTagCountInTestFile = 2; | 575 const int kTotalBaseTagCountInTestFile = 2; |
575 std::wstring page_file_path = data_dir_; | 576 |
576 file_util::AppendToPath(&page_file_path, L"dom_serializer"); | 577 FilePath page_file_path = FilePath::FromWStringHack(data_dir_).Append( |
577 page_file_path.append(1, file_util::kPathSeparator); | 578 FILE_PATH_LITERAL("dom_serializer")); |
| 579 file_util::EnsureEndsWithSeparator(&page_file_path); |
| 580 |
578 // Get page dir URL which is base URL of this file. | 581 // Get page dir URL which is base URL of this file. |
579 GURL path_dir_url = net::FilePathToFileURL(page_file_path); | 582 GURL path_dir_url = net::FilePathToFileURL(page_file_path.ToWStringHack()); |
580 // Get file path. | 583 // Get file path. |
581 file_util::AppendToPath(&page_file_path, L"html_doc_has_base_tag.htm"); | 584 page_file_path = |
| 585 page_file_path.Append(FILE_PATH_LITERAL("html_doc_has_base_tag.htm")); |
582 // Get file URL. | 586 // Get file URL. |
583 GURL file_url = net::FilePathToFileURL(page_file_path); | 587 GURL file_url = net::FilePathToFileURL(page_file_path.ToWStringHack()); |
584 ASSERT_TRUE(file_url.SchemeIsFile()); | 588 ASSERT_TRUE(file_url.SchemeIsFile()); |
585 std::wstring page_url = ASCIIToWide(file_url.spec()); | 589 std::wstring page_url = ASCIIToWide(file_url.spec()); |
586 // Load the test file. | 590 // Load the test file. |
587 LoadPageFromURL(page_url); | 591 LoadPageFromURL(page_url); |
588 // Since for this test, we assume there is no savable sub-resource links for | 592 // Since for this test, we assume there is no savable sub-resource links for |
589 // this test file, also all links are relative URLs in this test file, so we | 593 // this test file, also all links are relative URLs in this test file, so we |
590 // need to check those relative URLs and make sure document has BASE tag. | 594 // need to check those relative URLs and make sure document has BASE tag. |
591 WebFrameImpl* web_frame = | 595 WebFrameImpl* web_frame = |
592 webkit_glue::GetWebFrameImplFromWebViewForSpecificURL( | 596 webkit_glue::GetWebFrameImplFromWebViewForSpecificURL( |
593 test_shell_->webView(), file_url); | 597 test_shell_->webView(), file_url); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 } | 675 } |
672 } | 676 } |
673 } | 677 } |
674 // We have one more added BASE tag which is generated by JavaScript. | 678 // We have one more added BASE tag which is generated by JavaScript. |
675 ASSERT_EQ(new_base_tag_count, original_base_tag_count + 1); | 679 ASSERT_EQ(new_base_tag_count, original_base_tag_count + 1); |
676 // Make sure in new document, the base URL is equal with the |path_dir_url|. | 680 // Make sure in new document, the base URL is equal with the |path_dir_url|. |
677 GURL new_base_url( | 681 GURL new_base_url( |
678 WideToUTF8(webkit_glue::StringToStdWString(doc->baseURL()))); | 682 WideToUTF8(webkit_glue::StringToStdWString(doc->baseURL()))); |
679 ASSERT_EQ(new_base_url, path_dir_url); | 683 ASSERT_EQ(new_base_url, path_dir_url); |
680 } | 684 } |
OLD | NEW |