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 8813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8824 request.setURL(toKURL("javascript:location='" + redirectURL + "'")); | 8824 request.setURL(toKURL("javascript:location='" + redirectURL + "'")); |
8825 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); | 8825 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); |
8826 helper.webView()->mainFrameImpl()->loadRequest(request); | 8826 helper.webView()->mainFrameImpl()->loadRequest(request); |
8827 | 8827 |
8828 // Normally, the result of the JS url replaces the existing contents on the | 8828 // Normally, the result of the JS url replaces the existing contents on the |
8829 // Document. However, if the JS triggers a navigation, the contents should | 8829 // Document. However, if the JS triggers a navigation, the contents should |
8830 // not be replaced. | 8830 // not be replaced. |
8831 EXPECT_EQ("", toLocalFrame(helper.webView()->page()->mainFrame())->document(
)->documentElement()->innerText()); | 8831 EXPECT_EQ("", toLocalFrame(helper.webView()->page()->mainFrame())->document(
)->documentElement()->innerText()); |
8832 } | 8832 } |
8833 | 8833 |
| 8834 class MultipleDataChunkDelegate : public WebURLLoaderTestDelegate { |
| 8835 public: |
| 8836 void didReceiveData(WebURLLoaderClient* originalClient, WebURLLoader* loader
, const char* data, int dataLength, int encodedDataLength) override |
| 8837 { |
| 8838 EXPECT_GT(dataLength, 16); |
| 8839 originalClient->didReceiveData(loader, data, 16, 16, 16); |
| 8840 // This didReceiveData call shouldn't crash due to a failed assertion. |
| 8841 originalClient->didReceiveData(loader, data + 16, dataLength - 16, encod
edDataLength - 16, dataLength - 16); |
| 8842 } |
| 8843 }; |
| 8844 |
| 8845 TEST_F(WebFrameTest, ImageDocumentDecodeError) |
| 8846 { |
| 8847 std::string url = m_baseURL + "not_an_image.ico"; |
| 8848 URLTestHelpers::registerMockedURLLoad(toKURL(url), "not_an_image.ico", "imag
e/x-icon"); |
| 8849 MultipleDataChunkDelegate delegate; |
| 8850 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(&delegate)
; |
| 8851 |
| 8852 FrameTestHelpers::WebViewHelper helper; |
| 8853 helper.initializeAndLoad(url, true); |
| 8854 Document* document = toLocalFrame(helper.webView()->page()->mainFrame())->do
cument(); |
| 8855 EXPECT_TRUE(document->isImageDocument()); |
| 8856 EXPECT_EQ(Resource::DecodeError, toImageDocument(document)->cachedImage()->g
etStatus()); |
| 8857 } |
| 8858 |
8834 } // namespace blink | 8859 } // namespace blink |
OLD | NEW |