Closed Bug 941085 Opened 11 years ago Closed 10 years ago

File uploads support

Categories

(Remote Protocol :: Marionette, defect, P1)

defect

Tracking

(firefox40 fixed)

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: ato, Assigned: ato)

References

(Blocks 1 open bug)

Details

(Keywords: pi-marionette-server, pi-marionette-spec, Whiteboard: [marionette=1.0])

Attachments

(2 files, 1 obsolete file)

Attached file test_file_upload.py
Marionette lacks support for file uploads. WebDriver uses sendKeys on <input type=file> elements to set the value to the absolute path of the file. When using WebDriver remotely over the wire an additional end-point, POST /file, is used to temporarily store the file on the remote server until sendKeys is called a second time, upon which the absolute path should refer to the remote file instead of the local file. The resolution from our F2F in Boston was to follow the logic that sendKeys, by default, appends as it would textual elements. Provided the user agent supports the concept of multiple, calling it a second time would append another file. If the user agent doesn't understand this concept, it will replace the set file. The discussion around the resolution can be found here: http://www.w3.org/2013/06/13-testing-minutes.html#item08 See also the spec bug about covering this in the algorithm for sendKeys: https://www.w3.org/Bugs/Public/show_bug.cgi?id=23876 See the attached TC for a few tests, which can be executed using `python runtests.py --binary=/path/to/firefox --type=browser ~/test_file_upload.py`.
Whiteboard: [spec]
hsteen experimented with this using special powers last night, and was able to come up with a solution: <hallvors> yay. m.set_context(m.CONTEXT_CHROME) followed by m.execute_script('gBrowser.contentDocument.getElementById("input_type_file_id").value="file.txt" WORKS! I can upload files!
(AFAIK this won't work on Android though - the extension API is different.. In any case using send_keys or a dedicated API should be supported :))
It also won't work in a B2G context, but leaving Android and B2G as unsupported for the time being should be fine according to :automatedtester.
Whiteboard: [spec] → [marionette=1.0]
Priority: -- → P1
Assignee: nobody → ato
OS: Linux → All
Hardware: x86_64 → All
Attachment #8335385 - Attachment mime type: text/x-python → text/plain
Have a working patch locally. Need to add tests for uploading to local httpd.
Status: NEW → ASSIGNED
Attached file MozReview Request: bz://941085/ato (obsolete) —
/r/6359 - Bug 941085: File uploads support in Marionette Pull down this commit: hg pull review -r 810d78270512243b91f0e93a199907e9cbeaf406
Comment on attachment 8586157 [details] MozReview Request: bz://941085/ato /r/6359 - Bug 941085: File uploads support in Marionette Pull down this commit: hg pull review -r 9c53900e6c7d8ba99f2d256dd2f054a346b011d5
Attachment #8586157 - Flags: review?(dburns)
Comment on attachment 8586157 [details] MozReview Request: bz://941085/ato https://reviewboard.mozilla.org/r/6357/#review5323 ::: testing/marionette/driver.js (Diff revision 2) > + let f; variable name to `file`
Attachment #8586157 - Flags: review?(dburns)
Comment on attachment 8586157 [details] MozReview Request: bz://941085/ato /r/6359 - Bug 941085: File uploads support in Marionette Pull down this commit: hg pull -r 73ab0d4b4ca088eca38ad8ff49286b97dff76b8c https://reviewboard-hg.mozilla.org/gecko/
Attachment #8586157 - Flags: review?(dburns)
New try run, fixes sendKeysToElement for non-file input elements: https://treeherder.mozilla.org/#/jobs?repo=try&revision=5583d4255b66
Try is not happy, will review after next try run
Attachment #8586157 - Flags: review?(dburns)
Comment on attachment 8586157 [details] MozReview Request: bz://941085/ato /r/6359 - Bug 941085: File uploads support in Marionette Pull down this commit: hg pull -r 81ffce46bc24c3eb0485d42b4b27d5af262159cc https://reviewboard-hg.mozilla.org/gecko/
Attachment #8586157 - Flags: review?(dburns)
Filed bug 1149998 since we seem unable to use HTMLElement#mozSetFileArray on CPOW-wrapped elements passed from a remote content process.
Comment on attachment 8586157 [details] MozReview Request: bz://941085/ato /r/6359 - Bug 941085: File uploads support in Marionette Pull down this commit: hg pull -r 906d7b65c4bc4315fe0d93284e5ecdebb054130b https://reviewboard-hg.mozilla.org/gecko/
Windows failure :(
Disabled failing test on Windows due to http://bugs.python.org/issue14574 and filed bug 1150512 about moving to wptserve. Pushed to inbound: https://hg.mozilla.org/integration/mozilla-inbound/rev/93166201fca0
Attachment #8586157 - Flags: review?(dburns) → review+
Fixed test failures and pushed to inbound again: https://hg.mozilla.org/integration/mozilla-inbound/rev/f3a27b508519 The cause of the failures was that GaiaTestRunner relied on internal state set in BaseMarionetteTestRunner (self.httpd) and modified this. This patch changed BaseMarionetteTestRunner.start_httpd to create_httpd which instead returned the httpd which the constructor assigned to self.httpd. This was a problem for GaiaTestRunner because it is overriding start_httpd.
Either e10s isn't being entirely truthful to us about its load events, or WebElement.click is doing something very wrong. I added another explicit wait for the URL to change after the submit element is clicked. I didn't see the problem rerunning the tests on e10s locally 40 times. Pushed to inbound again: https://hg.mozilla.org/integration/mozilla-inbound/rev/3ea71f4c74e6
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
Attachment #8586157 - Attachment is obsolete: true
Attachment #8618061 - Flags: review+
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: