| OLD | NEW |
| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 private: | 185 private: |
| 186 const WebURL url_; | 186 const WebURL url_; |
| 187 const WebString local_path_; | 187 const WebString local_path_; |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 // Serialize DOM belonging to a frame with the specified |frame_url|. | 190 // Serialize DOM belonging to a frame with the specified |frame_url|. |
| 191 void SerializeDomForURL(const GURL& frame_url) { | 191 void SerializeDomForURL(const GURL& frame_url) { |
| 192 // Find corresponding WebFrame according to frame_url. | 192 // Find corresponding WebFrame according to frame_url. |
| 193 WebFrame* web_frame = FindSubFrameByURL(frame_url); | 193 WebFrame* web_frame = FindSubFrameByURL(frame_url); |
| 194 ASSERT_TRUE(web_frame != NULL); | 194 ASSERT_TRUE(web_frame != NULL); |
| 195 WebString file_path = | 195 WebString file_path = WebString::fromUTF8("c:\\dummy.htm"); |
| 196 base::FilePath(FILE_PATH_LITERAL("c:\\dummy.htm")).AsUTF16Unsafe(); | |
| 197 SingleLinkRewritingDelegate delegate(frame_url, file_path); | 196 SingleLinkRewritingDelegate delegate(frame_url, file_path); |
| 198 // Start serializing DOM. | 197 // Start serializing DOM. |
| 199 bool result = WebFrameSerializer::serialize(web_frame->toWebLocalFrame(), | 198 bool result = WebFrameSerializer::serialize(web_frame->toWebLocalFrame(), |
| 200 this, &delegate); | 199 this, &delegate); |
| 201 ASSERT_TRUE(result); | 200 ASSERT_TRUE(result); |
| 202 } | 201 } |
| 203 | 202 |
| 204 void SerializeHTMLDOMWithDocTypeOnRenderer(const GURL& file_url) { | 203 void SerializeHTMLDOMWithDocTypeOnRenderer(const GURL& file_url) { |
| 205 // Make sure original contents have document type. | 204 // Make sure original contents have document type. |
| 206 WebFrame* web_frame = FindSubFrameByURL(file_url); | 205 WebFrame* web_frame = FindSubFrameByURL(file_url); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 WebFrame* web_frame = FindSubFrameByURL(file_url); | 466 WebFrame* web_frame = FindSubFrameByURL(file_url); |
| 468 WebDocument doc = web_frame->document(); | 467 WebDocument doc = web_frame->document(); |
| 469 ASSERT_TRUE(doc.isHTMLDocument()); | 468 ASSERT_TRUE(doc.isHTMLDocument()); |
| 470 WebElement body_element = doc.body(); | 469 WebElement body_element = doc.body(); |
| 471 // Unescaped string for "%⊅¹'". | 470 // Unescaped string for "%⊅¹'". |
| 472 static const wchar_t parsed_value[] = { | 471 static const wchar_t parsed_value[] = { |
| 473 '%', 0x2285, 0x00b9, '\'', 0 | 472 '%', 0x2285, 0x00b9, '\'', 0 |
| 474 }; | 473 }; |
| 475 WebString value = body_element.getAttribute("title"); | 474 WebString value = body_element.getAttribute("title"); |
| 476 WebString content = doc.contentAsTextForTesting(); | 475 WebString content = doc.contentAsTextForTesting(); |
| 477 ASSERT_TRUE(base::UTF16ToWide(value) == parsed_value); | 476 ASSERT_TRUE(base::UTF16ToWide(value.utf16()) == parsed_value); |
| 478 ASSERT_TRUE(base::UTF16ToWide(content) == parsed_value); | 477 ASSERT_TRUE(base::UTF16ToWide(content.utf16()) == parsed_value); |
| 479 | 478 |
| 480 // Do serialization. | 479 // Do serialization. |
| 481 SerializeDomForURL(file_url); | 480 SerializeDomForURL(file_url); |
| 482 // Check the serialized string. | 481 // Check the serialized string. |
| 483 ASSERT_TRUE(serialization_reported_end_of_data_); | 482 ASSERT_TRUE(serialization_reported_end_of_data_); |
| 484 // Confirm that the serialized string has no non-standard HTML entities. | 483 // Confirm that the serialized string has no non-standard HTML entities. |
| 485 ASSERT_EQ(std::string::npos, serialized_contents_.find("%")); | 484 ASSERT_EQ(std::string::npos, serialized_contents_.find("%")); |
| 486 ASSERT_EQ(std::string::npos, serialized_contents_.find("⊅")); | 485 ASSERT_EQ(std::string::npos, serialized_contents_.find("⊅")); |
| 487 ASSERT_EQ(std::string::npos, serialized_contents_.find("¹")); | 486 ASSERT_EQ(std::string::npos, serialized_contents_.find("¹")); |
| 488 ASSERT_EQ(std::string::npos, serialized_contents_.find("'")); | 487 ASSERT_EQ(std::string::npos, serialized_contents_.find("'")); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 NavigateToURL(shell(), file_url); | 870 NavigateToURL(shell(), file_url); |
| 872 | 871 |
| 873 PostTaskToInProcessRendererAndWait( | 872 PostTaskToInProcessRendererAndWait( |
| 874 base::Bind( | 873 base::Bind( |
| 875 &DomSerializerTests:: | 874 &DomSerializerTests:: |
| 876 SubResourceForElementsInNonHTMLNamespaceOnRenderer, | 875 SubResourceForElementsInNonHTMLNamespaceOnRenderer, |
| 877 base::Unretained(this), file_url)); | 876 base::Unretained(this), file_url)); |
| 878 } | 877 } |
| 879 | 878 |
| 880 } // namespace content | 879 } // namespace content |
| OLD | NEW |