| Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| index e280ce94e14f36d2e8dfc195b0808cd36a294bd9..cb0fd6c179ab8b37ac5f789a5b0cf6d62ba7180f 100644
|
| --- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| +++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| @@ -4239,6 +4239,52 @@ TEST_P(ParameterizedWebFrameTest, ClearFocusedNodeTest) {
|
| EXPECT_EQ(0, webViewHelper.webView()->focusedElement());
|
| }
|
|
|
| +class ChangedSelectionCounter : public FrameTestHelpers::TestWebFrameClient {
|
| + public:
|
| + ChangedSelectionCounter() : m_callCount(0) {}
|
| + void didChangeSelection(bool isSelectionEmpty) { m_callCount++; }
|
| + int count() const { return m_callCount; }
|
| + void reset() { m_callCount = 0; }
|
| +
|
| + private:
|
| + int m_callCount;
|
| +};
|
| +
|
| +TEST_P(ParameterizedWebFrameTest, OneFocusChangeMeansOneSelectionChange) {
|
| + ChangedSelectionCounter counter;
|
| + FrameTestHelpers::WebViewHelper webViewHelper;
|
| + registerMockedHttpURLLoad("editable_elements.html");
|
| + webViewHelper.initializeAndLoad(m_baseURL + "editable_elements.html", true,
|
| + &counter);
|
| +
|
| + WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
|
| + Document* document = frame->frame()->document();
|
| +
|
| + // Move to a text-field.
|
| + Element* firstField = document->getElementById("input1");
|
| + counter.reset();
|
| + firstField->focus();
|
| + EXPECT_EQ(1, counter.count());
|
| +
|
| + // Move to another text-field.
|
| + Element* secondField = document->getElementById("input2");
|
| + counter.reset();
|
| + secondField->focus();
|
| + EXPECT_EQ(1, counter.count());
|
| +
|
| + // Move to a number-field.
|
| + Element* numberField = document->getElementById("input3");
|
| + counter.reset();
|
| + numberField->focus();
|
| + EXPECT_EQ(1, counter.count());
|
| +
|
| + // Move to an editable element.
|
| + Element* editableP = document->getElementById("p1");
|
| + counter.reset();
|
| + editableP->focus();
|
| + EXPECT_EQ(1, counter.count());
|
| +}
|
| +
|
| // Implementation of WebFrameClient that tracks the v8 contexts that are created
|
| // and destroyed for verification.
|
| class ContextLifetimeTestWebFrameClient
|
|
|