OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 void SwapAndVerifyMiddleChildConsistency(const char* const message, | 314 void SwapAndVerifyMiddleChildConsistency(const char* const message, |
315 WebFrame* parent, | 315 WebFrame* parent, |
316 WebFrame* new_child); | 316 WebFrame* new_child); |
317 void SwapAndVerifyLastChildConsistency(const char* const message, | 317 void SwapAndVerifyLastChildConsistency(const char* const message, |
318 WebFrame* parent, | 318 WebFrame* parent, |
319 WebFrame* new_child); | 319 WebFrame* new_child); |
320 void SwapAndVerifySubframeConsistency(const char* const message, | 320 void SwapAndVerifySubframeConsistency(const char* const message, |
321 WebFrame* parent, | 321 WebFrame* parent, |
322 WebFrame* new_child); | 322 WebFrame* new_child); |
323 | 323 |
| 324 int NumMarkersInRange(const Document* document, |
| 325 const EphemeralRange& range, |
| 326 DocumentMarker::MarkerTypes marker_types) { |
| 327 int node_count = 0; |
| 328 for (Node& node : range.Nodes()) |
| 329 node_count += document->Markers().MarkersFor(&node, marker_types).size(); |
| 330 return node_count; |
| 331 } |
| 332 |
324 std::string base_url_; | 333 std::string base_url_; |
325 std::string not_base_url_; | 334 std::string not_base_url_; |
326 std::string chrome_url_; | 335 std::string chrome_url_; |
327 }; | 336 }; |
328 | 337 |
329 typedef bool TestParamRootLayerScrolling; | 338 typedef bool TestParamRootLayerScrolling; |
330 class ParameterizedWebFrameTest | 339 class ParameterizedWebFrameTest |
331 : public ::testing::WithParamInterface<TestParamRootLayerScrolling>, | 340 : public ::testing::WithParamInterface<TestParamRootLayerScrolling>, |
332 private ScopedRootLayerScrollingForTest, | 341 private ScopedRootLayerScrollingForTest, |
333 public WebFrameTest { | 342 public WebFrameTest { |
(...skipping 6206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6540 const int kAllTextBeginOffset = 0; | 6549 const int kAllTextBeginOffset = 0; |
6541 const int kAllTextLength = 11; | 6550 const int kAllTextLength = 11; |
6542 frame->SelectRange(WebRange(kAllTextBeginOffset, kAllTextLength)); | 6551 frame->SelectRange(WebRange(kAllTextBeginOffset, kAllTextLength)); |
6543 EphemeralRange selection_range = | 6552 EphemeralRange selection_range = |
6544 frame->GetFrame() | 6553 frame->GetFrame() |
6545 ->Selection() | 6554 ->Selection() |
6546 .ComputeVisibleSelectionInDOMTreeDeprecated() | 6555 .ComputeVisibleSelectionInDOMTreeDeprecated() |
6547 .ToNormalizedEphemeralRange(); | 6556 .ToNormalizedEphemeralRange(); |
6548 | 6557 |
6549 EXPECT_EQ(1, textcheck.NumberOfTimesChecked()); | 6558 EXPECT_EQ(1, textcheck.NumberOfTimesChecked()); |
6550 EXPECT_EQ(1U, document->Markers() | 6559 EXPECT_EQ(1, NumMarkersInRange(document, selection_range, |
6551 .MarkersInRange(selection_range, DocumentMarker::kSpelling) | 6560 DocumentMarker::kSpelling)); |
6552 .size()); | |
6553 | 6561 |
6554 frame->ReplaceMisspelledRange("welcome"); | 6562 frame->ReplaceMisspelledRange("welcome"); |
6555 EXPECT_EQ("_welcome_.", | 6563 EXPECT_EQ("_welcome_.", |
6556 WebFrameContentDumper::DumpWebViewAsText( | 6564 WebFrameContentDumper::DumpWebViewAsText( |
6557 web_view_helper.WebView(), std::numeric_limits<size_t>::max()) | 6565 web_view_helper.WebView(), std::numeric_limits<size_t>::max()) |
6558 .Utf8()); | 6566 .Utf8()); |
6559 } | 6567 } |
6560 | 6568 |
6561 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { | 6569 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { |
6562 RegisterMockedHttpURLLoad("spell.html"); | 6570 RegisterMockedHttpURLLoad("spell.html"); |
(...skipping 26 matching lines...) Expand all Loading... |
6589 | 6597 |
6590 const int kAllTextBeginOffset = 0; | 6598 const int kAllTextBeginOffset = 0; |
6591 const int kAllTextLength = 11; | 6599 const int kAllTextLength = 11; |
6592 frame->SelectRange(WebRange(kAllTextBeginOffset, kAllTextLength)); | 6600 frame->SelectRange(WebRange(kAllTextBeginOffset, kAllTextLength)); |
6593 EphemeralRange selection_range = | 6601 EphemeralRange selection_range = |
6594 frame->GetFrame() | 6602 frame->GetFrame() |
6595 ->Selection() | 6603 ->Selection() |
6596 .ComputeVisibleSelectionInDOMTreeDeprecated() | 6604 .ComputeVisibleSelectionInDOMTreeDeprecated() |
6597 .ToNormalizedEphemeralRange(); | 6605 .ToNormalizedEphemeralRange(); |
6598 | 6606 |
6599 EXPECT_EQ(0U, document->Markers() | 6607 EXPECT_EQ(0, NumMarkersInRange(document, selection_range, |
6600 .MarkersInRange(selection_range, DocumentMarker::kSpelling) | 6608 DocumentMarker::kSpelling)); |
6601 .size()); | |
6602 } | 6609 } |
6603 | 6610 |
6604 static void GetSpellingMarkerOffsets(WebVector<unsigned>* offsets, | 6611 static void GetSpellingMarkerOffsets(WebVector<unsigned>* offsets, |
6605 const Document& document) { | 6612 const Document& document) { |
6606 Vector<unsigned> result; | 6613 Vector<unsigned> result; |
6607 const DocumentMarkerVector& document_markers = document.Markers().Markers(); | 6614 const DocumentMarkerVector& document_markers = document.Markers().Markers(); |
6608 for (size_t i = 0; i < document_markers.size(); ++i) | 6615 for (size_t i = 0; i < document_markers.size(); ++i) |
6609 result.push_back(document_markers[i]->StartOffset()); | 6616 result.push_back(document_markers[i]->StartOffset()); |
6610 offsets->Assign(result); | 6617 offsets->Assign(result); |
6611 } | 6618 } |
(...skipping 5431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12043 | 12050 |
12044 // Failing the original child frame navigation and trying to render fallback | 12051 // Failing the original child frame navigation and trying to render fallback |
12045 // content shouldn't crash. It should return NoLoadInProgress. This is so the | 12052 // content shouldn't crash. It should return NoLoadInProgress. This is so the |
12046 // caller won't attempt to replace the correctly empty frame with an error | 12053 // caller won't attempt to replace the correctly empty frame with an error |
12047 // page. | 12054 // page. |
12048 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, | 12055 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, |
12049 child->MaybeRenderFallbackContent(WebURLError())); | 12056 child->MaybeRenderFallbackContent(WebURLError())); |
12050 } | 12057 } |
12051 | 12058 |
12052 } // namespace blink | 12059 } // namespace blink |
OLD | NEW |