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