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

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

Issue 173283003: WebDocument::focusedNode should be focusedElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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 | « Source/web/WebDocument.cpp ('k') | public/web/WebDocument.h » ('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) 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 2904 matching lines...) Expand 10 before | Expand all | Expand 10 after
2915 WebFrame* frame = webViewHelper.webView()->mainFrame(); 2915 WebFrame* frame = webViewHelper.webView()->mainFrame();
2916 const int findIdentifier = 12345; 2916 const int findIdentifier = 12345;
2917 WebFindOptions options; 2917 WebFindOptions options;
2918 2918
2919 // Find in a <div> element. 2919 // Find in a <div> element.
2920 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options , false, 0)); 2920 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options , false, 0));
2921 frame->stopFinding(false); 2921 frame->stopFinding(false);
2922 WebRange range = frame->selectionRange(); 2922 WebRange range = frame->selectionRange();
2923 EXPECT_EQ(5, range.startOffset()); 2923 EXPECT_EQ(5, range.startOffset());
2924 EXPECT_EQ(9, range.endOffset()); 2924 EXPECT_EQ(9, range.endOffset());
2925 EXPECT_TRUE(frame->document().focusedNode().isNull()); 2925 EXPECT_TRUE(frame->document().focusedElement().isNull());
2926 2926
2927 // Find in an <input> value. 2927 // Find in an <input> value.
2928 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar2"), options , false, 0)); 2928 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar2"), options , false, 0));
2929 // Confirm stopFinding(false) sets the selection on the found text. 2929 // Confirm stopFinding(false) sets the selection on the found text.
2930 frame->stopFinding(false); 2930 frame->stopFinding(false);
2931 range = frame->selectionRange(); 2931 range = frame->selectionRange();
2932 ASSERT_FALSE(range.isNull()); 2932 ASSERT_FALSE(range.isNull());
2933 EXPECT_EQ(5, range.startOffset()); 2933 EXPECT_EQ(5, range.startOffset());
2934 EXPECT_EQ(9, range.endOffset()); 2934 EXPECT_EQ(9, range.endOffset());
2935 EXPECT_EQ(WebString::fromUTF8("INPUT"), frame->document().focusedNode().node Name()); 2935 EXPECT_EQ(WebString::fromUTF8("INPUT"), frame->document().focusedElement().t agName());
2936 2936
2937 // Find in a <textarea> content. 2937 // Find in a <textarea> content.
2938 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar3"), options , false, 0)); 2938 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar3"), options , false, 0));
2939 // Confirm stopFinding(false) sets the selection on the found text. 2939 // Confirm stopFinding(false) sets the selection on the found text.
2940 frame->stopFinding(false); 2940 frame->stopFinding(false);
2941 range = frame->selectionRange(); 2941 range = frame->selectionRange();
2942 ASSERT_FALSE(range.isNull()); 2942 ASSERT_FALSE(range.isNull());
2943 EXPECT_EQ(5, range.startOffset()); 2943 EXPECT_EQ(5, range.startOffset());
2944 EXPECT_EQ(9, range.endOffset()); 2944 EXPECT_EQ(9, range.endOffset());
2945 EXPECT_EQ(WebString::fromUTF8("TEXTAREA"), frame->document().focusedNode().n odeName()); 2945 EXPECT_EQ(WebString::fromUTF8("TEXTAREA"), frame->document().focusedElement( ).tagName());
2946 2946
2947 // Find in a contentEditable element. 2947 // Find in a contentEditable element.
2948 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar4"), options , false, 0)); 2948 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar4"), options , false, 0));
2949 // Confirm stopFinding(false) sets the selection on the found text. 2949 // Confirm stopFinding(false) sets the selection on the found text.
2950 frame->stopFinding(false); 2950 frame->stopFinding(false);
2951 range = frame->selectionRange(); 2951 range = frame->selectionRange();
2952 ASSERT_FALSE(range.isNull()); 2952 ASSERT_FALSE(range.isNull());
2953 EXPECT_EQ(0, range.startOffset()); 2953 EXPECT_EQ(0, range.startOffset());
2954 EXPECT_EQ(4, range.endOffset()); 2954 EXPECT_EQ(4, range.endOffset());
2955 // "bar4" is surrounded by <span>, but the focusable node should be the pare nt <div>. 2955 // "bar4" is surrounded by <span>, but the focusable node should be the pare nt <div>.
2956 EXPECT_EQ(WebString::fromUTF8("DIV"), frame->document().focusedNode().nodeNa me()); 2956 EXPECT_EQ(WebString::fromUTF8("DIV"), frame->document().focusedElement().tag Name());
2957 2957
2958 // Find in <select> content. 2958 // Find in <select> content.
2959 EXPECT_FALSE(frame->find(findIdentifier, WebString::fromUTF8("bar5"), option s, false, 0)); 2959 EXPECT_FALSE(frame->find(findIdentifier, WebString::fromUTF8("bar5"), option s, false, 0));
2960 // If there are any matches, stopFinding will set the selection on the found text. 2960 // If there are any matches, stopFinding will set the selection on the found text.
2961 // However, we do not expect any matches, so check that the selection is nul l. 2961 // However, we do not expect any matches, so check that the selection is nul l.
2962 frame->stopFinding(false); 2962 frame->stopFinding(false);
2963 range = frame->selectionRange(); 2963 range = frame->selectionRange();
2964 ASSERT_TRUE(range.isNull()); 2964 ASSERT_TRUE(range.isNull());
2965 } 2965 }
2966 2966
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after
5162 webViewHelper.initializeAndLoad("about:blank"); 5162 webViewHelper.initializeAndLoad("about:blank");
5163 5163
5164 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl() ->frameView(); 5164 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl() ->frameView();
5165 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200)); 5165 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200));
5166 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect()); 5166 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect());
5167 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200)); 5167 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200));
5168 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect()) ; 5168 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect()) ;
5169 } 5169 }
5170 5170
5171 } // namespace 5171 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebDocument.cpp ('k') | public/web/WebDocument.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698