| 668 | } |
| 669 | |
| 670 | bool Browser::IsDocumentNavigating(const std::string& page_load_strategy, |
| 671 | IHTMLDocument2* doc) { |
| 672 | LOG(TRACE) << "Entering Browser::IsDocumentNavigating"; |
| 673 | |
| 674 | bool is_navigating = true; |
| 675 | |
| 676 | // Starting WaitForDocumentComplete() |
| 677 | is_navigating = this->is_navigation_started_; |
| 678 | CComBSTR ready_state_bstr; |
| 679 | HRESULT hr = doc->get_readyState(&ready_state_bstr); |
| 680 | if (FAILED(hr) || is_navigating) { |
| 681 | if (FAILED(hr)) { |
| 682 | LOGHR(DEBUG, hr) << "IHTMLDocument2::get_readyState failed."; |
| 683 | } else if (is_navigating) { |
| 684 | LOG(DEBUG) << "DocumentComplete event fired, indicating a new navigation."; |
| 685 | } |
| 686 | return true; |
| 687 | } else { |
| 688 | std::wstring ready_state = ready_state_bstr; |
| 689 | if ((ready_state == L"complete") || |
| 690 | (page_load_strategy == EAGER_PAGE_LOAD_STRATEGY && ready_state == L"interactive")) { |
| 691 | is_navigating = false; |
| 692 | } else { |
| 693 | if (page_load_strategy == EAGER_PAGE_LOAD_STRATEGY) { |
| 694 | LOG(DEBUG) << "document.readyState is not 'complete' or 'interactive'; it was " << LOGWSTRING(ready_state); |
| 695 | } else { |
| 696 | LOG(DEBUG) << "document.readyState is not 'complete'; it was " << LOGWSTRING(ready_state); |
| 697 | } |
| 698 | return true; |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | // document.readyState == complete |
| 703 | is_navigating = this->is_navigation_started_; |
| 704 | CComPtr<IHTMLFramesCollection2> frames; |
| 705 | hr = doc->get_frames(&frames); |
| 706 | if (is_navigating || FAILED(hr)) { |
| 707 | LOG(DEBUG) << "Could not get frames, navigation has started or call to IHTMLDocument2::get_frames failed"; |
| 708 | return true; |
| 709 | } |
| 710 | |
| 711 | if (frames != NULL) { |
| 712 | long frame_count = 0; |
| 713 | hr = frames->get_length(&frame_count); |
| 714 | |
| 715 | CComVariant index; |
| 716 | index.vt = VT_I4; |
| 717 | for (long i = 0; i < frame_count; ++i) { |
| 718 | // Waiting on each frame |
| 719 | index.lVal = i; |
| 720 | CComVariant result; |
| 721 | hr = frames->item(&index, &result); |
| 722 | if (FAILED(hr)) { |
| 723 | LOGHR(DEBUG, hr) << "Could not get frame item for index " |
| 724 | << i |
| 725 | << ", call to IHTMLFramesCollection2::item failed, frame/frameset is broken"; |
| 726 | continue; |
| 727 | } |
no test coverage detected