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 4221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4232 webViewHelper.initializeAndLoad( | 4232 webViewHelper.initializeAndLoad( |
4233 m_baseURL + "iframe_clear_focused_node_test.html", true); | 4233 m_baseURL + "iframe_clear_focused_node_test.html", true); |
4234 | 4234 |
4235 // Clear the focused node. | 4235 // Clear the focused node. |
4236 webViewHelper.webView()->clearFocusedElement(); | 4236 webViewHelper.webView()->clearFocusedElement(); |
4237 | 4237 |
4238 // Now retrieve the FocusedNode and test it should be null. | 4238 // Now retrieve the FocusedNode and test it should be null. |
4239 EXPECT_EQ(0, webViewHelper.webView()->focusedElement()); | 4239 EXPECT_EQ(0, webViewHelper.webView()->focusedElement()); |
4240 } | 4240 } |
4241 | 4241 |
| 4242 class ChangedSelectionCounter : public FrameTestHelpers::TestWebFrameClient { |
| 4243 public: |
| 4244 ChangedSelectionCounter() : m_callCount(0) {} |
| 4245 void didChangeSelection(bool isSelectionEmpty) { m_callCount++; } |
| 4246 int count() const { return m_callCount; } |
| 4247 void reset() { m_callCount = 0; } |
| 4248 |
| 4249 private: |
| 4250 int m_callCount; |
| 4251 }; |
| 4252 |
| 4253 TEST_P(ParameterizedWebFrameTest, OneFocusChangeMeansOneSelectionChange) { |
| 4254 ChangedSelectionCounter counter; |
| 4255 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4256 registerMockedHttpURLLoad("editable_elements.html"); |
| 4257 webViewHelper.initializeAndLoad(m_baseURL + "editable_elements.html", true, |
| 4258 &counter); |
| 4259 |
| 4260 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
| 4261 Document* document = frame->frame()->document(); |
| 4262 |
| 4263 // Move to a text-field. |
| 4264 Element* firstField = document->getElementById("input1"); |
| 4265 counter.reset(); |
| 4266 firstField->focus(); |
| 4267 EXPECT_EQ(1, counter.count()); |
| 4268 |
| 4269 // Move to another text-field. |
| 4270 Element* secondField = document->getElementById("input2"); |
| 4271 counter.reset(); |
| 4272 secondField->focus(); |
| 4273 EXPECT_EQ(1, counter.count()); |
| 4274 |
| 4275 // Move to a number-field. |
| 4276 Element* numberField = document->getElementById("input3"); |
| 4277 counter.reset(); |
| 4278 numberField->focus(); |
| 4279 EXPECT_EQ(1, counter.count()); |
| 4280 |
| 4281 // Move to an editable element. |
| 4282 Element* editableP = document->getElementById("p1"); |
| 4283 counter.reset(); |
| 4284 editableP->focus(); |
| 4285 EXPECT_EQ(1, counter.count()); |
| 4286 } |
| 4287 |
4242 // Implementation of WebFrameClient that tracks the v8 contexts that are created | 4288 // Implementation of WebFrameClient that tracks the v8 contexts that are created |
4243 // and destroyed for verification. | 4289 // and destroyed for verification. |
4244 class ContextLifetimeTestWebFrameClient | 4290 class ContextLifetimeTestWebFrameClient |
4245 : public FrameTestHelpers::TestWebFrameClient { | 4291 : public FrameTestHelpers::TestWebFrameClient { |
4246 public: | 4292 public: |
4247 struct Notification { | 4293 struct Notification { |
4248 public: | 4294 public: |
4249 Notification(WebLocalFrame* frame, | 4295 Notification(WebLocalFrame* frame, |
4250 v8::Local<v8::Context> context, | 4296 v8::Local<v8::Context> context, |
4251 int worldId) | 4297 int worldId) |
(...skipping 6983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11235 | 11281 |
11236 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); | 11282 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); |
11237 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); | 11283 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); |
11238 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); | 11284 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); |
11239 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); | 11285 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); |
11240 | 11286 |
11241 webViewHelper.reset(); | 11287 webViewHelper.reset(); |
11242 } | 11288 } |
11243 | 11289 |
11244 } // namespace blink | 11290 } // namespace blink |
OLD | NEW |