Merge backout. a=backout

This commit is contained in:
Mounir Lamouri 2010-10-28 23:49:05 +02:00
commit 15d6c64a5d
10 changed files with 78 additions and 106 deletions

View File

@ -2131,15 +2131,17 @@ nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsAString&
{
nsCOMPtr<nsIURI> 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);

View File

@ -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,

View File

@ -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<nsIFormControl> 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<nsGenericHTMLElement*>(aOriginatingElement)->
GetURIAttr(nsGkAtoms::formaction, nsnull, action);
}
} else {
GetAttr(kNameSpaceID_None, nsGkAtoms::action, action);
if (!action.IsEmpty()) {
GetAction(action);
}
GetMozActionUri(action);
}
//

View File

@ -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,

View File

@ -238,7 +238,6 @@ _TEST_FILES = \
test_bug606817.html \
test_bug297761.html \
file_bug297761.html \
test_bug607145.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -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,<html></html>", "data:text/html,<html></html>?$PARAMS"],
["data:text/html,<html>How%20about%20this?</html>", "data:text/html,<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,<html></html>", "data:text/html,<html></html>?$PARAMS", null],
["data:text/html,<html>How%20about%20this?</html>", "data:text/html,<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();
}

View File

@ -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'),

View File

@ -1,74 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=607145
-->
<head>
<title>Test for Bug 607145</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=607145">Mozilla Bug 607145</a>
<p id="display"></p>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 607145 **/
function reflectURL(aElement, aAttr)
{
var idl = aAttr;
var attr = aAttr.toLowerCase();
var elmtName = aElement.tagName.toLowerCase();
ok(idl in aElement, idl + " should be available in " + elmtName);
// Default values.
is(aElement[idl], "", "." + idl + " default value should be the empty string");
is(aElement.getAttribute(attr), null,
"@" + attr + " default value should be null");
var previousDir = location.href.replace(/test\/[^\/]*$/, "");
var dir = location.href.replace(/test_bug607145.html[^\/]*$/, "");
var doc = location.href.replace(/\.html.*/, ".html")
var values = [
/* value to set, resolved value */
[ "foo.html", dir + "foo.html" ],
[ "data:text/html,<html></html>", "data:text/html,<html></html>" ],
[ "http://example.org/", "http://example.org/" ],
[ "//example.org/", "http://example.org/" ],
[ "?foo=bar", doc + "?foo=bar" ],
[ "#foo", location.href + "#foo" ],
[ "", location.href ],
[ " ", location.href ],
[ "../", previousDir ],
[ "...", dir + "..." ],
// invalid URL
[ "http://a b/", "" ],
];
for each (var value in values) {
aElement[idl] = value[0];
is(aElement[idl], value[1], "." + idl + " value should be " + value[1]);
is(aElement.getAttribute(attr), value[0],
"@" + attr + " value should be " + value[0]);
}
for each (var value in values) {
aElement.setAttribute(attr, value[0]);
is(aElement[idl], value[1], "." + idl + " value should be " + value[1]);
is(aElement.getAttribute(attr), value[0],
"@" + attr + " value should be " + value[0]);
}
}
reflectURL(document.createElement("form"), "action");
reflectURL(document.createElement("input"), "formAction");
reflectURL(document.createElement("button"), "formAction");
</script>
</pre>
</body>
</html>

View File

@ -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;
};

View File

@ -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);
},