Add new FrameTest.* unit tests and fix discovered CefFrame-related bugs.

- Allow empty |name| argument to CefBrowser::GetFrame. This will return the main frame.
- Modify CefBrowser::GetFrame to search both assigned and unique frame names.
- Calling CefFrame::IsFocused on the main frame should return true when there are no other frames.
- Fix CefBrowser::GetFrameIdentifiers and GetFrameNames to return correct values in the renderer process (issue #1236).
- Delete NavigationTest.FrameNameIdent which is now obsoleted by the new FrameTests.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1842 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2014-09-24 15:38:11 +00:00
parent c17cd60630
commit 39ca06a66d
12 changed files with 2455 additions and 206 deletions

View File

@@ -56,7 +56,7 @@ CefFrameHostImpl::CefFrameHostImpl(CefBrowserHostImpl* browser,
: frame_id_(frame_id),
is_main_frame_(is_main_frame),
browser_(browser),
is_focused_(false),
is_focused_(is_main_frame_), // The main frame always starts focused.
url_(url),
name_(name),
parent_frame_id_(parent_frame_id == kUnspecifiedFrameId ?

View File

@@ -190,9 +190,17 @@ CefRefPtr<CefFrame> CefBrowserImpl::GetFrame(int64 identifier) {
CefRefPtr<CefFrame> CefBrowserImpl::GetFrame(const CefString& name) {
CEF_REQUIRE_RT_RETURN(NULL);
if (render_view()->GetWebView()) {
WebFrame* frame =
render_view()->GetWebView()->findFrameByName(name.ToString16());
blink::WebView* web_view = render_view()->GetWebView();
if (web_view) {
const blink::WebString& frame_name = name.ToString16();
// Search by assigned frame name (Frame::name).
WebFrame* frame = web_view->findFrameByName(frame_name,
web_view->mainFrame());
if (!frame) {
// Search by unique frame name (Frame::uniqueName).
frame = webkit_glue::FindFrameByUniqueName(frame_name,
web_view->mainFrame());
}
if (frame)
return GetWebFrameImpl(frame).get();
}
@@ -222,6 +230,9 @@ size_t CefBrowserImpl::GetFrameCount() {
void CefBrowserImpl::GetFrameIdentifiers(std::vector<int64>& identifiers) {
CEF_REQUIRE_RT_RETURN_VOID();
if (identifiers.size() > 0)
identifiers.clear();
if (render_view()->GetWebView()) {
WebFrame* main_frame = render_view()->GetWebView()->mainFrame();
if (main_frame) {
@@ -237,6 +248,9 @@ void CefBrowserImpl::GetFrameIdentifiers(std::vector<int64>& identifiers) {
void CefBrowserImpl::GetFrameNames(std::vector<CefString>& names) {
CEF_REQUIRE_RT_RETURN_VOID();
if (names.size() > 0)
names.clear();
if (render_view()->GetWebView()) {
WebFrame* main_frame = render_view()->GetWebView()->mainFrame();
if (main_frame) {

View File

@@ -26,6 +26,7 @@ MSVC_PUSH_WARNING_LEVEL(0);
#include "third_party/WebKit/public/web/WebViewClient.h"
#include "third_party/WebKit/Source/core/dom/Node.h"
#include "third_party/WebKit/Source/web/WebLocalFrameImpl.h"
#include "third_party/WebKit/Source/web/WebViewImpl.h"
MSVC_POP_WARNING();
#undef LOG
@@ -94,4 +95,30 @@ int64 GetIdentifier(blink::WebFrame* frame) {
return kInvalidFrameId;
}
// Based on WebViewImpl::findFrameByName and FrameTree::find.
blink::WebFrame* FindFrameByUniqueName(const blink::WebString& unique_name,
blink::WebFrame* relative_to_frame) {
blink::Frame* start_frame = toWebLocalFrameImpl(relative_to_frame)->frame();
if (!start_frame)
return NULL;
const AtomicString& atomic_name = unique_name;
blink::Frame* found_frame = NULL;
// Search the subtree starting with |start_frame|.
for (blink::Frame* frame = start_frame;
frame;
frame = frame->tree().traverseNext(start_frame)) {
if (frame->tree().uniqueName() == atomic_name) {
found_frame = frame;
break;
}
}
if (found_frame && found_frame->isLocalFrame())
return blink::WebLocalFrameImpl::fromFrame(toLocalFrame(found_frame));
return NULL;
}
} // webkit_glue

View File

@@ -38,6 +38,11 @@ bool SetNodeValue(blink::WebNode& node, const blink::WebString& value);
int64 GetIdentifier(blink::WebFrame* frame);
// Find the frame with the specified |unique_name| relative to
// |relative_to_frame| in the frame hierarchy.
blink::WebFrame* FindFrameByUniqueName(const blink::WebString& unique_name,
blink::WebFrame* relative_to_frame);
} // webkit_glue
#endif // CEF_LIBCEF_RENDERER_WEBKIT_GLUE_H_