diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp
index 3f4f67f2f90c..8ffe0c2a15a4 100644
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -2131,15 +2131,17 @@ nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsAString&
{
nsCOMPtr uri;
PRBool hadAttr = GetURIAttr(aAttr, aBaseAttr, PR_FALSE, getter_AddRefs(uri));
-
- // If the content attribute isn't set or the URL is invalid, the default value
- // should be returned. The default default value is the empty string and it
- // looks like no attribute have a specified default value.
- if (!hadAttr || !uri) {
+ if (!hadAttr) {
aResult.Truncate();
return NS_OK;
}
+ if (!uri) {
+ // Just return the attr value
+ GetAttr(kNameSpaceID_None, aAttr, aResult);
+ return NS_OK;
+ }
+
nsCAutoString spec;
uri->GetSpec(spec);
CopyUTF8toUTF16(spec, aResult);
diff --git a/content/html/content/src/nsHTMLButtonElement.cpp b/content/html/content/src/nsHTMLButtonElement.cpp
index e9cb26fc35c4..2420d21242a9 100644
--- a/content/html/content/src/nsHTMLButtonElement.cpp
+++ b/content/html/content/src/nsHTMLButtonElement.cpp
@@ -218,7 +218,7 @@ nsHTMLButtonElement::GetForm(nsIDOMHTMLFormElement** aForm)
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, AccessKey, accesskey)
NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Autofocus, autofocus)
NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Disabled, disabled)
-NS_IMPL_URI_ATTR(nsHTMLButtonElement, FormAction, formaction)
+NS_IMPL_STRING_ATTR(nsHTMLButtonElement, FormAction, formaction)
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLButtonElement, FormEnctype, formenctype,
kFormDefaultEnctype->tag)
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLButtonElement, FormMethod, formmethod,
diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp
index ffca79720549..bb62ab3ac2c0 100644
--- a/content/html/content/src/nsHTMLFormElement.cpp
+++ b/content/html/content/src/nsHTMLFormElement.cpp
@@ -375,7 +375,7 @@ nsHTMLFormElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
}
NS_IMPL_STRING_ATTR(nsHTMLFormElement, AcceptCharset, acceptcharset)
-NS_IMPL_URI_ATTR(nsHTMLFormElement, Action, action)
+NS_IMPL_STRING_ATTR(nsHTMLFormElement, Action, action)
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLFormElement, Autocomplete, autocomplete,
kFormDefaultAutocomplete->tag)
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLFormElement, Enctype, enctype,
@@ -386,6 +386,17 @@ NS_IMPL_BOOL_ATTR(nsHTMLFormElement, NoValidate, novalidate)
NS_IMPL_STRING_ATTR(nsHTMLFormElement, Name, name)
NS_IMPL_STRING_ATTR(nsHTMLFormElement, Target, target)
+NS_IMETHODIMP
+nsHTMLFormElement::GetMozActionUri(nsAString& aValue)
+{
+ GetAttr(kNameSpaceID_None, nsGkAtoms::action, aValue);
+ if (aValue.IsEmpty()) {
+ // Avoid resolving action="" to the base uri, bug 297761.
+ return NS_OK;
+ }
+ return GetURIAttr(nsGkAtoms::action, nsnull, aValue);
+}
+
NS_IMETHODIMP
nsHTMLFormElement::Submit()
{
@@ -1419,23 +1430,18 @@ nsHTMLFormElement::GetActionURL(nsIURI** aActionURL,
// attribute specified, it should be used. Otherwise, the action attribute
// from the form element should be used.
//
- // In addition, if action="" or formaction="", we need to make sure we don't
- // try to resolve the URL but we should submit to the current document.
- //
nsAutoString action;
nsCOMPtr formControl = do_QueryInterface(aOriginatingElement);
if (formControl && formControl->IsSubmitControl() &&
aOriginatingElement->GetAttr(kNameSpaceID_None, nsGkAtoms::formaction,
action)) {
+ // Avoid resolving action="" to the base uri, bug 297761.
if (!action.IsEmpty()) {
static_cast(aOriginatingElement)->
GetURIAttr(nsGkAtoms::formaction, nsnull, action);
}
} else {
- GetAttr(kNameSpaceID_None, nsGkAtoms::action, action);
- if (!action.IsEmpty()) {
- GetAction(action);
- }
+ GetMozActionUri(action);
}
//
diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp
index cce840d6d78a..f56251136a4a 100644
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -962,7 +962,7 @@ NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLInputElement, Autocomplete, autocomplete,
NS_IMPL_BOOL_ATTR(nsHTMLInputElement, Autofocus, autofocus)
//NS_IMPL_BOOL_ATTR(nsHTMLInputElement, Checked, checked)
NS_IMPL_BOOL_ATTR(nsHTMLInputElement, Disabled, disabled)
-NS_IMPL_URI_ATTR(nsHTMLInputElement, FormAction, formaction)
+NS_IMPL_STRING_ATTR(nsHTMLInputElement, FormAction, formaction)
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLInputElement, FormEnctype, formenctype,
kFormDefaultEnctype->tag)
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLInputElement, FormMethod, formmethod,
diff --git a/content/html/content/test/Makefile.in b/content/html/content/test/Makefile.in
index e84f741f722a..7170818b06c6 100644
--- a/content/html/content/test/Makefile.in
+++ b/content/html/content/test/Makefile.in
@@ -238,7 +238,6 @@ _TEST_FILES = \
test_bug606817.html \
test_bug297761.html \
file_bug297761.html \
- test_bug607145.html \
$(NULL)
libs:: $(_TEST_FILES)
diff --git a/content/html/content/test/test_bug392567.html b/content/html/content/test/test_bug392567.html
index 766c8e7b870d..e7e76d8d0819 100644
--- a/content/html/content/test/test_bug392567.html
+++ b/content/html/content/test/test_bug392567.html
@@ -42,17 +42,17 @@ function runTests()
// List of tests to run, each test consists of form action URL and expected result URL
var tests = [
- [jarUrl, jarUrl + "?$PARAMS"],
- [jarUrl + "?jarTest1=jarTest2", jarUrl + "?$PARAMS"],
- [jarUrl + "?jarTest3=jarTest4#jarTest5", jarUrl + "?$PARAMS#jarTest5"],
- ["data:text/html,", "data:text/html,?$PARAMS"],
- ["data:text/html,How%20about%20this?", "data:text/html,How%20about%20this?$PARAMS"],
- [httpUrl, httpUrl + "?$PARAMS"],
- [httpUrl + "?httpTest1=httpTest2", httpUrl + "?$PARAMS"],
- [httpUrl + "?httpTest3=httpTest4#httpTest5", httpUrl + "?$PARAMS#httpTest5"],
- ["", documentURL + "?$PARAMS"],
- [" ", documentURL + "?$PARAMS"],
- ["../", previousDir + "?$PARAMS"],
+ [jarUrl, jarUrl + "?$PARAMS", null],
+ [jarUrl + "?jarTest1=jarTest2", jarUrl + "?$PARAMS", null],
+ [jarUrl + "?jarTest3=jarTest4#jarTest5", jarUrl + "?$PARAMS#jarTest5", null],
+ ["data:text/html,", "data:text/html,?$PARAMS", null],
+ ["data:text/html,How%20about%20this?", "data:text/html,How%20about%20this?$PARAMS", null],
+ [httpUrl, httpUrl + "?$PARAMS", null],
+ [httpUrl + "?httpTest1=httpTest2", httpUrl + "?$PARAMS", null ],
+ [httpUrl + "?httpTest3=httpTest4#httpTest5", httpUrl + "?$PARAMS#httpTest5", null],
+ ["", documentURL + "?$PARAMS", null],
+ [" ", documentURL + "?$PARAMS", document.location],
+ ["../", previousDir + "?$PARAMS", previousDir],
];
var currentTest = -1;
@@ -67,6 +67,10 @@ function runTests()
}
form.setAttribute("action", tests[currentTest][0]);
+ is(form.action, tests[currentTest][0],
+ "action IDL attribute should reflect the action content attribute");
+ is(form.mozActionUri, tests[currentTest][2] ? tests[currentTest][2] : tests[currentTest][0],
+ "mozActionUri IDL attribute should resolve the action URI");
form.key.value = "value" + currentTest;
form.submit();
}
diff --git a/content/html/content/test/test_bug566160.html b/content/html/content/test/test_bug566160.html
index c11faaef65db..cd258ce0b141 100644
--- a/content/html/content/test/test_bug566160.html
+++ b/content/html/content/test/test_bug566160.html
@@ -83,8 +83,41 @@ var gTestResults = {
var gPendingLoad = 0; // Has to be set after depending on the frames number.
+function checkFormActionAttribute(aElement)
+{
+ ok("formAction" in aElement, "formAction IDL attribute should be available in "
+ + aElement);
+
+ is(aElement.formAction, "", "formAction IDL attribute should be " +
+ "undefined by default");
+ is(aElement.getAttribute('formaction'), null, "formaction content attribute " +
+ "should be the empty string by default");
+
+ aElement.formAction = "foo";
+ is(aElement.getAttribute('formaction'), "foo", "formaction content attribute " +
+ "should be 'foo'.");
+ is(aElement.formAction, "foo", "formAction IDL attribute should reflect " +
+ "the content attribute");
+
+ aElement.setAttribute('formaction', 'bar');
+ is(aElement.getAttribute('formaction'), "bar", "formaction content attribute " +
+ "should be 'foo'.");
+ is(aElement.formAction, "bar", "formAction IDL attribute should reflect " +
+ "the content attribute");
+
+ aElement.removeAttribute('formaction');
+ is(aElement.formAction, "", "formAction IDL attribute should be " +
+ "undefined by default");
+ is(aElement.getAttribute('formaction'), null, "formaction content attribute " +
+ "should be the empty string by default");
+}
+
function runTests()
{
+ // First of all, let's check if .formAction and @formaction work correctly.
+ checkFormActionAttribute(document.createElement('input'));
+ checkFormActionAttribute(document.createElement('button'));
+
// We add a load event for the frames which will be called when the forms
// will be submitted.
var frames = [ document.getElementById('frame1'),
diff --git a/content/html/content/test/test_bug607145.html b/content/html/content/test/test_bug607145.html
deleted file mode 100644
index dd72371de884..000000000000
--- a/content/html/content/test/test_bug607145.html
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
- Test for Bug 607145
-
-
-
-
-
-Mozilla Bug 607145
-
-
-
-
-
-
diff --git a/dom/interfaces/html/nsIDOMHTMLFormElement.idl b/dom/interfaces/html/nsIDOMHTMLFormElement.idl
index 7d78a2d0035f..96da56492770 100644
--- a/dom/interfaces/html/nsIDOMHTMLFormElement.idl
+++ b/dom/interfaces/html/nsIDOMHTMLFormElement.idl
@@ -47,7 +47,7 @@
* http://www.w3.org/TR/DOM-Level-2-HTML/
*/
-[scriptable, uuid(0884ce23-e069-499e-a13c-a91c8ae0fc98)]
+[scriptable, uuid(653dc482-d6db-4e85-bdd9-151fd110e7b1)]
interface nsIDOMHTMLFormElement : nsIDOMHTMLElement
{
attribute DOMString name;
@@ -65,4 +65,7 @@ interface nsIDOMHTMLFormElement : nsIDOMHTMLElement
void submit();
void reset();
+
+ // This property returns the resolved action URI.
+ readonly attribute DOMString mozActionUri;
};
diff --git a/toolkit/components/passwordmgr/src/nsLoginManager.js b/toolkit/components/passwordmgr/src/nsLoginManager.js
index 4b7cfb7cfcc8..25140729414e 100644
--- a/toolkit/components/passwordmgr/src/nsLoginManager.js
+++ b/toolkit/components/passwordmgr/src/nsLoginManager.js
@@ -978,12 +978,11 @@ LoginManager.prototype = {
},
_getActionOrigin : function (form) {
- var uriString = form.action;
+ var uriString = form.mozActionUri;
- // If uriString equals the empty string that means actian attribute is
- // missing or invalid and it will submit to the baseURI.
+ // A blank or mission action submits to where it came from.
if (uriString == "")
- uriString = form.baseURI;
+ uriString = form.baseURI; // ala bug 297761
return this._getPasswordOrigin(uriString, true);
},