| 136 | } |
| 137 | |
| 138 | bool Element::IsEnabled() { |
| 139 | LOG(TRACE) << "Entering Element::IsEnabled"; |
| 140 | |
| 141 | bool result = false; |
| 142 | |
| 143 | // The atom is just the definition of an anonymous |
| 144 | // function: "function() {...}"; Wrap it in another function so we can |
| 145 | // invoke it with our arguments without polluting the current namespace. |
| 146 | std::wstring script_source(L"(function() { return ("); |
| 147 | script_source += atoms::asString(atoms::IS_ENABLED); |
| 148 | script_source += L")})();"; |
| 149 | |
| 150 | CComPtr<IHTMLDocument2> doc; |
| 151 | this->GetContainingDocument(false, &doc); |
| 152 | |
| 153 | if (this->IsXmlDocument(doc)) { |
| 154 | return false; |
| 155 | } |
| 156 | |
| 157 | Script script_wrapper(doc, script_source, 1); |
| 158 | script_wrapper.AddArgument(this->element_); |
| 159 | int status_code = script_wrapper.Execute(); |
| 160 | |
| 161 | if (status_code == WD_SUCCESS) { |
| 162 | result = script_wrapper.result().boolVal == VARIANT_TRUE; |
| 163 | } else { |
| 164 | LOG(WARN) << "Failed to determine is element enabled"; |
| 165 | } |
| 166 | |
| 167 | return result; |
| 168 | } |
| 169 | |
| 170 | bool Element::IsXmlDocument(IHTMLDocument2* doc) { |
| 171 | LOG(TRACE) << "Entering Element::IsXmlDocument"; |
no test coverage detected