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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "core/dom/FullscreenElementStack.h" | 43 #include "core/dom/FullscreenElementStack.h" |
44 #include "core/dom/Range.h" | 44 #include "core/dom/Range.h" |
45 #include "core/editing/Editor.h" | 45 #include "core/editing/Editor.h" |
46 #include "core/editing/FrameSelection.h" | 46 #include "core/editing/FrameSelection.h" |
47 #include "core/editing/SpellChecker.h" | 47 #include "core/editing/SpellChecker.h" |
48 #include "core/editing/VisiblePosition.h" | 48 #include "core/editing/VisiblePosition.h" |
49 #include "core/events/MouseEvent.h" | 49 #include "core/events/MouseEvent.h" |
50 #include "core/frame/FrameView.h" | 50 #include "core/frame/FrameView.h" |
51 #include "core/frame/LocalFrame.h" | 51 #include "core/frame/LocalFrame.h" |
52 #include "core/frame/Settings.h" | 52 #include "core/frame/Settings.h" |
| 53 #include "core/html/HTMLDocument.h" |
53 #include "core/html/HTMLFormElement.h" | 54 #include "core/html/HTMLFormElement.h" |
| 55 #include "core/loader/DocumentThreadableLoader.h" |
| 56 #include "core/loader/DocumentThreadableLoaderClient.h" |
54 #include "core/loader/FrameLoadRequest.h" | 57 #include "core/loader/FrameLoadRequest.h" |
| 58 #include "core/loader/ThreadableLoader.h" |
55 #include "core/page/EventHandler.h" | 59 #include "core/page/EventHandler.h" |
56 #include "core/page/Page.h" | 60 #include "core/page/Page.h" |
57 #include "core/rendering/HitTestResult.h" | 61 #include "core/rendering/HitTestResult.h" |
58 #include "core/rendering/RenderView.h" | 62 #include "core/rendering/RenderView.h" |
59 #include "core/rendering/TextAutosizer.h" | 63 #include "core/rendering/TextAutosizer.h" |
60 #include "core/rendering/compositing/RenderLayerCompositor.h" | 64 #include "core/rendering/compositing/RenderLayerCompositor.h" |
61 #include "platform/DragImage.h" | 65 #include "platform/DragImage.h" |
62 #include "platform/RuntimeEnabledFeatures.h" | 66 #include "platform/RuntimeEnabledFeatures.h" |
63 #include "platform/UserGestureIndicator.h" | 67 #include "platform/UserGestureIndicator.h" |
64 #include "platform/geometry/FloatRect.h" | 68 #include "platform/geometry/FloatRect.h" |
65 #include "platform/network/ResourceError.h" | 69 #include "platform/network/ResourceError.h" |
66 #include "platform/scroll/ScrollbarTheme.h" | 70 #include "platform/scroll/ScrollbarTheme.h" |
| 71 #include "platform/weborigin/SchemeRegistry.h" |
67 #include "public/platform/Platform.h" | 72 #include "public/platform/Platform.h" |
68 #include "public/platform/WebFloatRect.h" | 73 #include "public/platform/WebFloatRect.h" |
69 #include "public/platform/WebSelectionBound.h" | 74 #include "public/platform/WebSelectionBound.h" |
70 #include "public/platform/WebThread.h" | 75 #include "public/platform/WebThread.h" |
71 #include "public/platform/WebURL.h" | 76 #include "public/platform/WebURL.h" |
72 #include "public/platform/WebURLResponse.h" | 77 #include "public/platform/WebURLResponse.h" |
73 #include "public/platform/WebUnitTestSupport.h" | 78 #include "public/platform/WebUnitTestSupport.h" |
74 #include "public/web/WebDataSource.h" | 79 #include "public/web/WebDataSource.h" |
75 #include "public/web/WebDocument.h" | 80 #include "public/web/WebDocument.h" |
76 #include "public/web/WebFindOptions.h" | 81 #include "public/web/WebFindOptions.h" |
(...skipping 5780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5857 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 5862 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
5858 std::string content = localFrame->contentAsText(1024).utf8(); | 5863 std::string content = localFrame->contentAsText(1024).utf8(); |
5859 EXPECT_EQ("hello", content); | 5864 EXPECT_EQ("hello", content); |
5860 | 5865 |
5861 // Manually reset to break WebViewHelper's dependency on the stack allocated | 5866 // Manually reset to break WebViewHelper's dependency on the stack allocated |
5862 // TestWebFrameClient. | 5867 // TestWebFrameClient. |
5863 reset(); | 5868 reset(); |
5864 remoteFrame->close(); | 5869 remoteFrame->close(); |
5865 } | 5870 } |
5866 | 5871 |
| 5872 class MockDocumentThreadableLoaderClient : public WebCore::DocumentThreadableLoa
derClient { |
| 5873 public: |
| 5874 MockDocumentThreadableLoaderClient() : m_failed(false) { } |
| 5875 virtual void didFail(const WebCore::ResourceError&) OVERRIDE { m_failed = tr
ue;} |
| 5876 |
| 5877 void reset() { m_failed = false; } |
| 5878 bool failed() { return m_failed; } |
| 5879 |
| 5880 bool m_failed; |
| 5881 }; |
| 5882 |
| 5883 // FIXME: This would be better as a unittest on DocumentThreadableLoader but it |
| 5884 // requires spin-up of a frame. It may be possible to remove that requirement |
| 5885 // and convert it to a unittest. |
| 5886 TEST_F(WebFrameTest, LoaderOriginAccess) |
| 5887 { |
| 5888 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5889 webViewHelper.initializeAndLoad("about:blank"); |
| 5890 |
| 5891 WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); |
| 5892 |
| 5893 // Cross-origin request. |
| 5894 WebCore::KURL resourceUrl(WebCore::ParsedURLString, "chrome://test.pdf"); |
| 5895 registerMockedChromeURLLoad("test.pdf"); |
| 5896 |
| 5897 RefPtr<WebCore::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()
->page()->mainFrame()); |
| 5898 |
| 5899 MockDocumentThreadableLoaderClient client; |
| 5900 WebCore::ThreadableLoaderOptions options; |
| 5901 |
| 5902 // First try to load the request with regular access. Should fail. |
| 5903 options.crossOriginRequestPolicy = WebCore::UseAccessControl; |
| 5904 WebCore::ResourceLoaderOptions resourceLoaderOptions; |
| 5905 WebCore::DocumentThreadableLoader::loadResourceSynchronously( |
| 5906 *frame->document(), WebCore::ResourceRequest(resourceUrl), client, optio
ns, resourceLoaderOptions); |
| 5907 EXPECT_TRUE(client.failed()); |
| 5908 |
| 5909 client.reset(); |
| 5910 // Try to load the request with cross origin access. Should succeed. |
| 5911 options.crossOriginRequestPolicy = WebCore::AllowCrossOriginRequests; |
| 5912 WebCore::DocumentThreadableLoader::loadResourceSynchronously( |
| 5913 *frame->document(), WebCore::ResourceRequest(resourceUrl), client, optio
ns, resourceLoaderOptions); |
| 5914 EXPECT_FALSE(client.failed()); |
| 5915 } |
| 5916 |
5867 } // namespace | 5917 } // namespace |
OLD | NEW |