| 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 10637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10648 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); | 10648 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); |
| 10649 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); | 10649 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); |
| 10650 HashSet<AtomicString> names; | 10650 HashSet<AtomicString> names; |
| 10651 for (Frame* frame = mainFrame->tree().firstChild(); frame; | 10651 for (Frame* frame = mainFrame->tree().firstChild(); frame; |
| 10652 frame = frame->tree().traverseNext()) { | 10652 frame = frame->tree().traverseNext()) { |
| 10653 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); | 10653 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); |
| 10654 } | 10654 } |
| 10655 EXPECT_EQ(10u, names.size()); | 10655 EXPECT_EQ(10u, names.size()); |
| 10656 } | 10656 } |
| 10657 | 10657 |
| 10658 TEST_F(WebFrameTest, NoLoadingCompletionCallbacksInDetach) { |
| 10659 class LoadingObserverFrameClient |
| 10660 : public FrameTestHelpers::TestWebFrameClient { |
| 10661 public: |
| 10662 void frameDetached(WebLocalFrame*, DetachType) override { |
| 10663 m_didCallFrameDetached = true; |
| 10664 } |
| 10665 |
| 10666 void didStopLoading() override { |
| 10667 // TODO(dcheng): Investigate not calling this as well during frame detach. |
| 10668 m_didCallDidStopLoading = true; |
| 10669 } |
| 10670 |
| 10671 void didFailProvisionalLoad(WebLocalFrame*, |
| 10672 const WebURLError&, |
| 10673 WebHistoryCommitType) override { |
| 10674 EXPECT_TRUE(false) << "The load should not have failed."; |
| 10675 } |
| 10676 |
| 10677 void didFinishDocumentLoad(WebLocalFrame*) override { |
| 10678 // TODO(dcheng): Investigate not calling this as well during frame detach. |
| 10679 m_didCallDidFinishDocumentLoad = true; |
| 10680 } |
| 10681 |
| 10682 void didHandleOnloadEvents(WebLocalFrame*) override { |
| 10683 // TODO(dcheng): Investigate not calling this as well during frame detach. |
| 10684 m_didCallDidHandleOnloadEvents = true; |
| 10685 } |
| 10686 |
| 10687 void didFinishLoad(WebLocalFrame*) override { |
| 10688 EXPECT_TRUE(false) << "didFinishLoad() should not have been called."; |
| 10689 } |
| 10690 |
| 10691 void dispatchLoad() override { |
| 10692 EXPECT_TRUE(false) << "dispatchLoad() should not have been called."; |
| 10693 } |
| 10694 |
| 10695 bool didCallFrameDetached() const { return m_didCallFrameDetached; } |
| 10696 bool didCallDidStopLoading() const { return m_didCallDidStopLoading; } |
| 10697 bool didCallDidFinishDocumentLoad() const { |
| 10698 return m_didCallDidFinishDocumentLoad; |
| 10699 } |
| 10700 bool didCallDidHandleOnloadEvents() const { |
| 10701 return m_didCallDidHandleOnloadEvents; |
| 10702 } |
| 10703 |
| 10704 private: |
| 10705 bool m_didCallFrameDetached = false; |
| 10706 bool m_didCallDidStopLoading = false; |
| 10707 bool m_didCallDidFinishDocumentLoad = false; |
| 10708 bool m_didCallDidHandleOnloadEvents = false; |
| 10709 }; |
| 10710 |
| 10711 class MainFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 10712 public: |
| 10713 WebLocalFrame* createChildFrame(WebLocalFrame* parent, |
| 10714 WebTreeScopeType scope, |
| 10715 const WebString& name, |
| 10716 const WebString& uniqueName, |
| 10717 WebSandboxFlags sandboxFlags, |
| 10718 const WebFrameOwnerProperties&) override { |
| 10719 WebLocalFrame* frame = WebLocalFrame::create(scope, &m_childClient); |
| 10720 parent->appendChild(frame); |
| 10721 return frame; |
| 10722 } |
| 10723 |
| 10724 LoadingObserverFrameClient& childClient() { return m_childClient; } |
| 10725 |
| 10726 private: |
| 10727 LoadingObserverFrameClient m_childClient; |
| 10728 }; |
| 10729 |
| 10730 registerMockedHttpURLLoad("single_iframe.html"); |
| 10731 URLTestHelpers::registerMockedURLLoad( |
| 10732 toKURL(m_baseURL + "visible_iframe.html"), |
| 10733 WebString::fromUTF8("frame_with_frame.html")); |
| 10734 registerMockedHttpURLLoad("parent_detaching_frame.html"); |
| 10735 |
| 10736 FrameTestHelpers::WebViewHelper webViewHelper; |
| 10737 MainFrameClient mainFrameClient; |
| 10738 webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html", true, |
| 10739 &mainFrameClient); |
| 10740 |
| 10741 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); |
| 10742 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); |
| 10743 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); |
| 10744 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); |
| 10745 |
| 10746 webViewHelper.reset(); |
| 10747 } |
| 10748 |
| 10658 } // namespace blink | 10749 } // namespace blink |
| OLD | NEW |