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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 : m_baseURL("http://internal.test/"), | 193 : m_baseURL("http://internal.test/"), |
194 m_notBaseURL("http://external.test/"), | 194 m_notBaseURL("http://external.test/"), |
195 m_chromeURL("chrome://") {} | 195 m_chromeURL("chrome://") {} |
196 | 196 |
197 ~WebFrameTest() override { | 197 ~WebFrameTest() override { |
198 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 198 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
199 WebCache::clear(); | 199 WebCache::clear(); |
200 } | 200 } |
201 | 201 |
202 void registerMockedHttpURLLoad(const std::string& fileName) { | 202 void registerMockedHttpURLLoad(const std::string& fileName) { |
203 URLTestHelpers::registerMockedURLFromBaseURL( | 203 registerMockedURLLoadFromBase(m_baseURL, fileName); |
204 WebString::fromUTF8(m_baseURL.c_str()), | |
205 WebString::fromUTF8(fileName.c_str())); | |
206 } | 204 } |
207 | 205 |
208 void registerMockedChromeURLLoad(const std::string& fileName) { | 206 void registerMockedChromeURLLoad(const std::string& fileName) { |
209 URLTestHelpers::registerMockedURLFromBaseURL( | 207 registerMockedURLLoadFromBase(m_chromeURL, fileName); |
210 WebString::fromUTF8(m_chromeURL.c_str()), | 208 } |
211 WebString::fromUTF8(fileName.c_str())); | 209 |
210 void registerMockedURLLoadFromBase(const std::string& baseURL, | |
211 const std::string& fileName) { | |
212 URLTestHelpers::registerMockedURLLoadFromBase( | |
213 WebString::fromUTF8(m_baseURL), testing::webTestDataPath(), | |
Takashi Toyoshima
2017/01/26 11:36:02
Oops, just there is a bug, and I can repro it on l
| |
214 WebString::fromUTF8(fileName)); | |
212 } | 215 } |
213 | 216 |
214 void registerMockedHttpURLLoadWithCSP(const std::string& fileName, | 217 void registerMockedHttpURLLoadWithCSP(const std::string& fileName, |
215 const std::string& csp, | 218 const std::string& csp, |
216 bool reportOnly = false) { | 219 bool reportOnly = false) { |
217 WebURLResponse response; | 220 WebURLResponse response; |
218 response.setMIMEType("text/html"); | 221 response.setMIMEType("text/html"); |
219 response.addHTTPHeaderField( | 222 response.addHTTPHeaderField( |
220 reportOnly ? WebString("Content-Security-Policy-Report-Only") | 223 reportOnly ? WebString("Content-Security-Policy-Report-Only") |
221 : WebString("Content-Security-Policy"), | 224 : WebString("Content-Security-Policy"), |
222 WebString::fromUTF8(csp)); | 225 WebString::fromUTF8(csp)); |
223 std::string fullString = m_baseURL + fileName; | 226 std::string fullString = m_baseURL + fileName; |
224 URLTestHelpers::registerMockedURLLoadWithCustomResponse( | 227 URLTestHelpers::registerMockedURLLoadWithCustomResponse( |
225 toKURL(fullString.c_str()), WebString::fromUTF8(fileName.c_str()), | 228 toKURL(fullString), testing::webTestDataPath(fileName), response); |
226 WebString::fromUTF8(""), response); | |
227 } | 229 } |
228 | 230 |
229 void registerMockedHttpURLLoadWithMimeType(const std::string& fileName, | 231 void registerMockedHttpURLLoadWithMimeType(const std::string& fileName, |
230 const std::string& mimeType) { | 232 const std::string& mimeType) { |
231 URLTestHelpers::registerMockedURLFromBaseURL( | 233 URLTestHelpers::registerMockedURLLoadFromBase( |
232 WebString::fromUTF8(m_baseURL.c_str()), | 234 WebString::fromUTF8(m_baseURL), testing::webTestDataPath(), |
233 WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(mimeType)); | 235 WebString::fromUTF8(fileName), WebString::fromUTF8(mimeType)); |
234 } | 236 } |
235 | 237 |
236 void applyViewportStyleOverride( | 238 void applyViewportStyleOverride( |
237 FrameTestHelpers::WebViewHelper* webViewHelper) { | 239 FrameTestHelpers::WebViewHelper* webViewHelper) { |
238 webViewHelper->webView()->settings()->setViewportStyle( | 240 webViewHelper->webView()->settings()->setViewportStyle( |
239 WebViewportStyle::Mobile); | 241 WebViewportStyle::Mobile); |
240 } | 242 } |
241 | 243 |
242 static void configureCompositingWebView(WebSettings* settings) { | 244 static void configureCompositingWebView(WebSettings* settings) { |
243 settings->setAcceleratedCompositingEnabled(true); | 245 settings->setAcceleratedCompositingEnabled(true); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
618 // javascript. | 620 // javascript. |
619 std::string content = | 621 std::string content = |
620 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) | 622 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) |
621 .utf8(); | 623 .utf8(); |
622 EXPECT_EQ(std::string::npos, content.find("Clobbered")); | 624 EXPECT_EQ(std::string::npos, content.find("Clobbered")); |
623 } | 625 } |
624 | 626 |
625 TEST_P(ParameterizedWebFrameTest, LocationSetHostWithMissingPort) { | 627 TEST_P(ParameterizedWebFrameTest, LocationSetHostWithMissingPort) { |
626 std::string fileName = "print-location-href.html"; | 628 std::string fileName = "print-location-href.html"; |
627 registerMockedHttpURLLoad(fileName); | 629 registerMockedHttpURLLoad(fileName); |
628 URLTestHelpers::registerMockedURLLoad( | 630 registerMockedURLLoadFromBase("http://internal.test:0/", fileName); |
629 toKURL("http://internal.test:0/" + fileName), | |
630 WebString::fromUTF8(fileName)); | |
631 | 631 |
632 FrameTestHelpers::WebViewHelper webViewHelper; | 632 FrameTestHelpers::WebViewHelper webViewHelper; |
633 | 633 |
634 /// Pass true to enable JavaScript. | 634 /// Pass true to enable JavaScript. |
635 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); | 635 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); |
636 | 636 |
637 // Setting host to "hostname:" should be treated as "hostname:0". | 637 // Setting host to "hostname:" should be treated as "hostname:0". |
638 FrameTestHelpers::loadFrame( | 638 FrameTestHelpers::loadFrame( |
639 webViewHelper.webView()->mainFrame(), | 639 webViewHelper.webView()->mainFrame(), |
640 "javascript:location.host = 'internal.test:'; void 0;"); | 640 "javascript:location.host = 'internal.test:'; void 0;"); |
641 | 641 |
642 FrameTestHelpers::loadFrame( | 642 FrameTestHelpers::loadFrame( |
643 webViewHelper.webView()->mainFrame(), | 643 webViewHelper.webView()->mainFrame(), |
644 "javascript:document.body.textContent = location.href; void 0;"); | 644 "javascript:document.body.textContent = location.href; void 0;"); |
645 | 645 |
646 std::string content = | 646 std::string content = |
647 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) | 647 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) |
648 .utf8(); | 648 .utf8(); |
649 EXPECT_EQ("http://internal.test:0/" + fileName, content); | 649 EXPECT_EQ("http://internal.test:0/" + fileName, content); |
650 } | 650 } |
651 | 651 |
652 TEST_P(ParameterizedWebFrameTest, LocationSetEmptyPort) { | 652 TEST_P(ParameterizedWebFrameTest, LocationSetEmptyPort) { |
653 std::string fileName = "print-location-href.html"; | 653 std::string fileName = "print-location-href.html"; |
654 registerMockedHttpURLLoad(fileName); | 654 registerMockedHttpURLLoad(fileName); |
655 URLTestHelpers::registerMockedURLLoad( | 655 registerMockedURLLoadFromBase("http://internal.test:0/", fileName); |
656 toKURL("http://internal.test:0/" + fileName), | |
657 WebString::fromUTF8(fileName)); | |
658 | 656 |
659 FrameTestHelpers::WebViewHelper webViewHelper; | 657 FrameTestHelpers::WebViewHelper webViewHelper; |
660 | 658 |
661 /// Pass true to enable JavaScript. | 659 /// Pass true to enable JavaScript. |
662 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); | 660 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); |
663 | 661 |
664 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), | 662 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), |
665 "javascript:location.port = ''; void 0;"); | 663 "javascript:location.port = ''; void 0;"); |
666 | 664 |
667 FrameTestHelpers::loadFrame( | 665 FrameTestHelpers::loadFrame( |
(...skipping 6149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6817 client.reset(); | 6815 client.reset(); |
6818 | 6816 |
6819 // Programmatic scroll to same offset. No scroll event should be generated. | 6817 // Programmatic scroll to same offset. No scroll event should be generated. |
6820 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); | 6818 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); |
6821 EXPECT_FALSE(client.wasFrameScrolled()); | 6819 EXPECT_FALSE(client.wasFrameScrolled()); |
6822 EXPECT_FALSE(initialScrollState.wasScrolledByUser); | 6820 EXPECT_FALSE(initialScrollState.wasScrolledByUser); |
6823 client.reset(); | 6821 client.reset(); |
6824 } | 6822 } |
6825 | 6823 |
6826 TEST_P(ParameterizedWebFrameTest, FirstPartyForCookiesForRedirect) { | 6824 TEST_P(ParameterizedWebFrameTest, FirstPartyForCookiesForRedirect) { |
6827 String filePath = testing::blinkRootDir(); | 6825 String filePath = testing::webTestDataPath("first_party.html"); |
6828 filePath.append("/Source/web/tests/data/first_party.html"); | |
6829 | 6826 |
6830 WebURL testURL(toKURL("http://internal.test/first_party_redirect.html")); | 6827 WebURL testURL(toKURL("http://internal.test/first_party_redirect.html")); |
6831 char redirect[] = "http://internal.test/first_party.html"; | 6828 char redirect[] = "http://internal.test/first_party.html"; |
6832 WebURL redirectURL(toKURL(redirect)); | 6829 WebURL redirectURL(toKURL(redirect)); |
6833 WebURLResponse redirectResponse; | 6830 WebURLResponse redirectResponse; |
6834 redirectResponse.setMIMEType("text/html"); | 6831 redirectResponse.setMIMEType("text/html"); |
6835 redirectResponse.setHTTPStatusCode(302); | 6832 redirectResponse.setHTTPStatusCode(302); |
6836 redirectResponse.setHTTPHeaderField("Location", redirect); | 6833 redirectResponse.setHTTPHeaderField("Location", redirect); |
6837 Platform::current()->getURLLoaderMockFactory()->registerURL( | 6834 Platform::current()->getURLLoaderMockFactory()->registerURL( |
6838 testURL, redirectResponse, filePath); | 6835 testURL, redirectResponse, filePath); |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8241 Document* document = | 8238 Document* document = |
8242 webViewHelper.webView()->mainFrameImpl()->frame()->document(); | 8239 webViewHelper.webView()->mainFrameImpl()->frame()->document(); |
8243 | 8240 |
8244 Resource* resource = | 8241 Resource* resource = |
8245 fetchManifest(document, toKURL(m_baseURL + "link-manifest-fetch.json")); | 8242 fetchManifest(document, toKURL(m_baseURL + "link-manifest-fetch.json")); |
8246 | 8243 |
8247 EXPECT_TRUE(resource->isLoaded()); | 8244 EXPECT_TRUE(resource->isLoaded()); |
8248 } | 8245 } |
8249 | 8246 |
8250 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchAllow) { | 8247 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchAllow) { |
8251 URLTestHelpers::registerMockedURLLoad( | 8248 registerMockedURLLoadFromBase(m_notBaseURL, "link-manifest-fetch.json"); |
8252 toKURL(m_notBaseURL + "link-manifest-fetch.json"), | |
8253 "link-manifest-fetch.json"); | |
8254 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src *"); | 8249 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src *"); |
8255 | 8250 |
8256 FrameTestHelpers::WebViewHelper webViewHelper; | 8251 FrameTestHelpers::WebViewHelper webViewHelper; |
8257 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 8252 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
8258 Document* document = | 8253 Document* document = |
8259 webViewHelper.webView()->mainFrameImpl()->frame()->document(); | 8254 webViewHelper.webView()->mainFrameImpl()->frame()->document(); |
8260 | 8255 |
8261 Resource* resource = fetchManifest( | 8256 Resource* resource = fetchManifest( |
8262 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); | 8257 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); |
8263 | 8258 |
8264 EXPECT_TRUE(resource->isLoaded()); | 8259 EXPECT_TRUE(resource->isLoaded()); |
8265 } | 8260 } |
8266 | 8261 |
8267 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelf) { | 8262 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelf) { |
8268 URLTestHelpers::registerMockedURLLoad( | 8263 registerMockedURLLoadFromBase(m_notBaseURL, "link-manifest-fetch.json"); |
8269 toKURL(m_notBaseURL + "link-manifest-fetch.json"), | |
8270 "link-manifest-fetch.json"); | |
8271 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'"); | 8264 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'"); |
8272 | 8265 |
8273 FrameTestHelpers::WebViewHelper webViewHelper; | 8266 FrameTestHelpers::WebViewHelper webViewHelper; |
8274 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 8267 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
8275 Document* document = | 8268 Document* document = |
8276 webViewHelper.webView()->mainFrameImpl()->frame()->document(); | 8269 webViewHelper.webView()->mainFrameImpl()->frame()->document(); |
8277 | 8270 |
8278 Resource* resource = fetchManifest( | 8271 Resource* resource = fetchManifest( |
8279 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); | 8272 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); |
8280 | 8273 |
8281 // Fetching resource wasn't allowed. | 8274 // Fetching resource wasn't allowed. |
8282 ASSERT_TRUE(resource); | 8275 ASSERT_TRUE(resource); |
8283 EXPECT_TRUE(resource->errorOccurred()); | 8276 EXPECT_TRUE(resource->errorOccurred()); |
8284 EXPECT_TRUE(resource->resourceError().isAccessCheck()); | 8277 EXPECT_TRUE(resource->resourceError().isAccessCheck()); |
8285 } | 8278 } |
8286 | 8279 |
8287 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelfReportOnly) { | 8280 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelfReportOnly) { |
8288 URLTestHelpers::registerMockedURLLoad( | 8281 registerMockedURLLoadFromBase(m_notBaseURL, "link-manifest-fetch.json"); |
8289 toKURL(m_notBaseURL + "link-manifest-fetch.json"), | |
8290 "link-manifest-fetch.json"); | |
8291 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'", | 8282 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'", |
8292 /* report only */ true); | 8283 /* report only */ true); |
8293 | 8284 |
8294 FrameTestHelpers::WebViewHelper webViewHelper; | 8285 FrameTestHelpers::WebViewHelper webViewHelper; |
8295 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 8286 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
8296 Document* document = | 8287 Document* document = |
8297 webViewHelper.webView()->mainFrameImpl()->frame()->document(); | 8288 webViewHelper.webView()->mainFrameImpl()->frame()->document(); |
8298 | 8289 |
8299 Resource* resource = fetchManifest( | 8290 Resource* resource = fetchManifest( |
8300 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); | 8291 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); |
(...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10275 // Local methods | 10266 // Local methods |
10276 const WebString& result() const { return m_dataURL; } | 10267 const WebString& result() const { return m_dataURL; } |
10277 void reset() { m_dataURL = WebString(); } | 10268 void reset() { m_dataURL = WebString(); } |
10278 | 10269 |
10279 private: | 10270 private: |
10280 WebString m_dataURL; | 10271 WebString m_dataURL; |
10281 }; | 10272 }; |
10282 | 10273 |
10283 TEST_F(WebFrameTest, SaveImageAt) { | 10274 TEST_F(WebFrameTest, SaveImageAt) { |
10284 std::string url = m_baseURL + "image-with-data-url.html"; | 10275 std::string url = m_baseURL + "image-with-data-url.html"; |
10285 URLTestHelpers::registerMockedURLLoad(toKURL(url), | 10276 registerMockedURLLoadFromBase(m_baseURL, "image-with-data-url.html"); |
10286 "image-with-data-url.html"); | 10277 URLTestHelpers::registerMockedURLLoad( |
10287 URLTestHelpers::registerMockedURLLoad(toKURL("http://test"), "white-1x1.png"); | 10278 toKURL("http://test"), testing::webTestDataPath("white-1x1.png")); |
10288 | 10279 |
10289 FrameTestHelpers::WebViewHelper helper; | 10280 FrameTestHelpers::WebViewHelper helper; |
10290 SaveImageFromDataURLWebFrameClient client; | 10281 SaveImageFromDataURLWebFrameClient client; |
10291 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); | 10282 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); |
10292 webView->resize(WebSize(400, 400)); | 10283 webView->resize(WebSize(400, 400)); |
10293 webView->updateAllLifecyclePhases(); | 10284 webView->updateAllLifecyclePhases(); |
10294 | 10285 |
10295 WebLocalFrame* localFrame = webView->mainFrameImpl(); | 10286 WebLocalFrame* localFrame = webView->mainFrameImpl(); |
10296 | 10287 |
10297 client.reset(); | 10288 client.reset(); |
(...skipping 16 matching lines...) Expand all Loading... | |
10314 WebString::fromUTF8("data:image/gif;base64" | 10305 WebString::fromUTF8("data:image/gif;base64" |
10315 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), | 10306 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), |
10316 client.result()); | 10307 client.result()); |
10317 | 10308 |
10318 // Explicitly reset to break dependency on locally scoped client. | 10309 // Explicitly reset to break dependency on locally scoped client. |
10319 helper.reset(); | 10310 helper.reset(); |
10320 } | 10311 } |
10321 | 10312 |
10322 TEST_F(WebFrameTest, SaveImageWithImageMap) { | 10313 TEST_F(WebFrameTest, SaveImageWithImageMap) { |
10323 std::string url = m_baseURL + "image-map.html"; | 10314 std::string url = m_baseURL + "image-map.html"; |
10324 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-map.html"); | 10315 registerMockedURLLoadFromBase(m_baseURL, "image-map.html"); |
10325 | 10316 |
10326 FrameTestHelpers::WebViewHelper helper; | 10317 FrameTestHelpers::WebViewHelper helper; |
10327 SaveImageFromDataURLWebFrameClient client; | 10318 SaveImageFromDataURLWebFrameClient client; |
10328 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); | 10319 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); |
10329 webView->resize(WebSize(400, 400)); | 10320 webView->resize(WebSize(400, 400)); |
10330 | 10321 |
10331 WebLocalFrame* localFrame = webView->mainFrameImpl(); | 10322 WebLocalFrame* localFrame = webView->mainFrameImpl(); |
10332 | 10323 |
10333 client.reset(); | 10324 client.reset(); |
10334 localFrame->saveImageAt(WebPoint(25, 25)); | 10325 localFrame->saveImageAt(WebPoint(25, 25)); |
(...skipping 12 matching lines...) Expand all Loading... | |
10347 client.reset(); | 10338 client.reset(); |
10348 localFrame->saveImageAt(WebPoint(125, 25)); | 10339 localFrame->saveImageAt(WebPoint(125, 25)); |
10349 EXPECT_EQ(WebString(), client.result()); | 10340 EXPECT_EQ(WebString(), client.result()); |
10350 | 10341 |
10351 // Explicitly reset to break dependency on locally scoped client. | 10342 // Explicitly reset to break dependency on locally scoped client. |
10352 helper.reset(); | 10343 helper.reset(); |
10353 } | 10344 } |
10354 | 10345 |
10355 TEST_F(WebFrameTest, CopyImageAt) { | 10346 TEST_F(WebFrameTest, CopyImageAt) { |
10356 std::string url = m_baseURL + "canvas-copy-image.html"; | 10347 std::string url = m_baseURL + "canvas-copy-image.html"; |
10357 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html"); | 10348 registerMockedURLLoadFromBase(m_baseURL, "canvas-copy-image.html"); |
10358 | 10349 |
10359 FrameTestHelpers::WebViewHelper helper; | 10350 FrameTestHelpers::WebViewHelper helper; |
10360 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0); | 10351 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0); |
10361 webView->resize(WebSize(400, 400)); | 10352 webView->resize(WebSize(400, 400)); |
10362 | 10353 |
10363 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber( | 10354 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber( |
10364 WebClipboard::BufferStandard); | 10355 WebClipboard::BufferStandard); |
10365 | 10356 |
10366 WebLocalFrame* localFrame = webView->mainFrameImpl(); | 10357 WebLocalFrame* localFrame = webView->mainFrameImpl(); |
10367 localFrame->copyImageAt(WebPoint(50, 50)); | 10358 localFrame->copyImageAt(WebPoint(50, 50)); |
10368 | 10359 |
10369 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber( | 10360 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber( |
10370 WebClipboard::BufferStandard)); | 10361 WebClipboard::BufferStandard)); |
10371 | 10362 |
10372 WebImage image = | 10363 WebImage image = |
10373 static_cast<WebMockClipboard*>(Platform::current()->clipboard()) | 10364 static_cast<WebMockClipboard*>(Platform::current()->clipboard()) |
10374 ->readRawImage(WebClipboard::Buffer()); | 10365 ->readRawImage(WebClipboard::Buffer()); |
10375 | 10366 |
10376 SkAutoLockPixels autoLock(image.getSkBitmap()); | 10367 SkAutoLockPixels autoLock(image.getSkBitmap()); |
10377 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0)); | 10368 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0)); |
10378 }; | 10369 }; |
10379 | 10370 |
10380 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) { | 10371 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) { |
10381 std::string url = m_baseURL + "canvas-copy-image.html"; | 10372 std::string url = m_baseURL + "canvas-copy-image.html"; |
10382 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html"); | 10373 registerMockedURLLoadFromBase(m_baseURL, "canvas-copy-image.html"); |
10383 | 10374 |
10384 FrameTestHelpers::WebViewHelper helper; | 10375 FrameTestHelpers::WebViewHelper helper; |
10385 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0); | 10376 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0); |
10386 webView->resize(WebSize(400, 400)); | 10377 webView->resize(WebSize(400, 400)); |
10387 webView->updateAllLifecyclePhases(); | 10378 webView->updateAllLifecyclePhases(); |
10388 webView->setPageScaleFactor(2); | 10379 webView->setPageScaleFactor(2); |
10389 webView->setVisualViewportOffset(WebFloatPoint(200, 200)); | 10380 webView->setVisualViewportOffset(WebFloatPoint(200, 200)); |
10390 | 10381 |
10391 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber( | 10382 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber( |
10392 WebClipboard::BufferStandard); | 10383 WebClipboard::BufferStandard); |
10393 | 10384 |
10394 WebLocalFrame* localFrame = webView->mainFrameImpl(); | 10385 WebLocalFrame* localFrame = webView->mainFrameImpl(); |
10395 localFrame->copyImageAt(WebPoint(0, 0)); | 10386 localFrame->copyImageAt(WebPoint(0, 0)); |
10396 | 10387 |
10397 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber( | 10388 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber( |
10398 WebClipboard::BufferStandard)); | 10389 WebClipboard::BufferStandard)); |
10399 | 10390 |
10400 WebImage image = | 10391 WebImage image = |
10401 static_cast<WebMockClipboard*>(Platform::current()->clipboard()) | 10392 static_cast<WebMockClipboard*>(Platform::current()->clipboard()) |
10402 ->readRawImage(WebClipboard::Buffer()); | 10393 ->readRawImage(WebClipboard::Buffer()); |
10403 | 10394 |
10404 SkAutoLockPixels autoLock(image.getSkBitmap()); | 10395 SkAutoLockPixels autoLock(image.getSkBitmap()); |
10405 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0)); | 10396 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0)); |
10406 }; | 10397 }; |
10407 | 10398 |
10408 TEST_F(WebFrameTest, CopyImageWithImageMap) { | 10399 TEST_F(WebFrameTest, CopyImageWithImageMap) { |
10409 SaveImageFromDataURLWebFrameClient client; | 10400 SaveImageFromDataURLWebFrameClient client; |
10410 | 10401 |
10411 std::string url = m_baseURL + "image-map.html"; | 10402 std::string url = m_baseURL + "image-map.html"; |
10412 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-map.html"); | 10403 registerMockedURLLoadFromBase(m_baseURL, "image-map.html"); |
10413 | 10404 |
10414 FrameTestHelpers::WebViewHelper helper; | 10405 FrameTestHelpers::WebViewHelper helper; |
10415 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); | 10406 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); |
10416 webView->resize(WebSize(400, 400)); | 10407 webView->resize(WebSize(400, 400)); |
10417 | 10408 |
10418 client.reset(); | 10409 client.reset(); |
10419 WebLocalFrame* localFrame = webView->mainFrameImpl(); | 10410 WebLocalFrame* localFrame = webView->mainFrameImpl(); |
10420 localFrame->saveImageAt(WebPoint(25, 25)); | 10411 localFrame->saveImageAt(WebPoint(25, 25)); |
10421 EXPECT_EQ( | 10412 EXPECT_EQ( |
10422 WebString::fromUTF8("data:image/gif;base64" | 10413 WebString::fromUTF8("data:image/gif;base64" |
(...skipping 12 matching lines...) Expand all Loading... | |
10435 EXPECT_EQ(WebString(), client.result()); | 10426 EXPECT_EQ(WebString(), client.result()); |
10436 // Explicitly reset to break dependency on locally scoped client. | 10427 // Explicitly reset to break dependency on locally scoped client. |
10437 helper.reset(); | 10428 helper.reset(); |
10438 } | 10429 } |
10439 | 10430 |
10440 TEST_F(WebFrameTest, LoadJavascriptURLInNewFrame) { | 10431 TEST_F(WebFrameTest, LoadJavascriptURLInNewFrame) { |
10441 FrameTestHelpers::WebViewHelper helper; | 10432 FrameTestHelpers::WebViewHelper helper; |
10442 helper.initialize(true); | 10433 helper.initialize(true); |
10443 | 10434 |
10444 std::string redirectURL = m_baseURL + "foo.html"; | 10435 std::string redirectURL = m_baseURL + "foo.html"; |
10445 URLTestHelpers::registerMockedURLLoad(toKURL(redirectURL), "foo.html"); | 10436 URLTestHelpers::registerMockedURLLoad(toKURL(redirectURL), |
10437 testing::webTestDataPath("foo.html")); | |
10446 WebURLRequest request(toKURL("javascript:location='" + redirectURL + "'")); | 10438 WebURLRequest request(toKURL("javascript:location='" + redirectURL + "'")); |
10447 helper.webView()->mainFrameImpl()->loadRequest(request); | 10439 helper.webView()->mainFrameImpl()->loadRequest(request); |
10448 | 10440 |
10449 // Normally, the result of the JS url replaces the existing contents on the | 10441 // Normally, the result of the JS url replaces the existing contents on the |
10450 // Document. However, if the JS triggers a navigation, the contents should | 10442 // Document. However, if the JS triggers a navigation, the contents should |
10451 // not be replaced. | 10443 // not be replaced. |
10452 EXPECT_EQ("", toLocalFrame(helper.webView()->page()->mainFrame()) | 10444 EXPECT_EQ("", toLocalFrame(helper.webView()->page()->mainFrame()) |
10453 ->document() | 10445 ->document() |
10454 ->documentElement() | 10446 ->documentElement() |
10455 ->innerText()); | 10447 ->innerText()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10567 int dataLength) override { | 10559 int dataLength) override { |
10568 EXPECT_GT(dataLength, 16); | 10560 EXPECT_GT(dataLength, 16); |
10569 originalClient->didReceiveData(data, 16); | 10561 originalClient->didReceiveData(data, 16); |
10570 // This didReceiveData call shouldn't crash due to a failed assertion. | 10562 // This didReceiveData call shouldn't crash due to a failed assertion. |
10571 originalClient->didReceiveData(data + 16, dataLength - 16); | 10563 originalClient->didReceiveData(data + 16, dataLength - 16); |
10572 } | 10564 } |
10573 }; | 10565 }; |
10574 | 10566 |
10575 TEST_F(WebFrameTest, ImageDocumentDecodeError) { | 10567 TEST_F(WebFrameTest, ImageDocumentDecodeError) { |
10576 std::string url = m_baseURL + "not_an_image.ico"; | 10568 std::string url = m_baseURL + "not_an_image.ico"; |
10577 URLTestHelpers::registerMockedURLLoad(toKURL(url), "not_an_image.ico", | 10569 URLTestHelpers::registerMockedURLLoad( |
10578 "image/x-icon"); | 10570 toKURL(url), testing::webTestDataPath("not_an_image.ico"), |
10571 "image/x-icon"); | |
10579 MultipleDataChunkDelegate delegate; | 10572 MultipleDataChunkDelegate delegate; |
10580 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(&delegate); | 10573 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(&delegate); |
10581 FrameTestHelpers::WebViewHelper helper; | 10574 FrameTestHelpers::WebViewHelper helper; |
10582 helper.initializeAndLoad(url, true); | 10575 helper.initializeAndLoad(url, true); |
10583 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); | 10576 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); |
10584 | 10577 |
10585 Document* document = | 10578 Document* document = |
10586 toLocalFrame(helper.webView()->page()->mainFrame())->document(); | 10579 toLocalFrame(helper.webView()->page()->mainFrame())->document(); |
10587 EXPECT_TRUE(document->isImageDocument()); | 10580 EXPECT_TRUE(document->isImageDocument()); |
10588 EXPECT_EQ(ResourceStatus::DecodeError, | 10581 EXPECT_EQ(ResourceStatus::DecodeError, |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11220 | 11213 |
11221 LoadingObserverFrameClient& childClient() { return m_childClient; } | 11214 LoadingObserverFrameClient& childClient() { return m_childClient; } |
11222 | 11215 |
11223 private: | 11216 private: |
11224 LoadingObserverFrameClient m_childClient; | 11217 LoadingObserverFrameClient m_childClient; |
11225 }; | 11218 }; |
11226 | 11219 |
11227 registerMockedHttpURLLoad("single_iframe.html"); | 11220 registerMockedHttpURLLoad("single_iframe.html"); |
11228 URLTestHelpers::registerMockedURLLoad( | 11221 URLTestHelpers::registerMockedURLLoad( |
11229 toKURL(m_baseURL + "visible_iframe.html"), | 11222 toKURL(m_baseURL + "visible_iframe.html"), |
11230 WebString::fromUTF8("frame_with_frame.html")); | 11223 testing::webTestDataPath("frame_with_frame.html")); |
11231 registerMockedHttpURLLoad("parent_detaching_frame.html"); | 11224 registerMockedHttpURLLoad("parent_detaching_frame.html"); |
11232 | 11225 |
11233 FrameTestHelpers::WebViewHelper webViewHelper; | 11226 FrameTestHelpers::WebViewHelper webViewHelper; |
11234 MainFrameClient mainFrameClient; | 11227 MainFrameClient mainFrameClient; |
11235 webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html", true, | 11228 webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html", true, |
11236 &mainFrameClient); | 11229 &mainFrameClient); |
11237 | 11230 |
11238 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); | 11231 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); |
11239 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); | 11232 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); |
11240 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); | 11233 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); |
11241 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); | 11234 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); |
11242 | 11235 |
11243 webViewHelper.reset(); | 11236 webViewHelper.reset(); |
11244 } | 11237 } |
11245 | 11238 |
11246 } // namespace blink | 11239 } // namespace blink |
OLD | NEW |