Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: third_party/WebKit/Source/core/dom/DocumentTest.cpp

Issue 2956673002: [reland] Move navigation-induced hiding of form-validation-bubble to the browser process. (Closed)
Patch Set: Keep ValidationMessageClient::DocumentDetached method. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014, Google Inc. All rights reserved. 2 * Copyright (c) 2014, 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 287
288 class MockValidationMessageClient 288 class MockValidationMessageClient
289 : public GarbageCollectedFinalized<MockValidationMessageClient>, 289 : public GarbageCollectedFinalized<MockValidationMessageClient>,
290 public ValidationMessageClient { 290 public ValidationMessageClient {
291 USING_GARBAGE_COLLECTED_MIXIN(MockValidationMessageClient); 291 USING_GARBAGE_COLLECTED_MIXIN(MockValidationMessageClient);
292 292
293 public: 293 public:
294 MockValidationMessageClient() { Reset(); } 294 MockValidationMessageClient() { Reset(); }
295 void Reset() { 295 void Reset() {
296 show_validation_message_was_called = false; 296 show_validation_message_was_called = false;
297 will_unload_document_was_called = false;
298 document_detached_was_called = false; 297 document_detached_was_called = false;
299 } 298 }
300 bool show_validation_message_was_called; 299 bool show_validation_message_was_called;
301 bool will_unload_document_was_called;
302 bool document_detached_was_called; 300 bool document_detached_was_called;
303 301
304 // ValidationMessageClient functions. 302 // ValidationMessageClient functions.
305 void ShowValidationMessage(const Element& anchor, 303 void ShowValidationMessage(const Element& anchor,
306 const String& main_message, 304 const String& main_message,
307 TextDirection, 305 TextDirection,
308 const String& sub_message, 306 const String& sub_message,
309 TextDirection) override { 307 TextDirection) override {
310 show_validation_message_was_called = true; 308 show_validation_message_was_called = true;
311 } 309 }
312 void HideValidationMessage(const Element& anchor) override {} 310 void HideValidationMessage(const Element& anchor) override {}
313 bool IsValidationMessageVisible(const Element& anchor) override { 311 bool IsValidationMessageVisible(const Element& anchor) override {
314 return true; 312 return true;
315 } 313 }
316 void WillUnloadDocument(const Document&) override {
317 will_unload_document_was_called = true;
318 }
319 void DocumentDetached(const Document&) override { 314 void DocumentDetached(const Document&) override {
320 document_detached_was_called = true; 315 document_detached_was_called = true;
321 } 316 }
322 void WillBeDestroyed() override {} 317 void WillBeDestroyed() override {}
323 318
324 // DEFINE_INLINE_VIRTUAL_TRACE() { ValidationMessageClient::trace(visitor); } 319 // DEFINE_INLINE_VIRTUAL_TRACE() { ValidationMessageClient::trace(visitor); }
325 }; 320 };
326 321
327 class MockWebApplicationCacheHost 322 class MockWebApplicationCacheHost
328 : NON_EXPORTED_BASE(public blink::WebApplicationCacheHost) { 323 : NON_EXPORTED_BASE(public blink::WebApplicationCacheHost) {
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 toHTMLInputElement(GetDocument().body()->firstChild()); 814 toHTMLInputElement(GetDocument().body()->firstChild());
820 DVLOG(0) << GetDocument().body()->outerHTML(); 815 DVLOG(0) << GetDocument().body()->outerHTML();
821 816
822 // Sanity check. 817 // Sanity check.
823 input->reportValidity(); 818 input->reportValidity();
824 EXPECT_TRUE(mock_client->show_validation_message_was_called); 819 EXPECT_TRUE(mock_client->show_validation_message_was_called);
825 mock_client->Reset(); 820 mock_client->Reset();
826 821
827 // prepareForCommit() unloads the document, and shutdown. 822 // prepareForCommit() unloads the document, and shutdown.
828 GetDocument().GetFrame()->PrepareForCommit(); 823 GetDocument().GetFrame()->PrepareForCommit();
829 EXPECT_TRUE(mock_client->will_unload_document_was_called);
830 EXPECT_TRUE(mock_client->document_detached_was_called); 824 EXPECT_TRUE(mock_client->document_detached_was_called);
831 // Unload handler tried to show a validation message, but it should fail. 825 // Unload handler tried to show a validation message, but it should fail.
832 EXPECT_FALSE(mock_client->show_validation_message_was_called); 826 EXPECT_FALSE(mock_client->show_validation_message_was_called);
833 827
834 GetPage().SetValidationMessageClient(original_client); 828 GetPage().SetValidationMessageClient(original_client);
835 } 829 }
836 830
837 TEST_F(DocumentTest, SandboxDisablesAppCache) { 831 TEST_F(DocumentTest, SandboxDisablesAppCache) {
838 RefPtr<SecurityOrigin> origin = 832 RefPtr<SecurityOrigin> origin =
839 SecurityOrigin::CreateFromString("https://test.com"); 833 SecurityOrigin::CreateFromString("https://test.com");
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 EXPECT_EQ(DocumentLifecycle::kVisualUpdatePending, 907 EXPECT_EQ(DocumentLifecycle::kVisualUpdatePending,
914 GetDocument().Lifecycle().GetState()); 908 GetDocument().Lifecycle().GetState());
915 909
916 GetDocument().EnsurePaintLocationDataValidForNode( 910 GetDocument().EnsurePaintLocationDataValidForNode(
917 GetDocument().getElementById("stickyChild")); 911 GetDocument().getElementById("stickyChild"));
918 EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean, 912 EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean,
919 GetDocument().Lifecycle().GetState()); 913 GetDocument().Lifecycle().GetState());
920 } 914 }
921 915
922 } // namespace blink 916 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/html/HTMLFormControlElementTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698