TEST_F(DocumentMarkerControllerTest, NodeWillBeRemovedMarkedByRemoveChildren) { setBodyInnerHTML("<b><i>foo</i></b>"); RefPtrWillBeRawPtr<Element> parent = toElement(document().body()->firstChild()->firstChild()); markNodeContents(parent.get()); EXPECT_EQ(1u, markerController().markers().size()); parent->removeChildren(); // No more reference to marked node. Heap::collectAllGarbage(); EXPECT_EQ(0u, markerController().markers().size()); }
TEST_F(DocumentMarkerControllerTest, NodeWillBeRemovedBySetInnerHTML) { setBodyInnerHTML("<b><i>foo</i></b>"); { Element* parent = toElement(document().body()->firstChild()->firstChild()); markNodeContents(parent); EXPECT_EQ(1u, markerController().markers().size()); setBodyInnerHTML(""); } // No more reference to marked node. ThreadHeap::collectAllGarbage(); EXPECT_EQ(0u, markerController().markers().size()); }
TEST_F(DocumentMarkerControllerTest, DidMoveToNewDocument) { setBodyInnerHTML("<b><i>foo</i></b>"); RefPtrWillBeRawPtr<Element> parent = toElement(document().body()->firstChild()->firstChild()); markNodeContents(parent.get()); EXPECT_EQ(1u, markerController().markers().size()); RefPtrWillBePersistent<Document> anotherDocument = Document::create(); anotherDocument->adoptNode(parent.get(), ASSERT_NO_EXCEPTION); // No more reference to marked node. Heap::collectAllGarbage(); EXPECT_EQ(0u, markerController().markers().size()); EXPECT_EQ(0u, anotherDocument->markers().markers().size()); }
TEST_F(DocumentMarkerControllerTest, NodeWillBeRemovedMarkedByNormalize) { setBodyInnerHTML("<b><i>foo</i></b>"); { RefPtrWillBeRawPtr<Element> parent = toElement(document().body()->firstChild()->firstChild()); parent->appendChild(createTextNode("bar").get()); markNodeContents(parent.get()); EXPECT_EQ(2u, markerController().markers().size()); parent->normalize(); } // No more reference to marked node. Heap::collectAllGarbage(); EXPECT_EQ(1u, markerController().markers().size()); }
TEST_F(DocumentMarkerControllerTest, UpdateRenderedRects) { setBodyInnerHTML("<div style='margin: 100px'>foo</div>"); Element* div = toElement(document().body()->firstChild()); markNodeContents(div); Vector<IntRect> renderedRects = markerController().renderedRectsForMarkers(DocumentMarker::Spelling); EXPECT_EQ(1u, renderedRects.size()); div->setAttribute(HTMLNames::styleAttr, "margin: 200px"); document().updateStyleAndLayout(); Vector<IntRect> newRenderedRects = markerController().renderedRectsForMarkers(DocumentMarker::Spelling); EXPECT_EQ(1u, newRenderedRects.size()); EXPECT_NE(renderedRects[0], newRenderedRects[0]); }
TEST_F(DocumentMarkerControllerTest, UpdateRenderedRects) { LayoutRect invalidRect = RenderedDocumentMarker::create(DocumentMarker(0, 0, false))->renderedRect(); setBodyInnerHTML("<div style='margin: 100px'>foo</div>"); RefPtrWillBeRawPtr<Element> div = toElement(document().body()->firstChild()); markNodeContents(div); Vector<IntRect> renderedRects = markerController().renderedRectsForMarkers(DocumentMarker::Spelling); EXPECT_EQ(1u, renderedRects.size()); EXPECT_NE(invalidRect, renderedRects[0]); div->setAttribute(HTMLNames::styleAttr, "margin: 200px"); document().updateLayout(); Vector<IntRect> newRenderedRects = markerController().renderedRectsForMarkers(DocumentMarker::Spelling); EXPECT_EQ(1u, newRenderedRects.size()); EXPECT_NE(renderedRects[0], newRenderedRects[0]); }