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