Permalink
Browse files

Bug 600813 - Removing PUT and DELETE form methods. a=blocking-b7

  • Loading branch information...
mounirlamouri committed Sep 30, 2010
1 parent a013a3e commit a94d43b800ac6a3983a05ca967e2ec9cdc746072
@@ -44,10 +44,8 @@ class nsIFormControl;
class nsISimpleEnumerator;
class nsIURI;
-#define NS_FORM_METHOD_GET 0
-#define NS_FORM_METHOD_POST 1
-#define NS_FORM_METHOD_PUT 2
-#define NS_FORM_METHOD_DELETE 3
+#define NS_FORM_METHOD_GET 0
+#define NS_FORM_METHOD_POST 1
#define NS_FORM_ENCTYPE_URLENCODED 0
#define NS_FORM_ENCTYPE_MULTIPART 1
#define NS_FORM_ENCTYPE_TEXTPLAIN 2
@@ -39,10 +39,8 @@
#define nsFormSubmissionConstants_h__
static const nsAttrValue::EnumTable kFormMethodTable[] = {
- { "get", NS_FORM_METHOD_GET },
- { "post", NS_FORM_METHOD_POST },
- { "put", NS_FORM_METHOD_PUT },
- { "delete", NS_FORM_METHOD_DELETE },
+ { "get", NS_FORM_METHOD_GET },
+ { "post", NS_FORM_METHOD_POST },
{ 0 }
};
// Default method is 'get'.
@@ -508,19 +508,6 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase
*/
NS_HIDDEN_(nsresult) GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsAString& aResult);
- /**
- * Helper method for NS_IMPL_ENUM_ATTR_DEFAULT_VALUE.
- * Gets the enum value string of an attribute and using a default value if
- * the attribute is missing or the string is an invalid enum value.
- *
- * @param aType the name of the attribute.
- * @param aDefault the default value if the attribute is missing or invalid.
- * @param aResult string corresponding to the value [out].
- */
- NS_HIDDEN_(nsresult) GetEnumAttr(nsIAtom* aAttr,
- const char* aDefault,
- nsAString& aResult);
-
protected:
/**
* Add/remove this element to the documents name cache
@@ -707,6 +694,19 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase
*/
NS_HIDDEN_(nsresult) GetURIListAttr(nsIAtom* aAttr, nsAString& aResult);
+ /**
+ * Helper method for NS_IMPL_ENUM_ATTR_DEFAULT_VALUE.
+ * Gets the enum value string of an attribute and using a default value if
+ * the attribute is missing or the string is an invalid enum value.
+ *
+ * @param aType the name of the attribute.
+ * @param aDefault the default value if the attribute is missing or invalid.
+ * @param aResult string corresponding to the value [out].
+ */
+ NS_HIDDEN_(nsresult) GetEnumAttr(nsIAtom* aAttr,
+ const char* aDefault,
+ nsAString& aResult);
+
/**
* Locates the nsIEditor associated with this node. In general this is
* equivalent to GetEditorInternal(), but for designmode or contenteditable,
@@ -878,25 +878,11 @@ nsHTMLFormElement::SubmitSubmission(nsFormSubmission* aFormSubmission)
getter_AddRefs(postDataStream));
NS_ENSURE_SUBMIT_SUCCESS(rv);
- nsAutoString method;
- if (originatingElement &&
- originatingElement->HasAttr(kNameSpaceID_None,
- nsGkAtoms::formmethod)) {
- if (!originatingElement->IsHTML()) {
- return NS_ERROR_UNEXPECTED;
- }
- static_cast<nsGenericHTMLElement*>(originatingElement)->
- GetEnumAttr(nsGkAtoms::formmethod, kFormDefaultMethod->tag, method);
- } else {
- GetEnumAttr(nsGkAtoms::method, kFormDefaultMethod->tag, method);
- }
-
rv = linkHandler->OnLinkClickSync(this, actionURI,
target.get(),
postDataStream, nsnull,
getter_AddRefs(docShell),
- getter_AddRefs(mSubmittingRequest),
- NS_LossyConvertUTF16toASCII(method).get());
+ getter_AddRefs(mSubmittingRequest));
NS_ENSURE_SUBMIT_SUCCESS(rv);
}
@@ -1,8 +0,0 @@
-function handleRequest(request, response)
-{
- // Redirect to another domain.
- // Using 307 to keep the method.
- response.setStatusLine(null, 307, "Temp");
- response.setHeader("Location",
- "http://example.org:80/tests/content/html/content/test/583288_submit_server.sjs");
-}
@@ -1,5 +0,0 @@
-function handleRequest(request, response)
-{
- // Send the HTTP method.
- response.write(request.method);
-}
@@ -212,11 +212,6 @@ _TEST_FILES = \
test_bug590353-1.html \
test_bug590353-2.html \
test_bug593689.html \
- test_bug583288-1.html \
- test_bug583288-2.html \
- test_bug583288-3.html \
- 583288_submit_server.sjs \
- 583288_redirect_server.sjs \
$(NULL)
libs:: $(_TEST_FILES)
@@ -1,143 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=583288
--->
-<head>
- <title>Test for Bug 583288</title>
- <script type="application/javascript" src="/MochiKit/packed.js"></script>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body onload='runTests();'>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=583288">Mozilla Bug 583288</a>
-<p id="display"></p>
-<style>
- iframe { width: 70px; height: 40px;}
-</style>
-<!--<div id="content" style="display: none">-->
-<div id="content">
- <iframe name='get' id='get'></iframe>
- <iframe name='post' id='post'></iframe>
- <iframe name='put' id='put'></iframe>
- <iframe name='del' id='del'></iframe>
- <iframe name='get2' id='get2'></iframe>
- <iframe name='post2' id='post2'></iframe>
- <iframe name='put2' id='put2'></iframe>
- <iframe name='del2' id='del2'></iframe>
-
- <form action="583288_submit_server.sjs" target='get' method='get'>
- </form>
- <form action="583288_submit_server.sjs" target='post' method='post'>
- </form>
- <form action="583288_submit_server.sjs" target='put' method='put'>
- </form>
- <form action="583288_submit_server.sjs" target='del' method='delete'>
- </form>
-
- <form action="583288_submit_server.sjs">
- <input type='submit' id='iget' value='get' formtarget='get2' formmethod='get'>
- </form>
- <form action="583288_submit_server.sjs">
- <input type='submit' id='ipost' value='post' formtarget='post2' formmethod='post'>
- </form>
- <form action="583288_submit_server.sjs">
- <input type='submit' id='iput' value='put' formtarget='put2' formmethod='put'>
- </form>
- <form action="583288_submit_server.sjs">
- <input type='submit' id='idel' value='delete' formtarget='del2' formmethod='delete'>
- </form>
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-/** Test for Bug 583288 **/
-
-SimpleTest.waitForExplicitFinish();
-
-var gTestResults = {
- get: "GET",
- get2: "GET",
- post: "POST",
- post2: "POST",
- put: "PUT",
- put2: "PUT",
- del: "DELETE",
- del2: "DELETE",
-};
-
-var gPendingLoad = 0; // Has to be set after depending on the frames number.
-
-function runTests()
-{
- // We add a load event for the frames which will be called when the forms
- // will be submitted.
- var frames = [ document.getElementById('get'),
- document.getElementById('get2'),
- document.getElementById('post'),
- document.getElementById('post2'),
- document.getElementById('put'),
- document.getElementById('put2'),
- document.getElementById('del'),
- document.getElementById('del2'),
- ];
- gPendingLoad = frames.length;
-
- for (var i=0; i<frames.length; ++i) {
- frames[i].setAttribute('onload', "frameLoaded(this);");
- }
-
- // The four first forms can be submitted with .submit().
- for (var i=0; i<4; ++i) {
- document.forms[i].submit();
- }
-
- /**
- * We are going to focus each element before interacting with them so we are
- * sure they will be visible in the iframe.
- * Considering we are using synthesizeKey that may be not required.
- *
- * Focusing the first element (id='iget') is launching the tests.
- */
- document.getElementById('iget').addEventListener('focus', function(aEvent) {
- aEvent.target.removeEventListener('focus', arguments.callee, false);
- synthesizeKey("VK_RETURN", {});
- document.getElementById('ipost').focus();
- }, false);
-
- document.getElementById('ipost').addEventListener('focus', function(aEvent) {
- aEvent.target.removeEventListener('focus', arguments.callee, false);
- synthesizeKey("VK_RETURN", {});
- document.getElementById('iput').focus();
- }, false);
-
- document.getElementById('iput').addEventListener('focus', function(aEvent) {
- aEvent.target.removeEventListener('focus', arguments.callee, false);
- synthesizeKey("VK_RETURN", {});
- document.getElementById('idel').focus();
- }, false);
-
- document.getElementById('idel').addEventListener('focus', function(aEvent) {
- aEvent.target.removeEventListener('focus', arguments.callee, false);
- synthesizeKey("VK_RETURN", {});
- }, false);
-
- document.getElementById('iget').focus();
-}
-
-function frameLoaded(aFrame) {
- // Check if formaction/action has the correct behavior.
- is(aFrame.contentDocument.documentElement.textContent, gTestResults[aFrame.name],
- "the method used during the form submission should be " +
- gTestResults[aFrame.name]);
-
- if (--gPendingLoad == 0) {
- SimpleTest.finish();
- }
-}
-
-</script>
-</pre>
-</body>
-</html>
@@ -1,99 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=583288
--->
-<head>
- <title>Test for Bug 583288</title>
- <script type="application/javascript" src="/MochiKit/packed.js"></script>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body onload='runTests();'>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=583288">Mozilla Bug 583288</a>
-<p id="display"></p>
-<style>
- iframe { width: 70px; height: 40px;}
-</style>
-<!--<div id="content" style="display: none">-->
-<div id="content">
- <iframe name='get' id='get'></iframe>
- <iframe name='post' id='post'></iframe>
- <iframe name='put' id='put'></iframe>
- <iframe name='del' id='del'></iframe>
-
- <form action="http://example.org:80/tests/content/html/content/test/583288_submit_server.sjs" target='get' method='get'>
- </form>
- <form action="http://example.org:80/tests/content/html/content/test/583288_submit_server.sjs" target='post' method='post'>
- </form>
- <form action="http://example.org:80/tests/content/html/content/test/583288_submit_server.sjs" target='put' method='put'>
- </form>
- <form action="http://example.org:80/tests/content/html/content/test/583288_submit_server.sjs" target='del' method='delete'>
- </form>
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-/** Test for Bug 583288 **/
-
-SimpleTest.waitForExplicitFinish();
-
-var gLoaded = 0;
-
-function runTests()
-{
- // We add a load event for the frames which will be called when the forms
- // will be submitted.
- var frames = [ document.getElementById('get'),
- document.getElementById('post'),
- document.getElementById('put'),
- document.getElementById('del'),
- ];
-
- for (var i=0; i<2; ++i) {
- frames[i].setAttribute('onload', "frameShouldLoad();");
- }
- for (var i=2; i<4; ++i) {
- frames[i].setAttribute('onload', "frameShouldNotLoad();");
- }
-
- // The four forms can be submitted with .submit().
- // Submitting those which should be blocked so we can considering if the the
- // last ones are submitted, that means the firsts were blocked.
- for (var i=3; i>=0; --i) {
- document.forms[i].submit();
- }
-
- // After the two first succefull submissions, we are going to stop the test.
- // The expected successfull submissions have been requested at the end so we
- // expect them at the end. So if the two firsts ones didn't show up, we are
- // assuming they have been blocked.
- // Unfortunately, it doesn't sound like there is a better way to test that.
- // The worst thing that can happen here is to have a random green (if the
- // first two submissions were not blocked but came after the last two).
-}
-
-function frameShouldLoad() {
- ok(true, "The form submission should succeed.");
- if (++gLoaded == 2) {
- finished();
- }
-}
-
-function frameShouldNotLoad() {
- ok(false, "The form submission should have been blocked");
- if (++gLoaded == 2) {
- finished();
- }
-}
-
-function finished()
-{
- SimpleTest.finish();
-}
-
-</script>
-</pre>
-</body>
-</html>
Oops, something went wrong.

0 comments on commit a94d43b

Please sign in to comment.