| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 #include "public/platform/WebURL.h" | 69 #include "public/platform/WebURL.h" |
| 70 #include "public/platform/WebURLResponse.h" | 70 #include "public/platform/WebURLResponse.h" |
| 71 #include "public/platform/WebUnitTestSupport.h" | 71 #include "public/platform/WebUnitTestSupport.h" |
| 72 #include "public/web/WebDataSource.h" | 72 #include "public/web/WebDataSource.h" |
| 73 #include "public/web/WebDocument.h" | 73 #include "public/web/WebDocument.h" |
| 74 #include "public/web/WebFindOptions.h" | 74 #include "public/web/WebFindOptions.h" |
| 75 #include "public/web/WebFormElement.h" | 75 #include "public/web/WebFormElement.h" |
| 76 #include "public/web/WebFrameClient.h" | 76 #include "public/web/WebFrameClient.h" |
| 77 #include "public/web/WebHistoryItem.h" | 77 #include "public/web/WebHistoryItem.h" |
| 78 #include "public/web/WebRange.h" | 78 #include "public/web/WebRange.h" |
| 79 #include "public/web/WebRemoteFrame.h" |
| 79 #include "public/web/WebScriptSource.h" | 80 #include "public/web/WebScriptSource.h" |
| 80 #include "public/web/WebSearchableFormData.h" | 81 #include "public/web/WebSearchableFormData.h" |
| 81 #include "public/web/WebSecurityOrigin.h" | 82 #include "public/web/WebSecurityOrigin.h" |
| 82 #include "public/web/WebSecurityPolicy.h" | 83 #include "public/web/WebSecurityPolicy.h" |
| 83 #include "public/web/WebSettings.h" | 84 #include "public/web/WebSettings.h" |
| 84 #include "public/web/WebSpellCheckClient.h" | 85 #include "public/web/WebSpellCheckClient.h" |
| 85 #include "public/web/WebTextCheckingCompletion.h" | 86 #include "public/web/WebTextCheckingCompletion.h" |
| 86 #include "public/web/WebTextCheckingResult.h" | 87 #include "public/web/WebTextCheckingResult.h" |
| 87 #include "public/web/WebViewClient.h" | 88 #include "public/web/WebViewClient.h" |
| 88 #include "web/WebLocalFrameImpl.h" | 89 #include "web/WebLocalFrameImpl.h" |
| (...skipping 5517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5606 EXPECT_TRUE(client.didNotify()); | 5607 EXPECT_TRUE(client.didNotify()); |
| 5607 EXPECT_EQ(0xff0000ff, frame->document().brandColor()); | 5608 EXPECT_EQ(0xff0000ff, frame->document().brandColor()); |
| 5608 // Change of second brand-color meta tag will not change frame's brand | 5609 // Change of second brand-color meta tag will not change frame's brand |
| 5609 // color. | 5610 // color. |
| 5610 client.reset(); | 5611 client.reset(); |
| 5611 frame->executeScript(WebScriptSource("document.getElementById('bc2').setAttr
ibute('content', '#00FF00');")); | 5612 frame->executeScript(WebScriptSource("document.getElementById('bc2').setAttr
ibute('content', '#00FF00');")); |
| 5612 EXPECT_TRUE(client.didNotify()); | 5613 EXPECT_TRUE(client.didNotify()); |
| 5613 EXPECT_EQ(0xff0000ff, frame->document().brandColor()); | 5614 EXPECT_EQ(0xff0000ff, frame->document().brandColor()); |
| 5614 } | 5615 } |
| 5615 | 5616 |
| 5617 class WebFrameSwapTest : public WebFrameTest { |
| 5618 protected: |
| 5619 WebFrameSwapTest() |
| 5620 { |
| 5621 registerMockedHttpURLLoad("frame-a-b-c.html"); |
| 5622 registerMockedHttpURLLoad("subframe-a.html"); |
| 5623 registerMockedHttpURLLoad("subframe-b.html"); |
| 5624 registerMockedHttpURLLoad("subframe-c.html"); |
| 5625 registerMockedHttpURLLoad("subframe-hello.html"); |
| 5626 |
| 5627 m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html"); |
| 5628 } |
| 5629 |
| 5630 void reset() { m_webViewHelper.reset(); } |
| 5631 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame();
} |
| 5632 |
| 5633 private: |
| 5634 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 5635 }; |
| 5636 |
| 5637 // FIXME: We should have tests for main frame swaps, but it interacts poorly |
| 5638 // with the geolocation inspector agent, since the lifetime of the inspector |
| 5639 // agent is tied to the Page, but the inspector agent is created by the |
| 5640 // instantiation of the main frame. |
| 5641 |
| 5642 void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* par
ent, WebFrame* newChild) |
| 5643 { |
| 5644 SCOPED_TRACE(message); |
| 5645 parent->firstChild()->swap(newChild); |
| 5646 |
| 5647 EXPECT_EQ(newChild, parent->firstChild()); |
| 5648 EXPECT_EQ(newChild->parent(), parent); |
| 5649 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling(
)); |
| 5650 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); |
| 5651 } |
| 5652 |
| 5653 TEST_F(WebFrameSwapTest, SwapFirstChild) |
| 5654 { |
| 5655 WebFrame* remoteFrame = WebRemoteFrame::create(0); |
| 5656 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame
); |
| 5657 |
| 5658 FrameTestHelpers::TestWebFrameClient client; |
| 5659 WebFrame* localFrame = WebLocalFrame::create(&client); |
| 5660 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame)
; |
| 5661 |
| 5662 // FIXME: This almost certainly fires more load events on the iframe element |
| 5663 // than it should. |
| 5664 // Finally, make sure an embedder triggered load in the local frame swapped |
| 5665 // back in works. |
| 5666 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| 5667 std::string content = localFrame->contentAsText(1024).utf8(); |
| 5668 EXPECT_EQ("hello", content); |
| 5669 |
| 5670 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 5671 // TestWebFrameClient. |
| 5672 reset(); |
| 5673 remoteFrame->close(); |
| 5674 } |
| 5675 |
| 5676 void swapAndVerifyMiddleChildConsistency(const char* const message, WebFrame* pa
rent, WebFrame* newChild) |
| 5677 { |
| 5678 SCOPED_TRACE(message); |
| 5679 parent->firstChild()->nextSibling()->swap(newChild); |
| 5680 |
| 5681 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()); |
| 5682 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()); |
| 5683 EXPECT_EQ(newChild->parent(), parent); |
| 5684 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()); |
| 5685 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()); |
| 5686 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()); |
| 5687 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()); |
| 5688 } |
| 5689 |
| 5690 TEST_F(WebFrameSwapTest, SwapMiddleChild) |
| 5691 { |
| 5692 WebFrame* remoteFrame = WebRemoteFrame::create(0); |
| 5693 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram
e); |
| 5694 |
| 5695 FrameTestHelpers::TestWebFrameClient client; |
| 5696 WebFrame* localFrame = WebLocalFrame::create(&client); |
| 5697 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame
); |
| 5698 |
| 5699 // FIXME: This almost certainly fires more load events on the iframe element |
| 5700 // than it should. |
| 5701 // Finally, make sure an embedder triggered load in the local frame swapped |
| 5702 // back in works. |
| 5703 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| 5704 std::string content = localFrame->contentAsText(1024).utf8(); |
| 5705 EXPECT_EQ("hello", content); |
| 5706 |
| 5707 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 5708 // TestWebFrameClient. |
| 5709 reset(); |
| 5710 remoteFrame->close(); |
| 5711 } |
| 5712 |
| 5713 void swapAndVerifyLastChildConsistency(const char* const message, WebFrame* pare
nt, WebFrame* newChild) |
| 5714 { |
| 5715 SCOPED_TRACE(message); |
| 5716 parent->lastChild()->swap(newChild); |
| 5717 |
| 5718 EXPECT_EQ(newChild, parent->lastChild()); |
| 5719 EXPECT_EQ(newChild->parent(), parent); |
| 5720 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()->nextSibling()); |
| 5721 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()->nextSibling()); |
| 5722 } |
| 5723 |
| 5724 TEST_F(WebFrameSwapTest, SwapLastChild) |
| 5725 { |
| 5726 WebFrame* remoteFrame = WebRemoteFrame::create(0); |
| 5727 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame)
; |
| 5728 |
| 5729 FrameTestHelpers::TestWebFrameClient client; |
| 5730 WebFrame* localFrame = WebLocalFrame::create(&client); |
| 5731 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); |
| 5732 |
| 5733 // FIXME: This almost certainly fires more load events on the iframe element |
| 5734 // than it should. |
| 5735 // Finally, make sure an embedder triggered load in the local frame swapped |
| 5736 // back in works. |
| 5737 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| 5738 std::string content = localFrame->contentAsText(1024).utf8(); |
| 5739 EXPECT_EQ("hello", content); |
| 5740 |
| 5741 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 5742 // TestWebFrameClient. |
| 5743 reset(); |
| 5744 remoteFrame->close(); |
| 5745 } |
| 5746 |
| 5616 } // namespace | 5747 } // namespace |
| OLD | NEW |