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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 #include "public/web/WebScriptSource.h" | 91 #include "public/web/WebScriptSource.h" |
92 #include "public/web/WebSearchableFormData.h" | 92 #include "public/web/WebSearchableFormData.h" |
93 #include "public/web/WebSecurityOrigin.h" | 93 #include "public/web/WebSecurityOrigin.h" |
94 #include "public/web/WebSecurityPolicy.h" | 94 #include "public/web/WebSecurityPolicy.h" |
95 #include "public/web/WebSettings.h" | 95 #include "public/web/WebSettings.h" |
96 #include "public/web/WebSpellCheckClient.h" | 96 #include "public/web/WebSpellCheckClient.h" |
97 #include "public/web/WebTextCheckingCompletion.h" | 97 #include "public/web/WebTextCheckingCompletion.h" |
98 #include "public/web/WebTextCheckingResult.h" | 98 #include "public/web/WebTextCheckingResult.h" |
99 #include "public/web/WebViewClient.h" | 99 #include "public/web/WebViewClient.h" |
100 #include "web/WebLocalFrameImpl.h" | 100 #include "web/WebLocalFrameImpl.h" |
| 101 #include "web/WebRemoteFrameImpl.h" |
101 #include "web/WebViewImpl.h" | 102 #include "web/WebViewImpl.h" |
102 #include "web/tests/FrameTestHelpers.h" | 103 #include "web/tests/FrameTestHelpers.h" |
103 #include "wtf/Forward.h" | 104 #include "wtf/Forward.h" |
104 #include "wtf/dtoa/utils.h" | 105 #include "wtf/dtoa/utils.h" |
105 #include <gmock/gmock.h> | 106 #include <gmock/gmock.h> |
106 #include <gtest/gtest.h> | 107 #include <gtest/gtest.h> |
107 #include <map> | 108 #include <map> |
108 #include <v8.h> | 109 #include <v8.h> |
109 | 110 |
110 namespace { | 111 namespace { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 webViewHelper->webView()->settings()->setDefaultFontSize(12); | 179 webViewHelper->webView()->settings()->setDefaultFontSize(12); |
179 webViewHelper->webView()->resize(WebSize(640, 480)); | 180 webViewHelper->webView()->resize(WebSize(640, 480)); |
180 } | 181 } |
181 | 182 |
182 PassOwnPtr<DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHelper* we
bViewHelper, const std::string& testcase) | 183 PassOwnPtr<DragImage> nodeImageTestSetup(FrameTestHelpers::WebViewHelper* we
bViewHelper, const std::string& testcase) |
183 { | 184 { |
184 registerMockedHttpURLLoad("nodeimage.html"); | 185 registerMockedHttpURLLoad("nodeimage.html"); |
185 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); | 186 webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); |
186 webViewHelper->webView()->resize(WebSize(640, 480)); | 187 webViewHelper->webView()->resize(WebSize(640, 480)); |
187 webViewHelper->webView()->layout(); | 188 webViewHelper->webView()->layout(); |
188 RefPtr<LocalFrame> frame = toLocalFrame(webViewHelper->webViewImpl()->pa
ge()->mainFrame()); | 189 RefPtrWillBeRawPtr<LocalFrame> frame = toLocalFrame(webViewHelper->webVi
ewImpl()->page()->mainFrame()); |
| 190 ASSERT(frame); |
189 Element* element = frame->document()->getElementById(testcase.c_str()); | 191 Element* element = frame->document()->getElementById(testcase.c_str()); |
190 return frame->nodeImage(*element); | 192 return frame->nodeImage(*element); |
191 } | 193 } |
192 | 194 |
193 std::string m_baseURL; | 195 std::string m_baseURL; |
194 std::string m_chromeURL; | 196 std::string m_chromeURL; |
195 }; | 197 }; |
196 | 198 |
197 class UseMockScrollbarSettings { | 199 class UseMockScrollbarSettings { |
198 public: | 200 public: |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); | 636 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); |
635 EXPECT_NE(std::string::npos, content.find("Message 1.")); | 637 EXPECT_NE(std::string::npos, content.find("Message 1.")); |
636 EXPECT_EQ(std::string::npos, content.find("Message 2.")); | 638 EXPECT_EQ(std::string::npos, content.find("Message 2.")); |
637 } | 639 } |
638 | 640 |
639 TEST_F(WebFrameTest, PostMessageThenDetach) | 641 TEST_F(WebFrameTest, PostMessageThenDetach) |
640 { | 642 { |
641 FrameTestHelpers::WebViewHelper webViewHelper; | 643 FrameTestHelpers::WebViewHelper webViewHelper; |
642 webViewHelper.initializeAndLoad("about:blank"); | 644 webViewHelper.initializeAndLoad("about:blank"); |
643 | 645 |
644 RefPtr<LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->page()-
>mainFrame()); | 646 RefPtrWillBeRawPtr<LocalFrame> frame = toLocalFrame(webViewHelper.webViewImp
l()->page()->mainFrame()); |
645 NonThrowableExceptionState exceptionState; | 647 NonThrowableExceptionState exceptionState; |
646 frame->domWindow()->postMessage(SerializedScriptValue::create("message"), 0,
"*", frame->domWindow(), exceptionState); | 648 frame->domWindow()->postMessage(SerializedScriptValue::create("message"), 0,
"*", frame->domWindow(), exceptionState); |
647 webViewHelper.reset(); | 649 webViewHelper.reset(); |
648 EXPECT_FALSE(exceptionState.hadException()); | 650 EXPECT_FALSE(exceptionState.hadException()); |
649 | 651 |
650 // Success is not crashing. | 652 // Success is not crashing. |
651 runPendingTasks(); | 653 runPendingTasks(); |
652 } | 654 } |
653 | 655 |
654 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient
{ | 656 class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient
{ |
(...skipping 2822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3477 webViewHelper.webView()->resize(WebSize(640, 480)); | 3479 webViewHelper.webView()->resize(WebSize(640, 480)); |
3478 webViewHelper.webView()->layout(); | 3480 webViewHelper.webView()->layout(); |
3479 runPendingTasks(); | 3481 runPendingTasks(); |
3480 | 3482 |
3481 static const char* kFindString = "result"; | 3483 static const char* kFindString = "result"; |
3482 static const int kFindIdentifier = 12345; | 3484 static const int kFindIdentifier = 12345; |
3483 | 3485 |
3484 WebFindOptions options; | 3486 WebFindOptions options; |
3485 WebString searchText = WebString::fromUTF8(kFindString); | 3487 WebString searchText = WebString::fromUTF8(kFindString); |
3486 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3488 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
3487 RefPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(mainFrame->trave
rseNext(false)); | 3489 RefPtrWillBeRawPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(main
Frame->traverseNext(false)); |
3488 RefPtr<LocalFrame> holdSecondFrame = secondFrame->frame(); | 3490 RefPtrWillBeRawPtr<LocalFrame> holdSecondFrame(secondFrame->frame()); |
3489 | 3491 |
3490 // Detach the frame before finding. | 3492 // Detach the frame before finding. |
3491 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); | 3493 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); |
3492 | 3494 |
3493 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3495 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
3494 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false,
0)); | 3496 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false,
0)); |
3495 | 3497 |
3496 runPendingTasks(); | 3498 runPendingTasks(); |
3497 EXPECT_FALSE(client.findResultsAreReady()); | 3499 EXPECT_FALSE(client.findResultsAreReady()); |
3498 | 3500 |
3499 mainFrame->resetMatchCount(); | 3501 mainFrame->resetMatchCount(); |
3500 | 3502 |
3501 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3503 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
3502 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 3504 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
3503 | 3505 |
3504 runPendingTasks(); | 3506 runPendingTasks(); |
3505 EXPECT_TRUE(client.findResultsAreReady()); | 3507 EXPECT_TRUE(client.findResultsAreReady()); |
3506 | |
3507 holdSecondFrame.release(); | |
3508 } | 3508 } |
3509 | 3509 |
3510 TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings) | 3510 TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings) |
3511 { | 3511 { |
3512 registerMockedHttpURLLoad("find_in_page.html"); | 3512 registerMockedHttpURLLoad("find_in_page.html"); |
3513 registerMockedHttpURLLoad("find_in_page_frame.html"); | 3513 registerMockedHttpURLLoad("find_in_page_frame.html"); |
3514 | 3514 |
3515 FindUpdateWebFrameClient client; | 3515 FindUpdateWebFrameClient client; |
3516 FrameTestHelpers::WebViewHelper webViewHelper; | 3516 FrameTestHelpers::WebViewHelper webViewHelper; |
3517 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3517 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); |
3518 webViewHelper.webView()->resize(WebSize(640, 480)); | 3518 webViewHelper.webView()->resize(WebSize(640, 480)); |
3519 webViewHelper.webView()->layout(); | 3519 webViewHelper.webView()->layout(); |
3520 runPendingTasks(); | 3520 runPendingTasks(); |
3521 | 3521 |
3522 static const char* kFindString = "result"; | 3522 static const char* kFindString = "result"; |
3523 static const int kFindIdentifier = 12345; | 3523 static const int kFindIdentifier = 12345; |
3524 | 3524 |
3525 WebFindOptions options; | 3525 WebFindOptions options; |
3526 WebString searchText = WebString::fromUTF8(kFindString); | 3526 WebString searchText = WebString::fromUTF8(kFindString); |
3527 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3527 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
3528 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); | 3528 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); |
3529 RefPtr<LocalFrame> holdSecondFrame = secondFrame->frame(); | 3529 RefPtrWillBeRawPtr<LocalFrame> holdSecondFrame(secondFrame->frame()); |
3530 | 3530 |
3531 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3531 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
3532 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; | 3532 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; |
3533 | 3533 |
3534 runPendingTasks(); | 3534 runPendingTasks(); |
3535 EXPECT_FALSE(client.findResultsAreReady()); | 3535 EXPECT_FALSE(client.findResultsAreReady()); |
3536 | 3536 |
3537 // Detach the frame between finding and scoping. | 3537 // Detach the frame between finding and scoping. |
3538 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); | 3538 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); |
3539 | 3539 |
3540 mainFrame->resetMatchCount(); | 3540 mainFrame->resetMatchCount(); |
3541 | 3541 |
3542 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3542 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
3543 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 3543 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
3544 | 3544 |
3545 runPendingTasks(); | 3545 runPendingTasks(); |
3546 EXPECT_TRUE(client.findResultsAreReady()); | 3546 EXPECT_TRUE(client.findResultsAreReady()); |
3547 | |
3548 holdSecondFrame.release(); | |
3549 } | 3547 } |
3550 | 3548 |
3551 TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings) | 3549 TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings) |
3552 { | 3550 { |
3553 registerMockedHttpURLLoad("find_in_page.html"); | 3551 registerMockedHttpURLLoad("find_in_page.html"); |
3554 registerMockedHttpURLLoad("find_in_page_frame.html"); | 3552 registerMockedHttpURLLoad("find_in_page_frame.html"); |
3555 | 3553 |
3556 FindUpdateWebFrameClient client; | 3554 FindUpdateWebFrameClient client; |
3557 FrameTestHelpers::WebViewHelper webViewHelper; | 3555 FrameTestHelpers::WebViewHelper webViewHelper; |
3558 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3556 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); |
3559 webViewHelper.webView()->resize(WebSize(640, 480)); | 3557 webViewHelper.webView()->resize(WebSize(640, 480)); |
3560 webViewHelper.webView()->layout(); | 3558 webViewHelper.webView()->layout(); |
3561 runPendingTasks(); | 3559 runPendingTasks(); |
3562 | 3560 |
3563 static const char* kFindString = "result"; | 3561 static const char* kFindString = "result"; |
3564 static const int kFindIdentifier = 12345; | 3562 static const int kFindIdentifier = 12345; |
3565 | 3563 |
3566 WebFindOptions options; | 3564 WebFindOptions options; |
3567 WebString searchText = WebString::fromUTF8(kFindString); | 3565 WebString searchText = WebString::fromUTF8(kFindString); |
3568 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3566 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
3569 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); | 3567 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); |
3570 RefPtr<LocalFrame> holdSecondFrame = secondFrame->frame(); | 3568 RefPtrWillBeRawPtr<LocalFrame> holdSecondFrame(secondFrame->frame()); |
3571 | 3569 |
3572 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3570 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
3573 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; | 3571 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; |
3574 | 3572 |
3575 runPendingTasks(); | 3573 runPendingTasks(); |
3576 EXPECT_FALSE(client.findResultsAreReady()); | 3574 EXPECT_FALSE(client.findResultsAreReady()); |
3577 | 3575 |
3578 mainFrame->resetMatchCount(); | 3576 mainFrame->resetMatchCount(); |
3579 | 3577 |
3580 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3578 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
3581 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 3579 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
3582 | 3580 |
3583 // The first scopeStringMatches will have reset the state. Detach before it
actually scopes. | 3581 // The first scopeStringMatches will have reset the state. Detach before it
actually scopes. |
3584 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); | 3582 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); |
3585 | 3583 |
3586 runPendingTasks(); | 3584 runPendingTasks(); |
3587 EXPECT_TRUE(client.findResultsAreReady()); | 3585 EXPECT_TRUE(client.findResultsAreReady()); |
3588 | |
3589 holdSecondFrame.release(); | |
3590 } | 3586 } |
3591 | 3587 |
3592 TEST_F(WebFrameTest, ResetMatchCount) | 3588 TEST_F(WebFrameTest, ResetMatchCount) |
3593 { | 3589 { |
3594 registerMockedHttpURLLoad("find_in_generated_frame.html"); | 3590 registerMockedHttpURLLoad("find_in_generated_frame.html"); |
3595 | 3591 |
3596 FindUpdateWebFrameClient client; | 3592 FindUpdateWebFrameClient client; |
3597 FrameTestHelpers::WebViewHelper webViewHelper; | 3593 FrameTestHelpers::WebViewHelper webViewHelper; |
3598 webViewHelper.initializeAndLoad(m_baseURL + "find_in_generated_frame.html",
true, &client); | 3594 webViewHelper.initializeAndLoad(m_baseURL + "find_in_generated_frame.html",
true, &client); |
3599 webViewHelper.webView()->resize(WebSize(640, 480)); | 3595 webViewHelper.webView()->resize(WebSize(640, 480)); |
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5333 registerMockedHttpURLLoad("iframe_reload.html"); | 5329 registerMockedHttpURLLoad("iframe_reload.html"); |
5334 registerMockedHttpURLLoad("visible_iframe.html"); | 5330 registerMockedHttpURLLoad("visible_iframe.html"); |
5335 TestCachePolicyWebFrameClient mainClient(0); | 5331 TestCachePolicyWebFrameClient mainClient(0); |
5336 TestCachePolicyWebFrameClient childClient(&mainClient); | 5332 TestCachePolicyWebFrameClient childClient(&mainClient); |
5337 mainClient.setChildWebFrameClient(&childClient); | 5333 mainClient.setChildWebFrameClient(&childClient); |
5338 | 5334 |
5339 FrameTestHelpers::WebViewHelper webViewHelper; | 5335 FrameTestHelpers::WebViewHelper webViewHelper; |
5340 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); | 5336 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); |
5341 | 5337 |
5342 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); | 5338 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); |
5343 RefPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstC
hild()); | 5339 RefPtrWillBeRawPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainF
rame->firstChild()); |
5344 ASSERT_EQ(childFrame->client(), &childClient); | 5340 ASSERT_EQ(childFrame->client(), &childClient); |
5345 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); | 5341 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); |
5346 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); | 5342 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); |
5347 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy); | 5343 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy); |
5348 | 5344 |
5349 FrameTestHelpers::reloadFrame(mainFrame); | 5345 FrameTestHelpers::reloadFrame(mainFrame); |
5350 | 5346 |
5351 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. | 5347 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. |
5352 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); | 5348 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); |
5353 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); | 5349 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6027 | 6023 |
6028 EXPECT_EQ(newChild, parent->firstChild()); | 6024 EXPECT_EQ(newChild, parent->firstChild()); |
6029 EXPECT_EQ(newChild->parent(), parent); | 6025 EXPECT_EQ(newChild->parent(), parent); |
6030 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling(
)); | 6026 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling(
)); |
6031 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); | 6027 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); |
6032 } | 6028 } |
6033 | 6029 |
6034 TEST_F(WebFrameSwapTest, SwapFirstChild) | 6030 TEST_F(WebFrameSwapTest, SwapFirstChild) |
6035 { | 6031 { |
6036 WebFrame* remoteFrame = WebRemoteFrame::create(0); | 6032 WebFrame* remoteFrame = WebRemoteFrame::create(0); |
| 6033 // FIXME: Oilpan: add a guard/protector-like helper type that tidies this up
. |
| 6034 RefPtrWillBePersistent<WebRemoteFrameImpl> protect(toWebRemoteFrameImpl(remo
teFrame)); |
6037 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame
); | 6035 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame
); |
6038 | 6036 |
6039 FrameTestHelpers::TestWebFrameClient client; | 6037 FrameTestHelpers::TestWebFrameClient client; |
6040 WebFrame* localFrame = WebLocalFrame::create(&client); | 6038 WebFrame* localFrame = WebLocalFrame::create(&client); |
6041 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame)
; | 6039 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame)
; |
6042 | 6040 |
6043 // FIXME: This almost certainly fires more load events on the iframe element | 6041 // FIXME: This almost certainly fires more load events on the iframe element |
6044 // than it should. | 6042 // than it should. |
6045 // Finally, make sure an embedder triggered load in the local frame swapped | 6043 // Finally, make sure an embedder triggered load in the local frame swapped |
6046 // back in works. | 6044 // back in works. |
(...skipping 17 matching lines...) Expand all Loading... |
6064 EXPECT_EQ(newChild->parent(), parent); | 6062 EXPECT_EQ(newChild->parent(), parent); |
6065 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()); | 6063 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()); |
6066 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()); | 6064 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()); |
6067 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()); | 6065 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()); |
6068 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()); | 6066 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()); |
6069 } | 6067 } |
6070 | 6068 |
6071 TEST_F(WebFrameSwapTest, SwapMiddleChild) | 6069 TEST_F(WebFrameSwapTest, SwapMiddleChild) |
6072 { | 6070 { |
6073 WebFrame* remoteFrame = WebRemoteFrame::create(0); | 6071 WebFrame* remoteFrame = WebRemoteFrame::create(0); |
| 6072 RefPtrWillBePersistent<WebRemoteFrameImpl> protect(toWebRemoteFrameImpl(remo
teFrame)); |
6074 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram
e); | 6073 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram
e); |
6075 | 6074 |
6076 FrameTestHelpers::TestWebFrameClient client; | 6075 FrameTestHelpers::TestWebFrameClient client; |
6077 WebFrame* localFrame = WebLocalFrame::create(&client); | 6076 WebFrame* localFrame = WebLocalFrame::create(&client); |
6078 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame
); | 6077 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame
); |
6079 | 6078 |
6080 // FIXME: This almost certainly fires more load events on the iframe element | 6079 // FIXME: This almost certainly fires more load events on the iframe element |
6081 // than it should. | 6080 // than it should. |
6082 // Finally, make sure an embedder triggered load in the local frame swapped | 6081 // Finally, make sure an embedder triggered load in the local frame swapped |
6083 // back in works. | 6082 // back in works. |
(...skipping 14 matching lines...) Expand all Loading... |
6098 | 6097 |
6099 EXPECT_EQ(newChild, parent->lastChild()); | 6098 EXPECT_EQ(newChild, parent->lastChild()); |
6100 EXPECT_EQ(newChild->parent(), parent); | 6099 EXPECT_EQ(newChild->parent(), parent); |
6101 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()->nextSibling()); | 6100 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()->nextSibling()); |
6102 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()->nextSibling()); | 6101 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()->nextSibling()); |
6103 } | 6102 } |
6104 | 6103 |
6105 TEST_F(WebFrameSwapTest, SwapLastChild) | 6104 TEST_F(WebFrameSwapTest, SwapLastChild) |
6106 { | 6105 { |
6107 WebFrame* remoteFrame = WebRemoteFrame::create(0); | 6106 WebFrame* remoteFrame = WebRemoteFrame::create(0); |
| 6107 RefPtrWillBePersistent<WebRemoteFrameImpl> protect(toWebRemoteFrameImpl(remo
teFrame)); |
6108 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame)
; | 6108 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame)
; |
6109 | 6109 |
6110 FrameTestHelpers::TestWebFrameClient client; | 6110 FrameTestHelpers::TestWebFrameClient client; |
6111 WebFrame* localFrame = WebLocalFrame::create(&client); | 6111 WebFrame* localFrame = WebLocalFrame::create(&client); |
6112 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); | 6112 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); |
6113 | 6113 |
6114 // FIXME: This almost certainly fires more load events on the iframe element | 6114 // FIXME: This almost certainly fires more load events on the iframe element |
6115 // than it should. | 6115 // than it should. |
6116 // Finally, make sure an embedder triggered load in the local frame swapped | 6116 // Finally, make sure an embedder triggered load in the local frame swapped |
6117 // back in works. | 6117 // back in works. |
(...skipping 14 matching lines...) Expand all Loading... |
6132 EXPECT_TRUE(oldFrame->firstChild()); | 6132 EXPECT_TRUE(oldFrame->firstChild()); |
6133 oldFrame->swap(newFrame); | 6133 oldFrame->swap(newFrame); |
6134 | 6134 |
6135 EXPECT_FALSE(newFrame->firstChild()); | 6135 EXPECT_FALSE(newFrame->firstChild()); |
6136 EXPECT_FALSE(newFrame->lastChild()); | 6136 EXPECT_FALSE(newFrame->lastChild()); |
6137 } | 6137 } |
6138 | 6138 |
6139 TEST_F(WebFrameSwapTest, SwapParentShouldDetachChildren) | 6139 TEST_F(WebFrameSwapTest, SwapParentShouldDetachChildren) |
6140 { | 6140 { |
6141 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(0); | 6141 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(0); |
| 6142 RefPtrWillBePersistent<WebRemoteFrameImpl> protect(toWebRemoteFrameImpl(remo
teFrame)); |
6142 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling(); | 6143 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling(); |
6143 EXPECT_TRUE(targetFrame); | 6144 EXPECT_TRUE(targetFrame); |
6144 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); | 6145 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); |
6145 | 6146 |
6146 targetFrame = mainFrame()->firstChild()->nextSibling(); | 6147 targetFrame = mainFrame()->firstChild()->nextSibling(); |
6147 EXPECT_TRUE(targetFrame); | 6148 EXPECT_TRUE(targetFrame); |
6148 | 6149 |
6149 // Create child frames in the target frame before testing the swap. | 6150 // Create child frames in the target frame before testing the swap. |
6150 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | 6151 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
6151 remoteFrame->createRemoteChild("", &remoteFrameClient); | 6152 remoteFrame->createRemoteChild("", &remoteFrameClient); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6186 { | 6187 { |
6187 FrameTestHelpers::WebViewHelper webViewHelper; | 6188 FrameTestHelpers::WebViewHelper webViewHelper; |
6188 webViewHelper.initializeAndLoad("about:blank"); | 6189 webViewHelper.initializeAndLoad("about:blank"); |
6189 | 6190 |
6190 SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); | 6191 SchemeRegistry::registerURLSchemeAsDisplayIsolated("chrome"); |
6191 | 6192 |
6192 // Cross-origin request. | 6193 // Cross-origin request. |
6193 KURL resourceUrl(ParsedURLString, "chrome://test.pdf"); | 6194 KURL resourceUrl(ParsedURLString, "chrome://test.pdf"); |
6194 registerMockedChromeURLLoad("test.pdf"); | 6195 registerMockedChromeURLLoad("test.pdf"); |
6195 | 6196 |
6196 RefPtr<LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->page()-
>mainFrame()); | 6197 RefPtrWillBeRawPtr<LocalFrame> frame(toLocalFrame(webViewHelper.webViewImpl(
)->page()->mainFrame())); |
6197 | 6198 |
6198 MockDocumentThreadableLoaderClient client; | 6199 MockDocumentThreadableLoaderClient client; |
6199 ThreadableLoaderOptions options; | 6200 ThreadableLoaderOptions options; |
6200 | 6201 |
6201 // First try to load the request with regular access. Should fail. | 6202 // First try to load the request with regular access. Should fail. |
6202 options.crossOriginRequestPolicy = UseAccessControl; | 6203 options.crossOriginRequestPolicy = UseAccessControl; |
6203 ResourceLoaderOptions resourceLoaderOptions; | 6204 ResourceLoaderOptions resourceLoaderOptions; |
6204 DocumentThreadableLoader::loadResourceSynchronously( | 6205 DocumentThreadableLoader::loadResourceSynchronously( |
6205 *frame->document(), ResourceRequest(resourceUrl), client, options, resou
rceLoaderOptions); | 6206 *frame->document(), ResourceRequest(resourceUrl), client, options, resou
rceLoaderOptions); |
6206 EXPECT_TRUE(client.failed()); | 6207 EXPECT_TRUE(client.failed()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6272 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6273 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6273 | 6274 |
6274 // Neither should a page reload. | 6275 // Neither should a page reload. |
6275 localFrame->reload(); | 6276 localFrame->reload(); |
6276 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6277 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6277 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6278 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6278 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6279 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6279 } | 6280 } |
6280 | 6281 |
6281 } // namespace | 6282 } // namespace |
OLD | NEW |