| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bindings/core/v8/ExceptionState.h" | 5 #include "bindings/core/v8/ExceptionState.h" |
| 6 #include "core/HTMLNames.h" | 6 #include "core/HTMLNames.h" |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/QualifiedName.h" | 8 #include "core/dom/QualifiedName.h" |
| 9 #include "core/editing/EditingTestBase.h" | 9 #include "core/editing/EditingTestBase.h" |
| 10 #include "core/editing/FrameSelection.h" | 10 #include "core/editing/FrameSelection.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 .setBaseAndExtent( | 42 .setBaseAndExtent( |
| 43 Position(document().documentElement(), 1), | 43 Position(document().documentElement(), 1), |
| 44 Position(document().getElementById("va")->firstChild(), 2)) | 44 Position(document().getElementById("va")->firstChild(), 2)) |
| 45 .build()); | 45 .build()); |
| 46 | 46 |
| 47 FormatBlockCommand* command = | 47 FormatBlockCommand* command = |
| 48 FormatBlockCommand::create(document(), HTMLNames::footerTag); | 48 FormatBlockCommand::create(document(), HTMLNames::footerTag); |
| 49 command->apply(); | 49 command->apply(); |
| 50 | 50 |
| 51 EXPECT_EQ( | 51 EXPECT_EQ( |
| 52 "<body contenteditable=\"false\">\n" | 52 "<head><style> .CLASS13 { -webkit-user-modify: read-write; " |
| 53 "<pre><var id=\"va\" class=\"CLASS13\">\nC\n</var></pre><input></body>", | 53 "}</style></head>foo<body contenteditable=\"false\">\n<pre><var " |
| 54 "id=\"va\" " |
| 55 "class=\"CLASS13\">\n<footer>C</footer></var></pre><input></body>", |
| 54 document().documentElement()->innerHTML()); | 56 document().documentElement()->innerHTML()); |
| 55 } | 57 } |
| 56 | 58 |
| 57 // This is a regression test for https://crbug.com/660801 | 59 // This is a regression test for https://crbug.com/660801 |
| 58 TEST_F(ApplyBlockElementCommandTest, visibilityChangeDuringCommand) { | 60 TEST_F(ApplyBlockElementCommandTest, visibilityChangeDuringCommand) { |
| 59 document().head()->insertAdjacentHTML( | 61 document().head()->insertAdjacentHTML( |
| 60 "afterbegin", "<style>li:first-child { visibility:visible; }</style>", | 62 "afterbegin", "<style>li:first-child { visibility:visible; }</style>", |
| 61 ASSERT_NO_EXCEPTION); | 63 ASSERT_NO_EXCEPTION); |
| 62 setBodyContent("<ul style='visibility:hidden'><li>xyz</li></ul>"); | 64 setBodyContent("<ul style='visibility:hidden'><li>xyz</li></ul>"); |
| 63 document().setDesignMode("on"); | 65 document().setDesignMode("on"); |
| 64 | 66 |
| 65 updateAllLifecyclePhases(); | 67 updateAllLifecyclePhases(); |
| 66 selection().setSelection( | 68 selection().setSelection( |
| 67 SelectionInDOMTree::Builder() | 69 SelectionInDOMTree::Builder() |
| 68 .collapse(Position(document().querySelector("li"), 0)) | 70 .collapse(Position(document().querySelector("li"), 0)) |
| 69 .build()); | 71 .build()); |
| 70 | 72 |
| 71 IndentOutdentCommand* command = | 73 IndentOutdentCommand* command = |
| 72 IndentOutdentCommand::create(document(), IndentOutdentCommand::Indent); | 74 IndentOutdentCommand::create(document(), IndentOutdentCommand::Indent); |
| 73 command->apply(); | 75 command->apply(); |
| 74 | 76 |
| 75 EXPECT_EQ( | 77 EXPECT_EQ( |
| 76 "<head><style>li:first-child { visibility:visible; }</style></head>" | 78 "<head><style>li:first-child { visibility:visible; }</style></head>" |
| 77 "<body><ul style=\"visibility:hidden\"><ul></ul><li>xyz</li></ul></body>", | 79 "<body><ul style=\"visibility:hidden\"><ul></ul><li>xyz</li></ul></body>", |
| 78 document().documentElement()->innerHTML()); | 80 document().documentElement()->innerHTML()); |
| 79 } | 81 } |
| 80 | 82 |
| 81 } // namespace blink | 83 } // namespace blink |
| OLD | NEW |