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/WebThread.h" | 74 #include "public/platform/WebThread.h" |
70 #include "public/platform/WebURL.h" | 75 #include "public/platform/WebURL.h" |
71 #include "public/platform/WebURLResponse.h" | 76 #include "public/platform/WebURLResponse.h" |
72 #include "public/platform/WebUnitTestSupport.h" | 77 #include "public/platform/WebUnitTestSupport.h" |
73 #include "public/web/WebDataSource.h" | 78 #include "public/web/WebDataSource.h" |
74 #include "public/web/WebDocument.h" | 79 #include "public/web/WebDocument.h" |
75 #include "public/web/WebFindOptions.h" | 80 #include "public/web/WebFindOptions.h" |
76 #include "public/web/WebFormElement.h" | 81 #include "public/web/WebFormElement.h" |
(...skipping 5530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5607 EXPECT_TRUE(client.didNotify()); | 5612 EXPECT_TRUE(client.didNotify()); |
5608 EXPECT_EQ(0xff0000ff, frame->document().brandColor()); | 5613 EXPECT_EQ(0xff0000ff, frame->document().brandColor()); |
5609 // Change of second brand-color meta tag will not change frame's brand | 5614 // Change of second brand-color meta tag will not change frame's brand |
5610 // color. | 5615 // color. |
5611 client.reset(); | 5616 client.reset(); |
5612 frame->executeScript(WebScriptSource("document.getElementById('bc2').setAttr ibute('content', '#00FF00');")); | 5617 frame->executeScript(WebScriptSource("document.getElementById('bc2').setAttr ibute('content', '#00FF00');")); |
5613 EXPECT_TRUE(client.didNotify()); | 5618 EXPECT_TRUE(client.didNotify()); |
5614 EXPECT_EQ(0xff0000ff, frame->document().brandColor()); | 5619 EXPECT_EQ(0xff0000ff, frame->document().brandColor()); |
5615 } | 5620 } |
5616 | 5621 |
5622 class MockDocumentThreadableLoaderClient : public WebCore::DocumentThreadableLoa derClient { | |
5623 public: | |
5624 MockDocumentThreadableLoaderClient() : m_failed(false) { } | |
5625 virtual void didFail(const WebCore::ResourceError&) OVERRIDE { m_failed = tr ue;} | |
5626 | |
5627 void reset() { m_failed = false; } | |
5628 bool failed() { return m_failed; } | |
5629 | |
5630 bool m_failed; | |
5631 }; | |
5632 | |
5633 // FIXME: This would be better as a unittest on DocumentThreadableLoader but it | |
5634 // requires spin-up of a frame. It may be possible to remove that requirement | |
Nate Chapin
2014/07/07 17:24:52
FWIW, this is a nearly universal problem with anyt
| |
5635 // and convert it to a unittest. | |
5636 TEST_F(WebFrameTest, LoaderOriginAccess) | |
5637 { | |
5638 FrameTestHelpers::WebViewHelper webViewHelper; | |
5639 webViewHelper.initializeAndLoad("about:blank"); | |
5640 | |
5641 WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); | |
5642 | |
5643 // Cross-origin request. | |
5644 WebCore::KURL resourceUrl(WebCore::ParsedURLString, "chrome://test.pdf"); | |
5645 registerMockedChromeURLLoad("test.pdf"); | |
5646 | |
5647 RefPtr<WebCore::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl() ->page()->mainFrame()); | |
5648 | |
5649 MockDocumentThreadableLoaderClient client; | |
5650 WebCore::ThreadableLoaderOptions options; | |
5651 | |
5652 // First try to load the request with regular access. Should fail. | |
5653 options.crossOriginRequestPolicy = WebCore::UseAccessControl; | |
5654 WebCore::ResourceLoaderOptions resourceLoaderOptions; | |
5655 WebCore::DocumentThreadableLoader::loadResourceSynchronously( | |
5656 *frame->document(), WebCore::ResourceRequest(resourceUrl), client, optio ns, resourceLoaderOptions); | |
5657 EXPECT_TRUE(client.failed()); | |
5658 | |
5659 client.reset(); | |
5660 // Try to load the request with cross origin access. Should succeed. | |
5661 options.crossOriginRequestPolicy = WebCore::AllowCrossOriginRequests; | |
5662 WebCore::DocumentThreadableLoader::loadResourceSynchronously( | |
5663 *frame->document(), WebCore::ResourceRequest(resourceUrl), client, optio ns, resourceLoaderOptions); | |
5664 EXPECT_FALSE(client.failed()); | |
5665 } | |
5666 | |
5617 } // namespace | 5667 } // namespace |
OLD | NEW |