| 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 | 702 |
| 703 TEST_F(DocumentTest, ValidationMessageCleanup) { | 703 TEST_F(DocumentTest, ValidationMessageCleanup) { |
| 704 ValidationMessageClient* original_client = | 704 ValidationMessageClient* original_client = |
| 705 &GetPage().GetValidationMessageClient(); | 705 &GetPage().GetValidationMessageClient(); |
| 706 MockValidationMessageClient* mock_client = new MockValidationMessageClient(); | 706 MockValidationMessageClient* mock_client = new MockValidationMessageClient(); |
| 707 GetDocument().GetSettings()->SetScriptEnabled(true); | 707 GetDocument().GetSettings()->SetScriptEnabled(true); |
| 708 GetPage().SetValidationMessageClient(mock_client); | 708 GetPage().SetValidationMessageClient(mock_client); |
| 709 // implicitOpen()-implicitClose() makes Document.loadEventFinished() | 709 // implicitOpen()-implicitClose() makes Document.loadEventFinished() |
| 710 // true. It's necessary to kick unload process. | 710 // true. It's necessary to kick unload process. |
| 711 GetDocument().ImplicitOpen(kForceSynchronousParsing); | 711 GetDocument().ImplicitOpen(kForceSynchronousParsing); |
| 712 GetDocument().ImplicitClose(); | 712 GetDocument().CheckCompleted(); |
| 713 GetDocument().AppendChild(GetDocument().createElement("html")); | 713 GetDocument().AppendChild(GetDocument().createElement("html")); |
| 714 SetHtmlInnerHTML("<body><input required></body>"); | 714 SetHtmlInnerHTML("<body><input required></body>"); |
| 715 Element* script = GetDocument().createElement("script"); | 715 Element* script = GetDocument().createElement("script"); |
| 716 script->setTextContent( | 716 script->setTextContent( |
| 717 "window.onunload = function() {" | 717 "window.onunload = function() {" |
| 718 "document.querySelector('input').reportValidity(); };"); | 718 "document.querySelector('input').reportValidity(); };"); |
| 719 GetDocument().body()->AppendChild(script); | 719 GetDocument().body()->AppendChild(script); |
| 720 HTMLInputElement* input = | 720 HTMLInputElement* input = |
| 721 toHTMLInputElement(GetDocument().body()->FirstChild()); | 721 toHTMLInputElement(GetDocument().body()->FirstChild()); |
| 722 DVLOG(0) << GetDocument().body()->outerHTML(); | 722 DVLOG(0) << GetDocument().body()->outerHTML(); |
| 723 | 723 |
| 724 // Sanity check. | 724 // Sanity check. |
| 725 input->reportValidity(); | 725 input->reportValidity(); |
| 726 EXPECT_TRUE(mock_client->show_validation_message_was_called); | 726 EXPECT_TRUE(mock_client->show_validation_message_was_called); |
| 727 mock_client->Reset(); | 727 mock_client->Reset(); |
| 728 | 728 |
| 729 // prepareForCommit() unloads the document, and shutdown. | 729 // prepareForCommit() unloads the document, and shutdown. |
| 730 GetDocument().GetFrame()->PrepareForCommit(); | 730 GetDocument().GetFrame()->PrepareForCommit(); |
| 731 EXPECT_TRUE(mock_client->will_unload_document_was_called); | 731 EXPECT_TRUE(mock_client->will_unload_document_was_called); |
| 732 EXPECT_TRUE(mock_client->document_detached_was_called); | 732 EXPECT_TRUE(mock_client->document_detached_was_called); |
| 733 // Unload handler tried to show a validation message, but it should fail. | 733 // Unload handler tried to show a validation message, but it should fail. |
| 734 EXPECT_FALSE(mock_client->show_validation_message_was_called); | 734 EXPECT_FALSE(mock_client->show_validation_message_was_called); |
| 735 | 735 |
| 736 GetPage().SetValidationMessageClient(original_client); | 736 GetPage().SetValidationMessageClient(original_client); |
| 737 } | 737 } |
| 738 | 738 |
| 739 } // namespace blink | 739 } // namespace blink |
| OLD | NEW |