| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 Element* element = frame->document()->getElementById(testcase.c_str()); | 268 Element* element = frame->document()->getElementById(testcase.c_str()); |
| 269 return frame->nodeImage(*element); | 269 return frame->nodeImage(*element); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void removeElementById(WebLocalFrameImpl* frame, const AtomicString& id) { | 272 void removeElementById(WebLocalFrameImpl* frame, const AtomicString& id) { |
| 273 Element* element = frame->frame()->document()->getElementById(id); | 273 Element* element = frame->frame()->document()->getElementById(id); |
| 274 DCHECK(element); | 274 DCHECK(element); |
| 275 element->remove(); | 275 element->remove(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 // Both sets the inner html and runs the document lifecycle. |
| 279 void initializeWithHTML(LocalFrame& frame, const String& htmlContent) { |
| 280 frame.document()->body()->setInnerHTML(htmlContent, ASSERT_NO_EXCEPTION); |
| 281 frame.document()->view()->updateAllLifecyclePhases(); |
| 282 } |
| 283 |
| 278 std::string m_baseURL; | 284 std::string m_baseURL; |
| 279 std::string m_notBaseURL; | 285 std::string m_notBaseURL; |
| 280 std::string m_chromeURL; | 286 std::string m_chromeURL; |
| 281 }; | 287 }; |
| 282 | 288 |
| 283 typedef bool TestParamRootLayerScrolling; | 289 typedef bool TestParamRootLayerScrolling; |
| 284 class ParameterizedWebFrameTest | 290 class ParameterizedWebFrameTest |
| 285 : public ::testing::WithParamInterface<TestParamRootLayerScrolling>, | 291 : public ::testing::WithParamInterface<TestParamRootLayerScrolling>, |
| 286 private ScopedRootLayerScrollingForTest, | 292 private ScopedRootLayerScrollingForTest, |
| 287 public WebFrameTest { | 293 public WebFrameTest { |
| (...skipping 9975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10263 // seeing a Begin first doesn't break anything. (This currently happens). | 10269 // seeing a Begin first doesn't break anything. (This currently happens). |
| 10264 webViewHelper.webView()->handleInputEvent(endEvent); | 10270 webViewHelper.webView()->handleInputEvent(endEvent); |
| 10265 webViewHelper.webView()->handleInputEvent(updateEvent); | 10271 webViewHelper.webView()->handleInputEvent(updateEvent); |
| 10266 | 10272 |
| 10267 // Try a full Begin/Update/End cycle. | 10273 // Try a full Begin/Update/End cycle. |
| 10268 webViewHelper.webView()->handleInputEvent(beginEvent); | 10274 webViewHelper.webView()->handleInputEvent(beginEvent); |
| 10269 webViewHelper.webView()->handleInputEvent(updateEvent); | 10275 webViewHelper.webView()->handleInputEvent(updateEvent); |
| 10270 webViewHelper.webView()->handleInputEvent(endEvent); | 10276 webViewHelper.webView()->handleInputEvent(endEvent); |
| 10271 } | 10277 } |
| 10272 | 10278 |
| 10279 TEST_F(WebFrameTest, HidingScrollbarsOnScrollableAreaDisablesScrollbars) { |
| 10280 FrameTestHelpers::WebViewHelper webViewHelper; |
| 10281 webViewHelper.initialize(true); |
| 10282 webViewHelper.resize(WebSize(800, 600)); |
| 10283 WebViewImpl* webView = webViewHelper.webView(); |
| 10284 |
| 10285 initializeWithHTML( |
| 10286 *webView->mainFrameImpl()->frame(), |
| 10287 "<!DOCTYPE html>" |
| 10288 "<style>" |
| 10289 " #scroller { overflow: scroll; width: 1000px; height: 1000px }" |
| 10290 " #spacer { width: 2000px; height: 2000px }" |
| 10291 "</style>" |
| 10292 "<div id='scroller'>" |
| 10293 " <div id='spacer'></div>" |
| 10294 "</div>"); |
| 10295 |
| 10296 Document* document = webView->mainFrameImpl()->frame()->document(); |
| 10297 FrameView* frameView = webView->mainFrameImpl()->frameView(); |
| 10298 Element* scroller = document->getElementById("scroller"); |
| 10299 ScrollableArea* scrollerArea = |
| 10300 toLayoutBox(scroller->layoutObject())->getScrollableArea(); |
| 10301 |
| 10302 ASSERT_TRUE(scrollerArea->horizontalScrollbar()); |
| 10303 ASSERT_TRUE(scrollerArea->verticalScrollbar()); |
| 10304 ASSERT_TRUE(frameView->horizontalScrollbar()); |
| 10305 ASSERT_TRUE(frameView->verticalScrollbar()); |
| 10306 |
| 10307 EXPECT_FALSE(frameView->scrollbarsHidden()); |
| 10308 EXPECT_TRUE(frameView->horizontalScrollbar()->enabled()); |
| 10309 EXPECT_TRUE(frameView->verticalScrollbar()->enabled()); |
| 10310 |
| 10311 EXPECT_FALSE(scrollerArea->scrollbarsHidden()); |
| 10312 EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled()); |
| 10313 EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled()); |
| 10314 |
| 10315 frameView->setScrollbarsHidden(true); |
| 10316 EXPECT_FALSE(frameView->horizontalScrollbar()->enabled()); |
| 10317 EXPECT_FALSE(frameView->verticalScrollbar()->enabled()); |
| 10318 frameView->setScrollbarsHidden(false); |
| 10319 EXPECT_TRUE(frameView->horizontalScrollbar()->enabled()); |
| 10320 EXPECT_TRUE(frameView->verticalScrollbar()->enabled()); |
| 10321 |
| 10322 scrollerArea->setScrollbarsHidden(true); |
| 10323 EXPECT_FALSE(scrollerArea->horizontalScrollbar()->enabled()); |
| 10324 EXPECT_FALSE(scrollerArea->verticalScrollbar()->enabled()); |
| 10325 scrollerArea->setScrollbarsHidden(false); |
| 10326 EXPECT_TRUE(scrollerArea->horizontalScrollbar()->enabled()); |
| 10327 EXPECT_TRUE(scrollerArea->verticalScrollbar()->enabled()); |
| 10328 } |
| 10329 |
| 10273 TEST_F(WebFrameTest, UniqueNames) { | 10330 TEST_F(WebFrameTest, UniqueNames) { |
| 10274 registerMockedHttpURLLoad("frameset-repeated-name.html"); | 10331 registerMockedHttpURLLoad("frameset-repeated-name.html"); |
| 10275 registerMockedHttpURLLoad("frameset-dest.html"); | 10332 registerMockedHttpURLLoad("frameset-dest.html"); |
| 10276 FrameTestHelpers::WebViewHelper webViewHelper; | 10333 FrameTestHelpers::WebViewHelper webViewHelper; |
| 10277 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); | 10334 webViewHelper.initializeAndLoad(m_baseURL + "frameset-repeated-name.html"); |
| 10278 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); | 10335 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); |
| 10279 HashSet<AtomicString> names; | 10336 HashSet<AtomicString> names; |
| 10280 for (Frame* frame = mainFrame->tree().firstChild(); frame; | 10337 for (Frame* frame = mainFrame->tree().firstChild(); frame; |
| 10281 frame = frame->tree().traverseNext()) { | 10338 frame = frame->tree().traverseNext()) { |
| 10282 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); | 10339 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); |
| 10283 } | 10340 } |
| 10284 EXPECT_EQ(10u, names.size()); | 10341 EXPECT_EQ(10u, names.size()); |
| 10285 } | 10342 } |
| 10286 | 10343 |
| 10287 } // namespace blink | 10344 } // namespace blink |
| OLD | NEW |