/
ChangeLog
1262 lines (978 loc) · 58.6 KB
/
ChangeLog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
2018-01-10 Zan Dobersek <zdobersek@igalia.com>
WebDriver: deserializeTimeouts() shouldn't reject double timeout values
https://bugs.webkit.org/show_bug.cgi?id=181473
Reviewed by Carlos Garcia Campos.
With these changes, the following tests are fixed:
imported/selenium/py/test/selenium/webdriver/common/executing_async_javascript_tests.py::testShouldTimeoutIfScriptDoesNotInvokeCallbackWithLongTimeout
imported/selenium/py/test/selenium/webdriver/common/executing_async_javascript_tests.py::testShouldDetectPageLoadsWhileWaitingOnAnAsyncScriptAndReturnAnError
imported/selenium/py/test/selenium/webdriver/common/executing_async_javascript_tests.py::testShouldBeAbleToExecuteAsynchronousScripts
imported/selenium/py/test/selenium/webdriver/common/implicit_waits_tests.py::testShouldImplicitlyWaitForASingleElement
imported/selenium/py/test/selenium/webdriver/common/implicit_waits_tests.py::testShouldStillFailToFindAnElementWhenImplicitWaitsAreEnabled
imported/selenium/py/test/selenium/webdriver/common/implicit_waits_tests.py::testShouldReturnAfterFirstAttemptToFindOneAfterDisablingImplicitWaits
imported/selenium/py/test/selenium/webdriver/common/implicit_waits_tests.py::testShouldImplicitlyWaitUntilAtLeastOneElementIsFoundWhenSearchingForMany
imported/selenium/py/test/selenium/webdriver/common/implicit_waits_tests.py::testShouldStillFailToFindAnElemenstWhenImplicitWaitsAreEnabled
imported/selenium/py/test/selenium/webdriver/common/implicit_waits_tests.py::testShouldReturnAfterFirstAttemptToFindManyAfterDisablingImplicitWaits
imported/selenium/py/test/selenium/webdriver/common/page_load_timeout_tests.py::testShouldTimeoutOnPageLoadTakingTooLong
imported/selenium/py/test/selenium/webdriver/common/page_load_timeout_tests.py::testShouldTimeoutOnPageLoadTakingTooLong
imported/selenium/py/test/selenium/webdriver/common/webdriverwait_tests.py::testShouldWaitOnlyAsLongAsTimeoutSpecifiedWhenImplicitWaitsAreSet
The following two tests regress, and will be looked into separately:
imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_invalid
imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_invalid
* WebDriverService.cpp:
(WebDriver::integerValue): Helper function that retrieves an integer value
from a given JSON::Value object, if possible.
(WebDriver::deserializeTimeouts): Timeout JSON value has to be converted to
an integer, which is allowed if the value is of either Integer or Double type.
Helper integerValue() function retrieves the integer value, in addition to
ensuring that possible double value that we convert to an integer is already
in integer form to begin with.
2017-12-15 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: add support for accept/dismiss and notify unhandled prompt behavior
https://bugs.webkit.org/show_bug.cgi?id=179999
Reviewed by Carlos Alberto Lopez Perez.
They work as accept and dismiss, but unexpected alert open is still reported.
18. User Prompts
https://w3c.github.io/webdriver/webdriver-spec.html#dfn-known-prompt-handling-approaches-table
* Capabilities.h: Add DismissAndNotify and AcceptAndNotify to UnhandledPromptBehavior enum.
* Session.cpp:
(WebDriver::Session::handleUnexpectedAlertOpen): Move default implementation to dismissAndNotifyAlert and
acceptAndNotifyAlert and use dismissAndNotifyAlert by default.
(WebDriver::Session::dismissAndNotifyAlert):
(WebDriver::Session::acceptAndNotifyAlert):
* Session.h:
* WebDriverService.cpp:
(WebDriver::deserializeUnhandledPromptBehavior): Handle accept/dismiss and notify.
(WebDriver::WebDriverService::newSession): Ditto.
2017-12-11 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: get active element should return no such element error when there isn't an active element
https://bugs.webkit.org/show_bug.cgi?id=180421
Reviewed by Brian Burg.
We currently return unknown error.
Fixes: imported/w3c/webdriver/tests/element_retrieval/get_active_element.py::test_missing_document_element
* Session.cpp:
(WebDriver::Session::getActiveElement):
2017-12-04 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: implement element property command
https://bugs.webkit.org/show_bug.cgi?id=180244
Reviewed by Brian Burg.
13.3 Get Element Property
https://w3c.github.io/webdriver/webdriver-spec.html#get-element-property
Fixes: imported/w3c/webdriver/tests/state/get_element_property.py::test_no_browsing_context
imported/w3c/webdriver/tests/state/get_element_property.py::test_handle_prompt_dismiss
imported/w3c/webdriver/tests/state/get_element_property.py::test_handle_prompt_accept
imported/w3c/webdriver/tests/state/get_element_property.py::test_handle_prompt_missing_value
imported/w3c/webdriver/tests/state/get_element_property.py::test_element_stale
* Session.cpp:
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::getElementProperty):
* WebDriverService.h:
2017-12-02 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: handle user prompts shown while executing scripts
https://bugs.webkit.org/show_bug.cgi?id=179979
Reviewed by Brian Burg.
15.2 Executing Script
https://w3c.github.io/webdriver/webdriver-spec.html#executing-script
The rules to execute a function body are as follows. The algorithm will return success with the JSON
representation of the function’s return value, or an error if the evaluation of the function results in a
JavaScript exception being thrown or at any point during its execution an unhandled user prompt appears.
If at any point during the algorithm a user prompt appears, the user prompt handler must be invoked. If its
return value is an error, it must immediately return with that error and abort all subsequent substeps of this
algorithm.
This will be covered by new WPT tests that will be available after the next upgrade.
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult): Handle UnexpectedAlertOpen internal error.
* Session.cpp:
(WebDriver::Session::handleUserPrompts): Move code to handleUnexpectedAlertOpen() and call it instead.
(WebDriver::Session::handleUnexpectedAlertOpen): Code moved here to be used also by executeScript().
(WebDriver::Session::executeScript): In case of UnexpectedAlertOpen error, call handleUnexpectedAlertOpen().
* Session.h:
2017-12-01 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: implement status command
https://bugs.webkit.org/show_bug.cgi?id=180133
Reviewed by Brian Burg.
8.3 Status
https://w3c.github.io/webdriver/webdriver-spec.html#status
Fixes: imported/w3c/webdriver/tests/sessions/status.py::test_get_status_no_session
imported/w3c/webdriver/tests/sessions/status.py::test_status_with_session_running_on_endpoint_node
* WebDriverService.cpp:
(WebDriver::WebDriverService::status):
* WebDriverService.h:
2017-12-01 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: end point nodes are only allowed to have one session
https://bugs.webkit.org/show_bug.cgi?id=180131
Reviewed by Brian Burg.
We are currently keeping a map of sessions, but our service is always and end point node, so only one session
can exist at a time. Make findSessionOrCompleteWithError() return a boolean instead, failing in case the sessionID
parameter is not found or it doesn't match the current session. Replace the session map and active session
pointer with a single session member and return SessionNotCreated error when new session command is received and
there's an active session.
8. Sessions
A remote end has an associated maximum active sessions (an integer) that defines the number of active sessions
that are supported. This may be “unlimited” for intermediary nodes, but must be exactly one for a remote end
that is an endpoint node.
https://w3c.github.io/webdriver/webdriver-spec.html#dfn-maximum-active-sessions
Fixes: imported/w3c/webdriver/tests/sessions/new_session/default_values.py::test_repeat_new_session
* WebDriverService.cpp:
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::newSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::status):
(WebDriver::WebDriverService::setTimeouts):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::getCurrentURL):
(WebDriver::WebDriverService::back):
(WebDriver::WebDriverService::forward):
(WebDriver::WebDriverService::refresh):
(WebDriver::WebDriverService::getTitle):
(WebDriver::WebDriverService::getWindowHandle):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::getWindowHandles):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::WebDriverService::switchToParentFrame):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::findElement):
(WebDriver::WebDriverService::findElements):
(WebDriver::WebDriverService::findElementFromElement):
(WebDriver::WebDriverService::findElementsFromElement):
(WebDriver::WebDriverService::getActiveElement):
(WebDriver::WebDriverService::isElementSelected):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementText):
(WebDriver::WebDriverService::getElementTagName):
(WebDriver::WebDriverService::getElementRect):
(WebDriver::WebDriverService::isElementEnabled):
(WebDriver::WebDriverService::isElementDisplayed):
(WebDriver::WebDriverService::elementClick):
(WebDriver::WebDriverService::elementClear):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::executeScript):
(WebDriver::WebDriverService::executeAsyncScript):
(WebDriver::WebDriverService::getAllCookies):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::WebDriverService::deleteAllCookies):
(WebDriver::WebDriverService::dismissAlert):
(WebDriver::WebDriverService::acceptAlert):
(WebDriver::WebDriverService::getAlertText):
(WebDriver::WebDriverService::sendAlertText):
(WebDriver::WebDriverService::takeScreenshot):
(WebDriver::WebDriverService::takeElementScreenshot):
* WebDriverService.h:
2017-11-30 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: locator strategy should be validated before trying to find elements
https://bugs.webkit.org/show_bug.cgi?id=180187
Reviewed by Carlos Alberto Lopez Perez.
We currently rely on the js atom to raise an exception in case the locator strategy is not valid, but in case of
find element from element, if the element doesn't exist we fail with stale element error instead of invalid
argument as expected. So, let's validate the strategies when parsing them, which would also avoid going to the
browser in cae of invalid strategy.
Fixes: imported/w3c/webdriver/tests/retrieval/find_element_from_element.py::test_invalid_using_argument[a]
* WebDriverService.cpp:
(WebDriver::isValidStrategy):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
2017-11-30 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: remove elementSubmit command
https://bugs.webkit.org/show_bug.cgi?id=180186
Reviewed by Carlos Alberto Lopez Perez.
It's not in the spec, we had it only because selenium used it, but now it uses execute_script with custom code
to implement submit, so we can just remove it.
* Session.cpp:
(WebDriver::Session::elementSubmit): Deleted.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::elementSubmit): Deleted.
* WebDriverService.h:
2017-11-14 Carlos Garcia Campos <cgarcia@igalia.com>
Move JSONValues to WTF and convert uses of InspectorValues.h to JSONValues.h
https://bugs.webkit.org/show_bug.cgi?id=173793
Reviewed by Joseph Pecoraro.
* CMakeLists.txt:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* CommandResult.h:
(WebDriver::CommandResult::success):
(WebDriver::CommandResult::fail):
(WebDriver::CommandResult::result const):
(WebDriver::CommandResult::setAdditionalErrorData):
(WebDriver::CommandResult::additionalErrorData const):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::moveToplevelBrowsingContextWindow):
(WebDriver::Session::resizeToplevelBrowsingContextWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementClear):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::elementSubmit):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::parseAutomationCookie):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* Session.h:
* SessionHost.cpp:
(WebDriver::SessionHost::sendCommandToBackend):
(WebDriver::SessionHost::dispatchMessage):
* SessionHost.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::deserializeTimeouts):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::newSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::setTimeouts):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::getCurrentURL):
(WebDriver::WebDriverService::back):
(WebDriver::WebDriverService::forward):
(WebDriver::WebDriverService::refresh):
(WebDriver::WebDriverService::getTitle):
(WebDriver::WebDriverService::getWindowHandle):
(WebDriver::WebDriverService::getWindowRect):
(WebDriver::valueAsNumberInRange):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::getWindowHandles):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::WebDriverService::switchToParentFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::findElement):
(WebDriver::WebDriverService::findElements):
(WebDriver::WebDriverService::findElementFromElement):
(WebDriver::WebDriverService::findElementsFromElement):
(WebDriver::WebDriverService::isElementSelected):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementText):
(WebDriver::WebDriverService::getElementTagName):
(WebDriver::WebDriverService::getElementRect):
(WebDriver::WebDriverService::isElementEnabled):
(WebDriver::WebDriverService::isElementDisplayed):
(WebDriver::WebDriverService::elementClick):
(WebDriver::WebDriverService::elementClear):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::WebDriverService::elementSubmit):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::executeScript):
(WebDriver::WebDriverService::executeAsyncScript):
(WebDriver::WebDriverService::getAllCookies):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::WebDriverService::deleteAllCookies):
(WebDriver::WebDriverService::dismissAlert):
(WebDriver::WebDriverService::acceptAlert):
(WebDriver::WebDriverService::getAlertText):
(WebDriver::WebDriverService::sendAlertText):
(WebDriver::WebDriverService::takeScreenshot):
(WebDriver::WebDriverService::takeElementScreenshot):
* WebDriverService.h:
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformValidateCapability const):
(WebDriver::WebDriverService::platformMatchCapability const):
(WebDriver::WebDriverService::platformParseCapabilities const):
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformValidateCapability const):
(WebDriver::WebDriverService::platformMatchCapability const):
(WebDriver::WebDriverService::platformParseCapabilities const):
2017-11-28 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] WebDriver: stop making mandatory to provide a browser path if webkitgtk:browserOptions is present in capabilities
https://bugs.webkit.org/show_bug.cgi?id=180012
Reviewed by Carlos Alberto Lopez Perez.
Everything should be optional. We might want to disable overlay scrollbars, but still using the default browser,
for example, as I'm doing when running the selenium tests. We might also want to provide additional browser
arguments, but using the default browser.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformValidateCapability const): Do not consider invalid to not provide a
browser binary when webkitgtk:browserOptions is present.
(WebDriver::WebDriverService::platformParseCapabilities const): Override default capabilities with the ones
provided.
2017-11-27 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: Implement get active element command
https://bugs.webkit.org/show_bug.cgi?id=180001
Reviewed by Brian Burg.
12.6 Get Active Element
https://w3c.github.io/webdriver/webdriver-spec.html#get-active-element
Fixes imported/w3c/webdriver/tests/element_retrieval/get_active_element.py.
* Session.cpp:
(WebDriver::Session::getActiveElement):
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::getActiveElement):
* WebDriverService.h:
2017-11-21 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: do not try to parse http body if method is not POST
https://bugs.webkit.org/show_bug.cgi?id=179918
Reviewed by Darin Adler.
As said in the spec:
5. If request’s method is POST:
1. Let parse result be the result of parsing as JSON with request’s body as the argument. If this process
throws an exception, return an error with error code invalid argument and jump back to step 1 in this
overall algorithm.
2. If parse result is not an Object, send an error with error code invalid argument and jump back to step 1
in this overall algorithm.
Otherwise, let parameters be parse result.
Otherwise, let parameters be null.
6.3 Processing Model
https://w3c.github.io/webdriver/webdriver-spec.html#processing-model
Now, w3c tests are sending null as body of delete session command (it used to be just empty), making it fail
with invalid argument error.
* WebDriverService.cpp:
(WebDriver::WebDriverService::findCommand):
(WebDriver::WebDriverService::handleRequest):
* WebDriverService.h:
2017-11-21 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: crash in Session::computeElementLayout when called without a current browsing context
https://bugs.webkit.org/show_bug.cgi?id=179917
Reviewed by Darin Adler.
In the case of computeElementLayout message, the frameHandle parameter is not optional, but we still need to
provide a valid value (empty string means the default frame) when m_currentBrowsingContext is std::nullopt. The
same applies to selectOptionElement.
* Session.cpp:
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::selectOptionElement):
2017-11-15 Carlos Garcia Campos <cgarcia@igalia.com>
[WPE] Add initial support for WebDriver
https://bugs.webkit.org/show_bug.cgi?id=179727
Reviewed by Michael Catanzaro.
Add WPE implementation for platform-specific methods. Move the version handling to a common file
WebDriverServiceGLib.cpp.
* Capabilities.h:
* PlatformGTK.cmake:
* PlatformWPE.cmake:
* glib/WebDriverServiceGLib.cpp: Added.
(WebDriver::parseVersion):
(WebDriver::WebDriverService::platformCompareBrowserVersions):
* gtk/WebDriverServiceGtk.cpp:
* wpe/WebDriverServiceWPE.cpp: Copied from Source/WebDriver/gtk/WebDriverServiceGtk.cpp.
(WebDriver::WebDriverService::platformCapabilities):
(WebDriver::WebDriverService::platformValidateCapability const):
(WebDriver::WebDriverService::platformMatchCapability const):
(WebDriver::WebDriverService::platformParseCapabilities const):
2017-11-07 Brian Burg <bburg@apple.com>
Web Automation: inViewCenterPoint should not include topContentInset when computed in viewport coordinates
https://bugs.webkit.org/show_bug.cgi?id=179129
<rdar://problem/35297038>
Reviewed by Simon Fraser.
Adjust code to use the proper coordinate system when requesting element layout.
* Session.cpp:
(WebDriver::Session::computeElementLayout):
2017-11-09 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: WebDriverService::matchCapabilities should follow the spec
https://bugs.webkit.org/show_bug.cgi?id=179371
Reviewed by Brian Burg.
The returned object should contain all the entries mentioned in the spec, not only the ones already present in
the passed in capabilities object.
7.2 Processing Capabilities
https://w3c.github.io/webdriver/webdriver-spec.html#dfn-matching-capabilities
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
* WebDriverService.h:
2017-11-09 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: capabilities with null value shouldn't be added to the validated capabilities object
https://bugs.webkit.org/show_bug.cgi?id=179369
Reviewed by Brian Burg.
"4. If deserialized is not null, set a property on result with name name and value deserialized."
7.2 Processing Capabilities
https://w3c.github.io/webdriver/webdriver-spec.html#dfn-validate-capabilities
Fixes: imported/w3c/webdriver/tests/sessions/new_session/create_firstMatch.py::test_valid[platformName-None]
* WebDriverService.cpp:
(WebDriver::WebDriverService::validatedCapabilities const):
2017-10-27 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: unknown capabilities should produce an InvalidArgument error when validating capabilities
https://bugs.webkit.org/show_bug.cgi?id=178868
Reviewed by Brian Burg.
7.2 Processing Capabilities
https://w3c.github.io/webdriver/webdriver-spec.html#dfn-validate-capabilities
Fixes: imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py::test_invalid_extensions
* WebDriverService.cpp:
(WebDriver::WebDriverService::validatedCapabilities const):
2017-10-27 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: deserializeTimeouts should fail if the value is not integer
https://bugs.webkit.org/show_bug.cgi?id=178866
Reviewed by Brian Burg.
If value is not an integer, or it is less than 0 or greater than 2^64 – 1, return error with error code invalid
argument.
https://w3c.github.io/webdriver/webdriver-spec.html#dfn-deserialize-as-a-timeout
Fixes: imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py::test_invalid_values[timeouts-value59-body0]
imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py::test_invalid_values[timeouts-value59-body1]
* WebDriverService.cpp:
(WebDriver::deserializeTimeouts):
2017-10-27 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: failing to process capabilities should produce InvalidArgument error not SessionNotCreated
https://bugs.webkit.org/show_bug.cgi?id=178864
Reviewed by Brian Burg.
Fixes most of the tests in imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py.
7.2 Processing Capabilities
https://w3c.github.io/webdriver/webdriver-spec.html#processing-capabilities
* WebDriverService.cpp:
(WebDriver::WebDriverService::processCapabilities const):
2017-10-02 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: HTTP status code is not correct for some of the errors
https://bugs.webkit.org/show_bug.cgi?id=177354
Reviewed by Brian Burg.
I think this changed in the spec at some point. The thing is that no such alert, frame and window and stale
element reference errors should return 404 instead of 400.
https://w3c.github.io/webdriver/webdriver-spec.html#handling-errors
* CommandResult.cpp:
(WebDriver::CommandResult::httpStatusCode const):
2017-09-19 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: Implement commands to get and set the window rect
https://bugs.webkit.org/show_bug.cgi?id=177134
Reviewed by Brian Burg.
We are currently implementing the selenium legacy ones, we should implement the w3c ones instead.
https://w3c.github.io/webdriver/webdriver-spec.html#resizing-and-positioning-windows
* Session.cpp:
(WebDriver::Session::getToplevelBrowsingContextRect): Helper to get the window rect. This is used by both get
and set window rect commands.
(WebDriver::Session::moveToplevelBrowsingContextwindow): Helper to ask automation to move the window.
(WebDriver::Session::resizeToplevelBrowsingContextwindow): Helper to ask automation to resize the window.
(WebDriver::Session::getWindowRect): Handle prompts and then call getToplevelBrowsingContextRect().
(WebDriver::Session::setWindowRect): Handle prompts and then move and resize the window according to the given
parameters and finish the operation calling getToplevelBrowsingContextRect().
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::getWindowRect): Ask the session to get the window rect.
(WebDriver::valueAsNumberInRange): Helper to check a value is a valid number in the given range.
(WebDriver::WebDriverService::setWindowRect): Get and check size and position from parameters and then ask the
session to set the window rect.
* WebDriverService.h:
2017-09-19 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: wrong response in case of errors
https://bugs.webkit.org/show_bug.cgi?id=177127
Reviewed by Brian Burg.
I misunderstood the spec when I implemented this, so we either return a "value" key with the result in case of
success or the error object as the body in case of error. We should always add a "value" key to the body and set
it with either the result or the error object.
https://w3c.github.io/webdriver/webdriver-spec.html#dfn-send-an-error
* WebDriverService.cpp:
(WebDriver::WebDriverService::sendResponse const):
2017-09-18 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: wrong key name for capabilities in new session response
https://bugs.webkit.org/show_bug.cgi?id=177074
Reviewed by Brian Burg.
We are using "value", it should be "capabilities".
https://w3c.github.io/webdriver/webdriver-spec.html#new-session
* WebDriverService.cpp:
(WebDriver::WebDriverService::newSession):
2017-09-18 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: HTTP responses should include Cache-Control header with no-cache value
https://bugs.webkit.org/show_bug.cgi?id=177073
Reviewed by Sergio Villar Senin.
6.3 Processing Model.
Set the response’s header with name and value with the following values:
Content-Type "application/json; charset=utf-8"
Cache-Control "no-cache"
https://w3c.github.io/webdriver/webdriver-spec.html#dfn-send-a-response
We were setting the Content-Type, but not the Cache-Control. This is checked by all WPT WebDriver tests.
* soup/HTTPServerSoup.cpp:
(WebDriver::HTTPServer::listen): Add Cache-Control header.
2017-09-09 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: ensure we close all windows handles when closing the session
https://bugs.webkit.org/show_bug.cgi?id=176508
Reviewed by Brian Burg.
The spec says that when closing the session all top level browsing contexts should be closed. We are currently
checking if we have an active top level browsing context and then we try to close it before trying with the
rest. It can happen that we are in an inconsistent state, for example if the current top level browsing context
has been closed by JavaScript or another action and the user didn't switch to another one before closing the
session. In such case, closing the session will fail with NoSuchwindow and any other window open will not be
closed. It's safer to always ask for all window handles and close them, which is what the spec says too.
* Session.cpp:
(WebDriver::firstWindowHandleInResult): Helper class to get the first window handle in the result array.
(WebDriver::Session::closeAllToplevelBrowsingContexts): Use firstWindowHandleInResult().
(WebDriver::Session::close): Close the current top level browsing context and get all window handles to close
them all if needed.
2017-08-28 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: implement screen capture commands
https://bugs.webkit.org/show_bug.cgi?id=174615
Reviewed by Brian Burg.
Implement takeScreenshot and takeElementScreenshot commands.
19. Screen Capture.
https://w3c.github.io/webdriver/webdriver-spec.html#screen-capture
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult): Handle ScreenshotError protocol error.
(WebDriver::CommandResult::httpStatusCode const): Add UnableToCaptureScreen.
(WebDriver::CommandResult::errorString const): Ditto.
* CommandResult.h:
* Session.cpp:
(WebDriver::Session::takeScreenshot):
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::takeScreenshot):
(WebDriver::WebDriverService::takeElementScreenshot):
* WebDriverService.h:
2017-08-28 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: implement cookies commands
https://bugs.webkit.org/show_bug.cgi?id=174613
Reviewed by Brian Burg.
Add cookies commands.
16. Cookies.
https://w3c.github.io/webdriver/webdriver-spec.html#cookies
* CommandResult.cpp:
(WebDriver::CommandResult::httpStatusCode const): Add NoSuchCookie error.
(WebDriver::CommandResult::errorString const): Ditto.
* CommandResult.h:
* Session.cpp:
(WebDriver::parseAutomationCookie): Parse JSON cookie object returned by automation and convert it to a Cookie struct.
(WebDriver::builtAutomationCookie): Build a JSON cookie object as expected by automation from a Cookie struct.
(WebDriver::serializeCookie): Serialize a Cookie struct into a JSON cookie object according to the WebDriver spec.
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::getAllCookies):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::WebDriverService::deleteAllCookies):
* WebDriverService.h:
2017-07-28 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: fix return value of close window command
https://bugs.webkit.org/show_bug.cgi?id=174861
Reviewed by Brian Burg.
We are currently returning null, but we should return the list of window handles, and try to close the session
if there aren't more window handles.
10.2 Close Window
https://w3c.github.io/webdriver/webdriver-spec.html#close-window
3. If there are no more open top-level browsing contexts, then try to close the session.
4. Return the result of running the remote end steps for the Get Window Handles command.
* Session.cpp:
(WebDriver::Session::closeAllToplevelBrowsingContexts): Helper function to close the given toplevel browsing
context and the next one if there are more.
(WebDriver::Session::close): Call closeAllToplevelBrowsingContexts() to delete all toplevel browsing contexts of
the session.
(WebDriver::Session::closeTopLevelBrowsingContext): Close the given toplevel browsing context and call
getWindowHandles() when done.
(WebDriver::Session::closeWindow): Call closeTopLevelBrowsingContext() passing the current toplevel browsing context.
(WebDriver::Session::getWindowHandles): Remove the early return, this command doesn't depend on a current
toplevel browsing context.
* Session.h:
* SessionHost.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::run): Disconnect the server when main loop quits.
(WebDriver::WebDriverService::deleteSession): Do not fail if the given session is not active.
(WebDriver::WebDriverService::closeWindow): Remove the session if the closed window was the last one.
* WebDriverService.h: Remove unused quit() method.
* glib/SessionHostGlib.cpp:
(WebDriver::SessionHost::isConnected): Return whether host is connected to a browser instance.
(WebDriver::SessionHost::dbusConnectionClosedCallback): Delete m_browser.
2017-08-14 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: handle click events on option elements
https://bugs.webkit.org/show_bug.cgi?id=174710
<rdar://problem/33459305>
Reviewed by Brian Burg.
Option elements are considered as a special case by the specification. When clicking an option element, we
should get its container and use it when scrolling into view and calculating in-view center point instead of the
option element itself. Then, we should not emulate a click, but change the selected status of the option element
like if it were done by a user action, firing the corresponding events. Now we check whether the element is an
option to call selectOptionElement() or performMouseInteraction().
This fixes more than 20 selenium tests.
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult): Handle ElementNotSelectable protocol error.
(WebDriver::CommandResult::httpStatusCode const): Add ElementNotSelectable.
(WebDriver::CommandResult::errorString const): Ditto.
* CommandResult.h:
* Session.cpp:
(WebDriver::Session::selectOptionElement): Ask automation to select the given option element.
(WebDriver::Session::elementClick): Call selectOptionElement() or performMouseInteraction() depending on whether
the element is an option or not.
* Session.h:
2017-08-11 Carlos Alberto Lopez Perez <clopez@igalia.com>
Fix build warning in WebDriverService.h
https://bugs.webkit.org/show_bug.cgi?id=166682
Unreviewed build fix.
* WebDriverService.h: Fixes the warning: class 'Capabilities' was previously declared as a struct [-Wmismatched-tags]
2017-08-08 Michael Catanzaro <mcatanzaro@igalia.com>
Unreviewed, fix Ubuntu LTS build
https://bugs.webkit.org/show_bug.cgi?id=174490
* glib/SessionHostGlib.cpp:
2017-08-08 Michael Catanzaro <mcatanzaro@igalia.com>
[CMake] Properly test if compiler supports compiler flags
https://bugs.webkit.org/show_bug.cgi?id=174490
Reviewed by Konstantin Tokarev.
* WebDriverService.cpp:
(WebDriver::WebDriverService::run):
* glib/SessionHostGlib.cpp:
2017-08-07 Carlos Garcia Campos <cgarcia@igalia.com>
Web Automation: setUserInputForCurrentJavaScriptPrompt should fail if current dialog is not a prompt
https://bugs.webkit.org/show_bug.cgi?id=175261
Reviewed by Brian Burg.
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult): Handle ElementNotInteractable protocol error.
2017-08-07 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: implement unhandled prompt behavior
https://bugs.webkit.org/show_bug.cgi?id=175184
Reviewed by Brian Burg.
Handle user prompts before running some of the commands according to the specification.
* Capabilities.h: Add UnhandledPromptBehavior capability.
* CommandResult.cpp:
(WebDriver::CommandResult::httpStatusCode const): Add UnexpectedAlertOpen error.
(WebDriver::CommandResult::errorString const): Ditto.
* CommandResult.h:
(WebDriver::CommandResult::setAdditonalErrorData): New method to set an additional data object that will be sent
as part of the result error message.
(WebDriver::CommandResult::additionalErrorData const): Return the additional data object.
* Session.cpp:
(WebDriver::Session::handleUserPrompts): Check if there's an active JavaScript dialog and deal with it depeding
on the unhandled prompt behavior.
(WebDriver::Session::reportUnexpectedAlertOpen): Generate an error message with UnexpectedAlertOpen error and
including the alert text as additional error data.
(WebDriver::Session::go): Handle user prompts before running the command.
(WebDriver::Session::getCurrentURL): Ditto.
(WebDriver::Session::back): Ditto.
(WebDriver::Session::forward): Ditto.
(WebDriver::Session::refresh): Ditto.
(WebDriver::Session::getTitle): Ditto.
(WebDriver::Session::closeWindow): Ditto.
(WebDriver::Session::switchToFrame): Ditto.
(WebDriver::Session::switchToParentFrame): Ditto.
(WebDriver::Session::isElementSelected): Ditto.
(WebDriver::Session::getElementText): Ditto.
(WebDriver::Session::getElementTagName): Ditto.
(WebDriver::Session::getElementRect): Ditto.
(WebDriver::Session::isElementEnabled): Ditto.
(WebDriver::Session::isElementDisplayed): Ditto.
(WebDriver::Session::getElementAttribute): Ditto.
(WebDriver::Session::elementSendKeys): Ditto.
(WebDriver::Session::elementSubmit): Ditto.
(WebDriver::Session::executeScript): Ditto.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::sendResponse const): Send data object as part of the result error message if present.
(WebDriver::deserializeUnhandledPromptBehavior):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::newSession):
2017-08-07 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: implement user prompt commands
https://bugs.webkit.org/show_bug.cgi?id=174614
Reviewed by Brian Burg.
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult): Handle NoJavaScriptDialog protocol error.
(WebDriver::CommandResult::httpStatusCode const): Add NoSuchAlert.
(WebDriver::CommandResult::errorString const): Ditto.
* CommandResult.h:
* Session.cpp:
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::dismissAlert):
(WebDriver::WebDriverService::acceptAlert):
(WebDriver::WebDriverService::getAlertText):
(WebDriver::WebDriverService::sendAlertText):
* WebDriverService.h:
2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK][WPE] Add API to provide browser information required by automation
https://bugs.webkit.org/show_bug.cgi?id=175130
Reviewed by Brian Burg.
* Session.cpp:
(WebDriver::Session::createTopLevelBrowsingContext): Check if startAutomationSession and complete the command
with error in that case.
* SessionHost.h:
* glib/SessionHostGlib.cpp:
(WebDriver::SessionHost::matchCapabilities): Match the capabilities that are known only after the browser has
been launched.
(WebDriver::SessionHost::startAutomationSession): Handle the StartAutomationSession response, extracting the
capabilities and calling matchCapabilities() to match them.
(WebDriver::SessionHost::setTargetList): Return early if the session was rejected before due to invalid
capabilities.
2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: Implement page load strategy
https://bugs.webkit.org/show_bug.cgi?id=175183
Reviewed by Brian Burg.
Validate and parse page load strategy when processing capabilities.
* Capabilities.h:
* Session.cpp:
(WebDriver::Session::pageLoadStrategyString const): Helper to get the page load strategy as a String to be
passed to Automation.
(WebDriver::Session::go): Pass page load strategy if present.
(WebDriver::Session::back): Ditto.
(WebDriver::Session::forward): Ditto.
(WebDriver::Session::refresh): Ditto.
(WebDriver::Session::waitForNavigationToComplete): Ditto.
* Session.h:
* WebDriverService.cpp:
(WebDriver::deserializePageLoadStrategy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::newSession):
2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
Unreviewed. Try to fix build with clang after r220315.
* WebDriverService.cpp:
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
WebDriver: properly handle capabilities and process firstMatch too
https://bugs.webkit.org/show_bug.cgi?id=174618
Reviewed by Brian Burg.