| OLD | NEW |
| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 class MockValidationMessageClient | 252 class MockValidationMessageClient |
| 253 : public GarbageCollectedFinalized<MockValidationMessageClient>, | 253 : public GarbageCollectedFinalized<MockValidationMessageClient>, |
| 254 public ValidationMessageClient { | 254 public ValidationMessageClient { |
| 255 USING_GARBAGE_COLLECTED_MIXIN(MockValidationMessageClient); | 255 USING_GARBAGE_COLLECTED_MIXIN(MockValidationMessageClient); |
| 256 | 256 |
| 257 public: | 257 public: |
| 258 MockValidationMessageClient() { Reset(); } | 258 MockValidationMessageClient() { Reset(); } |
| 259 void Reset() { | 259 void Reset() { |
| 260 show_validation_message_was_called = false; | 260 show_validation_message_was_called = false; |
| 261 will_unload_document_was_called = false; | |
| 262 document_detached_was_called = false; | |
| 263 } | 261 } |
| 264 bool show_validation_message_was_called; | 262 bool show_validation_message_was_called; |
| 265 bool will_unload_document_was_called; | |
| 266 bool document_detached_was_called; | |
| 267 | 263 |
| 268 // ValidationMessageClient functions. | 264 // ValidationMessageClient functions. |
| 269 void ShowValidationMessage(const Element& anchor, | 265 void ShowValidationMessage(const Element& anchor, |
| 270 const String& main_message, | 266 const String& main_message, |
| 271 TextDirection, | 267 TextDirection, |
| 272 const String& sub_message, | 268 const String& sub_message, |
| 273 TextDirection) override { | 269 TextDirection) override { |
| 274 show_validation_message_was_called = true; | 270 show_validation_message_was_called = true; |
| 275 } | 271 } |
| 276 void HideValidationMessage(const Element& anchor) override {} | 272 void HideValidationMessage(const Element& anchor) override {} |
| 277 bool IsValidationMessageVisible(const Element& anchor) override { | 273 bool IsValidationMessageVisible(const Element& anchor) override { |
| 278 return true; | 274 return true; |
| 279 } | 275 } |
| 280 void WillUnloadDocument(const Document&) override { | |
| 281 will_unload_document_was_called = true; | |
| 282 } | |
| 283 void DocumentDetached(const Document&) override { | |
| 284 document_detached_was_called = true; | |
| 285 } | |
| 286 void WillBeDestroyed() override {} | 276 void WillBeDestroyed() override {} |
| 287 | 277 |
| 288 // DEFINE_INLINE_VIRTUAL_TRACE() { ValidationMessageClient::trace(visitor); } | 278 // DEFINE_INLINE_VIRTUAL_TRACE() { ValidationMessageClient::trace(visitor); } |
| 289 }; | 279 }; |
| 290 | 280 |
| 291 class MockWebApplicationCacheHost | 281 class MockWebApplicationCacheHost |
| 292 : NON_EXPORTED_BASE(public blink::WebApplicationCacheHost) { | 282 : NON_EXPORTED_BASE(public blink::WebApplicationCacheHost) { |
| 293 public: | 283 public: |
| 294 MockWebApplicationCacheHost() {} | 284 MockWebApplicationCacheHost() {} |
| 295 ~MockWebApplicationCacheHost() override {} | 285 ~MockWebApplicationCacheHost() override {} |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 toHTMLInputElement(GetDocument().body()->firstChild()); | 762 toHTMLInputElement(GetDocument().body()->firstChild()); |
| 773 DVLOG(0) << GetDocument().body()->outerHTML(); | 763 DVLOG(0) << GetDocument().body()->outerHTML(); |
| 774 | 764 |
| 775 // Sanity check. | 765 // Sanity check. |
| 776 input->reportValidity(); | 766 input->reportValidity(); |
| 777 EXPECT_TRUE(mock_client->show_validation_message_was_called); | 767 EXPECT_TRUE(mock_client->show_validation_message_was_called); |
| 778 mock_client->Reset(); | 768 mock_client->Reset(); |
| 779 | 769 |
| 780 // prepareForCommit() unloads the document, and shutdown. | 770 // prepareForCommit() unloads the document, and shutdown. |
| 781 GetDocument().GetFrame()->PrepareForCommit(); | 771 GetDocument().GetFrame()->PrepareForCommit(); |
| 782 EXPECT_TRUE(mock_client->will_unload_document_was_called); | |
| 783 EXPECT_TRUE(mock_client->document_detached_was_called); | |
| 784 // Unload handler tried to show a validation message, but it should fail. | 772 // Unload handler tried to show a validation message, but it should fail. |
| 785 EXPECT_FALSE(mock_client->show_validation_message_was_called); | 773 EXPECT_FALSE(mock_client->show_validation_message_was_called); |
| 786 | 774 |
| 787 GetPage().SetValidationMessageClient(original_client); | 775 GetPage().SetValidationMessageClient(original_client); |
| 788 } | 776 } |
| 789 | 777 |
| 790 TEST_F(DocumentTest, SandboxDisablesAppCache) { | 778 TEST_F(DocumentTest, SandboxDisablesAppCache) { |
| 791 RefPtr<SecurityOrigin> origin = | 779 RefPtr<SecurityOrigin> origin = |
| 792 SecurityOrigin::CreateFromString("https://test.com"); | 780 SecurityOrigin::CreateFromString("https://test.com"); |
| 793 GetDocument().SetSecurityOrigin(origin); | 781 GetDocument().SetSecurityOrigin(origin); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 EXPECT_EQ(DocumentLifecycle::kVisualUpdatePending, | 854 EXPECT_EQ(DocumentLifecycle::kVisualUpdatePending, |
| 867 GetDocument().Lifecycle().GetState()); | 855 GetDocument().Lifecycle().GetState()); |
| 868 | 856 |
| 869 GetDocument().EnsurePaintLocationDataValidForNode( | 857 GetDocument().EnsurePaintLocationDataValidForNode( |
| 870 GetDocument().getElementById("stickyChild")); | 858 GetDocument().getElementById("stickyChild")); |
| 871 EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean, | 859 EXPECT_EQ(DocumentLifecycle::kCompositingInputsClean, |
| 872 GetDocument().Lifecycle().GetState()); | 860 GetDocument().Lifecycle().GetState()); |
| 873 } | 861 } |
| 874 | 862 |
| 875 } // namespace blink | 863 } // namespace blink |
| OLD | NEW |