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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 URLTestHelpers::registerMockedURLLoadWithCustomResponse(toKURL(fullStrin
g.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(""), resp
onse); | 210 URLTestHelpers::registerMockedURLLoadWithCustomResponse(toKURL(fullStrin
g.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(""), resp
onse); |
211 } | 211 } |
212 | 212 |
213 void registerMockedHttpURLLoadWithMimeType(const std::string& fileName, cons
t std::string& mimeType) | 213 void registerMockedHttpURLLoadWithMimeType(const std::string& fileName, cons
t std::string& mimeType) |
214 { | 214 { |
215 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(mimeType
)); | 215 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(mimeType
)); |
216 } | 216 } |
217 | 217 |
218 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp
er) | 218 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp
er) |
219 { | 219 { |
220 RawPtr<StyleSheetContents> styleSheet = StyleSheetContents::create(CSSPa
rserContext(UASheetMode, 0)); | 220 StyleSheetContents* styleSheet = StyleSheetContents::create(CSSParserCon
text(UASheetMode, 0)); |
221 styleSheet->parseString(loadResourceAsASCIIString("viewportAndroid.css")
); | 221 styleSheet->parseString(loadResourceAsASCIIString("viewportAndroid.css")
); |
222 RawPtr<RuleSet> ruleSet = RuleSet::create(); | 222 RuleSet* ruleSet = RuleSet::create(); |
223 ruleSet->addRulesFromSheet(styleSheet.get(), MediaQueryEvaluator("screen
")); | 223 ruleSet->addRulesFromSheet(styleSheet, MediaQueryEvaluator("screen")); |
224 | 224 |
225 Document* document = toLocalFrame(webViewHelper->webViewImpl()->page()->
mainFrame())->document(); | 225 Document* document = toLocalFrame(webViewHelper->webViewImpl()->page()->
mainFrame())->document(); |
226 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), ViewportStyleResolver::UserAgentOrigin); | 226 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet, ViewportStyleResolver::UserAgentOrigin); |
227 document->ensureStyleResolver().viewportStyleResolver()->resolve(); | 227 document->ensureStyleResolver().viewportStyleResolver()->resolve(); |
228 } | 228 } |
229 | 229 |
230 static void configueCompositingWebView(WebSettings* settings) | 230 static void configueCompositingWebView(WebSettings* settings) |
231 { | 231 { |
232 settings->setAcceleratedCompositingEnabled(true); | 232 settings->setAcceleratedCompositingEnabled(true); |
233 settings->setPreferCompositingToLCDTextEnabled(true); | 233 settings->setPreferCompositingToLCDTextEnabled(true); |
234 } | 234 } |
235 | 235 |
236 static void configureAndroid(WebSettings* settings) | 236 static void configureAndroid(WebSettings* settings) |
(...skipping 14 matching lines...) Expand all Loading... |
251 webViewHelper->initializeAndLoad(url, true); | 251 webViewHelper->initializeAndLoad(url, true); |
252 webViewHelper->webView()->settings()->setDefaultFontSize(12); | 252 webViewHelper->webView()->settings()->setDefaultFontSize(12); |
253 webViewHelper->resize(WebSize(640, 480)); | 253 webViewHelper->resize(WebSize(640, 480)); |
254 } | 254 } |
255 | 255 |
256 PassOwnPtr<DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHelper* we
bViewHelper, const std::string& testcase) | 256 PassOwnPtr<DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHelper* we
bViewHelper, const std::string& testcase) |
257 { | 257 { |
258 registerMockedHttpURLLoad("nodeimage.html"); | 258 registerMockedHttpURLLoad("nodeimage.html"); |
259 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); | 259 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); |
260 webViewHelper->resize(WebSize(640, 480)); | 260 webViewHelper->resize(WebSize(640, 480)); |
261 RawPtr<LocalFrame> frame = toLocalFrame(webViewHelper->webViewImpl()->pa
ge()->mainFrame()); | 261 LocalFrame* frame = toLocalFrame(webViewHelper->webViewImpl()->page()->m
ainFrame()); |
262 DCHECK(frame); | 262 DCHECK(frame); |
263 Element* element = frame->document()->getElementById(testcase.c_str()); | 263 Element* element = frame->document()->getElementById(testcase.c_str()); |
264 return frame->nodeImage(*element); | 264 return frame->nodeImage(*element); |
265 } | 265 } |
266 | 266 |
267 void removeElementById(WebLocalFrameImpl* frame, const AtomicString& id) | 267 void removeElementById(WebLocalFrameImpl* frame, const AtomicString& id) |
268 { | 268 { |
269 Element* element = frame->frame()->document()->getElementById(id); | 269 Element* element = frame->frame()->document()->getElementById(id); |
270 DCHECK(element); | 270 DCHECK(element); |
271 element->remove(); | 271 element->remove(); |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); | 833 std::string content = WebFrameContentDumper::dumpWebViewAsText(webViewHelper
.webView(), 1024).utf8(); |
834 EXPECT_NE(std::string::npos, content.find("Message 1.")); | 834 EXPECT_NE(std::string::npos, content.find("Message 1.")); |
835 EXPECT_EQ(std::string::npos, content.find("Message 2.")); | 835 EXPECT_EQ(std::string::npos, content.find("Message 2.")); |
836 } | 836 } |
837 | 837 |
838 TEST_P(ParameterizedWebFrameTest, PostMessageThenDetach) | 838 TEST_P(ParameterizedWebFrameTest, PostMessageThenDetach) |
839 { | 839 { |
840 FrameTestHelpers::WebViewHelper webViewHelper(this); | 840 FrameTestHelpers::WebViewHelper webViewHelper(this); |
841 webViewHelper.initializeAndLoad("about:blank"); | 841 webViewHelper.initializeAndLoad("about:blank"); |
842 | 842 |
843 RawPtr<LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->page()-
>mainFrame()); | 843 LocalFrame* frame = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr
ame()); |
844 NonThrowableExceptionState exceptionState; | 844 NonThrowableExceptionState exceptionState; |
845 frame->domWindow()->postMessage(SerializedScriptValueFactory::instance().cre
ate("message"), 0, "*", frame->localDOMWindow(), exceptionState); | 845 frame->domWindow()->postMessage(SerializedScriptValueFactory::instance().cre
ate("message"), 0, "*", frame->localDOMWindow(), exceptionState); |
846 webViewHelper.reset(); | 846 webViewHelper.reset(); |
847 EXPECT_FALSE(exceptionState.hadException()); | 847 EXPECT_FALSE(exceptionState.hadException()); |
848 | 848 |
849 // Success is not crashing. | 849 // Success is not crashing. |
850 runPendingTasks(); | 850 runPendingTasks(); |
851 } | 851 } |
852 | 852 |
853 namespace { | 853 namespace { |
(...skipping 3065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3919 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3919 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); |
3920 webViewHelper.resize(WebSize(640, 480)); | 3920 webViewHelper.resize(WebSize(640, 480)); |
3921 runPendingTasks(); | 3921 runPendingTasks(); |
3922 | 3922 |
3923 const char kFindString[] = "result"; | 3923 const char kFindString[] = "result"; |
3924 const int kFindIdentifier = 12345; | 3924 const int kFindIdentifier = 12345; |
3925 | 3925 |
3926 WebFindOptions options; | 3926 WebFindOptions options; |
3927 WebString searchText = WebString::fromUTF8(kFindString); | 3927 WebString searchText = WebString::fromUTF8(kFindString); |
3928 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3928 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
3929 RawPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(mainFrame->trave
rseNext(false)); | 3929 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); |
3930 RawPtr<LocalFrame> holdSecondFrame(secondFrame->frame()); | |
3931 | 3930 |
3932 // Detach the frame before finding. | 3931 // Detach the frame before finding. |
3933 removeElementById(mainFrame, "frame"); | 3932 removeElementById(mainFrame, "frame"); |
3934 | 3933 |
3935 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3934 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
3936 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false,
0)); | 3935 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false,
0)); |
3937 | 3936 |
3938 runPendingTasks(); | 3937 runPendingTasks(); |
3939 EXPECT_FALSE(client.findResultsAreReady()); | 3938 EXPECT_FALSE(client.findResultsAreReady()); |
3940 | 3939 |
(...skipping 16 matching lines...) Expand all Loading... |
3957 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3956 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); |
3958 webViewHelper.resize(WebSize(640, 480)); | 3957 webViewHelper.resize(WebSize(640, 480)); |
3959 runPendingTasks(); | 3958 runPendingTasks(); |
3960 | 3959 |
3961 const char kFindString[] = "result"; | 3960 const char kFindString[] = "result"; |
3962 const int kFindIdentifier = 12345; | 3961 const int kFindIdentifier = 12345; |
3963 | 3962 |
3964 WebFindOptions options; | 3963 WebFindOptions options; |
3965 WebString searchText = WebString::fromUTF8(kFindString); | 3964 WebString searchText = WebString::fromUTF8(kFindString); |
3966 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3965 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
3967 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); | |
3968 RawPtr<LocalFrame> holdSecondFrame(secondFrame->frame()); | |
3969 | 3966 |
3970 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3967 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
3971 EXPECT_TRUE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText,
options, false, 0)); | 3968 EXPECT_TRUE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText,
options, false, 0)); |
3972 | 3969 |
3973 runPendingTasks(); | 3970 runPendingTasks(); |
3974 EXPECT_FALSE(client.findResultsAreReady()); | 3971 EXPECT_FALSE(client.findResultsAreReady()); |
3975 | 3972 |
3976 // Detach the frame between finding and scoping. | 3973 // Detach the frame between finding and scoping. |
3977 removeElementById(mainFrame, "frame"); | 3974 removeElementById(mainFrame, "frame"); |
3978 | 3975 |
(...skipping 16 matching lines...) Expand all Loading... |
3995 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3992 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); |
3996 webViewHelper.resize(WebSize(640, 480)); | 3993 webViewHelper.resize(WebSize(640, 480)); |
3997 runPendingTasks(); | 3994 runPendingTasks(); |
3998 | 3995 |
3999 const char kFindString[] = "result"; | 3996 const char kFindString[] = "result"; |
4000 const int kFindIdentifier = 12345; | 3997 const int kFindIdentifier = 12345; |
4001 | 3998 |
4002 WebFindOptions options; | 3999 WebFindOptions options; |
4003 WebString searchText = WebString::fromUTF8(kFindString); | 4000 WebString searchText = WebString::fromUTF8(kFindString); |
4004 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 4001 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
4005 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); | |
4006 RawPtr<LocalFrame> holdSecondFrame(secondFrame->frame()); | |
4007 | 4002 |
4008 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 4003 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
4009 EXPECT_TRUE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText,
options, false, 0)); | 4004 EXPECT_TRUE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText,
options, false, 0)); |
4010 | 4005 |
4011 runPendingTasks(); | 4006 runPendingTasks(); |
4012 EXPECT_FALSE(client.findResultsAreReady()); | 4007 EXPECT_FALSE(client.findResultsAreReady()); |
4013 | 4008 |
4014 mainFrame->resetMatchCount(); | 4009 mainFrame->resetMatchCount(); |
4015 | 4010 |
4016 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 4011 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4071 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 4066 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
4072 | 4067 |
4073 mainFrame->resetMatchCount(); | 4068 mainFrame->resetMatchCount(); |
4074 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 4069 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
4075 | 4070 |
4076 runPendingTasks(); | 4071 runPendingTasks(); |
4077 EXPECT_TRUE(client.findResultsAreReady()); | 4072 EXPECT_TRUE(client.findResultsAreReady()); |
4078 | 4073 |
4079 // Get the tickmarks for the original find request. | 4074 // Get the tickmarks for the original find request. |
4080 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); | 4075 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
4081 RawPtr<Scrollbar> scrollbar = frameView->createScrollbar(HorizontalScrollbar
); | 4076 Scrollbar* scrollbar = frameView->createScrollbar(HorizontalScrollbar); |
4082 Vector<IntRect> originalTickmarks; | 4077 Vector<IntRect> originalTickmarks; |
4083 scrollbar->getTickmarks(originalTickmarks); | 4078 scrollbar->getTickmarks(originalTickmarks); |
4084 EXPECT_EQ(4u, originalTickmarks.size()); | 4079 EXPECT_EQ(4u, originalTickmarks.size()); |
4085 | 4080 |
4086 // Override the tickmarks. | 4081 // Override the tickmarks. |
4087 Vector<IntRect> overridingTickmarksExpected; | 4082 Vector<IntRect> overridingTickmarksExpected; |
4088 overridingTickmarksExpected.append(IntRect(0, 0, 100, 100)); | 4083 overridingTickmarksExpected.append(IntRect(0, 0, 100, 100)); |
4089 overridingTickmarksExpected.append(IntRect(0, 20, 100, 100)); | 4084 overridingTickmarksExpected.append(IntRect(0, 20, 100, 100)); |
4090 overridingTickmarksExpected.append(IntRect(0, 30, 100, 100)); | 4085 overridingTickmarksExpected.append(IntRect(0, 30, 100, 100)); |
4091 mainFrame->setTickmarks(overridingTickmarksExpected); | 4086 mainFrame->setTickmarks(overridingTickmarksExpected); |
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5790 { | 5785 { |
5791 registerMockedHttpURLLoad("fragment_middle_click.html"); | 5786 registerMockedHttpURLLoad("fragment_middle_click.html"); |
5792 TestNavigationPolicyWebFrameClient client; | 5787 TestNavigationPolicyWebFrameClient client; |
5793 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5788 FrameTestHelpers::WebViewHelper webViewHelper(this); |
5794 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue, &client); | 5789 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue, &client); |
5795 | 5790 |
5796 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF
rame())->document(); | 5791 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF
rame())->document(); |
5797 KURL destination = document->url(); | 5792 KURL destination = document->url(); |
5798 destination.setFragmentIdentifier("test"); | 5793 destination.setFragmentIdentifier("test"); |
5799 | 5794 |
5800 RawPtr<Event> event = MouseEvent::create(EventTypeNames::click, false, false
, | 5795 Event* event = MouseEvent::create(EventTypeNames::click, false, false, |
5801 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, PlatformEvent::NoModifiers,
1, 0, nullptr, 0, | 5796 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, PlatformEvent::NoModifiers,
1, 0, nullptr, 0, |
5802 PlatformMouseEvent::RealOrIndistinguishable, String()); | 5797 PlatformMouseEvent::RealOrIndistinguishable, String()); |
5803 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); | 5798 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); |
5804 frameRequest.setTriggeringEvent(event); | 5799 frameRequest.setTriggeringEvent(event); |
5805 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); | 5800 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); |
5806 } | 5801 } |
5807 | 5802 |
5808 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { | 5803 class TestNewWindowWebViewClient : public FrameTestHelpers::TestWebViewClient { |
5809 public: | 5804 public: |
5810 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW
indowFeatures&, | 5805 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW
indowFeatures&, |
(...skipping 29 matching lines...) Expand all Loading... |
5840 registerMockedHttpURLLoad("hello_world.html"); | 5835 registerMockedHttpURLLoad("hello_world.html"); |
5841 TestNewWindowWebViewClient webViewClient; | 5836 TestNewWindowWebViewClient webViewClient; |
5842 TestNewWindowWebFrameClient webFrameClient; | 5837 TestNewWindowWebFrameClient webFrameClient; |
5843 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5838 FrameTestHelpers::WebViewHelper webViewHelper(this); |
5844 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra
meClient, &webViewClient); | 5839 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra
meClient, &webViewClient); |
5845 | 5840 |
5846 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF
rame())->document(); | 5841 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF
rame())->document(); |
5847 KURL destination = toKURL(m_baseURL + "hello_world.html"); | 5842 KURL destination = toKURL(m_baseURL + "hello_world.html"); |
5848 | 5843 |
5849 // ctrl+click event | 5844 // ctrl+click event |
5850 RawPtr<Event> event = MouseEvent::create(EventTypeNames::click, false, false
, | 5845 Event* event = MouseEvent::create(EventTypeNames::click, false, false, |
5851 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, PlatformEvent::CtrlKey, 0, 0
, nullptr, 0, | 5846 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, PlatformEvent::CtrlKey, 0, 0
, nullptr, 0, |
5852 PlatformMouseEvent::RealOrIndistinguishable, String()); | 5847 PlatformMouseEvent::RealOrIndistinguishable, String()); |
5853 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); | 5848 FrameLoadRequest frameRequest(document, ResourceRequest(destination)); |
5854 frameRequest.setTriggeringEvent(event); | 5849 frameRequest.setTriggeringEvent(event); |
5855 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 5850 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
5856 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); | 5851 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa
d(frameRequest); |
5857 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()-
>mainFrame()); | 5852 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()-
>mainFrame()); |
5858 | 5853 |
5859 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. | 5854 // decidePolicyForNavigation should be called both for the original request
and the ctrl+click. |
5860 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); | 5855 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6009 registerMockedHttpURLLoad("iframe_reload.html"); | 6004 registerMockedHttpURLLoad("iframe_reload.html"); |
6010 registerMockedHttpURLLoad("visible_iframe.html"); | 6005 registerMockedHttpURLLoad("visible_iframe.html"); |
6011 TestCachePolicyWebFrameClient mainClient(0); | 6006 TestCachePolicyWebFrameClient mainClient(0); |
6012 TestCachePolicyWebFrameClient childClient(&mainClient); | 6007 TestCachePolicyWebFrameClient childClient(&mainClient); |
6013 mainClient.setChildWebFrameClient(&childClient); | 6008 mainClient.setChildWebFrameClient(&childClient); |
6014 | 6009 |
6015 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6010 FrameTestHelpers::WebViewHelper webViewHelper(this); |
6016 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); | 6011 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); |
6017 | 6012 |
6018 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); | 6013 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); |
6019 RawPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstC
hild()); | 6014 WebLocalFrameImpl* childFrame = toWebLocalFrameImpl(mainFrame->firstChild())
; |
6020 ASSERT_EQ(childFrame->client(), &childClient); | 6015 ASSERT_EQ(childFrame->client(), &childClient); |
6021 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); | 6016 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); |
6022 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); | 6017 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); |
6023 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::UseProtocolCachePoli
cy); | 6018 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::UseProtocolCachePoli
cy); |
6024 | 6019 |
6025 FrameTestHelpers::reloadFrame(mainFrame); | 6020 FrameTestHelpers::reloadFrame(mainFrame); |
6026 | 6021 |
6027 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. | 6022 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. |
6028 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); | 6023 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); |
6029 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); | 6024 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6788 { | 6783 { |
6789 registerMockedHttpURLLoad("link-manifest-change.html"); | 6784 registerMockedHttpURLLoad("link-manifest-change.html"); |
6790 | 6785 |
6791 ManifestChangeWebFrameClient webFrameClient; | 6786 ManifestChangeWebFrameClient webFrameClient; |
6792 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6787 FrameTestHelpers::WebViewHelper webViewHelper(this); |
6793 webViewHelper.initializeAndLoad(m_baseURL + "link-manifest-change.html", tru
e, &webFrameClient); | 6788 webViewHelper.initializeAndLoad(m_baseURL + "link-manifest-change.html", tru
e, &webFrameClient); |
6794 | 6789 |
6795 EXPECT_EQ(14, webFrameClient.manifestChangeCount()); | 6790 EXPECT_EQ(14, webFrameClient.manifestChangeCount()); |
6796 } | 6791 } |
6797 | 6792 |
6798 static RawPtr<Resource> fetchManifest(Document* document, const KURL& url) | 6793 static Resource* fetchManifest(Document* document, const KURL& url) |
6799 { | 6794 { |
6800 FetchRequest fetchRequest = FetchRequest(ResourceRequest(url), FetchInitiato
rInfo()); | 6795 FetchRequest fetchRequest = FetchRequest(ResourceRequest(url), FetchInitiato
rInfo()); |
6801 fetchRequest.mutableResourceRequest().setRequestContext(WebURLRequest::Reque
stContextManifest); | 6796 fetchRequest.mutableResourceRequest().setRequestContext(WebURLRequest::Reque
stContextManifest); |
6802 | 6797 |
6803 return RawResource::fetchSynchronously(fetchRequest, document->fetcher()); | 6798 return RawResource::fetchSynchronously(fetchRequest, document->fetcher()); |
6804 } | 6799 } |
6805 | 6800 |
6806 TEST_P(ParameterizedWebFrameTest, ManifestFetch) | 6801 TEST_P(ParameterizedWebFrameTest, ManifestFetch) |
6807 { | 6802 { |
6808 registerMockedHttpURLLoad("foo.html"); | 6803 registerMockedHttpURLLoad("foo.html"); |
6809 registerMockedHttpURLLoad("link-manifest-fetch.json"); | 6804 registerMockedHttpURLLoad("link-manifest-fetch.json"); |
6810 | 6805 |
6811 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6806 FrameTestHelpers::WebViewHelper webViewHelper(this); |
6812 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 6807 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
6813 Document* document = toWebLocalFrameImpl(webViewHelper.webViewImpl()->mainFr
ame())->frame()->document(); | 6808 Document* document = toWebLocalFrameImpl(webViewHelper.webViewImpl()->mainFr
ame())->frame()->document(); |
6814 | 6809 |
6815 RawPtr<Resource> resource = fetchManifest(document, toKURL(m_baseURL + "link
-manifest-fetch.json")); | 6810 Resource* resource = fetchManifest(document, toKURL(m_baseURL + "link-manife
st-fetch.json")); |
6816 | 6811 |
6817 EXPECT_TRUE(resource->isLoaded()); | 6812 EXPECT_TRUE(resource->isLoaded()); |
6818 } | 6813 } |
6819 | 6814 |
6820 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchAllow) | 6815 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchAllow) |
6821 { | 6816 { |
6822 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f
etch.json"), "link-manifest-fetch.json"); | 6817 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f
etch.json"), "link-manifest-fetch.json"); |
6823 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src *"); | 6818 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src *"); |
6824 | 6819 |
6825 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6820 FrameTestHelpers::WebViewHelper webViewHelper(this); |
6826 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 6821 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
6827 Document* document = toWebLocalFrameImpl(webViewHelper.webViewImpl()->mainFr
ame())->frame()->document(); | 6822 Document* document = toWebLocalFrameImpl(webViewHelper.webViewImpl()->mainFr
ame())->frame()->document(); |
6828 | 6823 |
6829 RawPtr<Resource> resource = fetchManifest(document, toKURL(m_notBaseURL + "l
ink-manifest-fetch.json")); | 6824 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man
ifest-fetch.json")); |
6830 | 6825 |
6831 EXPECT_TRUE(resource->isLoaded()); | 6826 EXPECT_TRUE(resource->isLoaded()); |
6832 } | 6827 } |
6833 | 6828 |
6834 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelf) | 6829 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelf) |
6835 { | 6830 { |
6836 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f
etch.json"), "link-manifest-fetch.json"); | 6831 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f
etch.json"), "link-manifest-fetch.json"); |
6837 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'"); | 6832 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'"); |
6838 | 6833 |
6839 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6834 FrameTestHelpers::WebViewHelper webViewHelper(this); |
6840 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 6835 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
6841 Document* document = toWebLocalFrameImpl(webViewHelper.webViewImpl()->mainFr
ame())->frame()->document(); | 6836 Document* document = toWebLocalFrameImpl(webViewHelper.webViewImpl()->mainFr
ame())->frame()->document(); |
6842 | 6837 |
6843 RawPtr<Resource> resource = fetchManifest(document, toKURL(m_notBaseURL + "l
ink-manifest-fetch.json")); | 6838 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man
ifest-fetch.json")); |
6844 | 6839 |
6845 EXPECT_EQ(0, resource.get()); // Fetching resource wasn't allowed. | 6840 EXPECT_EQ(0, resource); // Fetching resource wasn't allowed. |
6846 } | 6841 } |
6847 | 6842 |
6848 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelfReportOnly) | 6843 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelfReportOnly) |
6849 { | 6844 { |
6850 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f
etch.json"), "link-manifest-fetch.json"); | 6845 URLTestHelpers::registerMockedURLLoad(toKURL(m_notBaseURL + "link-manifest-f
etch.json"), "link-manifest-fetch.json"); |
6851 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'", /* repor
t only */ true); | 6846 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'", /* repor
t only */ true); |
6852 | 6847 |
6853 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6848 FrameTestHelpers::WebViewHelper webViewHelper(this); |
6854 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 6849 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
6855 Document* document = toWebLocalFrameImpl(webViewHelper.webViewImpl()->mainFr
ame())->frame()->document(); | 6850 Document* document = toWebLocalFrameImpl(webViewHelper.webViewImpl()->mainFr
ame())->frame()->document(); |
6856 | 6851 |
6857 RawPtr<Resource> resource = fetchManifest(document, toKURL(m_notBaseURL + "l
ink-manifest-fetch.json")); | 6852 Resource* resource = fetchManifest(document, toKURL(m_notBaseURL + "link-man
ifest-fetch.json")); |
6858 | 6853 |
6859 EXPECT_TRUE(resource->isLoaded()); | 6854 EXPECT_TRUE(resource->isLoaded()); |
6860 } | 6855 } |
6861 | 6856 |
6862 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) | 6857 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) |
6863 { | 6858 { |
6864 // Check that a reload ignoring cache on a frame will result in the cache | 6859 // Check that a reload ignoring cache on a frame will result in the cache |
6865 // policy of the request being set to ReloadBypassingCache. | 6860 // policy of the request being set to ReloadBypassingCache. |
6866 registerMockedHttpURLLoad("foo.html"); | 6861 registerMockedHttpURLLoad("foo.html"); |
6867 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6862 FrameTestHelpers::WebViewHelper webViewHelper(this); |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7617 ASSERT_TRUE(mainFrame()->firstChild()->isWebRemoteFrame()); | 7612 ASSERT_TRUE(mainFrame()->firstChild()->isWebRemoteFrame()); |
7618 LocalDOMWindow* mainWindow = toWebLocalFrameImpl(mainFrame())->frame()->loca
lDOMWindow(); | 7613 LocalDOMWindow* mainWindow = toWebLocalFrameImpl(mainFrame())->frame()->loca
lDOMWindow(); |
7619 | 7614 |
7620 KURL destination = toKURL("data:text/html:destination"); | 7615 KURL destination = toKURL("data:text/html:destination"); |
7621 mainWindow->open(destination.getString(), "frame1", "", mainWindow, mainWind
ow); | 7616 mainWindow->open(destination.getString(), "frame1", "", mainWindow, mainWind
ow); |
7622 ASSERT_FALSE(remoteClient.lastRequest().isNull()); | 7617 ASSERT_FALSE(remoteClient.lastRequest().isNull()); |
7623 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); | 7618 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); |
7624 | 7619 |
7625 // Pointing a named frame to an empty URL should just return a reference to | 7620 // Pointing a named frame to an empty URL should just return a reference to |
7626 // the frame's window without navigating it. | 7621 // the frame's window without navigating it. |
7627 RawPtr<DOMWindow> result = mainWindow->open("", "frame1", "", mainWindow, ma
inWindow); | 7622 DOMWindow* result = mainWindow->open("", "frame1", "", mainWindow, mainWindo
w); |
7628 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); | 7623 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); |
7629 EXPECT_EQ(result, remoteFrame->toImplBase()->frame()->domWindow()); | 7624 EXPECT_EQ(result, remoteFrame->toImplBase()->frame()->domWindow()); |
7630 | 7625 |
7631 reset(); | 7626 reset(); |
7632 } | 7627 } |
7633 | 7628 |
7634 class RemoteWindowCloseClient : public FrameTestHelpers::TestWebViewClient { | 7629 class RemoteWindowCloseClient : public FrameTestHelpers::TestWebViewClient { |
7635 public: | 7630 public: |
7636 RemoteWindowCloseClient() | 7631 RemoteWindowCloseClient() |
7637 : m_closed(false) | 7632 : m_closed(false) |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7814 { | 7809 { |
7815 FrameTestHelpers::WebViewHelper webViewHelper(this); | 7810 FrameTestHelpers::WebViewHelper webViewHelper(this); |
7816 webViewHelper.initializeAndLoad("about:blank"); | 7811 webViewHelper.initializeAndLoad("about:blank"); |
7817 | 7812 |
7818 SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); | 7813 SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); |
7819 | 7814 |
7820 // Cross-origin request. | 7815 // Cross-origin request. |
7821 KURL resourceUrl(ParsedURLString, "chrome://test.pdf"); | 7816 KURL resourceUrl(ParsedURLString, "chrome://test.pdf"); |
7822 registerMockedChromeURLLoad("test.pdf"); | 7817 registerMockedChromeURLLoad("test.pdf"); |
7823 | 7818 |
7824 RawPtr<LocalFrame> frame(toLocalFrame(webViewHelper.webViewImpl()->page()->m
ainFrame())); | 7819 LocalFrame* frame(toLocalFrame(webViewHelper.webViewImpl()->page()->mainFram
e())); |
7825 | 7820 |
7826 MockDocumentThreadableLoaderClient client; | 7821 MockDocumentThreadableLoaderClient client; |
7827 ThreadableLoaderOptions options; | 7822 ThreadableLoaderOptions options; |
7828 | 7823 |
7829 // First try to load the request with regular access. Should fail. | 7824 // First try to load the request with regular access. Should fail. |
7830 options.crossOriginRequestPolicy = UseAccessControl; | 7825 options.crossOriginRequestPolicy = UseAccessControl; |
7831 ResourceLoaderOptions resourceLoaderOptions; | 7826 ResourceLoaderOptions resourceLoaderOptions; |
7832 DocumentThreadableLoader::loadResourceSynchronously( | 7827 DocumentThreadableLoader::loadResourceSynchronously( |
7833 *frame->document(), ResourceRequest(resourceUrl), client, options, resou
rceLoaderOptions); | 7828 *frame->document(), ResourceRequest(resourceUrl), client, options, resou
rceLoaderOptions); |
7834 EXPECT_TRUE(client.failed()); | 7829 EXPECT_TRUE(client.failed()); |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8559 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); | 8554 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); |
8560 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 8555 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
8561 mainFrame->executeScript(WebScriptSource("hello = 'world';")); | 8556 mainFrame->executeScript(WebScriptSource("hello = 'world';")); |
8562 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); | 8557 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); |
8563 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri
ptSource("hello")); | 8558 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri
ptSource("hello")); |
8564 ASSERT_TRUE(result->IsString()); | 8559 ASSERT_TRUE(result->IsString()); |
8565 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC
ontext()).ToLocalChecked())); | 8560 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC
ontext()).ToLocalChecked())); |
8566 } | 8561 } |
8567 | 8562 |
8568 } // namespace blink | 8563 } // namespace blink |
OLD | NEW |