1 2017-10-27 Carlos Garcia Campos <cgarcia@igalia.com>
3 WebDriver: failing to process capabilities should produce InvalidArgument error not SessionNotCreated
4 https://bugs.webkit.org/show_bug.cgi?id=178864
6 Reviewed by Brian Burg.
8 Fixes most of the tests in imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py.
10 7.2 Processing Capabilities
11 https://w3c.github.io/webdriver/webdriver-spec.html#processing-capabilities
13 * WebDriverService.cpp:
14 (WebDriver::WebDriverService::processCapabilities const):
16 2017-10-10 Sam Weinig <sam@webkit.org>
18 Replace copyKeysToVector/copyValuesToVector with copyToVector(map.keys())/copyToVector(map.values())
19 https://bugs.webkit.org/show_bug.cgi?id=178102
21 Reviewed by Tim Horton.
24 (WebDriver::SessionHost::inspectorDisconnected):
26 2017-10-02 Carlos Garcia Campos <cgarcia@igalia.com>
28 WebDriver: HTTP status code is not correct for some of the errors
29 https://bugs.webkit.org/show_bug.cgi?id=177354
31 Reviewed by Brian Burg.
33 I think this changed in the spec at some point. The thing is that no such alert, frame and window and stale
34 element reference errors should return 404 instead of 400.
36 https://w3c.github.io/webdriver/webdriver-spec.html#handling-errors
39 (WebDriver::CommandResult::httpStatusCode const):
41 2017-09-19 Carlos Garcia Campos <cgarcia@igalia.com>
43 WebDriver: Implement commands to get and set the window rect
44 https://bugs.webkit.org/show_bug.cgi?id=177134
46 Reviewed by Brian Burg.
48 We are currently implementing the selenium legacy ones, we should implement the w3c ones instead.
50 https://w3c.github.io/webdriver/webdriver-spec.html#resizing-and-positioning-windows
53 (WebDriver::Session::getToplevelBrowsingContextRect): Helper to get the window rect. This is used by both get
54 and set window rect commands.
55 (WebDriver::Session::moveToplevelBrowsingContextwindow): Helper to ask automation to move the window.
56 (WebDriver::Session::resizeToplevelBrowsingContextwindow): Helper to ask automation to resize the window.
57 (WebDriver::Session::getWindowRect): Handle prompts and then call getToplevelBrowsingContextRect().
58 (WebDriver::Session::setWindowRect): Handle prompts and then move and resize the window according to the given
59 parameters and finish the operation calling getToplevelBrowsingContextRect().
61 * WebDriverService.cpp:
62 (WebDriver::WebDriverService::getWindowRect): Ask the session to get the window rect.
63 (WebDriver::valueAsNumberInRange): Helper to check a value is a valid number in the given range.
64 (WebDriver::WebDriverService::setWindowRect): Get and check size and position from parameters and then ask the
65 session to set the window rect.
68 2017-09-19 Carlos Garcia Campos <cgarcia@igalia.com>
70 WebDriver: wrong response in case of errors
71 https://bugs.webkit.org/show_bug.cgi?id=177127
73 Reviewed by Brian Burg.
75 I misunderstood the spec when I implemented this, so we either return a "value" key with the result in case of
76 success or the error object as the body in case of error. We should always add a "value" key to the body and set
77 it with either the result or the error object.
79 https://w3c.github.io/webdriver/webdriver-spec.html#dfn-send-an-error
81 * WebDriverService.cpp:
82 (WebDriver::WebDriverService::sendResponse const):
84 2017-09-18 Carlos Garcia Campos <cgarcia@igalia.com>
86 WebDriver: wrong key name for capabilities in new session response
87 https://bugs.webkit.org/show_bug.cgi?id=177074
89 Reviewed by Brian Burg.
91 We are using "value", it should be "capabilities".
92 https://w3c.github.io/webdriver/webdriver-spec.html#new-session
94 * WebDriverService.cpp:
95 (WebDriver::WebDriverService::newSession):
97 2017-09-18 Carlos Garcia Campos <cgarcia@igalia.com>
99 WebDriver: HTTP responses should include Cache-Control header with no-cache value
100 https://bugs.webkit.org/show_bug.cgi?id=177073
102 Reviewed by Sergio Villar Senin.
104 6.3 Processing Model.
105 Set the response’s header with name and value with the following values:
107 Content-Type "application/json; charset=utf-8"
108 Cache-Control "no-cache"
110 https://w3c.github.io/webdriver/webdriver-spec.html#dfn-send-a-response
112 We were setting the Content-Type, but not the Cache-Control. This is checked by all WPT WebDriver tests.
114 * soup/HTTPServerSoup.cpp:
115 (WebDriver::HTTPServer::listen): Add Cache-Control header.
117 2017-09-18 Michael Catanzaro <mcatanzaro@igalia.com>
119 [CMake] Rename WebKit target to WebKitLegacy and rename WebKit2 target to WebKit
120 https://bugs.webkit.org/show_bug.cgi?id=174558
122 Reviewed by Alex Christensen.
126 2017-09-15 JF Bastien <jfbastien@apple.com>
128 WTF: use Forward.h when appropriate instead of Vector.h
129 https://bugs.webkit.org/show_bug.cgi?id=176984
131 Reviewed by Saam Barati.
133 There's no need to include Vector.h when Forward.h will suffice. All we need is to move the template default parameters from Vector, and then the forward declaration can be used in so many new places: if a header only takes Vector by reference, rvalue reference, pointer, returns any of these, or has them as members then the header doesn't need to see the definition because the declaration will suffice.
137 2017-09-09 Carlos Garcia Campos <cgarcia@igalia.com>
139 WebDriver: ensure we close all windows handles when closing the session
140 https://bugs.webkit.org/show_bug.cgi?id=176508
142 Reviewed by Brian Burg.
144 The spec says that when closing the session all top level browsing contexts should be closed. We are currently
145 checking if we have an active top level browsing context and then we try to close it before trying with the
146 rest. It can happen that we are in an inconsistent state, for example if the current top level browsing context
147 has been closed by JavaScript or another action and the user didn't switch to another one before closing the
148 session. In such case, closing the session will fail with NoSuchwindow and any other window open will not be
149 closed. It's safer to always ask for all window handles and close them, which is what the spec says too.
152 (WebDriver::firstWindowHandleInResult): Helper class to get the first window handle in the result array.
153 (WebDriver::Session::closeAllToplevelBrowsingContexts): Use firstWindowHandleInResult().
154 (WebDriver::Session::close): Close the current top level browsing context and get all window handles to close
157 2017-08-28 Carlos Garcia Campos <cgarcia@igalia.com>
159 WebDriver: implement screen capture commands
160 https://bugs.webkit.org/show_bug.cgi?id=174615
162 Reviewed by Brian Burg.
164 Implement takeScreenshot and takeElementScreenshot commands.
167 https://w3c.github.io/webdriver/webdriver-spec.html#screen-capture
170 (WebDriver::CommandResult::CommandResult): Handle ScreenshotError protocol error.
171 (WebDriver::CommandResult::httpStatusCode const): Add UnableToCaptureScreen.
172 (WebDriver::CommandResult::errorString const): Ditto.
175 (WebDriver::Session::takeScreenshot):
177 * WebDriverService.cpp:
178 (WebDriver::WebDriverService::takeScreenshot):
179 (WebDriver::WebDriverService::takeElementScreenshot):
180 * WebDriverService.h:
182 2017-08-28 Carlos Garcia Campos <cgarcia@igalia.com>
184 WebDriver: implement cookies commands
185 https://bugs.webkit.org/show_bug.cgi?id=174613
187 Reviewed by Brian Burg.
189 Add cookies commands.
192 https://w3c.github.io/webdriver/webdriver-spec.html#cookies
195 (WebDriver::CommandResult::httpStatusCode const): Add NoSuchCookie error.
196 (WebDriver::CommandResult::errorString const): Ditto.
199 (WebDriver::parseAutomationCookie): Parse JSON cookie object returned by automation and convert it to a Cookie struct.
200 (WebDriver::builtAutomationCookie): Build a JSON cookie object as expected by automation from a Cookie struct.
201 (WebDriver::serializeCookie): Serialize a Cookie struct into a JSON cookie object according to the WebDriver spec.
202 (WebDriver::Session::getAllCookies):
203 (WebDriver::Session::getNamedCookie):
204 (WebDriver::Session::addCookie):
205 (WebDriver::Session::deleteCookie):
206 (WebDriver::Session::deleteAllCookies):
208 * WebDriverService.cpp:
209 (WebDriver::WebDriverService::getAllCookies):
210 (WebDriver::WebDriverService::getNamedCookie):
211 (WebDriver::deserializeCookie):
212 (WebDriver::WebDriverService::addCookie):
213 (WebDriver::WebDriverService::deleteCookie):
214 (WebDriver::WebDriverService::deleteAllCookies):
215 * WebDriverService.h:
217 2017-07-28 Carlos Garcia Campos <cgarcia@igalia.com>
219 WebDriver: fix return value of close window command
220 https://bugs.webkit.org/show_bug.cgi?id=174861
222 Reviewed by Brian Burg.
224 We are currently returning null, but we should return the list of window handles, and try to close the session
225 if there aren't more window handles.
228 https://w3c.github.io/webdriver/webdriver-spec.html#close-window
230 3. If there are no more open top-level browsing contexts, then try to close the session.
231 4. Return the result of running the remote end steps for the Get Window Handles command.
234 (WebDriver::Session::closeAllToplevelBrowsingContexts): Helper function to close the given toplevel browsing
235 context and the next one if there are more.
236 (WebDriver::Session::close): Call closeAllToplevelBrowsingContexts() to delete all toplevel browsing contexts of
238 (WebDriver::Session::closeTopLevelBrowsingContext): Close the given toplevel browsing context and call
239 getWindowHandles() when done.
240 (WebDriver::Session::closeWindow): Call closeTopLevelBrowsingContext() passing the current toplevel browsing context.
241 (WebDriver::Session::getWindowHandles): Remove the early return, this command doesn't depend on a current
242 toplevel browsing context.
245 * WebDriverService.cpp:
246 (WebDriver::WebDriverService::run): Disconnect the server when main loop quits.
247 (WebDriver::WebDriverService::deleteSession): Do not fail if the given session is not active.
248 (WebDriver::WebDriverService::closeWindow): Remove the session if the closed window was the last one.
249 * WebDriverService.h: Remove unused quit() method.
250 * glib/SessionHostGlib.cpp:
251 (WebDriver::SessionHost::isConnected): Return whether host is connected to a browser instance.
252 (WebDriver::SessionHost::dbusConnectionClosedCallback): Delete m_browser.
254 2017-08-14 Carlos Garcia Campos <cgarcia@igalia.com>
256 WebDriver: handle click events on option elements
257 https://bugs.webkit.org/show_bug.cgi?id=174710
258 <rdar://problem/33459305>
260 Reviewed by Brian Burg.
262 Option elements are considered as a special case by the specification. When clicking an option element, we
263 should get its container and use it when scrolling into view and calculating in-view center point instead of the
264 option element itself. Then, we should not emulate a click, but change the selected status of the option element
265 like if it were done by a user action, firing the corresponding events. Now we check whether the element is an
266 option to call selectOptionElement() or performMouseInteraction().
268 This fixes more than 20 selenium tests.
271 (WebDriver::CommandResult::CommandResult): Handle ElementNotSelectable protocol error.
272 (WebDriver::CommandResult::httpStatusCode const): Add ElementNotSelectable.
273 (WebDriver::CommandResult::errorString const): Ditto.
276 (WebDriver::Session::selectOptionElement): Ask automation to select the given option element.
277 (WebDriver::Session::elementClick): Call selectOptionElement() or performMouseInteraction() depending on whether
278 the element is an option or not.
281 2017-08-11 Carlos Alberto Lopez Perez <clopez@igalia.com>
283 Fix build warning in WebDriverService.h
284 https://bugs.webkit.org/show_bug.cgi?id=166682
286 Unreviewed build fix.
288 * WebDriverService.h: Fixes the warning: class 'Capabilities' was previously declared as a struct [-Wmismatched-tags]
290 2017-08-08 Michael Catanzaro <mcatanzaro@igalia.com>
292 Unreviewed, fix Ubuntu LTS build
293 https://bugs.webkit.org/show_bug.cgi?id=174490
295 * glib/SessionHostGlib.cpp:
297 2017-08-08 Michael Catanzaro <mcatanzaro@igalia.com>
299 [CMake] Properly test if compiler supports compiler flags
300 https://bugs.webkit.org/show_bug.cgi?id=174490
302 Reviewed by Konstantin Tokarev.
304 * WebDriverService.cpp:
305 (WebDriver::WebDriverService::run):
306 * glib/SessionHostGlib.cpp:
308 2017-08-07 Carlos Garcia Campos <cgarcia@igalia.com>
310 Web Automation: setUserInputForCurrentJavaScriptPrompt should fail if current dialog is not a prompt
311 https://bugs.webkit.org/show_bug.cgi?id=175261
313 Reviewed by Brian Burg.
316 (WebDriver::CommandResult::CommandResult): Handle ElementNotInteractable protocol error.
318 2017-08-07 Carlos Garcia Campos <cgarcia@igalia.com>
320 WebDriver: implement unhandled prompt behavior
321 https://bugs.webkit.org/show_bug.cgi?id=175184
323 Reviewed by Brian Burg.
325 Handle user prompts before running some of the commands according to the specification.
327 * Capabilities.h: Add UnhandledPromptBehavior capability.
329 (WebDriver::CommandResult::httpStatusCode const): Add UnexpectedAlertOpen error.
330 (WebDriver::CommandResult::errorString const): Ditto.
332 (WebDriver::CommandResult::setAdditonalErrorData): New method to set an additional data object that will be sent
333 as part of the result error message.
334 (WebDriver::CommandResult::additionalErrorData const): Return the additional data object.
336 (WebDriver::Session::handleUserPrompts): Check if there's an active JavaScript dialog and deal with it depeding
337 on the unhandled prompt behavior.
338 (WebDriver::Session::reportUnexpectedAlertOpen): Generate an error message with UnexpectedAlertOpen error and
339 including the alert text as additional error data.
340 (WebDriver::Session::go): Handle user prompts before running the command.
341 (WebDriver::Session::getCurrentURL): Ditto.
342 (WebDriver::Session::back): Ditto.
343 (WebDriver::Session::forward): Ditto.
344 (WebDriver::Session::refresh): Ditto.
345 (WebDriver::Session::getTitle): Ditto.
346 (WebDriver::Session::closeWindow): Ditto.
347 (WebDriver::Session::switchToFrame): Ditto.
348 (WebDriver::Session::switchToParentFrame): Ditto.
349 (WebDriver::Session::isElementSelected): Ditto.
350 (WebDriver::Session::getElementText): Ditto.
351 (WebDriver::Session::getElementTagName): Ditto.
352 (WebDriver::Session::getElementRect): Ditto.
353 (WebDriver::Session::isElementEnabled): Ditto.
354 (WebDriver::Session::isElementDisplayed): Ditto.
355 (WebDriver::Session::getElementAttribute): Ditto.
356 (WebDriver::Session::elementSendKeys): Ditto.
357 (WebDriver::Session::elementSubmit): Ditto.
358 (WebDriver::Session::executeScript): Ditto.
360 * WebDriverService.cpp:
361 (WebDriver::WebDriverService::sendResponse const): Send data object as part of the result error message if present.
362 (WebDriver::deserializeUnhandledPromptBehavior):
363 (WebDriver::WebDriverService::parseCapabilities const):
364 (WebDriver::WebDriverService::validatedCapabilities const):
365 (WebDriver::WebDriverService::newSession):
367 2017-08-07 Carlos Garcia Campos <cgarcia@igalia.com>
369 WebDriver: implement user prompt commands
370 https://bugs.webkit.org/show_bug.cgi?id=174614
372 Reviewed by Brian Burg.
375 (WebDriver::CommandResult::CommandResult): Handle NoJavaScriptDialog protocol error.
376 (WebDriver::CommandResult::httpStatusCode const): Add NoSuchAlert.
377 (WebDriver::CommandResult::errorString const): Ditto.
380 (WebDriver::Session::dismissAlert):
381 (WebDriver::Session::acceptAlert):
382 (WebDriver::Session::getAlertText):
383 (WebDriver::Session::sendAlertText):
385 * WebDriverService.cpp:
386 (WebDriver::WebDriverService::dismissAlert):
387 (WebDriver::WebDriverService::acceptAlert):
388 (WebDriver::WebDriverService::getAlertText):
389 (WebDriver::WebDriverService::sendAlertText):
390 * WebDriverService.h:
392 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
394 [GTK][WPE] Add API to provide browser information required by automation
395 https://bugs.webkit.org/show_bug.cgi?id=175130
397 Reviewed by Brian Burg.
400 (WebDriver::Session::createTopLevelBrowsingContext): Check if startAutomationSession and complete the command
401 with error in that case.
403 * glib/SessionHostGlib.cpp:
404 (WebDriver::SessionHost::matchCapabilities): Match the capabilities that are known only after the browser has
406 (WebDriver::SessionHost::startAutomationSession): Handle the StartAutomationSession response, extracting the
407 capabilities and calling matchCapabilities() to match them.
408 (WebDriver::SessionHost::setTargetList): Return early if the session was rejected before due to invalid
411 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
413 WebDriver: Implement page load strategy
414 https://bugs.webkit.org/show_bug.cgi?id=175183
416 Reviewed by Brian Burg.
418 Validate and parse page load strategy when processing capabilities.
422 (WebDriver::Session::pageLoadStrategyString const): Helper to get the page load strategy as a String to be
423 passed to Automation.
424 (WebDriver::Session::go): Pass page load strategy if present.
425 (WebDriver::Session::back): Ditto.
426 (WebDriver::Session::forward): Ditto.
427 (WebDriver::Session::refresh): Ditto.
428 (WebDriver::Session::waitForNavigationToComplete): Ditto.
430 * WebDriverService.cpp:
431 (WebDriver::deserializePageLoadStrategy):
432 (WebDriver::WebDriverService::parseCapabilities const):
433 (WebDriver::WebDriverService::validatedCapabilities const):
434 (WebDriver::WebDriverService::newSession):
436 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
438 Unreviewed. Try to fix build with clang after r220315.
440 * WebDriverService.cpp:
441 (WebDriver::WebDriverService::validatedCapabilities const):
442 (WebDriver::WebDriverService::mergeCapabilities const):
444 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
446 WebDriver: properly handle capabilities and process firstMatch too
447 https://bugs.webkit.org/show_bug.cgi?id=174618
449 Reviewed by Brian Burg.
451 Implement processing of capabilities following the spec. This patch adds validation, merging and matching of
454 7.2 Processing Capabilities.
455 https://w3c.github.io/webdriver/webdriver-spec.html#processing-capabilities
457 * Capabilities.h: Make all capabilities optional and move Timeouts struct here.
459 * WebDriverService.cpp:
460 (WebDriver::deserializeTimeouts): Helper to extract timeouts from JSON object.
461 (WebDriver::WebDriverService::parseCapabilities const): At this point capabilities have already been validated,
462 so we just need to get them without checking the value type.
463 (WebDriver::WebDriverService::validatedCapabilities const): Validate the given capabilities, ensuring types of
464 values are the expected one.
465 (WebDriver::WebDriverService::mergeCapabilities const): Merge the alwaysMatch and firstMatch capabilities into a
466 single object ensuring that the same capability is not in both.
467 (WebDriver::WebDriverService::matchCapabilities const): Try to match the merged capabilities againt the platform
468 expected capabilities.
469 (WebDriver::WebDriverService::processCapabilities const): Validate, merge and match the capabilities.
470 (WebDriver::WebDriverService::newSession): Use processCapabilities(). Also initialize the timeouts from
471 capabilities and add all capabilities to the command result.
472 (WebDriver::WebDriverService::setTimeouts): Use deserializeTimeouts().
473 * WebDriverService.h:
474 * glib/SessionHostGlib.cpp:
475 (WebDriver::SessionHost::launchBrowser): Updated to properly access the capabilities that are now optional.
476 (WebDriver::SessionHost::startAutomationSession): Add FIXME.
477 * gtk/WebDriverServiceGtk.cpp:
478 (WebDriver::WebDriverService::platformCapabilities): Return the Capabilities with the known required ones filled.
479 (WebDriver::WebDriverService::platformValidateCapability const): Validate webkitgtk:browserOptions.
480 (WebDriver::WebDriverService::platformMatchCapability const): This does nothing for now.
481 (WebDriver::WebDriverService::platformCompareBrowserVersions): Compare the given browser versions.
482 (WebDriver::WebDriverService::platformParseCapabilities const): Updated now that capabilites have already been
485 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
487 WebDriver: use in-view center point for clicks instead of bounding box center point
488 https://bugs.webkit.org/show_bug.cgi?id=174863
490 Reviewed by Simon Fraser.
492 The center of the element bounding box is not always part of the element, like in multiline links, for example.
494 11.1 Element Interactability.
495 https://www.w3.org/TR/webdriver/#dfn-in-view-center-point
498 (WebDriver::CommandResult::httpStatusCode): Add ElementClickIntercepted and ElementNotInteractable errors.
499 (WebDriver::CommandResult::errorString): Ditto.
500 * CommandResult.h: Ditto.
502 (WebDriver::Session::computeElementLayout): Get the in-view center point and isObscured from the result too.
503 (WebDriver::Session::getElementRect): Ignore in-view center point and isObscured.
504 (WebDriver::Session::elementClick): Fail in case the element is not interactable or is obscured.
507 2017-08-01 Michael Catanzaro <mcatanzaro@igalia.com>
509 [CMake] WebKitFS.cmake depends on options set in Option cmake files that are included later
510 https://bugs.webkit.org/show_bug.cgi?id=174855
512 Reviewed by Carlos Garcia Campos.
514 Don't create derived sources directory here anymore.
518 2017-07-26 Carlos Garcia Campos <cgarcia@igalia.com>
520 Unreviewed. Fix GTK distcheck.
522 Ensure WebDriver derived sources directory is created, WebKitFS.cmake is useless for this.
526 2017-07-24 Carlos Garcia Campos <cgarcia@igalia.com>
528 WebDriver: rename m_browsingContext as m_currentBrowsingContext in Session
529 https://bugs.webkit.org/show_bug.cgi?id=174783
531 Reviewed by Brian Burg.
533 We have m_toplevelBrowsingContext and m_browsingContext, which is confusing. m_browsingContext is actually the
534 current browsing context, and the spec also refers to it as the current browsing context, so better use
535 m_currentBrowsingContext.
538 (WebDriver::Session::switchToTopLevelBrowsingContext):
539 (WebDriver::Session::switchToBrowsingContext):
540 (WebDriver::Session::switchToFrame):
541 (WebDriver::Session::switchToParentFrame):
542 (WebDriver::Session::computeElementLayout):
543 (WebDriver::Session::findElements):
544 (WebDriver::Session::isElementSelected):
545 (WebDriver::Session::getElementText):
546 (WebDriver::Session::getElementTagName):
547 (WebDriver::Session::isElementEnabled):
548 (WebDriver::Session::isElementDisplayed):
549 (WebDriver::Session::getElementAttribute):
550 (WebDriver::Session::waitForNavigationToComplete):
551 (WebDriver::Session::elementClear):
552 (WebDriver::Session::elementSendKeys):
553 (WebDriver::Session::elementSubmit):
554 (WebDriver::Session::executeScript):
557 2017-07-20 Carlos Garcia Campos <cgarcia@igalia.com>
559 WebDriver: implement page load timeout
560 https://bugs.webkit.org/show_bug.cgi?id=174672
562 Reviewed by Brian Burg.
564 Handle timeout errors and pass the page load timeout to waitForNavigationToComplete and all other navigation
565 commands. Also fix the setTimeouts command that was still using the legacy name of the page load timeout,
566 instead of the one in the spec.
569 https://www.w3.org/TR/webdriver/#dfn-session-page-load-timeout
572 (WebDriver::CommandResult::CommandResult):
573 (WebDriver::CommandResult::httpStatusCode):
574 (WebDriver::CommandResult::errorString):
577 (WebDriver::Session::go):
578 (WebDriver::Session::back):
579 (WebDriver::Session::forward):
580 (WebDriver::Session::refresh):
581 (WebDriver::Session::waitForNavigationToComplete):
582 * WebDriverService.cpp:
583 (WebDriver::WebDriverService::setTimeouts):
585 2017-07-21 Carlos Garcia Campos <cgarcia@igalia.com>
587 WebDriver: wait until navigation is complete before running new commands and after a click
588 https://bugs.webkit.org/show_bug.cgi?id=174670
590 Reviewed by Brian Burg.
592 We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
593 the spec says we should always wait before executing a new command and also after a click. This is causing test
594 testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
595 + .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
596 the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
599 6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
600 jump to step 1 in this overall algorithm, otherwise continue.
601 https://www.w3.org/TR/webdriver/#processing-model
603 14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
604 value if it is an error. 2. Try to wait for navigation to complete.
605 https://www.w3.org/TR/webdriver/#element-click
608 (WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
609 wait for any pending navigation of current browsing context to complete.
610 (WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
612 * WebDriverService.cpp:
613 (WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
614 (WebDriver::WebDriverService::getCurrentURL): Ditto.
615 (WebDriver::WebDriverService::back): Ditto.
616 (WebDriver::WebDriverService::forward): Ditto.
617 (WebDriver::WebDriverService::refresh): Ditto.
618 (WebDriver::WebDriverService::getTitle): Ditto.
619 (WebDriver::WebDriverService::switchToFrame): Ditto.
620 (WebDriver::WebDriverService::switchToParentFrame): Ditto.
621 (WebDriver::WebDriverService::findElement): Ditto.
622 (WebDriver::WebDriverService::findElements): Ditto.
623 (WebDriver::WebDriverService::executeScript): Ditto.
624 (WebDriver::WebDriverService::executeAsyncScript): Ditto.
626 2017-07-21 Carlos Garcia Campos <cgarcia@igalia.com>
628 WebDriver: correctly handle main frame handles
629 https://bugs.webkit.org/show_bug.cgi?id=174668
631 Reviewed by Brian Burg.
633 When I switched to use std::optional instead of empty strings for the browsing contexts in WebDriver, I forgot
634 that automation uses empty string for frames to refer to the main frame. We should handle that case, because we
635 are currently considering empty strings as valid browsing context. It's not a big deal because Automation
636 converts back the empty string received to the main frame, though. We should also ensure we close the current
637 browsing context when switching to a new top level browsing context. This patch adds to helper private methods
638 to switch browsing contexts that deal with the special cases.
641 (WebDriver::Session::close):
642 (WebDriver::Session::switchToTopLevelBrowsingContext):
643 (WebDriver::Session::switchToBrowsingContext):
644 (WebDriver::Session::createTopLevelBrowsingContext):
645 (WebDriver::Session::go):
646 (WebDriver::Session::back):
647 (WebDriver::Session::forward):
648 (WebDriver::Session::refresh):
649 (WebDriver::Session::switchToWindow):
650 (WebDriver::Session::switchToFrame):
651 (WebDriver::Session::switchToParentFrame):
654 2017-07-18 Carlos Garcia Campos <cgarcia@igalia.com>
656 WebDriver: handle invalid selector errors
657 https://bugs.webkit.org/show_bug.cgi?id=174619
659 Reviewed by Brian Burg.
661 Add InvalidSelector error and handle it in case of protocol server error.
664 (WebDriver::CommandResult::CommandResult):
665 (WebDriver::CommandResult::httpStatusCode):
666 (WebDriver::CommandResult::errorString):
669 2017-07-18 Carlos Alberto Lopez Perez <clopez@igalia.com>
671 [GTK] Fix build with Clang after r219605.
672 https://bugs.webkit.org/show_bug.cgi?id=166682
674 Unreviewed build fix.
676 Clang-3.8 complains with the following error:
677 non-constant-expression cannot be narrowed from type 'gboolean' (aka 'int') to 'bool' in initializer list [-Wc++11-narrowing]
679 * glib/SessionHostGlib.cpp: insert an explicit cast to silence this issue.
681 2017-07-13 Carlos Garcia Campos <cgarcia@igalia.com>
683 Add initial implementation of WebDriver process to run the HTTP server
684 https://bugs.webkit.org/show_bug.cgi?id=166682
686 Reviewed by Brian Burg.
688 Add WebDriver process that runs the HTTP server and implements an initial set of commands. Most of the code is
689 cross-platform, only the HTTP server implementation, the code to launch the browser and the communication with
690 the remote inspector requires platform specific code. This patch includes the GTK port implementation, using
691 libsoup for the HTTP server, and GLib for launching the browser and communicating with the remote
692 inspector. This implementation follows the w3c spec (https://www.w3.org/TR/webdriver) as close as possible, but
693 using the official selenium python tests as reference.
695 * CMakeLists.txt: Added.
696 * Capabilities.h: Added.
697 * CommandResult.cpp: Added.
698 * CommandResult.h: Added.
699 * HTTPServer.cpp: Added.
700 * HTTPServer.h: Added.
701 * PlatformGTK.cmake: Added.
702 * Session.cpp: Added.
704 * SessionHost.cpp: Added.
705 * SessionHost.h: Added.
706 * WebDriverMain.cpp: Added.
707 * WebDriverService.cpp: Added.
708 * WebDriverService.h: Added.
710 * glib/SessionHostGlib.cpp: Added.
711 * gtk/WebDriverServiceGtk.cpp: Added.
712 * soup/HTTPServerSoup.cpp: Added.