Changeset 121463 in webkit
- Timestamp:
- Jun 28, 2012 1:34:47 PM (12 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 1 added
- 15 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r121451 r121463 1 2012-06-28 Shawn Singh <shawnsingh@chromium.org> 2 3 [chromium] Use WEBKIT_IMPLEMENTATION == 1 for webkit_unit_tests 4 https://bugs.webkit.org/show_bug.cgi?id=90094 5 6 Reviewed by Adam Barth. 7 8 This patch adds the WEBKIT_IMPLEMENTATION = 1 define to 9 WebKitUnitTests.gyp. To get it to compile correctly, some string 10 and URL code was refactored and fixed. 11 12 * WebKit.gypi: 13 * WebKitUnitTests.gyp: 14 * public/WebDOMMessageEvent.h: 15 (WebKit::WebDOMMessageEvent::WebDOMMessageEvent): 16 * tests/AssociatedURLLoaderTest.cpp: 17 * tests/EventListenerTest.cpp: 18 * tests/FrameTestHelpers.cpp: 19 (WebKit::FrameTestHelpers::loadFrame): 20 * tests/FrameTestHelpers.h: 21 * tests/ListenerLeakTest.cpp: 22 (WebKit::ListenerLeakTest::RunTest): 23 * tests/PopupMenuTest.cpp: 24 * tests/RunAllTests.cpp: 25 * tests/URLTestHelpers.cpp: Added. 26 (URLTestHelpers): 27 (WebKit::URLTestHelpers::registerMockedURLFromBaseURL): 28 (WebKit::URLTestHelpers::registerMockedURLLoad): 29 * tests/URLTestHelpers.h: Copied from Source/WebKit/chromium/public/WebDOMMessageEvent.h. 30 (WebKit): 31 (URLTestHelpers): 32 (WebKit::URLTestHelpers::toKURL): 33 * tests/WebFrameTest.cpp: 34 * tests/WebPageNewSerializerTest.cpp: 35 * tests/WebPageSerializerTest.cpp: 36 * tests/WebViewTest.cpp: 37 1 38 2012-06-28 Oli Lan <olilan@chromium.org> 2 39 -
trunk/Source/WebKit/chromium/WebKit.gypi
r121415 r121463 147 147 'tests/TreeTestHelpers.cpp', 148 148 'tests/TreeTestHelpers.h', 149 'tests/URLTestHelpers.cpp', 150 'tests/URLTestHelpers.h', 149 151 'tests/WebCompositorInputHandlerImplTest.cpp', 150 152 'tests/WebFrameTest.cpp', -
trunk/Source/WebKit/chromium/WebKitUnitTests.gyp
r121408 r121463 79 79 '../../Platform/chromium', 80 80 ], 81 'defines': [ 82 'WEBKIT_IMPLEMENTATION=1', 83 ], 81 84 'conditions': [ 82 85 ['inside_chromium_build==1 and component=="shared_library"', { -
trunk/Source/WebKit/chromium/public/WebDOMMessageEvent.h
r121408 r121463 47 47 class WebDOMMessageEvent : public WebDOMEvent { 48 48 public: 49 WebDOMMessageEvent() { } 49 50 WEBKIT_EXPORT void initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame* sourceFrame, const WebString& lastEventId); 50 51 -
trunk/Source/WebKit/chromium/tests/AssociatedURLLoaderTest.cpp
r121408 r121463 31 31 #include "config.h" 32 32 33 #include "URLTestHelpers.h" 33 34 #include "WebFrame.h" 34 35 #include "WebFrameClient.h" … … 43 44 #include <wtf/text/WTFString.h> 44 45 45 #include <googleurl/src/gurl.h>46 46 #include <gtest/gtest.h> 47 47 #include <webkit/support/webkit_support.h> 48 48 49 49 using namespace WebKit; 50 using WebKit::URLTestHelpers::toKURL; 50 51 51 52 namespace { … … 77 78 { 78 79 // Reuse one of the test files from WebFrameTest. 79 std::string filePath = webkit_support::GetWebKitRootDir().utf8();80 std::string filePath = std::string(webkit_support::GetWebKitRootDir().utf8().data()); 80 81 filePath += "/Source/WebKit/chromium/tests/data/iframes_test.html"; 81 m_frameFilePath = WebString::fromUTF8(filePath );82 m_frameFilePath = WebString::fromUTF8(filePath.c_str()); 82 83 } 83 84 … … 88 89 89 90 // Load the frame before trying to load resources. 90 GURL url = GURL("http://www.test.com/iframes_test.html");91 WebCore::KURL url = toKURL("http://www.test.com/iframes_test.html"); 91 92 WebURLResponse response; 92 93 response.initialize(); … … 185 186 WebURLRequest request; 186 187 request.initialize(); 187 request.setURL( GURL("http://www.test.com/success.html"));188 request.setURL(toKURL("http://www.test.com/success.html")); 188 189 request.setHTTPMethod(WebString::fromUTF8(unsafeMethod)); 189 190 WebURLLoaderOptions options; … … 201 202 WebURLRequest request; 202 203 request.initialize(); 203 request.setURL( GURL("http://www.test.com/success.html"));204 request.setURL(toKURL("http://www.test.com/success.html")); 204 205 request.setHTTPHeaderField(WebString::fromUTF8(headerField), WebString::fromUTF8(headerValue)); 205 206 WebURLLoaderOptions options; … … 231 232 id.append(".html"); 232 233 233 GURL url = GURL(id);234 WebCore::KURL url = toKURL(id); 234 235 WebURLRequest request; 235 236 request.initialize(); … … 283 284 TEST_F(AssociatedURLLoaderTest, SameOriginSuccess) 284 285 { 285 GURL url = GURL("http://www.test.com/SameOriginSuccess.html");286 WebCore::KURL url = toKURL("http://www.test.com/SameOriginSuccess.html"); 286 287 WebURLRequest request; 287 288 request.initialize(); … … 306 307 { 307 308 // This is cross-origin since the frame was loaded from www.test.com. 308 GURL url = GURL("http://www.other.com/SameOriginRestriction.html");309 WebCore::KURL url = toKURL("http://www.other.com/SameOriginRestriction.html"); 309 310 WebURLRequest request; 310 311 request.initialize(); … … 317 318 { 318 319 // This is cross-origin since the frame was loaded from www.test.com. 319 GURL url = GURL("http://www.other.com/CrossOriginSuccess.html");320 WebCore::KURL url = toKURL("http://www.other.com/CrossOriginSuccess.html"); 320 321 WebURLRequest request; 321 322 request.initialize(); … … 342 343 { 343 344 // This is cross-origin since the frame was loaded from www.test.com. 344 GURL url = GURL("http://www.other.com/CrossOriginWithAccessControlSuccess.html");345 WebCore::KURL url = toKURL("http://www.other.com/CrossOriginWithAccessControlSuccess.html"); 345 346 WebURLRequest request; 346 347 request.initialize(); … … 368 369 { 369 370 // This is cross-origin since the frame was loaded from www.test.com. 370 GURL url = GURL("http://www.other.com/CrossOriginWithAccessControlFailure.html");371 WebCore::KURL url = toKURL("http://www.other.com/CrossOriginWithAccessControlFailure.html"); 371 372 WebURLRequest request; 372 373 request.initialize(); … … 399 400 TEST_F(AssociatedURLLoaderTest, RedirectSuccess) 400 401 { 401 GURL url = GURL("http://www.test.com/RedirectSuccess.html");402 WebCore::KURL url = toKURL("http://www.test.com/RedirectSuccess.html"); 402 403 char redirect[] = "http://www.test.com/RedirectSuccess2.html"; // Same-origin 403 GURL redirectURL = GURL(redirect);404 WebCore::KURL redirectURL = toKURL(redirect); 404 405 405 406 WebURLRequest request; … … 436 437 TEST_F(AssociatedURLLoaderTest, RedirectCrossOriginWithAccessControlFailure) 437 438 { 438 GURL url = GURL("http://www.test.com/RedirectCrossOriginWithAccessControlFailure.html");439 WebCore::KURL url = toKURL("http://www.test.com/RedirectCrossOriginWithAccessControlFailure.html"); 439 440 char redirect[] = "http://www.other.com/RedirectCrossOriginWithAccessControlFailure.html"; // Cross-origin 440 GURL redirectURL = GURL(redirect);441 WebCore::KURL redirectURL = toKURL(redirect); 441 442 442 443 WebURLRequest request; … … 468 469 TEST_F(AssociatedURLLoaderTest, RedirectCrossOriginWithAccessControlSuccess) 469 470 { 470 GURL url = GURL("http://www.test.com/RedirectCrossOriginWithAccessControlSuccess.html");471 WebCore::KURL url = toKURL("http://www.test.com/RedirectCrossOriginWithAccessControlSuccess.html"); 471 472 char redirect[] = "http://www.other.com/RedirectCrossOriginWithAccessControlSuccess.html"; // Cross-origin 472 GURL redirectURL = GURL(redirect);473 WebCore::KURL redirectURL = toKURL(redirect); 473 474 474 475 WebURLRequest request; … … 591 592 WebURLRequest request; 592 593 request.initialize(); 593 GURL url = GURL("http://www.other.com/CrossOriginHeaderAllowResponseHeaders.html");594 WebCore::KURL url = toKURL("http://www.other.com/CrossOriginHeaderAllowResponseHeaders.html"); 594 595 request.setURL(url); 595 596 -
trunk/Source/WebKit/chromium/tests/EventListenerTest.cpp
r121408 r121463 32 32 33 33 #include "FrameTestHelpers.h" 34 #include "URLTestHelpers.h" 34 35 #include "WebDOMEvent.h" 35 36 #include "WebDOMEventListener.h" … … 79 80 std::string fileName("listener/mutation_event_listener.html"); 80 81 bool executeScript = true; 81 FrameTestHelpers::registerMockedURLLoad(baseURL, fileName);82 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8(fileName.c_str())); 82 83 m_webView = FrameTestHelpers::createWebViewAndLoad(baseURL + fileName, executeScript); 83 84 } -
trunk/Source/WebKit/chromium/tests/FrameTestHelpers.cpp
r121408 r121463 32 32 #include "FrameTestHelpers.h" 33 33 34 #include "URLTestHelpers.h" 34 35 #include <wtf/StdLibExtras.h> 35 36 #include "WebFrame.h" … … 41 42 #include "WebView.h" 42 43 #include "WebViewClient.h" 43 #include <googleurl/src/gurl.h>44 44 #include <webkit/support/webkit_support.h> 45 45 … … 47 47 namespace FrameTestHelpers { 48 48 49 void registerMockedURLLoad(const std::string& base, const std::string& fileName)50 {51 registerMockedURLLoad(GURL(base + fileName), fileName);52 }53 54 void registerMockedURLLoad(GURL url, const std::string& fileName)55 {56 WebURLResponse response;57 response.initialize();58 response.setMIMEType("text/html");59 60 std::string filePath = webkit_support::GetWebKitRootDir().utf8();61 filePath += "/Source/WebKit/chromium/tests/data/";62 filePath += fileName;63 64 webkit_support::RegisterMockedURL(url, response, WebString::fromUTF8(filePath));65 }66 67 49 void loadFrame(WebFrame* frame, const std::string& url) 68 50 { 69 51 WebURLRequest urlRequest; 70 52 urlRequest.initialize(); 71 urlRequest.setURL( GURL(url));53 urlRequest.setURL(URLTestHelpers::toKURL(url)); 72 54 frame->loadRequest(urlRequest); 73 55 } -
trunk/Source/WebKit/chromium/tests/FrameTestHelpers.h
r121408 r121463 34 34 #include <string> 35 35 36 class GURL;37 38 36 namespace WebKit { 39 37 … … 45 43 namespace FrameTestHelpers { 46 44 47 void registerMockedURLLoad(const std::string& base, const std::string& fileName);48 // Like the previous overload, but it allows more flexibility in the url since it is given by the caller.49 void registerMockedURLLoad(GURL, const std::string& fileName);50 51 45 void loadFrame(WebFrame*, const std::string& url); 52 46 -
trunk/Source/WebKit/chromium/tests/ListenerLeakTest.cpp
r121408 r121463 32 32 33 33 #include "FrameTestHelpers.h" 34 #include "URLTestHelpers.h" 34 35 #include "WebView.h" 35 36 #include <gtest/gtest.h> … … 91 92 std::string fileName(filename); 92 93 bool executeScript = true; 93 FrameTestHelpers::registerMockedURLLoad(baseURL, fileName);94 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8(fileName.c_str())); 94 95 m_webView = FrameTestHelpers::createWebViewAndLoad(baseURL + fileName, executeScript); 95 96 } -
trunk/Source/WebKit/chromium/tests/PopupMenuTest.cpp
r121408 r121463 44 44 #include "PopupMenuChromium.h" 45 45 #include "RuntimeEnabledFeatures.h" 46 #include "URLTestHelpers.h" 46 47 #include "WebDocument.h" 47 48 #include "WebElement.h" … … 64 65 using namespace WebCore; 65 66 using namespace WebKit; 67 using WebKit::URLTestHelpers::toKURL; 66 68 67 69 namespace { … … 250 252 void registerMockedURLLoad(const std::string& fileName) 251 253 { 252 WebURLResponse response; 253 response.initialize(); 254 response.setMIMEType("text/html"); 255 256 std::string filePath = webkit_support::GetWebKitRootDir().utf8(); 257 filePath += "/Source/WebKit/chromium/tests/data/popup/"; 258 filePath += fileName; 259 260 webkit_support::RegisterMockedURL(WebURL(GURL(baseURL + fileName)), response, WebString::fromUTF8(filePath)); 254 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + fileName), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8("popup/"), WebString::fromUTF8("text/html")); 261 255 } 262 256 … … 270 264 WebURLRequest urlRequest; 271 265 urlRequest.initialize(); 272 urlRequest.setURL(WebURL( GURL(baseURL + fileName)));266 urlRequest.setURL(WebURL(toKURL(baseURL + fileName))); 273 267 frame->loadRequest(urlRequest); 274 268 } … … 428 422 // mousedown event is held by select node, and we don't simulate the event for the node. 429 423 // So we can only see mouseup and click event. 430 EXPECT_STREQ("upclick", std::string(element.innerText().utf8()).c_str());424 EXPECT_STREQ("upclick", element.innerText().utf8().data()); 431 425 432 426 // Disable the item at index 1. … … 440 434 441 435 // The item at index 1 is disabled, so the text should not be changed. 442 EXPECT_STREQ("upclick", std::string(element.innerText().utf8()).c_str());436 EXPECT_STREQ("upclick", element.innerText().utf8().data()); 443 437 444 438 showPopup(); … … 449 443 450 444 // The item is changed to the item at index 2, from index 0, so change event is fired. 451 EXPECT_STREQ("upclickchangeupclick", std::string(element.innerText().utf8()).c_str());445 EXPECT_STREQ("upclickchangeupclick", element.innerText().utf8().data()); 452 446 } 453 447 … … 470 464 WebElement element = m_webView->mainFrame()->document().getElementById("message"); 471 465 // We only can see change event but no other mouse related events. 472 EXPECT_STREQ("change", std::string(element.innerText().utf8()).c_str());466 EXPECT_STREQ("change", element.innerText().utf8().data()); 473 467 } 474 468 … … 492 486 493 487 WebElement element = m_webView->mainFrame()->document().getElementById("message"); 494 EXPECT_STREQ("change", std::string(element.innerText().utf8()).c_str());488 EXPECT_STREQ("change", element.innerText().utf8().data()); 495 489 } 496 490 … … 514 508 515 509 WebElement element = m_webView->mainFrame()->document().getElementById("message"); 516 EXPECT_STREQ("click", std::string(element.innerText().utf8()).c_str());510 EXPECT_STREQ("click", element.innerText().utf8().data()); 517 511 } 518 512 -
trunk/Source/WebKit/chromium/tests/RunAllTests.cpp
r121408 r121463 28 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 29 */ 30 31 #include "config.h" 30 32 31 33 // FIXME: Avoid this source dependency on Chromium's base module. -
trunk/Source/WebKit/chromium/tests/URLTestHelpers.h
r121459 r121463 1 1 /* 2 * Copyright (C) 201 1Google Inc. All rights reserved.2 * Copyright (C) 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 29 */ 30 #ifndef WebDOMMessageEvent_h31 #define WebDOMMessageEvent_h32 30 33 #include "WebDOMEvent.h" 34 #include "WebMessagePortChannel.h" 35 #include "platform/WebSerializedScriptValue.h" 31 #ifndef URLTestHelpers_h 32 #define URLTestHelpers_h 36 33 37 #if WEBKIT_IMPLEMENTATION 38 #include "Event.h" 39 #include "MessageEvent.h" 40 #endif 34 #include "KURL.h" 35 #include <public/WebString.h> 41 36 42 37 namespace WebKit { 43 38 44 class WebFrame; 45 class WebString; 39 class WebURL; 46 40 47 class WebDOMMessageEvent : public WebDOMEvent { 48 public: 49 WEBKIT_EXPORT void initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame* sourceFrame, const WebString& lastEventId); 41 namespace URLTestHelpers { 50 42 51 WEBKIT_EXPORT WebSerializedScriptValue data() const; 52 WEBKIT_EXPORT WebString origin() const; 43 inline WebCore::KURL toKURL(const std::string& url) 44 { 45 WTF::String wtfString(url.c_str()); 46 return WebCore::KURL(WebCore::ParsedURLString, wtfString); 47 } 53 48 54 #if WEBKIT_IMPLEMENTATION 55 explicit WebDOMMessageEvent(const WTF::PassRefPtr<WebCore::MessageEvent>& e) : WebDOMEvent(e) { } 56 #endif 57 }; 49 // Helper functions for mock URLs. These functions set up the desired URL and mimeType, with a 200 OK return status. 50 // For the mock URL, fullURL == baseURL + fileName. 51 // For the actual file path: <WebKit root directory> + relativeBaseDirectory + fileName, 52 // or, if the relative base directory is not specified: <WebKit root directory> + fileName. 53 // 54 void registerMockedURLFromBaseURL(const WebString& baseURL, const WebString& fileName, const WebString& mimeType = WebString::fromUTF8("text/html")); 55 void registerMockedURLLoad(const WebURL& fullURL, const WebString& fileName, const WebString& mimeType = WebString::fromUTF8("text/html")); 56 void registerMockedURLLoad(const WebURL& fullURL, const WebString& fileName, const WebString& relativeBaseDirectory, const WebString& mimeType); 58 57 58 } // namespace URLTestHelpers 59 59 } // namespace WebKit 60 60 -
trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp
r121434 r121463 37 37 #include "FrameView.h" 38 38 #include "ResourceError.h" 39 #include "URLTestHelpers.h" 39 40 #include "WebDataSource.h" 40 41 #include "WebDocument.h" … … 56 57 57 58 using namespace WebKit; 59 using WebKit::URLTestHelpers::toKURL; 58 60 59 61 namespace { … … 74 76 void registerMockedHttpURLLoad(const std::string& fileName) 75 77 { 76 FrameTestHelpers::registerMockedURLLoad(m_baseURL, fileName);78 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(fileName.c_str())); 77 79 } 78 80 79 81 void registerMockedChromeURLLoad(const std::string& fileName) 80 82 { 81 FrameTestHelpers::registerMockedURLLoad(m_chromeURL, fileName);83 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chromeURL.c_str()), WebString::fromUTF8(fileName.c_str())); 82 84 } 83 85 … … 97 99 98 100 // Now retrieve the frames text and test it only includes visible elements. 99 std::string content = webView->mainFrame()->contentAsText(1024).utf8();101 std::string content = std::string(webView->mainFrame()->contentAsText(1024).utf8().data()); 100 102 EXPECT_NE(std::string::npos, content.find(" visible paragraph")); 101 103 EXPECT_NE(std::string::npos, content.find(" visible iframe")); … … 157 159 158 160 // Now retrieve the frame's text and ensure it was modified by running javascript. 159 std::string content = webView->mainFrame()->contentAsText(1024).utf8();161 std::string content = std::string(webView->mainFrame()->contentAsText(1024).utf8().data()); 160 162 EXPECT_NE(std::string::npos, content.find("Clobbered")); 161 163 } … … 176 178 177 179 // Now retrieve the frame's text and ensure it wasn't modified by running javascript. 178 std::string content = webView->mainFrame()->contentAsText(1024).utf8();180 std::string content = std::string(webView->mainFrame()->contentAsText(1024).utf8().data()); 179 181 EXPECT_EQ(std::string::npos, content.find("Clobbered")); 180 182 } … … 188 190 189 191 // Send a message with the correct origin. 190 WebSecurityOrigin correctOrigin(WebSecurityOrigin::create( GURL(m_baseURL)));192 WebSecurityOrigin correctOrigin(WebSecurityOrigin::create(toKURL(m_baseURL))); 191 193 WebDOMEvent event = webView->mainFrame()->document().createEvent("MessageEvent"); 192 194 WebDOMMessageEvent message = event.to<WebDOMMessageEvent>(); … … 196 198 197 199 // Send another message with incorrect origin. 198 WebSecurityOrigin incorrectOrigin(WebSecurityOrigin::create( GURL(m_chromeURL)));200 WebSecurityOrigin incorrectOrigin(WebSecurityOrigin::create(toKURL(m_chromeURL))); 199 201 webView->mainFrame()->dispatchMessageEventWithOriginCheck(incorrectOrigin, message); 200 202 … … 203 205 204 206 // Verify that only the first addition is in the body of the page. 205 std::string content = webView->mainFrame()->contentAsText(1024).utf8();207 std::string content = std::string(webView->mainFrame()->contentAsText(1024).utf8().data()); 206 208 EXPECT_NE(std::string::npos, content.find("Message 1.")); 207 209 EXPECT_EQ(std::string::npos, content.find("Message 2.")); … … 442 444 443 445 // Reload the page using the cache. 444 webViewImpl->mainFrame()->reloadWithOverrideURL( GURL(m_baseURL + secondURL), false);446 webViewImpl->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + secondURL), false); 445 447 webkit_support::ServeAsynchronousMockedRequests(); 446 448 ASSERT_EQ(previousOffset, webViewImpl->mainFrame()->scrollOffset()); … … 448 450 449 451 // Reload the page while ignoring the cache. 450 webViewImpl->mainFrame()->reloadWithOverrideURL( GURL(m_baseURL + thirdURL), true);452 webViewImpl->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + thirdURL), true); 451 453 webkit_support::ServeAsynchronousMockedRequests(); 452 454 ASSERT_EQ(previousOffset, webViewImpl->mainFrame()->scrollOffset()); … … 470 472 iframeDataSource->redirectChain(redirects); 471 473 ASSERT_EQ(2U, redirects.size()); 472 EXPECT_EQ( GURL("about:blank"), GURL(redirects[0]));473 EXPECT_EQ( GURL("http://www.test.com/visible_iframe.html"), GURL(redirects[1]));474 EXPECT_EQ(toKURL("about:blank"), toKURL(redirects[0].spec().data())); 475 EXPECT_EQ(toKURL("http://www.test.com/visible_iframe.html"), toKURL(redirects[1].spec().data())); 474 476 475 477 webView->close(); … … 732 734 // Generate a simple test case. 733 735 const char simpleSource[] = "<div>Foo bar</div><div></div>baz"; 734 GURL testURL("about:blank");736 WebCore::KURL testURL = toKURL("about:blank"); 735 737 frame->loadHTMLString(simpleSource, testURL); 736 738 webkit_support::RunAllPendingMessages(); … … 739 741 const std::string expected("Foo bar\nbaz"); 740 742 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); 741 EXPECT_EQ(expected, std::string(text.utf8() ));743 EXPECT_EQ(expected, std::string(text.utf8().data())); 742 744 743 745 // Try reading the same one with clipping of the text. 744 746 const int length = 5; 745 747 text = frame->contentAsText(length); 746 EXPECT_EQ(expected.substr(0, length), std::string(text.utf8() ));748 EXPECT_EQ(expected.substr(0, length), std::string(text.utf8().data())); 747 749 748 750 // Now do a new test with a subframe. … … 758 760 759 761 text = frame->contentAsText(std::numeric_limits<size_t>::max()); 760 EXPECT_EQ("Hello world\n\nsub\ntext", std::string(text.utf8() ));762 EXPECT_EQ("Hello world\n\nsub\ntext", std::string(text.utf8().data())); 761 763 762 764 // Get the frame text where the subframe separator falls on the boundary of 763 765 // what we'll take. There used to be a crash in this case. 764 766 text = frame->contentAsText(12); 765 EXPECT_EQ("Hello world", std::string(text.utf8() ));767 EXPECT_EQ("Hello world", std::string(text.utf8().data())); 766 768 767 769 webView->close(); … … 775 777 // Generate a simple test case. 776 778 const char simpleSource[] = "<p>Hello</p><p>World</p>"; 777 GURL testURL("about:blank");779 WebCore::KURL testURL = toKURL("about:blank"); 778 780 frame->loadHTMLString(simpleSource, testURL); 779 781 webkit_support::RunAllPendingMessages(); 780 782 781 783 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); 782 EXPECT_EQ("Hello\n\nWorld", std::string(text.utf8() ));783 784 const std::string html = frame->contentAsMarkup().utf8();784 EXPECT_EQ("Hello\n\nWorld", std::string(text.utf8().data())); 785 786 const std::string html = std::string(frame->contentAsMarkup().utf8().data()); 785 787 786 788 // Load again with the output html. 787 frame->loadHTMLString( html, testURL);789 frame->loadHTMLString(WebData(html.c_str(), html.length()), testURL); 788 790 webkit_support::RunAllPendingMessages(); 789 791 790 EXPECT_EQ(html, std::string(frame->contentAsMarkup().utf8() ));792 EXPECT_EQ(html, std::string(frame->contentAsMarkup().utf8().data())); 791 793 792 794 text = frame->contentAsText(std::numeric_limits<size_t>::max()); 793 EXPECT_EQ("Hello\n\nWorld", std::string(text.utf8() ));795 EXPECT_EQ("Hello\n\nWorld", std::string(text.utf8().data())); 794 796 795 797 // Test selection check -
trunk/Source/WebKit/chromium/tests/WebPageNewSerializerTest.cpp
r121408 r121463 31 31 #include "config.h" 32 32 33 #include "URLTestHelpers.h" 33 34 #include "WebFrame.h" 34 35 #include "WebFrameClient.h" … … 42 43 #include "WebView.h" 43 44 44 #include <googleurl/src/gurl.h>45 45 #include <gtest/gtest.h> 46 46 #include <webkit/support/webkit_support.h> 47 47 48 48 using namespace WebKit; 49 using WebKit::URLTestHelpers::toKURL; 50 using WebKit::URLTestHelpers::registerMockedURLLoad; 49 51 50 52 namespace { … … 111 113 } 112 114 113 void registerMockedURLLoad(const WebURL& url, const WebString& fileName, const WebString& mimeType)114 {115 WebURLResponse response;116 response.initialize();117 response.setMIMEType(mimeType);118 response.setHTTPStatusCode(200);119 std::string filePath = webkit_support::GetWebKitRootDir().utf8();120 filePath.append("/Source/WebKit/chromium/tests/data/pageserializer/");121 filePath.append(fileName.utf8());122 webkit_support::RegisterMockedURL(url, response, WebString::fromUTF8(filePath));123 }124 125 115 WebURL setUpCSSTestPage() 126 116 { 127 WebURL topFrameURL = GURL("http://www.test.com");128 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("css_test_page.html"), htmlMimeType());129 registerMockedURLLoad( GURL("http://www.test.com/link_styles.css"), WebString::fromUTF8("link_styles.css"), cssMimeType());130 registerMockedURLLoad( GURL("http://www.test.com/import_style_from_link.css"), WebString::fromUTF8("import_style_from_link.css"), cssMimeType());131 registerMockedURLLoad( GURL("http://www.test.com/import_styles.css"), WebString::fromUTF8("import_styles.css"), cssMimeType());132 registerMockedURLLoad( GURL("http://www.test.com/red_background.png"), WebString::fromUTF8("red_background.png"), pngMimeType());133 registerMockedURLLoad( GURL("http://www.test.com/orange_background.png"), WebString::fromUTF8("orange_background.png"), pngMimeType());134 registerMockedURLLoad( GURL("http://www.test.com/yellow_background.png"), WebString::fromUTF8("yellow_background.png"), pngMimeType());135 registerMockedURLLoad( GURL("http://www.test.com/green_background.png"), WebString::fromUTF8("green_background.png"), pngMimeType());136 registerMockedURLLoad( GURL("http://www.test.com/blue_background.png"), WebString::fromUTF8("blue_background.png"), pngMimeType());137 registerMockedURLLoad( GURL("http://www.test.com/purple_background.png"), WebString::fromUTF8("purple_background.png"), pngMimeType());138 registerMockedURLLoad( GURL("http://www.test.com/ul-dot.png"), WebString::fromUTF8("ul-dot.png"), pngMimeType());139 registerMockedURLLoad( GURL("http://www.test.com/ol-dot.png"), WebString::fromUTF8("ol-dot.png"), pngMimeType());117 WebURL topFrameURL = toKURL("http://www.test.com"); 118 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("css_test_page.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()); 119 registerMockedURLLoad(toKURL("http://www.test.com/link_styles.css"), WebString::fromUTF8("link_styles.css"), WebString::fromUTF8("pageserializer/"), cssMimeType()); 120 registerMockedURLLoad(toKURL("http://www.test.com/import_style_from_link.css"), WebString::fromUTF8("import_style_from_link.css"), WebString::fromUTF8("pageserializer/"), cssMimeType()); 121 registerMockedURLLoad(toKURL("http://www.test.com/import_styles.css"), WebString::fromUTF8("import_styles.css"), WebString::fromUTF8("pageserializer/"), cssMimeType()); 122 registerMockedURLLoad(toKURL("http://www.test.com/red_background.png"), WebString::fromUTF8("red_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 123 registerMockedURLLoad(toKURL("http://www.test.com/orange_background.png"), WebString::fromUTF8("orange_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 124 registerMockedURLLoad(toKURL("http://www.test.com/yellow_background.png"), WebString::fromUTF8("yellow_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 125 registerMockedURLLoad(toKURL("http://www.test.com/green_background.png"), WebString::fromUTF8("green_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 126 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"), WebString::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 127 registerMockedURLLoad(toKURL("http://www.test.com/purple_background.png"), WebString::fromUTF8("purple_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 128 registerMockedURLLoad(toKURL("http://www.test.com/ul-dot.png"), WebString::fromUTF8("ul-dot.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 129 registerMockedURLLoad(toKURL("http://www.test.com/ol-dot.png"), WebString::fromUTF8("ol-dot.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 140 130 return topFrameURL; 141 131 } 142 132 143 void loadURLInTopFrame(const GURL& url)133 void loadURLInTopFrame(const WebURL& url) 144 134 { 145 135 WebURLRequest urlRequest; 146 136 urlRequest.initialize(); 147 urlRequest.setURL( WebURL(url));137 urlRequest.setURL(url); 148 138 m_webView->mainFrame()->loadRequest(urlRequest); 149 139 // Make sure any pending request get served. … … 162 152 static bool resourceVectorContains(const WebVector<WebPageSerializer::Resource>& resources, const char* url, const char* mimeType) 163 153 { 164 WebURL webURL = WebURL( GURL(url));154 WebURL webURL = WebURL(toKURL(url)); 165 155 for (size_t i = 0; i < resources.size(); ++i) { 166 156 const WebPageSerializer::Resource& resource = resources[i]; … … 185 175 { 186 176 // Register the mocked frames. 187 WebURL topFrameURL = GURL("http://www.test.com");188 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("top_frame.html"), htmlMimeType());189 registerMockedURLLoad( GURL("http://www.test.com/iframe.html"), WebString::fromUTF8("iframe.html"), htmlMimeType());190 registerMockedURLLoad( GURL("http://www.test.com/iframe2.html"), WebString::fromUTF8("iframe2.html"), htmlMimeType());191 registerMockedURLLoad( GURL("http://www.test.com/red_background.png"), WebString::fromUTF8("red_background.png"), pngMimeType());192 registerMockedURLLoad( GURL("http://www.test.com/green_background.png"), WebString::fromUTF8("green_background.png"), pngMimeType());193 registerMockedURLLoad( GURL("http://www.test.com/blue_background.png"), WebString::fromUTF8("blue_background.png"), pngMimeType());177 WebURL topFrameURL = toKURL("http://www.test.com"); 178 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("top_frame.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()); 179 registerMockedURLLoad(toKURL("http://www.test.com/iframe.html"), WebString::fromUTF8("iframe.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()); 180 registerMockedURLLoad(toKURL("http://www.test.com/iframe2.html"), WebString::fromUTF8("iframe2.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()); 181 registerMockedURLLoad(toKURL("http://www.test.com/red_background.png"), WebString::fromUTF8("red_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 182 registerMockedURLLoad(toKURL("http://www.test.com/green_background.png"), WebString::fromUTF8("green_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 183 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"), WebString::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 194 184 195 185 loadURLInTopFrame(topFrameURL); … … 201 191 // The first resource should be the main-frame. 202 192 const WebPageSerializer::Resource& resource = resources[0]; 203 EXPECT_TRUE(resource.url == GURL("http://www.test.com"));193 EXPECT_TRUE(resource.url == WebURL(toKURL("http://www.test.com"))); 204 194 EXPECT_EQ(0, resource.mimeType.compare(WebCString("text/html"))); 205 195 EXPECT_FALSE(resource.data.isEmpty()); … … 228 218 // The first resource should be the main-frame. 229 219 const WebPageSerializer::Resource& resource = resources[0]; 230 EXPECT_TRUE(resource.url == GURL("http://www.test.com"));220 EXPECT_TRUE(resource.url == WebURL(toKURL("http://www.test.com"))); 231 221 EXPECT_EQ(0, resource.mimeType.compare(WebCString("text/html"))); 232 222 EXPECT_FALSE(resource.data.isEmpty()); … … 250 240 { 251 241 // Register the mocked frame and load it. 252 WebURL topFrameURL = GURL("http://www.test.com");253 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("blank_frames.html"), htmlMimeType());254 registerMockedURLLoad( GURL("http://www.test.com/red_background.png"), WebString::fromUTF8("red_background.png"), pngMimeType());255 registerMockedURLLoad( GURL("http://www.test.com/orange_background.png"), WebString::fromUTF8("orange_background.png"), pngMimeType());256 registerMockedURLLoad( GURL("http://www.test.com/blue_background.png"), WebString::fromUTF8("blue_background.png"), pngMimeType());242 WebURL topFrameURL = toKURL("http://www.test.com"); 243 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("blank_frames.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()); 244 registerMockedURLLoad(toKURL("http://www.test.com/red_background.png"), WebString::fromUTF8("red_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 245 registerMockedURLLoad(toKURL("http://www.test.com/orange_background.png"), WebString::fromUTF8("orange_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 246 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"), WebString::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 257 247 258 248 loadURLInTopFrame(topFrameURL); … … 264 254 // The first resource should be the main-frame. 265 255 const WebPageSerializer::Resource& resource = resources[0]; 266 EXPECT_TRUE(resource.url == GURL("http://www.test.com"));256 EXPECT_TRUE(resource.url == WebURL(toKURL("http://www.test.com"))); 267 257 EXPECT_EQ(0, resource.mimeType.compare(WebCString("text/html"))); 268 258 EXPECT_FALSE(resource.data.isEmpty()); … … 280 270 TEST_F(WebPageNewSerializeTest, SerializeXMLHasRightDeclaration) 281 271 { 282 WebURL topFrameURL = GURL("http://www.test.com/simple.xhtml");283 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("simple.xhtml"), xhtmlMimeType());272 WebURL topFrameURL = toKURL("http://www.test.com/simple.xhtml"); 273 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("simple.xhtml"), WebString::fromUTF8("pageserializer/"), xhtmlMimeType()); 284 274 285 275 loadURLInTopFrame(topFrameURL); … … 291 281 // We expect only one resource, the XML. 292 282 ASSERT_EQ(1U, resources.size()); 293 std::string xml = resources[0].data;283 std::string xml = std::string(resources[0].data.data()); 294 284 295 285 // We should have one and only one instance of the XML declaration. … … 311 301 312 302 // Read the MHTML data line per line and do some pseudo-parsing to make sure the right encoding is used for the different sections. 313 LineReader lineReader( mhtmlData);303 LineReader lineReader(std::string(mhtmlData.data())); 314 304 int sectionCheckedCount = 0; 315 305 const char* expectedEncoding = 0; -
trunk/Source/WebKit/chromium/tests/WebPageSerializerTest.cpp
r121408 r121463 32 32 #include "WebPageSerializer.h" 33 33 34 #include "URLTestHelpers.h" 34 35 #include "WebFrame.h" 35 36 #include "WebFrameClient.h" … … 40 41 #include "WebView.h" 41 42 42 #include <googleurl/src/gurl.h>43 43 #include <gtest/gtest.h> 44 44 #include <webkit/support/webkit_support.h> 45 45 46 46 using namespace WebKit; 47 using WebKit::URLTestHelpers::toKURL; 47 48 48 49 namespace { … … 74 75 } 75 76 76 void registerMockedURLLoad(const WebURL& url, const WebString& fileName)77 void registerMockedURLLoad(const std::string& url, const WebString& fileName) 77 78 { 78 WebURLResponse response; 79 response.initialize(); 80 response.setMIMEType("text/html"); 81 std::string filePath = webkit_support::GetWebKitRootDir().utf8(); 82 filePath.append("/Source/WebKit/chromium/tests/data/pageserialization/"); 83 filePath.append(fileName.utf8()); 84 webkit_support::RegisterMockedURL(url, response, WebString::fromUTF8(filePath)); 79 URLTestHelpers::registerMockedURLLoad(toKURL(url), fileName, WebString::fromUTF8("pageserialization/"), WebString::fromUTF8("text/html")); 85 80 } 86 81 87 void loadURLInTopFrame(const GURL& url)82 void loadURLInTopFrame(const WebURL& url) 88 83 { 89 84 WebURLRequest urlRequest; 90 85 urlRequest.initialize(); 91 urlRequest.setURL( WebURL(url));86 urlRequest.setURL(url); 92 87 m_webView->mainFrame()->loadRequest(urlRequest); 93 88 // Make sure any pending request get served. … … 97 92 static bool webVectorContains(const WebVector<WebURL>& vector, const char* url) 98 93 { 99 return vector.contains(WebURL( GURL(url)));94 return vector.contains(WebURL(toKURL(std::string(url)))); 100 95 } 101 96 … … 117 112 { 118 113 // Register the mocked frame and load it. 119 WebURL topFrameURL = GURL("http://www.test.com");120 registerMockedURLLoad( topFrameURL, WebString::fromUTF8("simple_page.html"));114 WebURL topFrameURL = toKURL("http://www.test.com"); 115 registerMockedURLLoad("http://www.test.com", WebString::fromUTF8("simple_page.html")); 121 116 loadURLInTopFrame(topFrameURL); 122 117 … … 151 146 { 152 147 // Register the mocked frames. 153 WebURL topFrameURL = GURL("http://www.test.com");154 registerMockedURLLoad( topFrameURL, WebString::fromUTF8("top_frame.html"));155 registerMockedURLLoad( GURL("http://www.test.com/simple_iframe.html"),148 WebURL topFrameURL = toKURL("http://www.test.com"); 149 registerMockedURLLoad("http://www.test.com", WebString::fromUTF8("top_frame.html")); 150 registerMockedURLLoad("http://www.test.com/simple_iframe.html", 156 151 WebString::fromUTF8("simple_iframe.html")); 157 registerMockedURLLoad( GURL("http://www.test.com/object_iframe.html"),152 registerMockedURLLoad("http://www.test.com/object_iframe.html", 158 153 WebString::fromUTF8("object_iframe.html")); 159 registerMockedURLLoad( GURL("http://www.test.com/embed_iframe.html"),154 registerMockedURLLoad("http://www.test.com/embed_iframe.html", 160 155 WebString::fromUTF8("embed_iframe.html")); 161 156 // If we don't register a mocked resource for awesome.png, it causes the 162 157 // document loader of the iframe that has it as its src to assert on close, 163 158 // not sure why. 164 registerMockedURLLoad( GURL("http://www.test.com/awesome.png"),159 registerMockedURLLoad("http://www.test.com/awesome.png", 165 160 WebString::fromUTF8("awesome.png")); 166 161 -
trunk/Source/WebKit/chromium/tests/WebViewTest.cpp
r121451 r121463 36 36 #include "FrameView.h" 37 37 #include "HTMLDocument.h" 38 #include "URLTestHelpers.h" 38 39 #include "WebDocument.h" 39 40 #include "WebFrame.h" … … 43 44 #include "WebViewClient.h" 44 45 #include "WebViewImpl.h" 45 #include <googleurl/src/gurl.h>46 46 #include <gtest/gtest.h> 47 47 #include <webkit/support/webkit_support.h> 48 48 49 49 using namespace WebKit; 50 using WebKit::URLTestHelpers::toKURL; 50 51 51 52 namespace { … … 118 119 TEST_F(WebViewTest, FocusIsInactive) 119 120 { 120 FrameTestHelpers::registerMockedURLLoad(m_baseURL, "visible_iframe.html");121 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), "visible_iframe.html"); 121 122 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "visible_iframe.html"); 122 123 … … 146 147 TEST_F(WebViewTest, ActiveState) 147 148 { 148 FrameTestHelpers::registerMockedURLLoad(m_baseURL, "visible_iframe.html");149 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), "visible_iframe.html"); 149 150 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "visible_iframe.html"); 150 151 … … 170 171 AutoResizeWebViewClient client; 171 172 std::string url = m_baseURL + "specify_size.html?" + pageWidth + ":" + pageHeight; 172 FrameTestHelpers::registerMockedURLLoad(GURL(url), "specify_size.html");173 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); 173 174 WebView* webView = FrameTestHelpers::createWebViewAndLoad(url, true, 0, &client); 174 175 client.testData().setWebView(webView); … … 269 270 void WebViewTest::testTextInputType(WebTextInputType expectedType, const std::string& htmlFile) 270 271 { 271 FrameTestHelpers::registerMockedURLLoad(m_baseURL, htmlFile);272 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(htmlFile.c_str())); 272 273 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + htmlFile); 273 274 webView->setInitialFocus(false); … … 309 310 TEST_F(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) 310 311 { 311 FrameTestHelpers::registerMockedURLLoad(m_baseURL, "input_field_populated.html");312 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html")); 312 313 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_populated.html"); 313 314 webView->setInitialFocus(false); … … 323 324 webView->close(); 324 325 325 FrameTestHelpers::registerMockedURLLoad(m_baseURL, "content_editable_populated.html");326 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("content_editable_populated.html")); 326 327 webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "content_editable_populated.html"); 327 328 webView->setInitialFocus(false);
Note: See TracChangeset
for help on using the changeset viewer.