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

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

Issue 2741633002: Remove FrameHost::eventHandlerRegistry() (Closed)
Patch Set: Rebase Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp ('k') | no next file » | 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 3293 matching lines...) Expand 10 before | Expand all | Expand 10 after
3304 3304
3305 // The page is initialized with at least one no-handlers call. 3305 // The page is initialized with at least one no-handlers call.
3306 // In practice we get two such calls because WebViewHelper::initializeAndLoad 3306 // In practice we get two such calls because WebViewHelper::initializeAndLoad
3307 // first initializes an empty frame, and then loads a document into it, so 3307 // first initializes an empty frame, and then loads a document into it, so
3308 // there are two FrameLoader::commitProvisionalLoad calls. 3308 // there are two FrameLoader::commitProvisionalLoad calls.
3309 EXPECT_LT(0, client.getAndResetHasTouchEventHandlerCallCount(false)); 3309 EXPECT_LT(0, client.getAndResetHasTouchEventHandlerCallCount(false));
3310 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); 3310 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
3311 3311
3312 // Adding the first document handler results in a has-handlers call. 3312 // Adding the first document handler results in a has-handlers call.
3313 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 3313 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
3314 EventHandlerRegistry* registry = 3314 EventHandlerRegistry* registry = &document->page()->eventHandlerRegistry();
3315 &document->frameHost()->eventHandlerRegistry();
3316 registry->didAddEventHandler(*document, touchEvent); 3315 registry->didAddEventHandler(*document, touchEvent);
3317 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); 3316 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
3318 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); 3317 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true));
3319 3318
3320 // Adding another handler has no effect. 3319 // Adding another handler has no effect.
3321 registry->didAddEventHandler(*document, touchEvent); 3320 registry->didAddEventHandler(*document, touchEvent);
3322 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); 3321 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
3323 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); 3322 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
3324 3323
3325 // Removing the duplicate handler has no effect. 3324 // Removing the duplicate handler has no effect.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
3420 // handlers also removes them from the event handler registry. Note that this 3419 // handlers also removes them from the event handler registry. Note that this
3421 // is different from detaching and re-attaching the same node, which is covered 3420 // is different from detaching and re-attaching the same node, which is covered
3422 // by layout tests under fast/events/. 3421 // by layout tests under fast/events/.
3423 TEST_P(WebViewTest, DeleteElementWithRegisteredHandler) { 3422 TEST_P(WebViewTest, DeleteElementWithRegisteredHandler) {
3424 std::string url = registerMockedHttpURLLoad("simple_div.html"); 3423 std::string url = registerMockedHttpURLLoad("simple_div.html");
3425 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true); 3424 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true);
3426 3425
3427 Persistent<Document> document = 3426 Persistent<Document> document =
3428 webViewImpl->mainFrameImpl()->frame()->document(); 3427 webViewImpl->mainFrameImpl()->frame()->document();
3429 Element* div = document->getElementById("div"); 3428 Element* div = document->getElementById("div");
3430 EventHandlerRegistry& registry = 3429 EventHandlerRegistry& registry = document->page()->eventHandlerRegistry();
3431 document->frameHost()->eventHandlerRegistry();
3432 3430
3433 registry.didAddEventHandler(*div, EventHandlerRegistry::ScrollEvent); 3431 registry.didAddEventHandler(*div, EventHandlerRegistry::ScrollEvent);
3434 EXPECT_TRUE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent)); 3432 EXPECT_TRUE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent));
3435 3433
3436 DummyExceptionStateForTesting exceptionState; 3434 DummyExceptionStateForTesting exceptionState;
3437 div->remove(exceptionState); 3435 div->remove(exceptionState);
3438 3436
3439 // For oilpan we have to force a GC to ensure the event handlers have been 3437 // For oilpan we have to force a GC to ensure the event handlers have been
3440 // removed when checking below. We do a precise GC (collectAllGarbage does not 3438 // removed when checking below. We do a precise GC (collectAllGarbage does not
3441 // scan the stack) to ensure the div element dies. This is also why the 3439 // scan the stack) to ensure the div element dies. This is also why the
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
4333 EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars()); 4331 EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars());
4334 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 4332 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
4335 EXPECT_NE(nullptr, 4333 EXPECT_NE(nullptr,
4336 frameView->layoutViewportScrollableArea()->verticalScrollbar()); 4334 frameView->layoutViewportScrollableArea()->verticalScrollbar());
4337 } else { 4335 } else {
4338 EXPECT_NE(nullptr, frameView->verticalScrollbar()); 4336 EXPECT_NE(nullptr, frameView->verticalScrollbar());
4339 } 4337 }
4340 } 4338 }
4341 4339
4342 } // namespace blink 4340 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698