2008-07-25 Brady Eidson <beidson@apple.com>
Reviewed by Sam
Test: security/set-form-autocomplete-attribute.html
Part of the fix for <rdar://problem/
6093281> - Improper handling of autocomplete
The autocomplete attribute works on both <form> and <input> elements, but was not
inherited properly when someone asked an <input> if it should autocomplete.
I fixed this up based on the rules in the current WF2 spec so if the <input> element
has its own autocomplete attribute set, it will follow that but otherwise it will
inherit from its parent <form>
* WebCore.base.exp:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::init):
(WebCore::HTMLInputElement::autoComplete):
(WebCore::HTMLInputElement::parseMappedAttribute):
* html/HTMLInputElement.h:
(WebCore::HTMLInputElement::):
WebKitTools:
2008-07-25 Brady Eidson <beidson@apple.com>
Reviewed by Sam
Add the ability to dump whether-or-not an element should have autocomplete enabled,
from the perspective of the WebKit API
* DumpRenderTree/LayoutTestController.cpp:
(elementDoesAutoCompleteForElementWithIdCallback):
(LayoutTestController::staticFunctions):
* DumpRenderTree/LayoutTestController.h:
* DumpRenderTree/mac/LayoutTestControllerMac.mm:
(LayoutTestController::elementDoesAutoCompleteForElementWithId):
* DumpRenderTree/win/LayoutTestControllerWin.cpp:
(LayoutTestController::elementDoesAutoCompleteForElementWithId): Stub for now until I can get on Windows
LayoutTests:
2008-07-25 Brady Eidson <beidson@apple.com>
Reviewed by Sam
Test for autocomplete attribute cleanup
* platform/win/Skipped:
* security/set-form-autocomplete-attribute-expected.txt: Added.
* security/set-form-autocomplete-attribute.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@35362
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-07-25 Brady Eidson <beidson@apple.com>
+
+ Reviewed by Sam
+
+ Test for autocomplete attribute cleanup
+
+ * platform/win/Skipped:
+ * security/set-form-autocomplete-attribute-expected.txt: Added.
+ * security/set-form-autocomplete-attribute.html: Added.
+
2008-07-25 Anders Carlsson <andersca@apple.com>
Reviewed by Mitz.
# No support for print-to-pdf in Windows DRT
printing
+# Need Windows DRT support for "elementDoesAutoCompleteForElementWithId()"
+security/set-form-autocomplete-attribute.html
+
--- /dev/null
+Element does autocomplete
+Element does autocomplete
+Element does *not* autocomplete
+Element does autocomplete
+Element does autocomplete
+Element does autocomplete
+Element does *not* autocomplete
+Element does autocomplete
+Element does *not* autocomplete
+Element does autocomplete
+Element does autocomplete
+Element does *not* autocomplete
+
+This test exercises the WebKit API "elementDoesAutoComplete:" to make sure that API clients get the correct answer about whether or not a an element should autocomplete.
--- /dev/null
+<html>
+<head>
+<script>
+
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function log(message)
+{
+ var txt = document.createTextNode(message);
+ document.getElementById("logger").appendChild(txt);
+ document.getElementById("logger").appendChild(document.createElement('br'));
+}
+
+function logAutoCompleteAPIResult()
+{
+ if (layoutTestController.elementDoesAutoCompleteForElementWithId("autoInput"))
+ log("Element does autocomplete");
+ else
+ log("Element does *not* autocomplete");
+}
+
+function runTest()
+{
+ if (!window.layoutTestController) {
+ alert("This test can only be run in DumpRenderTree");
+ return;
+ }
+
+ var form = document.getElementById("autoForm");
+ var input = document.getElementById("autoInput");
+
+ // Test with no autocomplete attribute on the <form>
+ logAutoCompleteAPIResult();
+
+ input.setAttribute("autocomplete", "cheese");
+ logAutoCompleteAPIResult();
+
+ input.setAttribute("autocomplete", "off");
+ logAutoCompleteAPIResult();
+
+ input.setAttribute("autocomplete", "on");
+ logAutoCompleteAPIResult();
+
+ input.setAttribute("autocomplete", "cheese");
+ logAutoCompleteAPIResult();
+
+ input.removeAttribute("autocomplete");
+ logAutoCompleteAPIResult();
+
+ // Test with autocomplete="off" on the <form>
+ form.setAttribute("autocomplete", "off");
+ logAutoCompleteAPIResult();
+
+ input.setAttribute("autocomplete", "cheese");
+ logAutoCompleteAPIResult();
+
+ input.setAttribute("autocomplete", "off");
+ logAutoCompleteAPIResult();
+
+ input.setAttribute("autocomplete", "on");
+ logAutoCompleteAPIResult();
+
+ input.setAttribute("autocomplete", "cheese");
+ logAutoCompleteAPIResult();
+
+ input.removeAttribute("autocomplete");
+ logAutoCompleteAPIResult();
+}
+
+</script>
+</head>
+<body onload="runTest();">
+<div id="logger"></div>
+<form id="autoForm" method="post">
+<input type="text" id="autoInput"/>
+</form>
+This test exercises the WebKit API "elementDoesAutoComplete:" to make sure that API clients get the correct answer about whether or not a an element should autocomplete.
+</body>
+</html>
+2008-07-25 Brady Eidson <beidson@apple.com>
+
+ Reviewed by Sam
+
+ Test: security/set-form-autocomplete-attribute.html
+
+ Part of the fix for <rdar://problem/6093281> - Improper handling of autocomplete
+
+ The autocomplete attribute works on both <form> and <input> elements, but was not
+ inherited properly when someone asked an <input> if it should autocomplete.
+
+ I fixed this up based on the rules in the current WF2 spec so if the <input> element
+ has its own autocomplete attribute set, it will follow that but otherwise it will
+ inherit from its parent <form>
+
+ * WebCore.base.exp:
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::init):
+ (WebCore::HTMLInputElement::autoComplete):
+ (WebCore::HTMLInputElement::parseMappedAttribute):
+ * html/HTMLInputElement.h:
+ (WebCore::HTMLInputElement::):
+
2008-07-25 Wouter Bolsterlee <uws+webkit@xs4all.nl>
Reviewed by Holger Freyther.
m_haveType = false;
m_activeSubmit = false;
- m_autocomplete = true;
+ m_autocomplete = Uninitialized;
m_inited = false;
m_autofilled = false;
cachedSelEnd = -1;
m_maxResults = -1;
-
- if (form())
- m_autocomplete = form()->autoComplete();
}
HTMLInputElement::~HTMLInputElement()
return m_name.isNull() ? emptyAtom : m_name;
}
+bool HTMLInputElement::autoComplete() const
+{
+ if (m_autocomplete != Uninitialized)
+ return m_autocomplete == On;
+
+ // Assuming we're still in a Form, respect the Form's setting
+ if (HTMLFormElement* form = this->form())
+ return form->autoComplete();
+
+ // The default is true
+ return true;
+}
+
+
static inline HTMLFormElement::CheckedRadioButtons& checkedRadioButtons(const HTMLInputElement *element)
{
if (HTMLFormElement* form = element->form())
m_name = attr->value();
checkedRadioButtons(this).addButton(this);
} else if (attr->name() == autocompleteAttr) {
- m_autocomplete = !equalIgnoringCase(attr->value(), "off");
+ if (equalIgnoringCase(attr->value(), "off"))
+ m_autocomplete = Off;
+ else if (attr->isEmpty())
+ m_autocomplete = Uninitialized;
+ else
+ m_autocomplete = On;
} else if (attr->name() == typeAttr) {
setInputType(attr->value());
} else if (attr->name() == valueAttr) {
SEARCH,
RANGE
};
+
+ enum AutoCompleteSetting {
+ Uninitialized,
+ On,
+ Off
+ };
HTMLInputElement(Document*, HTMLFormElement* = 0);
HTMLInputElement(const QualifiedName& tagName, Document*, HTMLFormElement* = 0);
virtual const AtomicString& name() const;
- bool autoComplete() const { return m_autocomplete; }
+ bool autoComplete() const;
// isChecked is used by the rendering tree/CSS while checked() is used by JS to determine checked state
virtual bool isChecked() const { return checked() && (inputType() == CHECKBOX || inputType() == RADIO); }
bool m_indeterminate : 1;
bool m_haveType : 1;
bool m_activeSubmit : 1;
- bool m_autocomplete : 1;
+ AutoCompleteSetting m_autocomplete : 2;
bool m_autofilled : 1;
bool m_inited : 1;
+2008-07-25 Brady Eidson <beidson@apple.com>
+
+ Reviewed by Sam
+
+ Add the ability to dump whether-or-not an element should have autocomplete enabled,
+ from the perspective of the WebKit API
+
+ * DumpRenderTree/LayoutTestController.cpp:
+ (elementDoesAutoCompleteForElementWithIdCallback):
+ (LayoutTestController::staticFunctions):
+
+ * DumpRenderTree/LayoutTestController.h:
+ * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+ (LayoutTestController::elementDoesAutoCompleteForElementWithId):
+ * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+ (LayoutTestController::elementDoesAutoCompleteForElementWithId): Stub for now until I can get on Windows
+
2008-07-25 chris fleizach <cfleizach@apple.com>
Reviewed by Beth Dakin
return JSValueMakeUndefined(context);
}
+static JSValueRef elementDoesAutoCompleteForElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+ JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+ ASSERT(!*exception);
+
+ bool autoCompletes = controller->elementDoesAutoCompleteForElementWithId(elementId.get());
+
+ return JSValueMakeBoolean(context, autoCompletes);
+}
+
// Static Values
static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
{ "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "windowCount", windowCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { "elementDoesAutoCompleteForElementWithId", elementDoesAutoCompleteForElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ 0, 0, 0 }
};
void setPersistentUserStyleSheetLocation(JSStringRef path);
void clearPersistentUserStyleSheet();
int windowCount();
+
+ bool elementDoesAutoCompleteForElementWithId(JSStringRef id);
bool dumpAsText() const { return m_dumpAsText; }
void setDumpAsText(bool dumpAsText) { m_dumpAsText = dumpAsText; }
#import <JavaScriptCore/JSRetainPtr.h>
#import <JavaScriptCore/JSStringRef.h>
#import <JavaScriptCore/JSStringRefCF.h>
+#import <WebKit/DOMDocument.h>
#import <WebKit/WebBackForwardList.h>
#import <WebKit/WebDatabaseManagerPrivate.h>
+#import <WebKit/WebDataSource.h>
#import <WebKit/WebFrame.h>
+#import <WebKit/WebHTMLRepresentation.h>
#import <WebKit/WebHTMLViewPrivate.h>
#import <WebKit/WebHistory.h>
#import <WebKit/WebNSURLExtras.h>
return CFArrayGetCount(openWindowsRef);
}
+bool LayoutTestController::elementDoesAutoCompleteForElementWithId(JSStringRef id)
+{
+ RetainPtr<CFStringRef> idCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, id));
+ NSString *idNS = (NSString *)idCF.get();
+
+ DOMElement *element = [[mainFrame DOMDocument] getElementById:idNS];
+ id rep = [[mainFrame dataSource] representation];
+
+ if ([rep class] == [WebHTMLRepresentation class])
+ return [(WebHTMLRepresentation *)rep elementDoesAutoComplete:element];
+
+ return false;
+}
+
void LayoutTestController::execCommand(JSStringRef name, JSStringRef value)
{
RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, name));
return openWindows().size();
}
+bool LayoutTestController::elementDoesAutoCompleteForElementWithId(JSStringRef id)
+{
+ // FIXME: Implement this almost exactly like the Mac version
+
+ return false;
+}
+
void LayoutTestController::execCommand(JSStringRef name, JSStringRef value)
{
wstring wName = jsStringRefToWString(name);