Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to WPT-test file uploads and fetches, fixes #12322 #12344

Merged
merged 1 commit into from Jul 9, 2016

Conversation

@izgzhen
Copy link
Contributor

izgzhen commented Jul 8, 2016

Using inputElem.selectFiles(["path1", "path2"]) in JavaScript with pref dom.htmlinputelement.select_files.enabled = true will simulate the effect of inputElem.click().

See #12322 for more, also related to #12343, #11131.


This change is Reviewable

@highfive
Copy link

highfive commented Jul 8, 2016

Heads up! This PR modifies the following files:

  • @KiChjang: components/net/filemanager_thread.rs, components/script/dom/webidls/HTMLInputElement.webidl, components/net_traits/filemanager_thread.rs, components/net_traits/filemanager_thread.rs, components/script/dom/htmlinputelement.rs
@izgzhen
Copy link
Contributor Author

izgzhen commented Jul 8, 2016

@highfive highfive assigned Manishearth and unassigned wafflespeanut Jul 8, 2016
@@ -70,6 +70,11 @@ interface HTMLInputElement : HTMLElement {
void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);

// also has obsolete members

// Select with file-system paths for testing purpose
[Pref="dom.htmlinputelement.select_files.enabled"]

This comment has been minimized.

@Manishearth

Manishearth Jul 8, 2016

Member

Perhaps this should be under dom.testing?

let opt_v = match opt_test_paths {
Some(v) => Some(v),
None => self.ui.open_file_dialog_multi("", patterns),
};

This comment has been minimized.

@Manishearth

Manishearth Jul 8, 2016

Member

This isn't process safe -- we should assert that the pref is enabled if opt_test_paths is nonempty here.

@izgzhen
Copy link
Contributor Author

izgzhen commented Jul 9, 2016

Okay, this passed the CI as well

let select_files_enabled = PREFS.get("dom.testing.htmlinputelement.select_files.enabled").as_boolean();

let opt_s = match (opt_test_path, select_files_enabled) {
(Some(s), Some(true)) => Some(s),

This comment has been minimized.

@Manishearth

Manishearth Jul 9, 2016

Member

we can just match on Some(s) if select_files_enabled here

This comment has been minimized.

@izgzhen

izgzhen Jul 9, 2016

Author Contributor

Well but select_files_enabled is Option<bool> :/

This comment has been minimized.

@Manishearth

Manishearth Jul 9, 2016

Member

.as_boolean().unwrap_or(false)

@bors-servo
Copy link
Contributor

bors-servo commented Jul 9, 2016

The latest upstream changes (presumably #12268) made this pull request unmergeable. Please resolve the merge conflicts.

@izgzhen izgzhen force-pushed the izgzhen:set-file-js branch 3 times, most recently from 0b221ff to cff79d3 Jul 9, 2016
opt_test_path
} else {
self.ui.open_file_dialog("", patterns)
};

This comment has been minimized.

@izgzhen

izgzhen Jul 9, 2016

Author Contributor

@Manishearth Looks good?

This comment has been minimized.

@Manishearth

Manishearth Jul 9, 2016

Member

Yep. Leave a comment here though mentioning that while this pref check is redundant, it's in place to ensure that a compromised script thread cannot request arbitrary files. r=me

@izgzhen izgzhen force-pushed the izgzhen:set-file-js branch from cff79d3 to 1302efb Jul 9, 2016
match self.ui.open_file_dialog_multi("", patterns) {
origin: FileOrigin, opt_test_paths: Option<Vec<String>>) {
// Check if the select_files preference is enabled,
// if so applying opt_test_paths for testing convenience

This comment has been minimized.

@izgzhen

izgzhen Jul 9, 2016

Author Contributor

This comment has been minimized.

@izgzhen

izgzhen Jul 9, 2016

Author Contributor

@Manishearth wait ... I will add another line about security

@izgzhen izgzhen force-pushed the izgzhen:set-file-js branch from 1302efb to 5e051c0 Jul 9, 2016
@Manishearth
Copy link
Member

Manishearth commented Jul 9, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jul 9, 2016

📌 Commit 5e051c0 has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Jul 9, 2016

Testing commit 5e051c0 with merge 8cb05a3...

bors-servo added a commit that referenced this pull request Jul 9, 2016
Add ability to WPT-test file uploads and fetches, fixes #12322

Using `inputElem.selectFiles(["path1", "path2"])` in JavaScript with pref `dom.htmlinputelement.select_files.enabled` = `true` will simulate the effect of `inputElem.click()`.

See #12322  for more, also related to #12343.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12344)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 9, 2016

@bors-servo bors-servo merged commit 5e051c0 into servo:master Jul 9, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.