Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 517043003: Move Frame to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase past r181245 conflict Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/dom/DocumentMarkerController.h" 42 #include "core/dom/DocumentMarkerController.h"
43 #include "core/dom/Fullscreen.h" 43 #include "core/dom/Fullscreen.h"
44 #include "core/dom/NodeRenderStyle.h" 44 #include "core/dom/NodeRenderStyle.h"
45 #include "core/dom/Range.h" 45 #include "core/dom/Range.h"
46 #include "core/editing/Editor.h" 46 #include "core/editing/Editor.h"
47 #include "core/editing/FrameSelection.h" 47 #include "core/editing/FrameSelection.h"
48 #include "core/editing/SpellChecker.h" 48 #include "core/editing/SpellChecker.h"
49 #include "core/editing/VisiblePosition.h" 49 #include "core/editing/VisiblePosition.h"
50 #include "core/events/MouseEvent.h" 50 #include "core/events/MouseEvent.h"
51 #include "core/fetch/MemoryCache.h" 51 #include "core/fetch/MemoryCache.h"
52 #include "core/frame/FrameProtector.h"
52 #include "core/frame/FrameView.h" 53 #include "core/frame/FrameView.h"
53 #include "core/frame/LocalFrame.h" 54 #include "core/frame/LocalFrame.h"
54 #include "core/frame/Settings.h" 55 #include "core/frame/Settings.h"
55 #include "core/html/HTMLDocument.h" 56 #include "core/html/HTMLDocument.h"
56 #include "core/html/HTMLFormElement.h" 57 #include "core/html/HTMLFormElement.h"
57 #include "core/loader/DocumentThreadableLoader.h" 58 #include "core/loader/DocumentThreadableLoader.h"
58 #include "core/loader/DocumentThreadableLoaderClient.h" 59 #include "core/loader/DocumentThreadableLoaderClient.h"
59 #include "core/loader/FrameLoadRequest.h" 60 #include "core/loader/FrameLoadRequest.h"
60 #include "core/loader/ThreadableLoader.h" 61 #include "core/loader/ThreadableLoader.h"
61 #include "core/page/EventHandler.h" 62 #include "core/page/EventHandler.h"
(...skipping 29 matching lines...) Expand all
91 #include "public/web/WebScriptSource.h" 92 #include "public/web/WebScriptSource.h"
92 #include "public/web/WebSearchableFormData.h" 93 #include "public/web/WebSearchableFormData.h"
93 #include "public/web/WebSecurityOrigin.h" 94 #include "public/web/WebSecurityOrigin.h"
94 #include "public/web/WebSecurityPolicy.h" 95 #include "public/web/WebSecurityPolicy.h"
95 #include "public/web/WebSettings.h" 96 #include "public/web/WebSettings.h"
96 #include "public/web/WebSpellCheckClient.h" 97 #include "public/web/WebSpellCheckClient.h"
97 #include "public/web/WebTextCheckingCompletion.h" 98 #include "public/web/WebTextCheckingCompletion.h"
98 #include "public/web/WebTextCheckingResult.h" 99 #include "public/web/WebTextCheckingResult.h"
99 #include "public/web/WebViewClient.h" 100 #include "public/web/WebViewClient.h"
100 #include "web/WebLocalFrameImpl.h" 101 #include "web/WebLocalFrameImpl.h"
102 #include "web/WebRemoteFrameImpl.h"
101 #include "web/WebViewImpl.h" 103 #include "web/WebViewImpl.h"
102 #include "web/tests/FrameTestHelpers.h" 104 #include "web/tests/FrameTestHelpers.h"
103 #include "wtf/Forward.h" 105 #include "wtf/Forward.h"
104 #include "wtf/dtoa/utils.h" 106 #include "wtf/dtoa/utils.h"
105 #include <gmock/gmock.h> 107 #include <gmock/gmock.h>
106 #include <gtest/gtest.h> 108 #include <gtest/gtest.h>
107 #include <map> 109 #include <map>
108 #include <v8.h> 110 #include <v8.h>
109 111
110 using namespace blink; 112 using namespace blink;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 webViewHelper->webView()->settings()->setDefaultFontSize(12); 186 webViewHelper->webView()->settings()->setDefaultFontSize(12);
185 webViewHelper->webView()->resize(WebSize(640, 480)); 187 webViewHelper->webView()->resize(WebSize(640, 480));
186 } 188 }
187 189
188 PassOwnPtr<blink::DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHel per* webViewHelper, const std::string& testcase) 190 PassOwnPtr<blink::DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHel per* webViewHelper, const std::string& testcase)
189 { 191 {
190 registerMockedHttpURLLoad("nodeimage.html"); 192 registerMockedHttpURLLoad("nodeimage.html");
191 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); 193 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html");
192 webViewHelper->webView()->resize(WebSize(640, 480)); 194 webViewHelper->webView()->resize(WebSize(640, 480));
193 webViewHelper->webView()->layout(); 195 webViewHelper->webView()->layout();
194 RefPtr<blink::LocalFrame> frame = toLocalFrame(webViewHelper->webViewImp l()->page()->mainFrame()); 196 LocalFrame* frame = toLocalFrame(webViewHelper->webViewImpl()->page()->m ainFrame());
197 FrameProtector protect(frame);
198 ASSERT(frame);
195 blink::Element* element = frame->document()->getElementById(testcase.c_s tr()); 199 blink::Element* element = frame->document()->getElementById(testcase.c_s tr());
196 return frame->nodeImage(*element); 200 return frame->nodeImage(*element);
197 } 201 }
198 202
199 std::string m_baseURL; 203 std::string m_baseURL;
200 std::string m_chromeURL; 204 std::string m_chromeURL;
201 }; 205 };
202 206
203 class UseMockScrollbarSettings { 207 class UseMockScrollbarSettings {
204 public: 208 public:
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10 24).utf8(); 644 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10 24).utf8();
641 EXPECT_NE(std::string::npos, content.find("Message 1.")); 645 EXPECT_NE(std::string::npos, content.find("Message 1."));
642 EXPECT_EQ(std::string::npos, content.find("Message 2.")); 646 EXPECT_EQ(std::string::npos, content.find("Message 2."));
643 } 647 }
644 648
645 TEST_F(WebFrameTest, PostMessageThenDetach) 649 TEST_F(WebFrameTest, PostMessageThenDetach)
646 { 650 {
647 FrameTestHelpers::WebViewHelper webViewHelper; 651 FrameTestHelpers::WebViewHelper webViewHelper;
648 webViewHelper.initializeAndLoad("about:blank"); 652 webViewHelper.initializeAndLoad("about:blank");
649 653
650 RefPtr<blink::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()-> page()->mainFrame()); 654
651 blink::NonThrowableExceptionState exceptionState; 655 LocalFrame* frame = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr ame());
656 FrameProtector protect(frame);
657 NonThrowableExceptionState exceptionState;
652 frame->domWindow()->postMessage(blink::SerializedScriptValue::create("messag e"), 0, "*", frame->domWindow(), exceptionState); 658 frame->domWindow()->postMessage(blink::SerializedScriptValue::create("messag e"), 0, "*", frame->domWindow(), exceptionState);
653 webViewHelper.reset(); 659 webViewHelper.reset();
654 EXPECT_FALSE(exceptionState.hadException()); 660 EXPECT_FALSE(exceptionState.hadException());
655 661
656 // Success is not crashing. 662 // Success is not crashing.
657 runPendingTasks(); 663 runPendingTasks();
658 } 664 }
659 665
660 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient { 666 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient {
661 public: 667 public:
(...skipping 2765 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 webViewHelper.webView()->resize(WebSize(640, 480)); 3433 webViewHelper.webView()->resize(WebSize(640, 480));
3428 webViewHelper.webView()->layout(); 3434 webViewHelper.webView()->layout();
3429 runPendingTasks(); 3435 runPendingTasks();
3430 3436
3431 static const char* kFindString = "result"; 3437 static const char* kFindString = "result";
3432 static const int kFindIdentifier = 12345; 3438 static const int kFindIdentifier = 12345;
3433 3439
3434 WebFindOptions options; 3440 WebFindOptions options;
3435 WebString searchText = WebString::fromUTF8(kFindString); 3441 WebString searchText = WebString::fromUTF8(kFindString);
3436 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); 3442 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame());
3437 RefPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(mainFrame->trave rseNext(false)); 3443 RefPtrWillBeRawPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(main Frame->traverseNext(false));
3438 RefPtr<blink::LocalFrame> holdSecondFrame = secondFrame->frame(); 3444 FrameProtector holdSecondFrame(secondFrame->frame());
3439 3445
3440 // Detach the frame before finding. 3446 // Detach the frame before finding.
3441 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); 3447 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove());
3442 3448
3443 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ; 3449 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ;
3444 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false, 0)); 3450 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false, 0));
3445 3451
3446 runPendingTasks(); 3452 runPendingTasks();
3447 EXPECT_FALSE(client.findResultsAreReady()); 3453 EXPECT_FALSE(client.findResultsAreReady());
3448 3454
3449 mainFrame->resetMatchCount(); 3455 mainFrame->resetMatchCount();
3450 3456
3451 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) 3457 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
3452 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); 3458 frame->scopeStringMatches(kFindIdentifier, searchText, options, true);
3453 3459
3454 runPendingTasks(); 3460 runPendingTasks();
3455 EXPECT_TRUE(client.findResultsAreReady()); 3461 EXPECT_TRUE(client.findResultsAreReady());
3456
3457 holdSecondFrame.release();
3458 } 3462 }
3459 3463
3460 TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings) 3464 TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings)
3461 { 3465 {
3462 registerMockedHttpURLLoad("find_in_page.html"); 3466 registerMockedHttpURLLoad("find_in_page.html");
3463 registerMockedHttpURLLoad("find_in_page_frame.html"); 3467 registerMockedHttpURLLoad("find_in_page_frame.html");
3464 3468
3465 FindUpdateWebFrameClient client; 3469 FindUpdateWebFrameClient client;
3466 FrameTestHelpers::WebViewHelper webViewHelper; 3470 FrameTestHelpers::WebViewHelper webViewHelper;
3467 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie nt); 3471 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie nt);
3468 webViewHelper.webView()->resize(WebSize(640, 480)); 3472 webViewHelper.webView()->resize(WebSize(640, 480));
3469 webViewHelper.webView()->layout(); 3473 webViewHelper.webView()->layout();
3470 runPendingTasks(); 3474 runPendingTasks();
3471 3475
3472 static const char* kFindString = "result"; 3476 static const char* kFindString = "result";
3473 static const int kFindIdentifier = 12345; 3477 static const int kFindIdentifier = 12345;
3474 3478
3475 WebFindOptions options; 3479 WebFindOptions options;
3476 WebString searchText = WebString::fromUTF8(kFindString); 3480 WebString searchText = WebString::fromUTF8(kFindString);
3477 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); 3481 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame());
3478 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext (false)); 3482 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext (false));
3479 RefPtr<blink::LocalFrame> holdSecondFrame = secondFrame->frame(); 3483 FrameProtector holdSecondFrame(secondFrame->frame());
3480 3484
3481 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) 3485 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
3482 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0)) ; 3486 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0)) ;
3483 3487
3484 runPendingTasks(); 3488 runPendingTasks();
3485 EXPECT_FALSE(client.findResultsAreReady()); 3489 EXPECT_FALSE(client.findResultsAreReady());
3486 3490
3487 // Detach the frame between finding and scoping. 3491 // Detach the frame between finding and scoping.
3488 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); 3492 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove());
3489 3493
3490 mainFrame->resetMatchCount(); 3494 mainFrame->resetMatchCount();
3491 3495
3492 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) 3496 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
3493 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); 3497 frame->scopeStringMatches(kFindIdentifier, searchText, options, true);
3494 3498
3495 runPendingTasks(); 3499 runPendingTasks();
3496 EXPECT_TRUE(client.findResultsAreReady()); 3500 EXPECT_TRUE(client.findResultsAreReady());
3497
3498 holdSecondFrame.release();
3499 } 3501 }
3500 3502
3501 TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings) 3503 TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings)
3502 { 3504 {
3503 registerMockedHttpURLLoad("find_in_page.html"); 3505 registerMockedHttpURLLoad("find_in_page.html");
3504 registerMockedHttpURLLoad("find_in_page_frame.html"); 3506 registerMockedHttpURLLoad("find_in_page_frame.html");
3505 3507
3506 FindUpdateWebFrameClient client; 3508 FindUpdateWebFrameClient client;
3507 FrameTestHelpers::WebViewHelper webViewHelper; 3509 FrameTestHelpers::WebViewHelper webViewHelper;
3508 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie nt); 3510 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie nt);
3509 webViewHelper.webView()->resize(WebSize(640, 480)); 3511 webViewHelper.webView()->resize(WebSize(640, 480));
3510 webViewHelper.webView()->layout(); 3512 webViewHelper.webView()->layout();
3511 runPendingTasks(); 3513 runPendingTasks();
3512 3514
3513 static const char* kFindString = "result"; 3515 static const char* kFindString = "result";
3514 static const int kFindIdentifier = 12345; 3516 static const int kFindIdentifier = 12345;
3515 3517
3516 WebFindOptions options; 3518 WebFindOptions options;
3517 WebString searchText = WebString::fromUTF8(kFindString); 3519 WebString searchText = WebString::fromUTF8(kFindString);
3518 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); 3520 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame());
3519 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext (false)); 3521 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext (false));
3520 RefPtr<blink::LocalFrame> holdSecondFrame = secondFrame->frame(); 3522 FrameProtector holdSecondFrame(secondFrame->frame());
3521 3523
3522 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) 3524 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
3523 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0)) ; 3525 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0)) ;
3524 3526
3525 runPendingTasks(); 3527 runPendingTasks();
3526 EXPECT_FALSE(client.findResultsAreReady()); 3528 EXPECT_FALSE(client.findResultsAreReady());
3527 3529
3528 mainFrame->resetMatchCount(); 3530 mainFrame->resetMatchCount();
3529 3531
3530 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) 3532 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
3531 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); 3533 frame->scopeStringMatches(kFindIdentifier, searchText, options, true);
3532 3534
3533 // The first scopeStringMatches will have reset the state. Detach before it actually scopes. 3535 // The first scopeStringMatches will have reset the state. Detach before it actually scopes.
3534 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); 3536 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove());
3535 3537
3536 runPendingTasks(); 3538 runPendingTasks();
3537 EXPECT_TRUE(client.findResultsAreReady()); 3539 EXPECT_TRUE(client.findResultsAreReady());
3538
3539 holdSecondFrame.release();
3540 } 3540 }
3541 3541
3542 TEST_F(WebFrameTest, ResetMatchCount) 3542 TEST_F(WebFrameTest, ResetMatchCount)
3543 { 3543 {
3544 registerMockedHttpURLLoad("find_in_generated_frame.html"); 3544 registerMockedHttpURLLoad("find_in_generated_frame.html");
3545 3545
3546 FindUpdateWebFrameClient client; 3546 FindUpdateWebFrameClient client;
3547 FrameTestHelpers::WebViewHelper webViewHelper; 3547 FrameTestHelpers::WebViewHelper webViewHelper;
3548 webViewHelper.initializeAndLoad(m_baseURL + "find_in_generated_frame.html", true, &client); 3548 webViewHelper.initializeAndLoad(m_baseURL + "find_in_generated_frame.html", true, &client);
3549 webViewHelper.webView()->resize(WebSize(640, 480)); 3549 webViewHelper.webView()->resize(WebSize(640, 480));
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after
5115 registerMockedHttpURLLoad("hello_world.html"); 5115 registerMockedHttpURLLoad("hello_world.html");
5116 TestNewWindowWebViewClient webViewClient; 5116 TestNewWindowWebViewClient webViewClient;
5117 TestNewWindowWebFrameClient webFrameClient; 5117 TestNewWindowWebFrameClient webFrameClient;
5118 FrameTestHelpers::WebViewHelper webViewHelper; 5118 FrameTestHelpers::WebViewHelper webViewHelper;
5119 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra meClient, &webViewClient); 5119 webViewHelper.initializeAndLoad(m_baseURL + "ctrl_click.html", true, &webFra meClient, &webViewClient);
5120 5120
5121 blink::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page() ->mainFrame())->document(); 5121 blink::Document* document = toLocalFrame(webViewHelper.webViewImpl()->page() ->mainFrame())->document();
5122 blink::KURL destination = toKURL(m_baseURL + "hello_world.html"); 5122 blink::KURL destination = toKURL(m_baseURL + "hello_world.html");
5123 5123
5124 // ctrl+click event 5124 // ctrl+click event
5125 RefPtrWillBeRawPtr<blink::Event> event = blink::MouseEvent::create(blink::Ev entTypeNames::click, false, false, 5125 RefPtrWillBeRawPtr<Event> event = blink::MouseEvent::create(blink::EventType Names::click, false, false,
5126 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0 , nullptr, nullptr); 5126 document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0 , nullptr, nullptr);
5127 blink::FrameLoadRequest frameRequest(document, blink::ResourceRequest(destin ation)); 5127 blink::FrameLoadRequest frameRequest(document, blink::ResourceRequest(destin ation));
5128 frameRequest.setTriggeringEvent(event); 5128 frameRequest.setTriggeringEvent(event);
5129 blink::UserGestureIndicator gesture(blink::DefinitelyProcessingUserGesture); 5129 blink::UserGestureIndicator gesture(blink::DefinitelyProcessingUserGesture);
5130 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa d(frameRequest); 5130 toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame())->loader().loa d(frameRequest);
5131 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF rame()); 5131 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF rame());
5132 5132
5133 // decidePolicyForNavigation should be called both for the original request and the ctrl+click. 5133 // decidePolicyForNavigation should be called both for the original request and the ctrl+click.
5134 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount()); 5134 EXPECT_EQ(2, webFrameClient.decidePolicyCallCount());
5135 } 5135 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
5283 registerMockedHttpURLLoad("iframe_reload.html"); 5283 registerMockedHttpURLLoad("iframe_reload.html");
5284 registerMockedHttpURLLoad("visible_iframe.html"); 5284 registerMockedHttpURLLoad("visible_iframe.html");
5285 TestCachePolicyWebFrameClient mainClient(0); 5285 TestCachePolicyWebFrameClient mainClient(0);
5286 TestCachePolicyWebFrameClient childClient(&mainClient); 5286 TestCachePolicyWebFrameClient childClient(&mainClient);
5287 mainClient.setChildWebFrameClient(&childClient); 5287 mainClient.setChildWebFrameClient(&childClient);
5288 5288
5289 FrameTestHelpers::WebViewHelper webViewHelper; 5289 FrameTestHelpers::WebViewHelper webViewHelper;
5290 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai nClient); 5290 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai nClient);
5291 5291
5292 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); 5292 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl();
5293 RefPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstC hild()); 5293 RefPtrWillBeRawPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainF rame->firstChild());
5294 ASSERT_EQ(childFrame->client(), &childClient); 5294 ASSERT_EQ(childFrame->client(), &childClient);
5295 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); 5295 EXPECT_EQ(mainClient.childFrameCreationCount(), 1);
5296 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); 5296 EXPECT_EQ(childClient.willSendRequestCallCount(), 1);
5297 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy); 5297 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy);
5298 5298
5299 FrameTestHelpers::reloadFrame(mainFrame); 5299 FrameTestHelpers::reloadFrame(mainFrame);
5300 5300
5301 // A new WebFrame should have been created, but the child WebFrameClient sho uld be reused. 5301 // A new WebFrame should have been created, but the child WebFrameClient sho uld be reused.
5302 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); 5302 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild()));
5303 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie nt); 5303 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie nt);
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
5977 5977
5978 EXPECT_EQ(newChild, parent->firstChild()); 5978 EXPECT_EQ(newChild, parent->firstChild());
5979 EXPECT_EQ(newChild->parent(), parent); 5979 EXPECT_EQ(newChild->parent(), parent);
5980 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling( )); 5980 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling( ));
5981 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); 5981 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling());
5982 } 5982 }
5983 5983
5984 TEST_F(WebFrameSwapTest, SwapFirstChild) 5984 TEST_F(WebFrameSwapTest, SwapFirstChild)
5985 { 5985 {
5986 WebFrame* remoteFrame = WebRemoteFrame::create(0); 5986 WebFrame* remoteFrame = WebRemoteFrame::create(0);
5987 // FIXME: Oilpan: add a guard/protector-like helper type that tidies this up .
5988 RefPtrWillBePersistent<WebRemoteFrameImpl> protect(toWebRemoteFrameImpl(remo teFrame));
5987 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame ); 5989 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame );
5988 5990
5989 FrameTestHelpers::TestWebFrameClient client; 5991 FrameTestHelpers::TestWebFrameClient client;
5990 WebFrame* localFrame = WebLocalFrame::create(&client); 5992 WebFrame* localFrame = WebLocalFrame::create(&client);
5991 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ; 5993 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ;
5992 5994
5993 // FIXME: This almost certainly fires more load events on the iframe element 5995 // FIXME: This almost certainly fires more load events on the iframe element
5994 // than it should. 5996 // than it should.
5995 // Finally, make sure an embedder triggered load in the local frame swapped 5997 // Finally, make sure an embedder triggered load in the local frame swapped
5996 // back in works. 5998 // back in works.
(...skipping 17 matching lines...) Expand all
6014 EXPECT_EQ(newChild->parent(), parent); 6016 EXPECT_EQ(newChild->parent(), parent);
6015 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()); 6017 EXPECT_EQ(newChild, parent->firstChild()->nextSibling());
6016 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()); 6018 EXPECT_EQ(newChild->previousSibling(), parent->firstChild());
6017 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()); 6019 EXPECT_EQ(newChild, parent->lastChild()->previousSibling());
6018 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()); 6020 EXPECT_EQ(newChild->nextSibling(), parent->lastChild());
6019 } 6021 }
6020 6022
6021 TEST_F(WebFrameSwapTest, SwapMiddleChild) 6023 TEST_F(WebFrameSwapTest, SwapMiddleChild)
6022 { 6024 {
6023 WebFrame* remoteFrame = WebRemoteFrame::create(0); 6025 WebFrame* remoteFrame = WebRemoteFrame::create(0);
6026 RefPtrWillBePersistent<WebRemoteFrameImpl> protect(toWebRemoteFrameImpl(remo teFrame));
6024 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e); 6027 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e);
6025 6028
6026 FrameTestHelpers::TestWebFrameClient client; 6029 FrameTestHelpers::TestWebFrameClient client;
6027 WebFrame* localFrame = WebLocalFrame::create(&client); 6030 WebFrame* localFrame = WebLocalFrame::create(&client);
6028 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame ); 6031 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame );
6029 6032
6030 // FIXME: This almost certainly fires more load events on the iframe element 6033 // FIXME: This almost certainly fires more load events on the iframe element
6031 // than it should. 6034 // than it should.
6032 // Finally, make sure an embedder triggered load in the local frame swapped 6035 // Finally, make sure an embedder triggered load in the local frame swapped
6033 // back in works. 6036 // back in works.
(...skipping 14 matching lines...) Expand all
6048 6051
6049 EXPECT_EQ(newChild, parent->lastChild()); 6052 EXPECT_EQ(newChild, parent->lastChild());
6050 EXPECT_EQ(newChild->parent(), parent); 6053 EXPECT_EQ(newChild->parent(), parent);
6051 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()->nextSibling()); 6054 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()->nextSibling());
6052 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()->nextSibling()); 6055 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()->nextSibling());
6053 } 6056 }
6054 6057
6055 TEST_F(WebFrameSwapTest, SwapLastChild) 6058 TEST_F(WebFrameSwapTest, SwapLastChild)
6056 { 6059 {
6057 WebFrame* remoteFrame = WebRemoteFrame::create(0); 6060 WebFrame* remoteFrame = WebRemoteFrame::create(0);
6061 RefPtrWillBePersistent<WebRemoteFrameImpl> protect(toWebRemoteFrameImpl(remo teFrame));
6058 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ; 6062 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ;
6059 6063
6060 FrameTestHelpers::TestWebFrameClient client; 6064 FrameTestHelpers::TestWebFrameClient client;
6061 WebFrame* localFrame = WebLocalFrame::create(&client); 6065 WebFrame* localFrame = WebLocalFrame::create(&client);
6062 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); 6066 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame);
6063 6067
6064 // FIXME: This almost certainly fires more load events on the iframe element 6068 // FIXME: This almost certainly fires more load events on the iframe element
6065 // than it should. 6069 // than it should.
6066 // Finally, make sure an embedder triggered load in the local frame swapped 6070 // Finally, make sure an embedder triggered load in the local frame swapped
6067 // back in works. 6071 // back in works.
(...skipping 25 matching lines...) Expand all
6093 { 6097 {
6094 FrameTestHelpers::WebViewHelper webViewHelper; 6098 FrameTestHelpers::WebViewHelper webViewHelper;
6095 webViewHelper.initializeAndLoad("about:blank"); 6099 webViewHelper.initializeAndLoad("about:blank");
6096 6100
6097 blink::SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); 6101 blink::SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome");
6098 6102
6099 // Cross-origin request. 6103 // Cross-origin request.
6100 blink::KURL resourceUrl(blink::ParsedURLString, "chrome://test.pdf"); 6104 blink::KURL resourceUrl(blink::ParsedURLString, "chrome://test.pdf");
6101 registerMockedChromeURLLoad("test.pdf"); 6105 registerMockedChromeURLLoad("test.pdf");
6102 6106
6103 RefPtr<blink::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()-> page()->mainFrame()); 6107 LocalFrame* frame = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr ame());
6108 FrameProtector protect(frame);
6104 6109
6105 MockDocumentThreadableLoaderClient client; 6110 MockDocumentThreadableLoaderClient client;
6106 blink::ThreadableLoaderOptions options; 6111 blink::ThreadableLoaderOptions options;
6107 6112
6108 // First try to load the request with regular access. Should fail. 6113 // First try to load the request with regular access. Should fail.
6109 options.crossOriginRequestPolicy = blink::UseAccessControl; 6114 options.crossOriginRequestPolicy = blink::UseAccessControl;
6110 blink::ResourceLoaderOptions resourceLoaderOptions; 6115 blink::ResourceLoaderOptions resourceLoaderOptions;
6111 blink::DocumentThreadableLoader::loadResourceSynchronously( 6116 blink::DocumentThreadableLoader::loadResourceSynchronously(
6112 *frame->document(), blink::ResourceRequest(resourceUrl), client, options , resourceLoaderOptions); 6117 *frame->document(), blink::ResourceRequest(resourceUrl), client, options , resourceLoaderOptions);
6113 EXPECT_TRUE(client.failed()); 6118 EXPECT_TRUE(client.failed());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
6179 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6184 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6180 6185
6181 // Neither should a page reload. 6186 // Neither should a page reload.
6182 localFrame->reload(); 6187 localFrame->reload();
6183 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); 6188 EXPECT_EQ(4u, frameClient.provisionalLoadCount());
6184 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); 6189 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition());
6185 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6190 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6186 } 6191 }
6187 6192
6188 } // namespace 6193 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698