Commit 7da56993 authored by japhet's avatar japhet Committed by Commit bot

Reset Frame::m_hasReceivedUserGesture for main frames on navigation

Child frames have some degree of continuity across navigations: the
contents are still embedded in the same document. Let them continue to
propagate user gesture state across navigations. However, main frames
don't have that continuity and should reset their user gesture state
on navigation.

TEST=DocumentUserGestureTokenTest.Navigate
BUG=chromedriver:922

Review-Url: https://codereview.chromium.org/2721423003
Cr-Commit-Position: refs/heads/master@{#456134}
parent 99e10123
...@@ -43,4 +43,14 @@ TEST_F(DocumentUserGestureTokenTest, NewGesture) { ...@@ -43,4 +43,14 @@ TEST_F(DocumentUserGestureTokenTest, NewGesture) {
EXPECT_TRUE(document().frame()->hasReceivedUserGesture()); EXPECT_TRUE(document().frame()->hasReceivedUserGesture());
} }
TEST_F(DocumentUserGestureTokenTest, Navigate) {
DocumentUserGestureToken::create(&document());
ASSERT_TRUE(document().frame()->hasReceivedUserGesture());
// Navigate to a different Document. In the main frame, user gesture state
// will get reset.
document().frame()->loader().load(FrameLoadRequest(nullptr, KURL()));
EXPECT_FALSE(document().frame()->hasReceivedUserGesture());
}
} // namespace blink } // namespace blink
...@@ -515,6 +515,8 @@ void LocalFrame::documentAttached() { ...@@ -515,6 +515,8 @@ void LocalFrame::documentAttached() {
selection().documentAttached(document()); selection().documentAttached(document());
inputMethodController().documentAttached(document()); inputMethodController().documentAttached(document());
spellChecker().documentAttached(document()); spellChecker().documentAttached(document());
if (isMainFrame())
m_hasReceivedUserGesture = false;
} }
LocalDOMWindow* LocalFrame::domWindow() const { LocalDOMWindow* LocalFrame::domWindow() const {
......
...@@ -110,7 +110,7 @@ bool WebFrame::swap(WebFrame* frame) { ...@@ -110,7 +110,7 @@ bool WebFrame::swap(WebFrame* frame) {
uniqueName); uniqueName);
} }
if (oldFrame->hasReceivedUserGesture()) if (m_parent && oldFrame->hasReceivedUserGesture())
frame->toImplBase()->frame()->setDocumentHasReceivedUserGesture(); frame->toImplBase()->frame()->setDocumentHasReceivedUserGesture();
frame->toImplBase()->frame()->getWindowProxyManager()->setGlobals(globals); frame->toImplBase()->frame()->getWindowProxyManager()->setGlobals(globals);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment