| 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 "core/dom/CSSSelectorWatch.h" | 5 #include "core/dom/CSSSelectorWatch.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/StyleEngine.h" | 8 #include "core/dom/StyleEngine.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/html/HTMLElement.h" | 10 #include "core/html/HTMLElement.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 document().body()->setInnerHTML( | 46 document().body()->setInnerHTML( |
| 47 "<div>" | 47 "<div>" |
| 48 " <span id='x' class='a'></span>" | 48 " <span id='x' class='a'></span>" |
| 49 " <span id='y' class='b'><span></span></span>" | 49 " <span id='y' class='b'><span></span></span>" |
| 50 " <span id='z'><span></span></span>" | 50 " <span id='z'><span></span></span>" |
| 51 "</div>"); | 51 "</div>"); |
| 52 | 52 |
| 53 CSSSelectorWatch& watch = CSSSelectorWatch::from(document()); | 53 CSSSelectorWatch& watch = CSSSelectorWatch::from(document()); |
| 54 | 54 |
| 55 Vector<String> selectors; | 55 Vector<String> selectors; |
| 56 selectors.append(".a"); | 56 selectors.push_back(".a"); |
| 57 watch.watchCSSSelectors(selectors); | 57 watch.watchCSSSelectors(selectors); |
| 58 | 58 |
| 59 document().view()->updateAllLifecyclePhases(); | 59 document().view()->updateAllLifecyclePhases(); |
| 60 | 60 |
| 61 selectors.clear(); | 61 selectors.clear(); |
| 62 selectors.append(".b"); | 62 selectors.push_back(".b"); |
| 63 selectors.append(".c"); | 63 selectors.push_back(".c"); |
| 64 selectors.append("#nomatch"); | 64 selectors.push_back("#nomatch"); |
| 65 watch.watchCSSSelectors(selectors); | 65 watch.watchCSSSelectors(selectors); |
| 66 | 66 |
| 67 document().view()->updateAllLifecyclePhases(); | 67 document().view()->updateAllLifecyclePhases(); |
| 68 | 68 |
| 69 Element* x = document().getElementById("x"); | 69 Element* x = document().getElementById("x"); |
| 70 Element* y = document().getElementById("y"); | 70 Element* y = document().getElementById("y"); |
| 71 Element* z = document().getElementById("z"); | 71 Element* z = document().getElementById("z"); |
| 72 ASSERT_TRUE(x); | 72 ASSERT_TRUE(x); |
| 73 ASSERT_TRUE(y); | 73 ASSERT_TRUE(y); |
| 74 ASSERT_TRUE(z); | 74 ASSERT_TRUE(z); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 86 EXPECT_EQ(2u, afterCount - beforeCount); | 86 EXPECT_EQ(2u, afterCount - beforeCount); |
| 87 | 87 |
| 88 EXPECT_EQ(1u, addedSelectors(watch).size()); | 88 EXPECT_EQ(1u, addedSelectors(watch).size()); |
| 89 EXPECT_TRUE(addedSelectors(watch).contains(".c")); | 89 EXPECT_TRUE(addedSelectors(watch).contains(".c")); |
| 90 | 90 |
| 91 EXPECT_EQ(1u, removedSelectors(watch).size()); | 91 EXPECT_EQ(1u, removedSelectors(watch).size()); |
| 92 EXPECT_TRUE(removedSelectors(watch).contains(".b")); | 92 EXPECT_TRUE(removedSelectors(watch).contains(".b")); |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace blink | 95 } // namespace blink |
| OLD | NEW |