Closed Bug 1847875 Opened 1 year ago Closed 10 months ago

Missing "id" in "Switch To Frame" command does not raise "invalid argument" error

Categories

(Testing :: geckodriver, defect, P3)

Default
defect

Tracking

(firefox124 fixed)

RESOLVED FIXED
124 Branch
Tracking Status
firefox124 --- fixed

People

(Reporter: whimboo, Assigned: jameshendry05, Mentored)

References

()

Details

(Whiteboard: [lang=rust][webdriver:m10][webdriver:external])

Attachments

(1 file, 1 obsolete file)

Originally filed as: https://github.com/mozilla/geckodriver/issues/2126

When observing the following lines it can be seen that a wrong payload where the element is not given under the id field but at top-level causes an id of null to be added:

1691431487144 webdriver::server DEBUG -> POST /session/05ce34bc-23c6-426a-a61a-3c9edf3e72da/frame {"element-6066-11e4-a52e-4f735466cecf": "d128ee63-b2bc-4f2c-871a-bc3784aa6d9e"}
1691431487146 Marionette DEBUG 0 -> [0,9,"WebDriver:SwitchToFrame",{"id":null}]

With no id specified geckodriver forwards just null. Looking at the remote end steps for Switch To Frame and specifically step 2 there is indeed a problem:

If id is not null, a Number object, or an Object that represents a web element, return error with error code invalid argument.

In the above case id is not specified in the request and as such it should indeed fail with an invalid argument error.

Mentor: hskupin
Severity: -- → S3
Priority: -- → P3
Whiteboard: [lang=rust]

Going to have a crack at this soon, just documenting my findings so far.
Reproduction steps:

  1. Run geckodriver -v
  2. Create a new session: curl -v -X POST 127.0.0.1:4444/session -H "Content-Type: application/json" -d '{"capabilities": {"alwaysMatch": {"acceptInsecureCerts": true}}}'
  3. Navigate to a web page in the opened browser
  4. Using the session id from step 2: curl localhost:4444/session/a6478af6-3792-4265-a501-733f7a47ef53/element/active
  5. Using the session id from step 2 and the element id from step 4: curl -X POST localhost:4444/session/a6478af6-3792-4265-a501-733f7a47ef53/frame -H "Content-Type: application/json" -d '{"element-6066-11e4-a52e-4f735466cecf":"a1136754-9e25-4006-878b-f90316de01b2"}'
  6. Receive {"value":null} and observe the null id being forwarded to marionette instead of a 400 Invalid Argument error.
Assignee: nobody → jameshendry05
Status: NEW → ASSIGNED

Fixed behaviour:

curl -X POST localhost:4444/session/$SESSION_ID/frame -H "Content-Type: application/json" -d '{}'

{"value":{"error":"invalid argument","message":"missing field `id` at line 1 column 2","stacktrace":""}}```
curl -X POST localhost:4444/session/$SESSION_ID/frame -H "Content-Type: application/json" -d '{"element-6066-11e4-a52e-4f735466cecf":"144f8120-dc30-46c4-aed6-8b7a9dd1aa3c"}'

{"value":{"error":"invalid argument","message":"missing field `id` at line 1 column 78","stacktrace":""}}

Passing {"id": null} explicitly still works:

curl -X POST localhost:4444/session/$SESSION_ID/frame -H "Content-Type: application/json" -d '{"id":null}'

{"value":null}
Attachment #9370532 - Attachment description: Bug 1847875: [geckodriver] Require FrameId to be passed explicitly r=whimboo → Bug 1847875: [geckodriver] Require FrameId to be passed explicitly and correct Marionette to Top r=whimboo
Attachment #9375612 - Attachment is obsolete: true
Blocks: 1871543

There was also a problem with null as value for id. As of now our implementation would trigger a switch to the parent frame, while it should indeed be the top-level frame. I'll adjust the bug's summary accordingly.

Summary: Missing "id" in "Switch To Frame" command does not raise "invalid argument" error → Missing "id" in "Switch To Frame" command does not raise "invalid argument" error, and "null" as value doesn't switch to the top frame
Pushed by hskupin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c0289f78466c [geckodriver] Require FrameId to be passed explicitly and correct Marionette to Top r=whimboo,webdriver-reviewers

(In reply to Henrik Skupin [:whimboo][⌚️UTC+1] from comment #5)

There was also a problem with null as value for id. As of now our implementation would trigger a switch to the parent frame, while it should indeed be the top-level frame. I'll adjust the bug's summary accordingly.

Actually this was just an internal naming issue in geckodriver and we already correctly passed the null value to Marionette.

Summary: Missing "id" in "Switch To Frame" command does not raise "invalid argument" error, and "null" as value doesn't switch to the top frame → Missing "id" in "Switch To Frame" command does not raise "invalid argument" error
Status: ASSIGNED → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 124 Branch

James, thank you a lot for your contribution! If you are interested on further contributions and you cannot find a specific bug to work on please let me know. I'm happy to help identifying a helpful bug. Some fix for dependencies for the 0.35.0 release (bug 1871543) would be great.

Whiteboard: [lang=rust] → [lang=rust][webdriver:m10][webdriver:external]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: