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

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

Issue 392283002: Always remove registered handlers for deleted node (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Clarifying comment. Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/web/tests/data/simple_div.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "public/web/WebView.h" 32 #include "public/web/WebView.h"
33 33
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/Element.h" 35 #include "core/dom/Element.h"
36 #include "core/frame/EventHandlerRegistry.h"
36 #include "core/frame/FrameView.h" 37 #include "core/frame/FrameView.h"
37 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
38 #include "core/frame/Settings.h" 39 #include "core/frame/Settings.h"
39 #include "core/html/HTMLDocument.h" 40 #include "core/html/HTMLDocument.h"
40 #include "core/html/HTMLIFrameElement.h" 41 #include "core/html/HTMLIFrameElement.h"
41 #include "core/html/HTMLInputElement.h" 42 #include "core/html/HTMLInputElement.h"
42 #include "core/html/HTMLTextAreaElement.h" 43 #include "core/html/HTMLTextAreaElement.h"
43 #include "core/loader/FrameLoadRequest.h" 44 #include "core/loader/FrameLoadRequest.h"
44 #include "core/page/Chrome.h" 45 #include "core/page/Chrome.h"
45 #include "core/page/Page.h" 46 #include "core/page/Page.h"
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 1792
1792 // Now removing the handler in the parent document results in a no-handlers call. 1793 // Now removing the handler in the parent document results in a no-handlers call.
1793 document->didRemoveTouchEventHandler(childFrame); 1794 document->didRemoveTouchEventHandler(childFrame);
1794 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false)); 1795 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false));
1795 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); 1796 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
1796 1797
1797 // Free the webView before the TouchEventHandlerWebViewClient gets freed. 1798 // Free the webView before the TouchEventHandlerWebViewClient gets freed.
1798 m_webViewHelper.reset(); 1799 m_webViewHelper.reset();
1799 } 1800 }
1800 1801
1802 // This test checks that deleting nodes which have only non-JS-registered touch
1803 // handlers also removes them from the event handler registry. Note that this
1804 // is different from detaching and re-attaching the same node, which is covered
1805 // by layout tests under fast/events/.
1806 TEST_F(WebViewTest, DeleteElementWithRegisteredHandler)
1807 {
1808 std::string url = m_baseURL + "simple_div.html";
1809 URLTestHelpers::registerMockedURLLoad(toKURL(url), "simple_div.html");
1810 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true);
1811
1812 WebCore::Document* document = webViewImpl->mainFrameImpl()->frame()->documen t();
1813 WebCore::Element* div = document->getElementById("div");
1814 WebCore::EventHandlerRegistry& registry = document->frameHost()->eventHandle rRegistry();
1815
1816 registry.didAddEventHandler(*div, WebCore::EventHandlerRegistry::ScrollEvent );
1817 EXPECT_TRUE(registry.hasEventHandlers(WebCore::EventHandlerRegistry::ScrollE vent));
1818
1819 WebCore::TrackExceptionState exceptionState;
1820 div->remove(exceptionState);
1821 EXPECT_FALSE(registry.hasEventHandlers(WebCore::EventHandlerRegistry::Scroll Event));
1822 }
1823
1801 static WebRect ExpectedRootBounds(WebCore::Document* document, float scaleFactor ) 1824 static WebRect ExpectedRootBounds(WebCore::Document* document, float scaleFactor )
1802 { 1825 {
1803 WebCore::Element* element = document->getElementById("root"); 1826 WebCore::Element* element = document->getElementById("root");
1804 if (!element) 1827 if (!element)
1805 element = document->getElementById("target"); 1828 element = document->getElementById("target");
1806 if (element->hasTagName(WebCore::HTMLNames::iframeTag)) 1829 if (element->hasTagName(WebCore::HTMLNames::iframeTag))
1807 return ExpectedRootBounds(toHTMLIFrameElement(element)->contentDocument( ), scaleFactor); 1830 return ExpectedRootBounds(toHTMLIFrameElement(element)->contentDocument( ), scaleFactor);
1808 1831
1809 WebCore::IntRect boundingBox; 1832 WebCore::IntRect boundingBox;
1810 if (element->hasTagName(WebCore::HTMLNames::htmlTag)) 1833 if (element->hasTagName(WebCore::HTMLNames::htmlTag))
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 2099
2077 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); 2100 EXPECT_EQ(0, client.getUserGestureNotificationsCount());
2078 2101
2079 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target"))); 2102 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target")));
2080 2103
2081 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); 2104 EXPECT_EQ(1, client.getUserGestureNotificationsCount());
2082 webView->setAutofillClient(0); 2105 webView->setAutofillClient(0);
2083 } 2106 }
2084 2107
2085 } // namespace 2108 } // namespace
OLDNEW
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/web/tests/data/simple_div.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698