| 328 | } |
| 329 | |
| 330 | bool ElementFinder::HasNativeCssSelectorEngine(const IECommandExecutor& executor) { |
| 331 | LOG(TRACE) << "Entering ElementFinder::HasNativeCssSelectorEngine"; |
| 332 | |
| 333 | BrowserHandle browser; |
| 334 | executor.GetCurrentBrowser(&browser); |
| 335 | |
| 336 | std::wstring script_source(L"(function() { return function(){"); |
| 337 | script_source += L"var root = document.documentElement;"; |
| 338 | script_source += L"if (root['querySelectorAll']) { return true; } "; |
| 339 | script_source += L"return false;"; |
| 340 | script_source += L"};})();"; |
| 341 | |
| 342 | CComPtr<IHTMLDocument2> doc; |
| 343 | browser->GetDocument(&doc); |
| 344 | |
| 345 | Script script_wrapper(doc, script_source, 0); |
| 346 | int status_code = script_wrapper.Execute(); |
| 347 | if (status_code != WD_SUCCESS) { |
| 348 | // If executing the script yields an error, then falling back to |
| 349 | // Sizzle will never work, so assume there is a native CSS selector |
| 350 | // engine. |
| 351 | return true; |
| 352 | } |
| 353 | return script_wrapper.result().boolVal == VARIANT_TRUE; |
| 354 | } |
| 355 | |
| 356 | } // namespace webdriver |
no test coverage detected