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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 runPendingTasks(); | 346 runPendingTasks(); |
347 webViewHelper.webView()->layout(); | 347 webViewHelper.webView()->layout(); |
348 | 348 |
349 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); | 349 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); |
350 EXPECT_EQ("http://www.test.com:0/" + fileName, content); | 350 EXPECT_EQ("http://www.test.com:0/" + fileName, content); |
351 } | 351 } |
352 | 352 |
353 class CSSCallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 353 class CSSCallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
354 public: | 354 public: |
355 CSSCallbackWebFrameClient() : m_updateCount(0) { } | 355 CSSCallbackWebFrameClient() : m_updateCount(0) { } |
356 virtual void didMatchCSS(WebFrame*, const WebVector<WebString>& newlyMatchin
gSelectors, const WebVector<WebString>& stoppedMatchingSelectors) OVERRIDE; | 356 virtual void didMatchCSS(WebLocalFrame*, const WebVector<WebString>& newlyMa
tchingSelectors, const WebVector<WebString>& stoppedMatchingSelectors) OVERRIDE; |
357 | 357 |
358 std::map<WebFrame*, std::set<std::string> > m_matchedSelectors; | 358 std::map<WebLocalFrame*, std::set<std::string> > m_matchedSelectors; |
359 int m_updateCount; | 359 int m_updateCount; |
360 }; | 360 }; |
361 | 361 |
362 void CSSCallbackWebFrameClient::didMatchCSS(WebFrame* frame, const WebVector<Web
String>& newlyMatchingSelectors, const WebVector<WebString>& stoppedMatchingSele
ctors) | 362 void CSSCallbackWebFrameClient::didMatchCSS(WebLocalFrame* frame, const WebVecto
r<WebString>& newlyMatchingSelectors, const WebVector<WebString>& stoppedMatchin
gSelectors) |
363 { | 363 { |
364 ++m_updateCount; | 364 ++m_updateCount; |
365 std::set<std::string>& frameSelectors = m_matchedSelectors[frame]; | 365 std::set<std::string>& frameSelectors = m_matchedSelectors[frame]; |
366 for (size_t i = 0; i < newlyMatchingSelectors.size(); ++i) { | 366 for (size_t i = 0; i < newlyMatchingSelectors.size(); ++i) { |
367 std::string selector = newlyMatchingSelectors[i].utf8(); | 367 std::string selector = newlyMatchingSelectors[i].utf8(); |
368 EXPECT_EQ(0U, frameSelectors.count(selector)) << selector; | 368 EXPECT_EQ(0U, frameSelectors.count(selector)) << selector; |
369 frameSelectors.insert(selector); | 369 frameSelectors.insert(selector); |
370 } | 370 } |
371 for (size_t i = 0; i < stoppedMatchingSelectors.size(); ++i) { | 371 for (size_t i = 0; i < stoppedMatchingSelectors.size(); ++i) { |
372 std::string selector = stoppedMatchingSelectors[i].utf8(); | 372 std::string selector = stoppedMatchingSelectors[i].utf8(); |
373 EXPECT_EQ(1U, frameSelectors.count(selector)) << selector; | 373 EXPECT_EQ(1U, frameSelectors.count(selector)) << selector; |
374 frameSelectors.erase(selector); | 374 frameSelectors.erase(selector); |
375 } | 375 } |
376 } | 376 } |
377 | 377 |
378 class WebFrameCSSCallbackTest : public testing::Test { | 378 class WebFrameCSSCallbackTest : public testing::Test { |
379 protected: | 379 protected: |
380 WebFrameCSSCallbackTest() | 380 WebFrameCSSCallbackTest() |
381 { | 381 { |
382 | 382 |
383 m_frame = m_helper.initializeAndLoad("about:blank", true, &m_client)->ma
inFrame(); | 383 m_frame = m_helper.initializeAndLoad("about:blank", true, &m_client)->ma
inFrame()->toWebLocalFrame(); |
384 } | 384 } |
385 | 385 |
386 ~WebFrameCSSCallbackTest() | 386 ~WebFrameCSSCallbackTest() |
387 { | 387 { |
388 EXPECT_EQ(1U, m_client.m_matchedSelectors.size()); | 388 EXPECT_EQ(1U, m_client.m_matchedSelectors.size()); |
389 } | 389 } |
390 | 390 |
391 WebDocument doc() const | 391 WebDocument doc() const |
392 { | 392 { |
393 return m_frame->document(); | 393 return m_frame->document(); |
(...skipping 17 matching lines...) Expand all Loading... |
411 | 411 |
412 void executeScript(const WebString& code) | 412 void executeScript(const WebString& code) |
413 { | 413 { |
414 m_frame->executeScript(WebScriptSource(code)); | 414 m_frame->executeScript(WebScriptSource(code)); |
415 m_frame->view()->layout(); | 415 m_frame->view()->layout(); |
416 runPendingTasks(); | 416 runPendingTasks(); |
417 } | 417 } |
418 | 418 |
419 CSSCallbackWebFrameClient m_client; | 419 CSSCallbackWebFrameClient m_client; |
420 FrameTestHelpers::WebViewHelper m_helper; | 420 FrameTestHelpers::WebViewHelper m_helper; |
421 WebFrame* m_frame; | 421 WebLocalFrame* m_frame; |
422 }; | 422 }; |
423 | 423 |
424 TEST_F(WebFrameCSSCallbackTest, AuthorStyleSheet) | 424 TEST_F(WebFrameCSSCallbackTest, AuthorStyleSheet) |
425 { | 425 { |
426 loadHTML( | 426 loadHTML( |
427 "<style>" | 427 "<style>" |
428 // This stylesheet checks that the internal property and value can't be | 428 // This stylesheet checks that the internal property and value can't be |
429 // set by a stylesheet, only WebDocument::watchCSSSelectors(). | 429 // set by a stylesheet, only WebDocument::watchCSSSelectors(). |
430 "div.initial_on { -internal-callback: none; }" | 430 "div.initial_on { -internal-callback: none; }" |
431 "div.initial_off { -internal-callback: -internal-presence; }" | 431 "div.initial_off { -internal-callback: -internal-presence; }" |
(...skipping 2226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2658 // Move focus back to the first edit box. | 2658 // Move focus back to the first edit box. |
2659 webViewHelper.webView()->advanceFocus(true); | 2659 webViewHelper.webView()->advanceFocus(true); |
2660 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); | 2660 webViewHelper.webViewImpl()->computeScaleAndScrollForFocusedNode(webViewHelp
er.webViewImpl()->focusedElement(), scale, scroll, needAnimation); |
2661 // The position should have stayed the same since this box was already on sc
reen with the right scale. | 2661 // The position should have stayed the same since this box was already on sc
reen with the right scale. |
2662 EXPECT_FALSE(needAnimation); | 2662 EXPECT_FALSE(needAnimation); |
2663 } | 2663 } |
2664 | 2664 |
2665 class TestReloadDoesntRedirectWebFrameClient : public FrameTestHelpers::TestWebF
rameClient { | 2665 class TestReloadDoesntRedirectWebFrameClient : public FrameTestHelpers::TestWebF
rameClient { |
2666 public: | 2666 public: |
2667 virtual WebNavigationPolicy decidePolicyForNavigation( | 2667 virtual WebNavigationPolicy decidePolicyForNavigation( |
2668 WebFrame*, WebDataSource::ExtraData*, const WebURLRequest&, WebNavigatio
nType, | 2668 WebLocalFrame*, WebDataSource::ExtraData*, const WebURLRequest&, WebNavi
gationType, |
2669 WebNavigationPolicy defaultPolicy, bool isRedirect) OVERRIDE | 2669 WebNavigationPolicy defaultPolicy, bool isRedirect) OVERRIDE |
2670 { | 2670 { |
2671 EXPECT_FALSE(isRedirect); | 2671 EXPECT_FALSE(isRedirect); |
2672 return WebNavigationPolicyCurrentTab; | 2672 return WebNavigationPolicyCurrentTab; |
2673 } | 2673 } |
2674 }; | 2674 }; |
2675 | 2675 |
2676 TEST_F(WebFrameTest, ReloadDoesntSetRedirect) | 2676 TEST_F(WebFrameTest, ReloadDoesntSetRedirect) |
2677 { | 2677 { |
2678 // Test for case in http://crbug.com/73104. Reloading a frame very quickly | 2678 // Test for case in http://crbug.com/73104. Reloading a frame very quickly |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2796 // Now retrieve the FocusedNode and test it should be null. | 2796 // Now retrieve the FocusedNode and test it should be null. |
2797 EXPECT_EQ(0, webViewHelper.webViewImpl()->focusedElement()); | 2797 EXPECT_EQ(0, webViewHelper.webViewImpl()->focusedElement()); |
2798 } | 2798 } |
2799 | 2799 |
2800 // Implementation of WebFrameClient that tracks the v8 contexts that are created | 2800 // Implementation of WebFrameClient that tracks the v8 contexts that are created |
2801 // and destroyed for verification. | 2801 // and destroyed for verification. |
2802 class ContextLifetimeTestWebFrameClient : public FrameTestHelpers::TestWebFrameC
lient { | 2802 class ContextLifetimeTestWebFrameClient : public FrameTestHelpers::TestWebFrameC
lient { |
2803 public: | 2803 public: |
2804 struct Notification { | 2804 struct Notification { |
2805 public: | 2805 public: |
2806 Notification(WebFrame* frame, v8::Handle<v8::Context> context, int world
Id) | 2806 Notification(WebLocalFrame* frame, v8::Handle<v8::Context> context, int
worldId) |
2807 : frame(frame) | 2807 : frame(frame) |
2808 , context(context->GetIsolate(), context) | 2808 , context(context->GetIsolate(), context) |
2809 , worldId(worldId) | 2809 , worldId(worldId) |
2810 { | 2810 { |
2811 } | 2811 } |
2812 | 2812 |
2813 ~Notification() | 2813 ~Notification() |
2814 { | 2814 { |
2815 context.Reset(); | 2815 context.Reset(); |
2816 } | 2816 } |
2817 | 2817 |
2818 bool Equals(Notification* other) | 2818 bool Equals(Notification* other) |
2819 { | 2819 { |
2820 return other && frame == other->frame && context == other->context &
& worldId == other->worldId; | 2820 return other && frame == other->frame && context == other->context &
& worldId == other->worldId; |
2821 } | 2821 } |
2822 | 2822 |
2823 WebFrame* frame; | 2823 WebLocalFrame* frame; |
2824 v8::Persistent<v8::Context> context; | 2824 v8::Persistent<v8::Context> context; |
2825 int worldId; | 2825 int worldId; |
2826 }; | 2826 }; |
2827 | 2827 |
2828 virtual ~ContextLifetimeTestWebFrameClient() | 2828 virtual ~ContextLifetimeTestWebFrameClient() |
2829 { | 2829 { |
2830 reset(); | 2830 reset(); |
2831 } | 2831 } |
2832 | 2832 |
2833 void reset() | 2833 void reset() |
2834 { | 2834 { |
2835 for (size_t i = 0; i < createNotifications.size(); ++i) | 2835 for (size_t i = 0; i < createNotifications.size(); ++i) |
2836 delete createNotifications[i]; | 2836 delete createNotifications[i]; |
2837 | 2837 |
2838 for (size_t i = 0; i < releaseNotifications.size(); ++i) | 2838 for (size_t i = 0; i < releaseNotifications.size(); ++i) |
2839 delete releaseNotifications[i]; | 2839 delete releaseNotifications[i]; |
2840 | 2840 |
2841 createNotifications.clear(); | 2841 createNotifications.clear(); |
2842 releaseNotifications.clear(); | 2842 releaseNotifications.clear(); |
2843 } | 2843 } |
2844 | 2844 |
2845 std::vector<Notification*> createNotifications; | 2845 std::vector<Notification*> createNotifications; |
2846 std::vector<Notification*> releaseNotifications; | 2846 std::vector<Notification*> releaseNotifications; |
2847 | 2847 |
2848 private: | 2848 private: |
2849 virtual void didCreateScriptContext(WebFrame* frame, v8::Handle<v8::Context>
context, int extensionGroup, int worldId) OVERRIDE | 2849 virtual void didCreateScriptContext(WebLocalFrame* frame, v8::Handle<v8::Con
text> context, int extensionGroup, int worldId) OVERRIDE |
2850 { | 2850 { |
2851 createNotifications.push_back(new Notification(frame, context, worldId))
; | 2851 createNotifications.push_back(new Notification(frame, context, worldId))
; |
2852 } | 2852 } |
2853 | 2853 |
2854 virtual void willReleaseScriptContext(WebFrame* frame, v8::Handle<v8::Contex
t> context, int worldId) OVERRIDE | 2854 virtual void willReleaseScriptContext(WebLocalFrame* frame, v8::Handle<v8::C
ontext> context, int worldId) OVERRIDE |
2855 { | 2855 { |
2856 releaseNotifications.push_back(new Notification(frame, context, worldId)
); | 2856 releaseNotifications.push_back(new Notification(frame, context, worldId)
); |
2857 } | 2857 } |
2858 }; | 2858 }; |
2859 | 2859 |
2860 // TODO(aa): Deflake this test. | 2860 // TODO(aa): Deflake this test. |
2861 TEST_F(WebFrameTest, FLAKY_ContextNotificationsLoadUnload) | 2861 TEST_F(WebFrameTest, FLAKY_ContextNotificationsLoadUnload) |
2862 { | 2862 { |
2863 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 2863 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
2864 | 2864 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3113 frame->executeCommand(WebString::fromUTF8("SelectAll")); | 3113 frame->executeCommand(WebString::fromUTF8("SelectAll")); |
3114 EXPECT_TRUE(frame->hasSelection()); | 3114 EXPECT_TRUE(frame->hasSelection()); |
3115 frame->executeCommand(WebString::fromUTF8("Unselect")); | 3115 frame->executeCommand(WebString::fromUTF8("Unselect")); |
3116 EXPECT_FALSE(frame->hasSelection()); | 3116 EXPECT_FALSE(frame->hasSelection()); |
3117 WebString selectionHtml = frame->selectionAsMarkup(); | 3117 WebString selectionHtml = frame->selectionAsMarkup(); |
3118 EXPECT_TRUE(selectionHtml.isEmpty()); | 3118 EXPECT_TRUE(selectionHtml.isEmpty()); |
3119 } | 3119 } |
3120 | 3120 |
3121 class TestExecuteScriptDuringDidCreateScriptContext : public FrameTestHelpers::T
estWebFrameClient { | 3121 class TestExecuteScriptDuringDidCreateScriptContext : public FrameTestHelpers::T
estWebFrameClient { |
3122 public: | 3122 public: |
3123 virtual void didCreateScriptContext(WebFrame* frame, v8::Handle<v8::Context>
context, int extensionGroup, int worldId) OVERRIDE | 3123 virtual void didCreateScriptContext(WebLocalFrame* frame, v8::Handle<v8::Con
text> context, int extensionGroup, int worldId) OVERRIDE |
3124 { | 3124 { |
3125 frame->executeScript(WebScriptSource("window.history = 'replaced';")); | 3125 frame->executeScript(WebScriptSource("window.history = 'replaced';")); |
3126 } | 3126 } |
3127 }; | 3127 }; |
3128 | 3128 |
3129 TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext) | 3129 TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext) |
3130 { | 3130 { |
3131 registerMockedHttpURLLoad("hello_world.html"); | 3131 registerMockedHttpURLLoad("hello_world.html"); |
3132 | 3132 |
3133 TestExecuteScriptDuringDidCreateScriptContext webFrameClient; | 3133 TestExecuteScriptDuringDidCreateScriptContext webFrameClient; |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4060 EXPECT_FALSE(client.triggered()); | 4060 EXPECT_FALSE(client.triggered()); |
4061 } | 4061 } |
4062 | 4062 |
4063 class TestSubstituteDataWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { | 4063 class TestSubstituteDataWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { |
4064 public: | 4064 public: |
4065 TestSubstituteDataWebFrameClient() | 4065 TestSubstituteDataWebFrameClient() |
4066 : m_commitCalled(false) | 4066 : m_commitCalled(false) |
4067 { | 4067 { |
4068 } | 4068 } |
4069 | 4069 |
4070 virtual void didFailProvisionalLoad(WebFrame* frame, const WebURLError& erro
r) | 4070 virtual void didFailProvisionalLoad(WebLocalFrame* frame, const WebURLError&
error) |
4071 { | 4071 { |
4072 frame->loadHTMLString("This should appear", toKURL("data:text/html,chrom
ewebdata"), error.unreachableURL, true); | 4072 frame->loadHTMLString("This should appear", toKURL("data:text/html,chrom
ewebdata"), error.unreachableURL, true); |
4073 runPendingTasks(); | 4073 runPendingTasks(); |
4074 } | 4074 } |
4075 | 4075 |
4076 virtual void didCommitProvisionalLoad(WebFrame* frame, bool) | 4076 virtual void didCommitProvisionalLoad(WebLocalFrame* frame, bool) |
4077 { | 4077 { |
4078 if (frame->dataSource()->response().url() != WebURL(URLTestHelpers::toKU
RL("about:blank"))) | 4078 if (frame->dataSource()->response().url() != WebURL(URLTestHelpers::toKU
RL("about:blank"))) |
4079 m_commitCalled = true; | 4079 m_commitCalled = true; |
4080 } | 4080 } |
4081 | 4081 |
4082 bool commitCalled() const { return m_commitCalled; } | 4082 bool commitCalled() const { return m_commitCalled; } |
4083 | 4083 |
4084 private: | 4084 private: |
4085 bool m_commitCalled; | 4085 bool m_commitCalled; |
4086 }; | 4086 }; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4118 EXPECT_EQ("This should appear", text.utf8()); | 4118 EXPECT_EQ("This should appear", text.utf8()); |
4119 EXPECT_TRUE(webFrameClient.commitCalled()); | 4119 EXPECT_TRUE(webFrameClient.commitCalled()); |
4120 } | 4120 } |
4121 | 4121 |
4122 class TestWillInsertBodyWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { | 4122 class TestWillInsertBodyWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { |
4123 public: | 4123 public: |
4124 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) | 4124 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) |
4125 { | 4125 { |
4126 } | 4126 } |
4127 | 4127 |
4128 virtual void didCommitProvisionalLoad(WebFrame*, bool) OVERRIDE | 4128 virtual void didCommitProvisionalLoad(WebLocalFrame*, bool) OVERRIDE |
4129 { | 4129 { |
4130 m_numBodies = 0; | 4130 m_numBodies = 0; |
4131 m_didLoad = true; | 4131 m_didLoad = true; |
4132 } | 4132 } |
4133 | 4133 |
4134 virtual void didCreateDocumentElement(WebFrame*) OVERRIDE | 4134 virtual void didCreateDocumentElement(WebLocalFrame*) OVERRIDE |
4135 { | 4135 { |
4136 EXPECT_EQ(0, m_numBodies); | 4136 EXPECT_EQ(0, m_numBodies); |
4137 } | 4137 } |
4138 | 4138 |
4139 virtual void willInsertBody(WebFrame*) OVERRIDE | 4139 virtual void willInsertBody(WebLocalFrame*) OVERRIDE |
4140 { | 4140 { |
4141 m_numBodies++; | 4141 m_numBodies++; |
4142 } | 4142 } |
4143 | 4143 |
4144 int m_numBodies; | 4144 int m_numBodies; |
4145 bool m_didLoad; | 4145 bool m_didLoad; |
4146 }; | 4146 }; |
4147 | 4147 |
4148 TEST_F(WebFrameTest, HTMLDocument) | 4148 TEST_F(WebFrameTest, HTMLDocument) |
4149 { | 4149 { |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4454 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0])
; | 4454 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0])
; |
4455 EXPECT_EQ(DocumentMarker::InvisibleSpellcheck, document->markers().markers()
[0]->type()); | 4455 EXPECT_EQ(DocumentMarker::InvisibleSpellcheck, document->markers().markers()
[0]->type()); |
4456 } | 4456 } |
4457 | 4457 |
4458 class TestAccessInitialDocumentWebFrameClient : public FrameTestHelpers::TestWeb
FrameClient { | 4458 class TestAccessInitialDocumentWebFrameClient : public FrameTestHelpers::TestWeb
FrameClient { |
4459 public: | 4459 public: |
4460 TestAccessInitialDocumentWebFrameClient() : m_didAccessInitialDocument(false
) | 4460 TestAccessInitialDocumentWebFrameClient() : m_didAccessInitialDocument(false
) |
4461 { | 4461 { |
4462 } | 4462 } |
4463 | 4463 |
4464 virtual void didAccessInitialDocument(WebFrame* frame) | 4464 virtual void didAccessInitialDocument(WebLocalFrame* frame) |
4465 { | 4465 { |
4466 EXPECT_TRUE(!m_didAccessInitialDocument); | 4466 EXPECT_TRUE(!m_didAccessInitialDocument); |
4467 m_didAccessInitialDocument = true; | 4467 m_didAccessInitialDocument = true; |
4468 } | 4468 } |
4469 | 4469 |
4470 bool m_didAccessInitialDocument; | 4470 bool m_didAccessInitialDocument; |
4471 }; | 4471 }; |
4472 | 4472 |
4473 TEST_F(WebFrameTest, DidAccessInitialDocumentBody) | 4473 TEST_F(WebFrameTest, DidAccessInitialDocumentBody) |
4474 { | 4474 { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4612 TestMainFrameUserOrProgrammaticScrollFrameClient() { reset(); } | 4612 TestMainFrameUserOrProgrammaticScrollFrameClient() { reset(); } |
4613 void reset() | 4613 void reset() |
4614 { | 4614 { |
4615 m_didScrollMainFrame = false; | 4615 m_didScrollMainFrame = false; |
4616 m_wasProgrammaticScroll = false; | 4616 m_wasProgrammaticScroll = false; |
4617 } | 4617 } |
4618 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat
icScroll; } | 4618 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat
icScroll; } |
4619 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro
grammaticScroll; } | 4619 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro
grammaticScroll; } |
4620 | 4620 |
4621 // WebFrameClient: | 4621 // WebFrameClient: |
4622 virtual void didChangeScrollOffset(WebFrame* frame) OVERRIDE | 4622 virtual void didChangeScrollOffset(WebLocalFrame* frame) OVERRIDE |
4623 { | 4623 { |
4624 if (frame->parent()) | 4624 if (frame->parent()) |
4625 return; | 4625 return; |
4626 EXPECT_FALSE(m_didScrollMainFrame); | 4626 EXPECT_FALSE(m_didScrollMainFrame); |
4627 WebCore::FrameView* view = toWebFrameImpl(frame)->frameView(); | 4627 WebCore::FrameView* view = toWebFrameImpl(frame)->frameView(); |
4628 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect | 4628 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect |
4629 // which is called from LocalFrame::createView (before the frame is asso
ciated | 4629 // which is called from LocalFrame::createView (before the frame is asso
ciated |
4630 // with the the view). | 4630 // with the the view). |
4631 if (view) { | 4631 if (view) { |
4632 m_didScrollMainFrame = true; | 4632 m_didScrollMainFrame = true; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4735 Platform::current()->unitTestSupport()->registerMockedURL(redirectURL, final
Response, filePath); | 4735 Platform::current()->unitTestSupport()->registerMockedURL(redirectURL, final
Response, filePath); |
4736 | 4736 |
4737 FrameTestHelpers::WebViewHelper webViewHelper; | 4737 FrameTestHelpers::WebViewHelper webViewHelper; |
4738 webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", tru
e); | 4738 webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", tru
e); |
4739 EXPECT_TRUE(webViewHelper.webView()->mainFrame()->document().firstPartyForCo
okies() == redirectURL); | 4739 EXPECT_TRUE(webViewHelper.webView()->mainFrame()->document().firstPartyForCo
okies() == redirectURL); |
4740 } | 4740 } |
4741 | 4741 |
4742 class TestNavigationPolicyWebFrameClient : public FrameTestHelpers::TestWebFrame
Client { | 4742 class TestNavigationPolicyWebFrameClient : public FrameTestHelpers::TestWebFrame
Client { |
4743 public: | 4743 public: |
4744 | 4744 |
4745 virtual void didNavigateWithinPage(WebFrame*, bool) | 4745 virtual void didNavigateWithinPage(WebLocalFrame*, bool) |
4746 { | 4746 { |
4747 EXPECT_TRUE(false); | 4747 EXPECT_TRUE(false); |
4748 } | 4748 } |
4749 }; | 4749 }; |
4750 | 4750 |
4751 TEST_F(WebFrameTest, SimulateFragmentAnchorMiddleClick) | 4751 TEST_F(WebFrameTest, SimulateFragmentAnchorMiddleClick) |
4752 { | 4752 { |
4753 registerMockedHttpURLLoad("fragment_middle_click.html"); | 4753 registerMockedHttpURLLoad("fragment_middle_click.html"); |
4754 TestNavigationPolicyWebFrameClient client; | 4754 TestNavigationPolicyWebFrameClient client; |
4755 FrameTestHelpers::WebViewHelper webViewHelper; | 4755 FrameTestHelpers::WebViewHelper webViewHelper; |
4756 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue, &client); | 4756 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue, &client); |
4757 | 4757 |
4758 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); | 4758 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); |
4759 WebCore::KURL destination = document->url(); | 4759 WebCore::KURL destination = document->url(); |
4760 destination.setFragmentIdentifier("test"); | 4760 destination.setFragmentIdentifier("test"); |
4761 | 4761 |
4762 RefPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCore::EventTyp
eNames::click, false, false, | 4762 RefPtr<WebCore::Event> event = WebCore::MouseEvent::create(WebCore::EventTyp
eNames::click, false, false, |
4763 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false,
1, nullptr, nullptr); | 4763 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, false, false, false, false,
1, nullptr, nullptr); |
4764 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de
stination)); | 4764 WebCore::FrameLoadRequest frameRequest(document, WebCore::ResourceRequest(de
stination)); |
4765 frameRequest.setTriggeringEvent(event); | 4765 frameRequest.setTriggeringEvent(event); |
4766 webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest
); | 4766 webViewHelper.webViewImpl()->page()->mainFrame()->loader().load(frameRequest
); |
4767 } | 4767 } |
4768 | 4768 |
4769 class TestNewWindowWebViewClient : public WebViewClient { | 4769 class TestNewWindowWebViewClient : public WebViewClient { |
4770 public: | 4770 public: |
4771 virtual WebView* createView(WebFrame*, const WebURLRequest&, const WebWindow
Features&, | 4771 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW
indowFeatures&, |
4772 const WebString&, WebNavigationPolicy, bool) OVERRIDE | 4772 const WebString&, WebNavigationPolicy, bool) OVERRIDE |
4773 { | 4773 { |
4774 EXPECT_TRUE(false); | 4774 EXPECT_TRUE(false); |
4775 return 0; | 4775 return 0; |
4776 } | 4776 } |
4777 }; | 4777 }; |
4778 | 4778 |
4779 class TestNewWindowWebFrameClient : public FrameTestHelpers::TestWebFrameClient
{ | 4779 class TestNewWindowWebFrameClient : public FrameTestHelpers::TestWebFrameClient
{ |
4780 public: | 4780 public: |
4781 TestNewWindowWebFrameClient() | 4781 TestNewWindowWebFrameClient() |
4782 : m_decidePolicyCallCount(0) | 4782 : m_decidePolicyCallCount(0) |
4783 { | 4783 { |
4784 } | 4784 } |
4785 | 4785 |
4786 virtual WebNavigationPolicy decidePolicyForNavigation(WebFrame*, WebDataSour
ce::ExtraData*, const WebURLRequest&, | 4786 virtual WebNavigationPolicy decidePolicyForNavigation(WebLocalFrame*, WebDat
aSource::ExtraData*, const WebURLRequest&, |
4787 WebNavigationType, WebNavigationPolicy policy, bool) OVERRIDE | 4787 WebNavigationType, WebNavigationPolicy policy, bool) OVERRIDE |
4788 { | 4788 { |
4789 m_decidePolicyCallCount++; | 4789 m_decidePolicyCallCount++; |
4790 return policy; | 4790 return policy; |
4791 } | 4791 } |
4792 | 4792 |
4793 int decidePolicyCallCount() const { return m_decidePolicyCallCount; } | 4793 int decidePolicyCallCount() const { return m_decidePolicyCallCount; } |
4794 | 4794 |
4795 private: | 4795 private: |
4796 int m_decidePolicyCallCount; | 4796 int m_decidePolicyCallCount; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4920 , m_willSendRequestCallCount(0) | 4920 , m_willSendRequestCallCount(0) |
4921 , m_childFrameCreationCount(0) | 4921 , m_childFrameCreationCount(0) |
4922 { | 4922 { |
4923 } | 4923 } |
4924 | 4924 |
4925 void setChildWebFrameClient(WebFrameClient* client) { m_client = client; } | 4925 void setChildWebFrameClient(WebFrameClient* client) { m_client = client; } |
4926 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } | 4926 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } |
4927 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } | 4927 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } |
4928 int childFrameCreationCount() const { return m_childFrameCreationCount; } | 4928 int childFrameCreationCount() const { return m_childFrameCreationCount; } |
4929 | 4929 |
4930 virtual WebFrame* createChildFrame(WebFrame* parent, const WebString&) | 4930 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString&) |
4931 { | 4931 { |
4932 m_childFrameCreationCount++; | 4932 m_childFrameCreationCount++; |
4933 WebFrame* frame = WebFrame::create(m_client); | 4933 WebFrame* frame = WebFrame::create(m_client); |
4934 parent->appendChild(frame); | 4934 parent->appendChild(frame); |
4935 return frame; | 4935 return frame; |
4936 } | 4936 } |
4937 | 4937 |
4938 virtual void frameDetached(WebFrame* frame) OVERRIDE | 4938 virtual void frameDetached(WebFrame* frame) OVERRIDE |
4939 { | 4939 { |
4940 if (frame->parent()) | 4940 if (frame->parent()) |
4941 frame->parent()->removeChild(frame); | 4941 frame->parent()->removeChild(frame); |
4942 frame->close(); | 4942 frame->close(); |
4943 } | 4943 } |
4944 | 4944 |
4945 virtual void willSendRequest(WebFrame* frame, unsigned, WebURLRequest& reque
st, const WebURLResponse&) OVERRIDE | 4945 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&
request, const WebURLResponse&) OVERRIDE |
4946 { | 4946 { |
4947 m_policy = request.cachePolicy(); | 4947 m_policy = request.cachePolicy(); |
4948 m_willSendRequestCallCount++; | 4948 m_willSendRequestCallCount++; |
4949 } | 4949 } |
4950 | 4950 |
4951 private: | 4951 private: |
4952 WebURLRequest::CachePolicy m_policy; | 4952 WebURLRequest::CachePolicy m_policy; |
4953 WebFrameClient* m_client; | 4953 WebFrameClient* m_client; |
4954 int m_willSendRequestCallCount; | 4954 int m_willSendRequestCallCount; |
4955 int m_childFrameCreationCount; | 4955 int m_childFrameCreationCount; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5001 EXPECT_EQ(item.urlString().utf8(), m_baseURL + "iframe_reload.html"); | 5001 EXPECT_EQ(item.urlString().utf8(), m_baseURL + "iframe_reload.html"); |
5002 } | 5002 } |
5003 | 5003 |
5004 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie
nt { | 5004 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie
nt { |
5005 public: | 5005 public: |
5006 TestSameDocumentWebFrameClient() | 5006 TestSameDocumentWebFrameClient() |
5007 : m_frameLoadTypeSameSeen(false) | 5007 : m_frameLoadTypeSameSeen(false) |
5008 { | 5008 { |
5009 } | 5009 } |
5010 | 5010 |
5011 virtual void willSendRequest(WebFrame* frame, unsigned, WebURLRequest&, cons
t WebURLResponse&) | 5011 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&,
const WebURLResponse&) |
5012 { | 5012 { |
5013 if (toWebFrameImpl(frame)->frame()->loader().loadType() == WebCore::Fram
eLoadTypeSame) | 5013 if (toWebFrameImpl(frame)->frame()->loader().loadType() == WebCore::Fram
eLoadTypeSame) |
5014 m_frameLoadTypeSameSeen = true; | 5014 m_frameLoadTypeSameSeen = true; |
5015 } | 5015 } |
5016 | 5016 |
5017 bool frameLoadTypeSameSeen() const { return m_frameLoadTypeSameSeen; } | 5017 bool frameLoadTypeSameSeen() const { return m_frameLoadTypeSameSeen; } |
5018 | 5018 |
5019 private: | 5019 private: |
5020 bool m_frameLoadTypeSameSeen; | 5020 bool m_frameLoadTypeSameSeen; |
5021 }; | 5021 }; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5106 EXPECT_EQ(client.differentDocumentStartCount(), 1); | 5106 EXPECT_EQ(client.differentDocumentStartCount(), 1); |
5107 } | 5107 } |
5108 | 5108 |
5109 class TestHistoryWebFrameClient : public WebFrameClient { | 5109 class TestHistoryWebFrameClient : public WebFrameClient { |
5110 public: | 5110 public: |
5111 TestHistoryWebFrameClient() | 5111 TestHistoryWebFrameClient() |
5112 { | 5112 { |
5113 m_replacesCurrentHistoryItem = false; | 5113 m_replacesCurrentHistoryItem = false; |
5114 m_frame = 0; | 5114 m_frame = 0; |
5115 } | 5115 } |
5116 void didStartProvisionalLoad(WebFrame* frame) | 5116 void didStartProvisionalLoad(WebLocalFrame* frame) |
5117 { | 5117 { |
5118 WebDataSource* ds = frame->provisionalDataSource(); | 5118 WebDataSource* ds = frame->provisionalDataSource(); |
5119 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); | 5119 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); |
5120 m_frame = frame; | 5120 m_frame = frame; |
5121 } | 5121 } |
5122 | 5122 |
5123 bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; } | 5123 bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; } |
5124 WebFrame* frame() { return m_frame; } | 5124 WebFrame* frame() { return m_frame; } |
5125 | 5125 |
5126 private: | 5126 private: |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5268 // After commit, there is. | 5268 // After commit, there is. |
5269 WebHistoryItem item = frame->currentHistoryItem(); | 5269 WebHistoryItem item = frame->currentHistoryItem(); |
5270 ASSERT_FALSE(item.isNull()); | 5270 ASSERT_FALSE(item.isNull()); |
5271 EXPECT_EQ(url, item.urlString().utf8()); | 5271 EXPECT_EQ(url, item.urlString().utf8()); |
5272 } | 5272 } |
5273 | 5273 |
5274 class FailCreateChildFrame : public WebFrameClient { | 5274 class FailCreateChildFrame : public WebFrameClient { |
5275 public: | 5275 public: |
5276 FailCreateChildFrame() : m_callCount(0) { } | 5276 FailCreateChildFrame() : m_callCount(0) { } |
5277 | 5277 |
5278 virtual WebFrame* createChildFrame(WebFrame* parent, const WebString& frameN
ame) OVERRIDE | 5278 virtual WebFrame* createChildFrame(WebLocalFrame* parent, const WebString& f
rameName) OVERRIDE |
5279 { | 5279 { |
5280 ++m_callCount; | 5280 ++m_callCount; |
5281 return 0; | 5281 return 0; |
5282 } | 5282 } |
5283 | 5283 |
5284 virtual void frameDetached(WebFrame* frame) OVERRIDE | 5284 virtual void frameDetached(WebFrame* frame) OVERRIDE |
5285 { | 5285 { |
5286 frame->close(); | 5286 frame->close(); |
5287 } | 5287 } |
5288 | 5288 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5482 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); | 5482 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); |
5483 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightInA
nonymous)); | 5483 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightInA
nonymous)); |
5484 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightDir
ectChild)); | 5484 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightDir
ectChild)); |
5485 | 5485 |
5486 WebCore::RenderBlock* anonymousBlock = percentHeightInAnonymous->containingB
lock(); | 5486 WebCore::RenderBlock* anonymousBlock = percentHeightInAnonymous->containingB
lock(); |
5487 EXPECT_TRUE(anonymousBlock->isAnonymous()); | 5487 EXPECT_TRUE(anonymousBlock->isAnonymous()); |
5488 EXPECT_FALSE(anonymousBlock->hasPercentHeightDescendants()); | 5488 EXPECT_FALSE(anonymousBlock->hasPercentHeightDescendants()); |
5489 } | 5489 } |
5490 | 5490 |
5491 } // namespace | 5491 } // namespace |
OLD | NEW |