| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 #include "platform/scroll/ScrollbarTheme.h" | 86 #include "platform/scroll/ScrollbarTheme.h" |
| 87 #include "platform/testing/URLTestHelpers.h" | 87 #include "platform/testing/URLTestHelpers.h" |
| 88 #include "platform/testing/UnitTestHelpers.h" | 88 #include "platform/testing/UnitTestHelpers.h" |
| 89 #include "platform/weborigin/SchemeRegistry.h" | 89 #include "platform/weborigin/SchemeRegistry.h" |
| 90 #include "platform/weborigin/SecurityOrigin.h" | 90 #include "platform/weborigin/SecurityOrigin.h" |
| 91 #include "public/platform/Platform.h" | 91 #include "public/platform/Platform.h" |
| 92 #include "public/platform/WebFloatRect.h" | 92 #include "public/platform/WebFloatRect.h" |
| 93 #include "public/platform/WebSecurityOrigin.h" | 93 #include "public/platform/WebSecurityOrigin.h" |
| 94 #include "public/platform/WebThread.h" | 94 #include "public/platform/WebThread.h" |
| 95 #include "public/platform/WebURL.h" | 95 #include "public/platform/WebURL.h" |
| 96 #include "public/platform/WebURLLoaderMockFactory.h" |
| 96 #include "public/platform/WebURLResponse.h" | 97 #include "public/platform/WebURLResponse.h" |
| 97 #include "public/platform/WebUnitTestSupport.h" | |
| 98 #include "public/web/WebCache.h" | 98 #include "public/web/WebCache.h" |
| 99 #include "public/web/WebConsoleMessage.h" | 99 #include "public/web/WebConsoleMessage.h" |
| 100 #include "public/web/WebDataSource.h" | 100 #include "public/web/WebDataSource.h" |
| 101 #include "public/web/WebDeviceEmulationParams.h" | 101 #include "public/web/WebDeviceEmulationParams.h" |
| 102 #include "public/web/WebDocument.h" | 102 #include "public/web/WebDocument.h" |
| 103 #include "public/web/WebFindOptions.h" | 103 #include "public/web/WebFindOptions.h" |
| 104 #include "public/web/WebFormElement.h" | 104 #include "public/web/WebFormElement.h" |
| 105 #include "public/web/WebFrameClient.h" | 105 #include "public/web/WebFrameClient.h" |
| 106 #include "public/web/WebFrameContentDumper.h" | 106 #include "public/web/WebFrameContentDumper.h" |
| 107 #include "public/web/WebFrameWidget.h" | 107 #include "public/web/WebFrameWidget.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 protected: | 177 protected: |
| 178 WebFrameTest() | 178 WebFrameTest() |
| 179 : m_baseURL("http://internal.test/") | 179 : m_baseURL("http://internal.test/") |
| 180 , m_notBaseURL("http://external.test/") | 180 , m_notBaseURL("http://external.test/") |
| 181 , m_chromeURL("chrome://") | 181 , m_chromeURL("chrome://") |
| 182 { | 182 { |
| 183 } | 183 } |
| 184 | 184 |
| 185 ~WebFrameTest() override | 185 ~WebFrameTest() override |
| 186 { | 186 { |
| 187 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 187 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
| 188 WebCache::clear(); |
| 188 } | 189 } |
| 189 | 190 |
| 190 void registerMockedHttpURLLoad(const std::string& fileName) | 191 void registerMockedHttpURLLoad(const std::string& fileName) |
| 191 { | 192 { |
| 192 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); | 193 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); |
| 193 } | 194 } |
| 194 | 195 |
| 195 void registerMockedChromeURLLoad(const std::string& fileName) | 196 void registerMockedChromeURLLoad(const std::string& fileName) |
| 196 { | 197 { |
| 197 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); | 198 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); |
| (...skipping 4915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5113 error.domain = "WebFrameTest"; | 5114 error.domain = "WebFrameTest"; |
| 5114 std::string errorURL = "http://0.0.0.0"; | 5115 std::string errorURL = "http://0.0.0.0"; |
| 5115 WebURLResponse response; | 5116 WebURLResponse response; |
| 5116 response.initialize(); | 5117 response.initialize(); |
| 5117 response.setURL(URLTestHelpers::toKURL(errorURL)); | 5118 response.setURL(URLTestHelpers::toKURL(errorURL)); |
| 5118 response.setMIMEType("text/html"); | 5119 response.setMIMEType("text/html"); |
| 5119 response.setHTTPStatusCode(500); | 5120 response.setHTTPStatusCode(500); |
| 5120 WebHistoryItem errorHistoryItem; | 5121 WebHistoryItem errorHistoryItem; |
| 5121 errorHistoryItem.initialize(); | 5122 errorHistoryItem.initialize(); |
| 5122 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL
.length())); | 5123 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL
.length())); |
| 5123 Platform::current()->unitTestSupport()->registerMockedErrorURL(URLTestHelper
s::toKURL(errorURL), response, error); | 5124 Platform::current()->getURLLoaderMockFactory()->registerErrorURL(URLTestHelp
ers::toKURL(errorURL), response, error); |
| 5124 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere
ntDocumentLoad, WebURLRequest::UseProtocolCachePolicy); | 5125 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere
ntDocumentLoad, WebURLRequest::UseProtocolCachePolicy); |
| 5125 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV
iew(), std::numeric_limits<size_t>::max()); | 5126 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV
iew(), std::numeric_limits<size_t>::max()); |
| 5126 EXPECT_EQ("This should appear", text.utf8()); | 5127 EXPECT_EQ("This should appear", text.utf8()); |
| 5127 EXPECT_TRUE(webFrameClient.commitCalled()); | 5128 EXPECT_TRUE(webFrameClient.commitCalled()); |
| 5128 } | 5129 } |
| 5129 | 5130 |
| 5130 class TestWillInsertBodyWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { | 5131 class TestWillInsertBodyWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { |
| 5131 public: | 5132 public: |
| 5132 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) | 5133 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) |
| 5133 { | 5134 { |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5756 filePath.append("/Source/web/tests/data/first_party.html"); | 5757 filePath.append("/Source/web/tests/data/first_party.html"); |
| 5757 | 5758 |
| 5758 WebURL testURL(toKURL("http://internal.test/first_party_redirect.html")); | 5759 WebURL testURL(toKURL("http://internal.test/first_party_redirect.html")); |
| 5759 char redirect[] = "http://internal.test/first_party.html"; | 5760 char redirect[] = "http://internal.test/first_party.html"; |
| 5760 WebURL redirectURL(toKURL(redirect)); | 5761 WebURL redirectURL(toKURL(redirect)); |
| 5761 WebURLResponse redirectResponse; | 5762 WebURLResponse redirectResponse; |
| 5762 redirectResponse.initialize(); | 5763 redirectResponse.initialize(); |
| 5763 redirectResponse.setMIMEType("text/html"); | 5764 redirectResponse.setMIMEType("text/html"); |
| 5764 redirectResponse.setHTTPStatusCode(302); | 5765 redirectResponse.setHTTPStatusCode(302); |
| 5765 redirectResponse.setHTTPHeaderField("Location", redirect); | 5766 redirectResponse.setHTTPHeaderField("Location", redirect); |
| 5766 Platform::current()->unitTestSupport()->registerMockedURL(testURL, redirectR
esponse, filePath); | 5767 Platform::current()->getURLLoaderMockFactory()->registerURL(testURL, redirec
tResponse, filePath); |
| 5767 | 5768 |
| 5768 WebURLResponse finalResponse; | 5769 WebURLResponse finalResponse; |
| 5769 finalResponse.initialize(); | 5770 finalResponse.initialize(); |
| 5770 finalResponse.setMIMEType("text/html"); | 5771 finalResponse.setMIMEType("text/html"); |
| 5771 Platform::current()->unitTestSupport()->registerMockedURL(redirectURL, final
Response, filePath); | 5772 Platform::current()->getURLLoaderMockFactory()->registerURL(redirectURL, fin
alResponse, filePath); |
| 5772 | 5773 |
| 5773 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5774 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 5774 webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", tru
e); | 5775 webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", tru
e); |
| 5775 EXPECT_TRUE(webViewHelper.webView()->mainFrame()->document().firstPartyForCo
okies() == redirectURL); | 5776 EXPECT_TRUE(webViewHelper.webView()->mainFrame()->document().firstPartyForCo
okies() == redirectURL); |
| 5776 } | 5777 } |
| 5777 | 5778 |
| 5778 class TestNavigationPolicyWebFrameClient : public FrameTestHelpers::TestWebFrame
Client { | 5779 class TestNavigationPolicyWebFrameClient : public FrameTestHelpers::TestWebFrame
Client { |
| 5779 public: | 5780 public: |
| 5780 | 5781 |
| 5781 void didNavigateWithinPage(WebLocalFrame*, const WebHistoryItem&, WebHistory
CommitType) override | 5782 void didNavigateWithinPage(WebLocalFrame*, const WebHistoryItem&, WebHistory
CommitType) override |
| (...skipping 2786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8568 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); | 8569 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); |
| 8569 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 8570 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 8570 mainFrame->executeScript(WebScriptSource("hello = 'world';")); | 8571 mainFrame->executeScript(WebScriptSource("hello = 'world';")); |
| 8571 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); | 8572 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); |
| 8572 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri
ptSource("hello")); | 8573 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri
ptSource("hello")); |
| 8573 ASSERT_TRUE(result->IsString()); | 8574 ASSERT_TRUE(result->IsString()); |
| 8574 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC
ontext()).ToLocalChecked())); | 8575 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC
ontext()).ToLocalChecked())); |
| 8575 } | 8576 } |
| 8576 | 8577 |
| 8577 } // namespace blink | 8578 } // namespace blink |
| OLD | NEW |