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

Form action url 11219 #13358

Merged
merged 1 commit into from Sep 28, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -98,7 +98,7 @@ impl HTMLFormElementMethods for HTMLFormElement {
make_setter!(SetAcceptCharset, "accept-charset");

// https://html.spec.whatwg.org/multipage/#dom-fs-action
make_url_or_base_getter!(Action, "action");
make_string_or_document_url_getter!(Action, "action");

// https://html.spec.whatwg.org/multipage/#dom-fs-action
make_setter!(SetAction, "action");
@@ -295,7 +295,7 @@ impl HTMLFormElement {
pub fn submit(&self, submit_method_flag: SubmittedFrom, submitter: FormSubmitter) {
// Step 1
let doc = document_from_node(self);
let base = doc.url();
let base = doc.base_url();
// TODO: Handle browsing contexts (Step 2, 3)
// Step 4
if submit_method_flag == SubmittedFrom::NotFromForm &&
@@ -123,6 +123,26 @@ macro_rules! make_url_or_base_getter(
);
);

#[macro_export]
macro_rules! make_string_or_document_url_getter(
( $attr:ident, $htmlname:tt ) => (
fn $attr(&self) -> DOMString {
use dom::bindings::inheritance::Castable;
use dom::element::Element;
use dom::node::document_from_node;
let element = self.upcast::<Element>();
let val = element.get_string_attribute(&atom!($htmlname));

if val.is_empty() {
let doc = document_from_node(self);
DOMString::from(doc.url().clone().into_string())
} else {
val
}
}
);
);

#[macro_export]
macro_rules! make_enumerated_getter(
( $attr:ident, $htmlname:tt, $default:expr, $(($choices: pat))|+) => (
"deleted_reftests": {},
"items": {
"testharness": {
"html/semantics/forms/the-form-element/form-action-url.html": [
{
"path": "html/semantics/forms/the-form-element/form-action-url.html",
"url": "/html/semantics/forms/the-form-element/form-action-url.html"
}
],
"html/semantics/forms/the-select-element/common-HTMLOptionsCollection-add.html": [
{
"path": "html/semantics/forms/the-select-element/common-HTMLOptionsCollection-add.html",
@@ -0,0 +1,9 @@
<!doctype html>

This comment has been minimized.

@mbrubeck

mbrubeck Sep 21, 2016

Contributor

This test should be added to the manifest. You can use this command to do so:

./mach test-wpt --manifest-update tests/wpt/web-platform-tests/html/semantics/forms/the-form-element/form-action-url.html
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t = async_test("Submit a form from an iframe with a base url");
var success = function() { t.done(); };
</script>

<iframe src="resources/form-action-url-iframe.html">
@@ -0,0 +1,11 @@
<!doctype html>
<base href="target/"></base>

<form action="form-action-url-target.html">
<input type="submit" value="Submit" />
</form>

<script>
var form = document.getElementsByTagName("form")[0];
form.submit();
</script>
@@ -0,0 +1,4 @@
<!doctype html>
<script>
window.parent.success();
</script>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.