OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Opera Software ASA. All rights reserved. | 2 * Copyright (c) 2013, Opera Software ASA. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "public/platform/WebThread.h" | 41 #include "public/platform/WebThread.h" |
42 #include "public/platform/WebURL.h" | 42 #include "public/platform/WebURL.h" |
43 #include "public/platform/WebURLRequest.h" | 43 #include "public/platform/WebURLRequest.h" |
44 #include "public/platform/WebURLResponse.h" | 44 #include "public/platform/WebURLResponse.h" |
45 #include "public/platform/WebUnitTestSupport.h" | 45 #include "public/platform/WebUnitTestSupport.h" |
46 #include "public/web/WebSettings.h" | 46 #include "public/web/WebSettings.h" |
47 #include "testing/gtest/include/gtest/gtest.h" | 47 #include "testing/gtest/include/gtest/gtest.h" |
48 #include "web/WebLocalFrameImpl.h" | 48 #include "web/WebLocalFrameImpl.h" |
49 #include "web/WebViewImpl.h" | 49 #include "web/WebViewImpl.h" |
50 #include "web/tests/FrameTestHelpers.h" | 50 #include "web/tests/FrameTestHelpers.h" |
| 51 #include "wtf/Assertions.h" |
51 #include "wtf/Vector.h" | 52 #include "wtf/Vector.h" |
52 | 53 |
53 using blink::URLTestHelpers::toKURL; | 54 using blink::URLTestHelpers::toKURL; |
54 using blink::URLTestHelpers::registerMockedURLLoad; | 55 using blink::URLTestHelpers::registerMockedURLLoad; |
55 | 56 |
56 namespace blink { | 57 namespace blink { |
57 | 58 |
58 class PageSerializerTest : public testing::Test { | 59 class PageSerializerTest : public testing::Test { |
59 public: | 60 public: |
60 PageSerializerTest() | 61 PageSerializerTest() |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 117 |
117 void serialize(const char* url) | 118 void serialize(const char* url) |
118 { | 119 { |
119 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), KURL(m_base
Url, url).string().utf8().data()); | 120 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), KURL(m_base
Url, url).string().utf8().data()); |
120 PageSerializer serializer(&m_resources, nullptr); | 121 PageSerializer serializer(&m_resources, nullptr); |
121 | 122 |
122 serializer.setRewriteURLFolder(m_rewriteFolder); | 123 serializer.setRewriteURLFolder(m_rewriteFolder); |
123 for (const auto& rewriteURL: m_rewriteURLs) | 124 for (const auto& rewriteURL: m_rewriteURLs) |
124 serializer.registerRewriteURL(rewriteURL.key, rewriteURL.value); | 125 serializer.registerRewriteURL(rewriteURL.key, rewriteURL.value); |
125 | 126 |
126 serializer.serialize(m_helper.webViewImpl()->mainFrameImpl()->frame()->p
age()); | 127 Frame* frame = m_helper.webViewImpl()->mainFrameImpl()->frame(); |
| 128 for (; frame; frame = frame->tree().traverseNext()) { |
| 129 // This is safe, because tests do not do cross-site navigation |
| 130 // (and therefore don't have remote frames). |
| 131 serializer.serializeFrame(*toLocalFrame(frame)); |
| 132 } |
127 } | 133 } |
128 | 134 |
129 Vector<SerializedResource>& getResources() | 135 Vector<SerializedResource>& getResources() |
130 { | 136 { |
131 return m_resources; | 137 return m_resources; |
132 } | 138 } |
133 | 139 |
134 | |
135 const SerializedResource* getResource(const char* url, const char* mimeType) | 140 const SerializedResource* getResource(const char* url, const char* mimeType) |
136 { | 141 { |
137 KURL kURL = KURL(m_baseUrl, url); | 142 KURL kURL = KURL(m_baseUrl, url); |
138 String mime(mimeType); | 143 String mime(mimeType); |
139 for (size_t i = 0; i < m_resources.size(); ++i) { | 144 for (size_t i = 0; i < m_resources.size(); ++i) { |
140 const SerializedResource& resource = m_resources[i]; | 145 const SerializedResource& resource = m_resources[i]; |
141 if (resource.url == kURL && !resource.data->isEmpty() | 146 if (resource.url == kURL && !resource.data->isEmpty() |
142 && (mime.isNull() || equalIgnoringCase(resource.mimeType, mime))
) | 147 && (mime.isNull() || equalIgnoringCase(resource.mimeType, mime))
) |
143 return &resource; | 148 return &resource; |
144 } | 149 } |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 EXPECT_EQ("saved from url=(0015)http://foo.com/", PageSerializer::markOfTheW
ebDeclaration(KURL(ParsedURLString, "http://foo.com"))); | 526 EXPECT_EQ("saved from url=(0015)http://foo.com/", PageSerializer::markOfTheW
ebDeclaration(KURL(ParsedURLString, "http://foo.com"))); |
522 EXPECT_EQ("saved from url=(0015)http://f-o.com/", PageSerializer::markOfTheW
ebDeclaration(KURL(ParsedURLString, "http://f-o.com"))); | 527 EXPECT_EQ("saved from url=(0015)http://f-o.com/", PageSerializer::markOfTheW
ebDeclaration(KURL(ParsedURLString, "http://f-o.com"))); |
523 EXPECT_EQ("saved from url=(0019)http://foo.com-%2D/", PageSerializer::markOf
TheWebDeclaration(KURL(ParsedURLString, "http://foo.com--"))); | 528 EXPECT_EQ("saved from url=(0019)http://foo.com-%2D/", PageSerializer::markOf
TheWebDeclaration(KURL(ParsedURLString, "http://foo.com--"))); |
524 EXPECT_EQ("saved from url=(0024)http://f-%2D.com-%2D%3E/", PageSerializer::m
arkOfTheWebDeclaration(KURL(ParsedURLString, "http://f--.com-->"))); | 529 EXPECT_EQ("saved from url=(0024)http://f-%2D.com-%2D%3E/", PageSerializer::m
arkOfTheWebDeclaration(KURL(ParsedURLString, "http://f--.com-->"))); |
525 EXPECT_EQ("saved from url=(0020)http://foo.com/?-%2D", PageSerializer::markO
fTheWebDeclaration(KURL(ParsedURLString, "http://foo.com?--"))); | 530 EXPECT_EQ("saved from url=(0020)http://foo.com/?-%2D", PageSerializer::markO
fTheWebDeclaration(KURL(ParsedURLString, "http://foo.com?--"))); |
526 EXPECT_EQ("saved from url=(0020)http://foo.com/#-%2D", PageSerializer::markO
fTheWebDeclaration(KURL(ParsedURLString, "http://foo.com#--"))); | 531 EXPECT_EQ("saved from url=(0020)http://foo.com/#-%2D", PageSerializer::markO
fTheWebDeclaration(KURL(ParsedURLString, "http://foo.com#--"))); |
527 EXPECT_EQ("saved from url=(0026)http://foo.com/#bar-%2Dbaz", PageSerializer:
:markOfTheWebDeclaration(KURL(ParsedURLString, "http://foo.com#bar--baz"))); | 532 EXPECT_EQ("saved from url=(0026)http://foo.com/#bar-%2Dbaz", PageSerializer:
:markOfTheWebDeclaration(KURL(ParsedURLString, "http://foo.com#bar--baz"))); |
528 } | 533 } |
529 | 534 |
530 } // namespace blink | 535 } // namespace blink |
OLD | NEW |